This commit is contained in:
Wolfgang Hottgenroth 2019-01-24 08:51:21 +01:00
commit 783e8a357e
Signed by: wn
GPG Key ID: B586EAFCDF2F65F4
8 changed files with 138 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.o
*.elf

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "hottislib"]
path = hottislib
url = git@gitlab.com:wolutator/hottislib.git

1
hottislib Submodule

@ -0,0 +1 @@
Subproject commit d129650a6fbc77f5b5474c2b5153fa6adbbda003

24
led.c Normal file
View File

@ -0,0 +1,24 @@
/*
* led.c
*
* Created on: Jan 24, 2019
* Author: wn
*/
#include "led.h"
#include "PontCoopScheduler.h"
#include <msp430g2553.h>
#include <stdlib.h>
void ledExec() {
P1OUT ^= BIT0;
}
void ledInit() {
P1DIR |= BIT0;
P1OUT &= ~BIT0;
schAdd(ledExec, NULL, 0, 1000);
}

15
led.h Normal file
View File

@ -0,0 +1,15 @@
/*
* led.h
*
* Created on: Jan 24, 2019
* Author: wn
*/
#ifndef LED_H_
#define LED_H_
void ledExec();
void ledInit();
#endif /* LED_H_ */

35
main.c Normal file
View File

@ -0,0 +1,35 @@
#include <msp430g2553.h>
#include <stdint.h>
#include <intrinsics.h>
#include <stdlib.h>
#include <stdbool.h>
#include "time.h"
#include "PontCoopScheduler.h"
#include "led.h"
int main() {
WDTCTL = WDTPW | WDTHOLD;
__disable_interrupt();
// highest possible system clock
DCOCTL = DCO0 | DCO1 | DCO2;
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
BCSCTL2 = 0;
BCSCTL3 = 0;
timeInit();
schInit();
ledInit();
__enable_interrupt();
while (1) {
schExec();
}
}

38
time.c Normal file
View File

@ -0,0 +1,38 @@
/*
* time.c
*
* Created on: 20.05.2014
* Author: wn
*/
#include <msp430g2553.h>
#include <isr_compat.h>
#include <stdint.h>
#include "time.h"
#include "PontCoopScheduler.h"
volatile uint32_t timestamp;
ISR(TIMER0_A0, TA0_ISR) {
timestamp++;
schUpdate();
}
void timeInit() {
timestamp = 0;
TACCR0 = 32;
TACCTL0 = CCIE;
TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR;
}
uint32_t getMillis() {
return timestamp;
}
void ms_active_delay(uint16_t delay) {
uint32_t start = timestamp;
while (start + delay > timestamp);
}

19
time.h Normal file
View File

@ -0,0 +1,19 @@
/*
* time.h
*
* Created on: 20.05.2014
* Author: wn
*/
#ifndef TIME_H_
#define TIME_H_
#include <stdint.h>
void timeInit();
uint32_t getMillis();
void ms_active_delay(uint16_t delay);
#endif /* TIME_H_ */