boilerplate

This commit is contained in:
Wolfgang Hottgenroth
2016-09-28 12:21:08 +02:00
parent e15738e929
commit 36ffda7e5d
7 changed files with 140 additions and 6 deletions

46
src/main.c Normal file
View File

@ -0,0 +1,46 @@
/*
* main.c
*
* Created on: 29.08.2016
* Author: wn
*/
#include <msp430g2553.h>
#include <stdint.h>
#include <intrinsics.h>
#include <stdlib.h>
#include <stdbool.h>
#include "time.h"
#include "PontCoopScheduler.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();
// schAdd(displayExec, NULL, 0, DISPLAY_CYCLE);
__enable_interrupt();
while (1) {
schExec();
}
}

38
src/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
src/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_ */