LED pin control macro and port config added. Some little bugfixes done.

This commit is contained in:
klaute 2016-08-23 14:09:50 +02:00
parent 728e2af5bf
commit 105a43aa5f
2 changed files with 34 additions and 11 deletions

View file

@ -11,6 +11,13 @@
#define MSG_TYPE_ANSWER_NOK 0x02 #define MSG_TYPE_ANSWER_NOK 0x02
#define MSG_TYPE_BAUDRATE 0x03 #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 \ #define EN_MUX_LINE0 \

View file

@ -78,16 +78,6 @@ int main(void)
{ {
SetupHardware(); 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 // initialize the command interpreter
cc_init(); cc_init();
@ -100,6 +90,8 @@ int main(void)
CDC2_Task(); CDC2_Task();
USB_USBTask(); USB_USBTask();
//uart_putc('1');
} }
} }
@ -131,8 +123,24 @@ void SetupHardware(void)
// set every pin to low // set every pin to low
EN_MUX_LINE0; EN_MUX_LINE0;
DDRB |= (1 << PIN0) | (1 << PIN1);
LED0_OFF;
LED1_OFF;
/* UART Hardware Initialization */ /* 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) ); uart_init( UART_BAUD_SELECT(baudrate, F_CPU) );
sei();
/* USB Hardware Initialization */ /* USB Hardware Initialization */
USB_Init(); USB_Init();
@ -328,19 +336,27 @@ void CDC2_Task(void)
} }
} }
//return;
//=========================================================================== //===========================================================================
uint8_t outBuffer[OUTPUT_BUFFER_SIZE]; uint8_t outBuffer[OUTPUT_BUFFER_SIZE];
// TODO read the USART data and send them to the host // TODO read the USART data and send them to the host
// Fill &Buffer with USART data or send the USART input buffer direct // Fill &Buffer with USART data or send the USART input buffer direct
uint16_t cnt = 0; uint16_t cnt = 0;
uint8_t c = uart_getc(); int c = uart_getc();
while (!(c & UART_NO_DATA) && cnt < OUTPUT_BUFFER_SIZE) while (!(c & UART_NO_DATA) && cnt < OUTPUT_BUFFER_SIZE)
{ {
//LED0_ON;
outBuffer[cnt] = c; outBuffer[cnt] = c;
c = uart_getc(); c = uart_getc();
cnt++; cnt++;
} }
/*
cnt = 1;
outBuffer[0] = '2';
*/
// send the data which was received from the uart connection // send the data which was received from the uart connection
if (cnt > 0) if (cnt > 0)
{ {