Hugo Zijlmans
/
BLDC
Diff: main.c
- Revision:
- 2:f034e862af1f
- Parent:
- 1:2c52307d223f
diff -r 2c52307d223f -r f034e862af1f main.c --- a/main.c Thu Dec 02 12:32:18 2010 +0000 +++ b/main.c Thu Dec 02 20:55:45 2010 +0000 @@ -6,6 +6,7 @@ #include "LPC1768.h" #include "MCPWM.h" #include "RIT.h" +#include "UART0.h" // BSP defines see main.h @@ -24,13 +25,16 @@ // Set the timer0, enable it and connect to ISR Timer0_init(); - + // Set the RIT, enable it and connect to ISR RIT_init(); // Initialize MCPWM //MCPWM_init(); + // Initialize UART0 + UART0_init(); + // Start the dispatcher dispatcher(); @@ -38,27 +42,35 @@ void dispatcher(void) { + int byte; + while (1) { // When the timer0 interrupt occurred if (i_flags.Timer0_int == 1) { - if ((FIOPIN & LED1)==LED1) - FIOCLR |= LED1; - else - FIOSET |= LED1; + i_flags.Timer0_int = 0; + } - i_flags.Timer0_int = 0; + // When the RIT interrupt occurred + if (i_flags.RIT_int == 1) { + i_flags.RIT_int = 0; + } + + // When UART0 TX is idle + if (i_flags.UART0_tx_idle == 1) { + i_flags.UART0_tx_idle = 0; } - // When the RIT interrupt occurred - if (i_flags.RIT_int == 1) { - if ((FIOPIN & LED2)==LED2) - FIOCLR |= LED2; + // When UART0 RX isn't idle + if (i_flags.UART0_rx_idle == 0) { + i_flags.UART0_rx_idle = 1; + byte = UART0_read(); + if(byte == 'a') + FIOSET |= LED1; else - FIOSET |= LED2; - - i_flags.RIT_int = 0; - } + FIOCLR |= LED1; + UART0_write(byte); + } } } \ No newline at end of file