diff --git a/master/master/lib/serparser.c b/master/master/lib/serparser.c new file mode 100644 --- /dev/null +++ b/master/master/lib/serparser.c @@ -0,0 +1,83 @@ +/* + * serparser.c + * + * Created: 10/25/2012 8:11:43 PM + * Author: ethanzonca + */ + + +// ************* Macros *************** +#define SERIAL_RX_HASBYTES UCSRA & _BV(RXC) +#define MAX_CMD_LEN 8 +#define BROADCAST_ADDR 0 + +//#define DEBUG + +// ************* Command Definitions *************** + +// Serial Commands +enum luma_cmd { // CMD ID# + BOARDTEMP = 0, // 0 + PRESSURE, // 1 +}; + +// Data length of each command, in bytes +uint8_t cmd_len[] = { + 2, // BOARDTEMP_LEN + 0, // PRESSURE_LEN +}; + +// Incoming command buffer +uint8_t buffer[MAX_CMD_LEN+2]; + +// Current buffer location +uint8_t buffercount = 0; + + + +/* Get char from UART */ +uint8_t uart_getchar(void) +{ + // Wait for chars + while (!(UCSRA & (1<