From 9acc1897c3dc5dc79b94f5cf019b8a3967b6dcf3 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Mon, 19 Feb 2024 10:24:26 +0100 Subject: [PATCH] initial --- Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ main.c | 41 +++++++++++++++++++++++++++++++++++++++++ readme.md | 13 +++++++++++++ time.c | 38 ++++++++++++++++++++++++++++++++++++++ time.h | 19 +++++++++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 Makefile create mode 100644 main.c create mode 100644 readme.md create mode 100644 time.c create mode 100644 time.h diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f0b1a62 --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +CC=msp430-gcc +AS=msp430-gcc +AR=msp430-ar + +# regular +CFLAGS=-Wall -mmcu=msp430g2553 -std=gnu99 -I hottislib -O3 -g0 + +# for debugging +# CFLAGS=-Wall -mmcu=msp430g2553 -std=gnu99 -I hottislib -g3 -ggdb -gdwarf-2 + +LDFLAGS=-mmcu=msp430g2553 + +blinky1.elf: main.o led.o time.o pattern.o PontCoopScheduler.o myrand.o measure.o + $(CC) -o $@ $(LDFLAGS) $^ + +PontCoopScheduler.o: hottislib/PontCoopScheduler.c hottislib/PontCoopScheduler.h + $(CC) $(CFLAGS) -c $< + +.c.o: + $(CC) $(CFLAGS) -c $< + + +.PHONY: all +all: blinky1.elf + +.PHONY: clean +clean: + -rm -f *.o *.elf + +.PHONY: upload +upload: blinky1.elf + mspdebug rf2500 "prog blinky1.elf" + +.PHONY: debug +debug: upload + mspdebug rf2500 gdb & + ddd --debugger "msp430-gdb -x blinky1.gdb" + + + + diff --git a/main.c b/main.c new file mode 100644 index 0000000..fd33029 --- /dev/null +++ b/main.c @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include + +#include "time.h" +#include "PontCoopScheduler.h" + +#include "led.h" +#include "pattern.h" +#include "measure.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(); + patternInit(); + measureInit(); + // ledSetMatrix(0, 0, BLUE); + + __enable_interrupt(); + + while (1) { + schExec(); + ledExec(); + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..096b931 --- /dev/null +++ b/readme.md @@ -0,0 +1,13 @@ +Build: +* make all + +Flash: +* make upload + +Debugger: +* enable debugging in Makefile +* mspdebug rf2500 gdb +* ddd --debugger msp430-gdb +* for every code change upload using Makefile and restart both mspdebug and ddd (or fine a way to reset the both) + + diff --git a/time.c b/time.c new file mode 100644 index 0000000..a7fd15f --- /dev/null +++ b/time.c @@ -0,0 +1,38 @@ +/* + * time.c + * + * Created on: 20.05.2014 + * Author: wn + */ + +#include +#include +#include + +#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); +} diff --git a/time.h b/time.h new file mode 100644 index 0000000..874251e --- /dev/null +++ b/time.h @@ -0,0 +1,19 @@ +/* + * time.h + * + * Created on: 20.05.2014 + * Author: wn + */ + +#ifndef TIME_H_ +#define TIME_H_ + +#include + +void timeInit(); +uint32_t getMillis(); +void ms_active_delay(uint16_t delay); + + + +#endif /* TIME_H_ */