diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-12-11 10:28:25 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-12-11 10:28:25 +0100 |
commit | 2253c912c86b5196e17657ee067abfc7afa4d652 (patch) | |
tree | c10d2722e0c44355bded196209bfba6d5827d06c /src/arch/msp430fr5969lp | |
parent | 540974f8f109aa8874f032eddf59819c76eb018e (diff) |
Add basic uptime getter, improve loop support
Diffstat (limited to 'src/arch/msp430fr5969lp')
-rw-r--r-- | src/arch/msp430fr5969lp/Makefile.inc | 2 | ||||
-rw-r--r-- | src/arch/msp430fr5969lp/arch.cc | 35 | ||||
-rw-r--r-- | src/arch/msp430fr5969lp/driver/uptime.cc | 9 |
3 files changed, 45 insertions, 1 deletions
diff --git a/src/arch/msp430fr5969lp/Makefile.inc b/src/arch/msp430fr5969lp/Makefile.inc index f4b96fe..81c8fdf 100644 --- a/src/arch/msp430fr5969lp/Makefile.inc +++ b/src/arch/msp430fr5969lp/Makefile.inc @@ -11,7 +11,7 @@ CXX = /opt/msp430/ti/gcc/bin/msp430-elf-g++ OBJCOPY = /opt/msp430/ti/gcc/bin/msp430-elf-objcopy TARGETS += src/arch/msp430fr5969lp/arch.cc src/arch/msp430fr5969lp/driver/gpio.cc -TARGETS += src/arch/msp430fr5969lp/driver/stdout.cc +TARGETS += src/arch/msp430fr5969lp/driver/stdout.cc src/arch/msp430fr5969lp/driver/uptime.cc OBJECTS = ${TARGETS:.cc=.o} diff --git a/src/arch/msp430fr5969lp/arch.cc b/src/arch/msp430fr5969lp/arch.cc index 19416e1..be821a6 100644 --- a/src/arch/msp430fr5969lp/arch.cc +++ b/src/arch/msp430fr5969lp/arch.cc @@ -16,10 +16,16 @@ void Arch::setup(void) // 16MHz DCO CSCTL0_H = CSKEY >> 8; CSCTL1 = DCORSEL | DCOFSEL_4; +#ifdef WITH_LOOP + CSCTL2 = SELA__LFXTCLK | SELS__DCOCLK | SELM__DCOCLK; +#else CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; +#endif CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; CSCTL0_H = 0; + +#ifdef WITH_LOOP // enable LXFT for RTC CSCTL0_H = CSKEY >> 8; CSCTL4 &= ~LFXTOFF; @@ -30,17 +36,46 @@ void Arch::setup(void) CSCTL0_H = 0; __delay_cycles(1000000); +#endif + + // 16MHz/16 -> ~1MHz timer + TA0CTL = TASSEL__SMCLK | ID__8 | MC__CONTINUOUS; + TA0EX0 = 1; + TA0CTL |= TACLR; + +#ifdef WITH_LOOP + + // 1s per wakeup for loop + TA1CTL = TASSEL__ACLK | ID__8 | MC__UP; + TA1EX0 = 0; + TA1CCR0 = 4096; + TA1CTL |= TACLR | TAIE; +#endif + //P1OUT = 0; //P4OUT = 0; } void Arch::idle_loop(void) { + __eint(); while (1); } Arch arch; +#ifdef WITH_LOOP + +extern void loop(); + +__attribute__((interrupt(TIMER1_A1_VECTOR))) __attribute__((wakeup)) void handle_timer0_overflow() +{ + if (TA1IV == 0x0e) { + loop(); + } +} + +#endif /* void uart_setup(void) { diff --git a/src/arch/msp430fr5969lp/driver/uptime.cc b/src/arch/msp430fr5969lp/driver/uptime.cc new file mode 100644 index 0000000..6d16441 --- /dev/null +++ b/src/arch/msp430fr5969lp/driver/uptime.cc @@ -0,0 +1,9 @@ +#include "driver/uptime.h" +#include <msp430.h> + +uint32_t Uptime::get() +{ + return TA0R; +} + +Uptime uptime; |