diff --git a/firmware/globals.h b/firmware/globals.h index fd28d7b..5bc9a3f 100755 --- a/firmware/globals.h +++ b/firmware/globals.h @@ -11,6 +11,13 @@ #define MSG_TYPE_ANSWER_NOK 0x02 #define MSG_TYPE_BAUDRATE 0x03 +/*****************************************************************************/ + + #define LED0_ON PORTB &= ~(1 << PIN0); + #define LED0_OFF PORTB |= (1 << PIN0); + #define LED1_ON PORTB &= ~(1 << PIN1); + #define LED1_OFF PORTB |= (1 << PIN1); + /*****************************************************************************/ #define EN_MUX_LINE0 \ diff --git a/firmware/main.c b/firmware/main.c index 9a8334b..3c731bb 100755 --- a/firmware/main.c +++ b/firmware/main.c @@ -78,16 +78,6 @@ int main(void) { SetupHardware(); - eeprom_busy_wait(); - baudrate = eeprom_read_dword(&eep_baudrate); - - if (baudrate == 0xffffffff) - { - eeprom_busy_wait(); - baudrate = 115200; - eeprom_write_dword(&eep_baudrate, baudrate); - } - // initialize the command interpreter cc_init(); @@ -100,6 +90,8 @@ int main(void) CDC2_Task(); USB_USBTask(); + + //uart_putc('1'); } } @@ -131,8 +123,24 @@ void SetupHardware(void) // set every pin to low EN_MUX_LINE0; + DDRB |= (1 << PIN0) | (1 << PIN1); + + LED0_OFF; + LED1_OFF; + /* UART Hardware Initialization */ + eeprom_busy_wait(); + baudrate = eeprom_read_dword(&eep_baudrate); + + if (baudrate == 0xffffffff) + { + eeprom_busy_wait(); + baudrate = 115200; + eeprom_write_dword(&eep_baudrate, baudrate); + } + uart_init( UART_BAUD_SELECT(baudrate, F_CPU) ); + sei(); /* USB Hardware Initialization */ USB_Init(); @@ -328,19 +336,27 @@ void CDC2_Task(void) } } + //return; + //=========================================================================== uint8_t outBuffer[OUTPUT_BUFFER_SIZE]; // TODO read the USART data and send them to the host // Fill &Buffer with USART data or send the USART input buffer direct uint16_t cnt = 0; - uint8_t c = uart_getc(); + int c = uart_getc(); while (!(c & UART_NO_DATA) && cnt < OUTPUT_BUFFER_SIZE) { + //LED0_ON; outBuffer[cnt] = c; c = uart_getc(); cnt++; } + /* + cnt = 1; + outBuffer[0] = '2'; + */ + // send the data which was received from the uart connection if (cnt > 0) {