Mercurial > avr_jtag
diff src/avr_jtag.c @ 3:e410832c3280
Issue of avr-ld.
- For some unknown reason, avr-ld can not handle multiple objects well.
- Fixed by compile all source at once.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 22 Feb 2009 01:40:36 +0800 |
parents | abf221bf3ce4 |
children | 61f27549de57 |
line wrap: on
line diff
--- a/src/avr_jtag.c Sat Feb 21 23:06:50 2009 +0800 +++ b/src/avr_jtag.c Sun Feb 22 01:40:36 2009 +0800 @@ -1,13 +1,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <util/delay.h> #include "avriotools.h" #include "cmd_proto.h" #include "jtag.h" #define BAUD_RATE 420000 -static char client_buf[255 + CP_CMD_OVERHEAD]; +static char client_buf[256 + CP_CMD_OVERHEAD]; static void ack(int seq) { @@ -40,6 +41,19 @@ uart_putc(buf[i]); } +void flash_init(void) { + pin_mode(&PORTB, PINB4, PM_OUTPUT); + pin_mode(&PORTB, PINB5, PM_OUTPUT); + pin_lo(PORTB, PINB4); + pin_lo(PORTB, PINB5); +} + +void flash_led(void) { + pin_hi(PORTB, PINB4); + _delay_ms(50); + pin_lo(PORTB, PINB4); +} + #define GET_DATA_BITS(data) ((data)[0] | ((data)[1] << 8)) int main(int argc, char * const argv[]) { @@ -47,16 +61,20 @@ cmd_proto_t *cp; int c, nbits; int bsz; - char buf[16]; + static char buf[16]; - jtag_init(); + flash_init(); + flash_led(); + uart_init(BAUD_RATE); - + jtag_init(); cp = cmd_proto_new(); - + while(1) { uart_getc(c); cmd = cmd_proto_rcv(cp, c); + if(cmd == NULL) + continue; if(cmd == &BAD_CMD) { nak(cmd->seq, "BAD CMD"); @@ -67,7 +85,7 @@ nak(cmd->seq, "CSUM ERR"); continue; } - + switch(cmd->code) { case CPCMD_PING: memcpy(client_buf + CP_CMD_HEAD_SZ, cmd->data, cmd->data_sz);