From 21ff17d2af1e50542d9343d7177269a8910ebbe3 Mon Sep 17 00:00:00 2001 From: travisutk Date: Sun, 17 Apr 2011 21:03:44 +0000 Subject: [PATCH] Preparing for an AVR port of at least the monitor. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@993 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/Makefile | 5 +- firmware/apps/monitor/monitor.c | 21 ++++---- firmware/include/gfports.h | 3 +- firmware/include/glitch.h | 4 -- firmware/include/platform.h | 8 ++- firmware/lib/atmega168.c | 89 +++++++++++++++++++++++++++++++++ firmware/lib/command.c | 16 ++++++ 7 files changed, 128 insertions(+), 18 deletions(-) create mode 100644 firmware/lib/atmega168.c diff --git a/firmware/Makefile b/firmware/Makefile index 36c0cdf..11eaddb 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -24,8 +24,9 @@ platform?=goodfet #GCCINC=-T ldscripts/161x.x GCCINC=-T ldscripts/$(mcu).x -CCEXTRA?= -CC=msp430-gcc -Wall -Os -fno-strict-aliasing -g -mmcu=$(mcu) -D$(mcu) -D$(platform) -Dplatform=$(platform) -DGCC $(GCCINC) -I include -I platforms $(CCEXTRA) +CCEXTRA?= -D$(mcu) -D$(platform) -Dplatform=$(platform) -DGCC $(GCCINC) -I include -I platforms +GCC?=msp430-gcc +CC=$(GCC) -Wall -Os -fno-strict-aliasing -g -mmcu=$(mcu) $(CCEXTRA) # Available Applications # ====================== diff --git a/firmware/apps/monitor/monitor.c b/firmware/apps/monitor/monitor.c index ab6f8a4..73aa61c 100644 --- a/firmware/apps/monitor/monitor.c +++ b/firmware/apps/monitor/monitor.c @@ -123,19 +123,22 @@ void monitor_handle_fn(uint8_t const app, break; case MONITOR_DIR: - P5DIR=cmddata[0]; - txdata(app,verb,1); - break; + //P5DIR=cmddata[0]; + debugstr("Command deprecated."); + txdata(app,verb,1); + break; case MONITOR_IN: - cmddata[0]=P5IN; - txdata(app,verb,1); - break; + //cmddata[0]=P5IN; + debugstr("Command deprecated."); + txdata(app,verb,1); + break; case MONITOR_OUT: - P5OUT=cmddata[0]; - txdata(app,verb,1); - break; + //P5OUT=cmddata[0]; + debugstr("Command deprecated."); + txdata(app,verb,1); + break; case MONITOR_SILENT: silent=cmddata[0]; diff --git a/firmware/include/gfports.h b/firmware/include/gfports.h index 7257c9d..d38dd21 100644 --- a/firmware/include/gfports.h +++ b/firmware/include/gfports.h @@ -6,7 +6,8 @@ #ifndef GFPORTS #define GFPORTS -#include +//#include + // N.B., only asm-clean CPP definitions allowed. diff --git a/firmware/include/glitch.h b/firmware/include/glitch.h index 5705e4e..e208549 100644 --- a/firmware/include/glitch.h +++ b/firmware/include/glitch.h @@ -9,10 +9,6 @@ #include "command.h" #include "app.h" -#include -#include -#include - #define GLITCH 0x71 //Command codes diff --git a/firmware/include/platform.h b/firmware/include/platform.h index a9f9ebc..d1efb89 100644 --- a/firmware/include/platform.h +++ b/firmware/include/platform.h @@ -9,10 +9,14 @@ #include "gfports.h" -#include +#include + +#ifdef MSP430 #include +#include #include -#include + +#endif #include "config.h" diff --git a/firmware/lib/atmega168.c b/firmware/lib/atmega168.c new file mode 100644 index 0000000..36795fa --- /dev/null +++ b/firmware/lib/atmega168.c @@ -0,0 +1,89 @@ +//! MSP430F1612/1611 clock and I/O definitions + +#include "platform.h" + +//! Receive a byte. +unsigned char serial0_rx(){ + return 0; +} + +//! Receive a byte. +unsigned char serial1_rx(){ + return 0; +} + +//! Transmit a byte. +void serial0_tx(unsigned char x){ +} + +//! Transmit a byte on the second UART. +void serial1_tx(unsigned char x){ +} + +//! Set the baud rate. +void setbaud0(unsigned char rate){ + + //http://mspgcc.sourceforge.net/baudrate.html + switch(rate){ + case 1://9600 baud + + break; + case 2://19200 baud + + break; + case 3://38400 baud + + break; + case 4://57600 baud + + break; + default: + case 5://115200 baud + + break; + } +} + +//! Set the baud rate of the second uart. +void setbaud1(unsigned char rate){ + //http://mspgcc.sourceforge.net/baudrate.html + switch(rate){ + case 1://9600 baud + + break; + case 2://19200 baud + + break; + case 3://38400 baud + + break; + case 4://57600 baud + + break; + default: + case 5://115200 baud + + break; + } +} + + +void msp430_init_uart0(){ +} + + +void msp430_init_uart1(){ +} + + + +//! Initialization is correct. +void msp430_init_dco_done(){ + //Nothing to do for the 1612. +} + + +void msp430_init_dco() { + +} + diff --git a/firmware/lib/command.c b/firmware/lib/command.c index 8b83d47..ec74ebb 100644 --- a/firmware/lib/command.c +++ b/firmware/lib/command.c @@ -140,17 +140,22 @@ void msdelay(unsigned int ms){ delaying slightly longer than requested. */ void prep_timer() { + #ifdef MSP430 BCSCTL2 = 0x00; /* In particular, use DCOCLK as SMCLK source with divider 1. Hence, Timer B ticks with system clock at 16 MHz. */ TBCTL = 0x0204; /* Driven by SMCLK; disable Timer B interrupts; reset timer in case it was previously in use */ + #else + #warning "Function unimplemented for this platform." + #endif } //! Delay for specified number of milliseconds (given 16 MHz clock) void delay_ms( unsigned int ms ) { + #ifdef MSP430 // 16000 ticks = 1 ms TBCTL |= 0x20; // Start timer! while (ms--) { @@ -159,11 +164,15 @@ void delay_ms( unsigned int ms ) TBCTL = 0x0224; } TBCTL = 0x0204; // Reset Timer B, till next time + #else + #warning "Function unimplemented for this platform." + #endif } //! Delay for specified number of microseconds (given 16 MHz clock) void delay_us( unsigned int us ) { + #ifdef MSP430 // 16 ticks = 1 us TBCTL |= 0x20; // Start timer! while (us--) { @@ -172,13 +181,20 @@ void delay_us( unsigned int us ) TBCTL = 0x0224; } TBCTL = 0x0204; // Reset Timer B, till next time + #else + #warning "Function unimplemented for this platform." + #endif } //! Delay for specified number of clock ticks (16 MHz clock implies 62.5 ns per tick). void delay_ticks( unsigned int num_ticks ) { + #ifdef MSP430 TBCTL |= 0x20; // Start timer while (TBR < num_ticks) asm( "nop" ); TBCTL = 0x0204; // Reset Timer B, till next time + #else + #warning "Function unimplemented for this platform." + #endif } -- 2.20.1