X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Finclude%2Fcommand.h;h=dfa4003422bb5ce3de98febc7d99f2ee77cb3c4c;hp=5d7813be4bfba645890bb62a0a4b926de7d053ae;hb=5fb0341d348e101b30794945a6c91546e25e8e7b;hpb=6a87a627534bd71abda0c446269dd03c5cad4a42 diff --git a/firmware/include/command.h b/firmware/include/command.h index 5d7813b..dfa4003 100644 --- a/firmware/include/command.h +++ b/firmware/include/command.h @@ -1,22 +1,128 @@ -//! Command handling functions. +/*! \file command.h + \author Travis Goodspeed + \brief Command codes and buffers. +*/ + + +#ifndef COMMAND_H +#define COMMAND_H + +#include + +//Types +#define u8 unsigned char +#define u16 unsigned int +#define u32 unsigned long + + +#ifdef msp430x2274 +//256 bytes, plus overhead +//For chips with very little RAM. +#define CMDDATALEN 0x104 +//#warning Very little RAM. +#endif + +#ifndef CMDDATALEN +//512 bytes +#define CMDDATALEN 0x204 +//4k +//#define CMDDATALEN 0x1004 +#endif //! Global data buffer. -extern unsigned char cmddata[256]; +extern unsigned char cmddata[CMDDATALEN]; +extern unsigned char silent; + #define cmddataword ((unsigned int*) cmddata) +#define cmddatalong ((unsigned long*) cmddata) #define memorybyte ((unsigned char*) 0) +#define memoryword ((unsigned int*) 0) -// Command prefixes +// Global Commands #define READ 0x00 #define WRITE 0x01 #define PEEK 0x02 #define POKE 0x03 +#define SETUP 0x10 +#define START 0x20 +#define STOP 0x21 +#define CALL 0x30 +#define EXEC 0x31 #define NOK 0x7E #define OK 0x7F -//!Handle a command. Defined in goodfet.c -void handle(unsigned char app,unsigned char verb,unsigned char len); +#define DEBUGSTR 0xFF + + + +//SPI commands +#define SPI_JEDEC 0x80 +#define SPI_ERASE 0x81 +#define SPI_RW_EM260 0x82 + +//OCT commands +#define OCT_CMP 0x90 +#define OCT_RES 0x91 -//!Transmit data. +#ifdef GCC +#define WEAKDEF __attribute__ ((weak)) +#else +//Compiler doesn't support weak linking. :( +#define WEAKDEF +#endif + +//! Handle a command. Defined in goodfet.c +void handle(uint8_t const app, + uint8_t const verb, + uint32_t const len); +//! Transmit a header. +void txhead(unsigned char app, + unsigned char verb, + unsigned long len); +//! Transmit data. void txdata(unsigned char app, unsigned char verb, - unsigned char len); + unsigned long len); +//! Transmit a string. +void txstring(unsigned char app, + unsigned char verb, + const char *str); + +//! Receive a long. +unsigned long rxlong(); +//! Receive a word. +unsigned int rxword(); + +//! Transmit a long. +void txlong(unsigned long l); +//! Transmit a word. +void txword(unsigned int l); + +//! Transmit a debug sequence of bytes +void debugbytes(const char *bytes, unsigned int len); +//! Transmit a debug string. +void debugstr(const char *str); +//! brief Debug a hex word string. +void debughex(u16 v); +//! brief Debug a hex long string. +void debughex32(u32 v); + +//! Delay for a count. +void delay(unsigned int count); +//! MSDelay +void msdelay(unsigned int ms); + + +//! Prepare Timer B; call before using delay_ms or delay_us. +void prep_timer(); + +//! Delay for specified number of milliseconds (given 16 MHz clock) +void delay_ms( unsigned int ms ); + +//! Delay for specified number of microseconds (given 16 MHz clock) +void delay_us( unsigned int us ); + +//! Delay for specified number of clock ticks (16 MHz clock implies 62.5 ns per tick). +void delay_ticks( unsigned int num_ticks ); + +#endif // COMMAND_H