From 6a87a627534bd71abda0c446269dd03c5cad4a42 Mon Sep 17 00:00:00 2001 From: travisutk Date: Wed, 3 Jun 2009 17:10:12 +0000 Subject: [PATCH] Firmware coming together. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@22 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/apps/Makefile | 24 ++++++++++ firmware/apps/goodfet.c | 78 +++++++++++++++++++++++++++++++++ firmware/apps/monitor/monitor.c | 15 +++++++ firmware/include/apps.h | 10 +++++ firmware/include/command.h | 22 ++++++++++ firmware/lib/command.c | 16 +++++++ 6 files changed, 165 insertions(+) create mode 100644 firmware/apps/Makefile create mode 100644 firmware/apps/goodfet.c create mode 100644 firmware/apps/monitor/monitor.c create mode 100644 firmware/include/apps.h create mode 100644 firmware/include/command.h create mode 100644 firmware/lib/command.c diff --git a/firmware/apps/Makefile b/firmware/apps/Makefile new file mode 100644 index 0000000..83f3125 --- /dev/null +++ b/firmware/apps/Makefile @@ -0,0 +1,24 @@ + +PORT=/dev/ttyUSB0 +BSL=tos-bsl --invert-reset --invert-test -c $(PORT) + +#mcu=msp430x1611 +mcu=msp430x1612 + +#ldscript is wonky +GCCINC=-T ../ldscripts/161x.x + +CC=msp430-gcc -g -mmcu=$(mcu) -DGCC $(GCCINC) -I ../include + +apps= monitor/monitor.c +libs= ../lib/msp430f1612.c ../lib/command.c +app=goodfet + +install: $(app) + $(BSL) -e -p $(app) + $(BSL) -P $(app) -r +$(app): $(app).c $(libs) $(apps) +erase: + $(BSL) -e +clean: + rm -f $(app) diff --git a/firmware/apps/goodfet.c b/firmware/apps/goodfet.c new file mode 100644 index 0000000..c5e037e --- /dev/null +++ b/firmware/apps/goodfet.c @@ -0,0 +1,78 @@ +//GOODFET Echo test. + + +#include "platform.h" +#include "command.h" +#include "apps.h" + +#include +#include +#include + + +//LED on P1.0 +//IO on P5 + +//! Initialize registers and all that jazz. +void init(){ + volatile unsigned int i; + WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer + + //LED and TX OUT + PLEDDIR |= PLEDPIN; + + msp430_init_dco(); + msp430_init_uart(); + + //Enable Interrupts. + //eint(); +} + +//! Handle a command. +void handle(unsigned char app, + unsigned char verb, + unsigned char len){ + switch(app){ + case MONITOR: + monitorhandle(app,verb,len); + break; + default: + txdata(app,NOK,0); + } +} + +//! Main loop. +int main(void) +{ + volatile unsigned int i; + unsigned char app, verb, len; + + init(); + + //Command loop. There's no end! + while(1){ + //Ready + txdata(MONITOR,OK,0); + + //Magic 3 + app=serial_rx(); + verb=serial_rx(); + len=serial_rx(); + //Read data, if any + for(i=0;i