![](/media/cache/profiles/74961657ae02e93fc17be9d9fc864620.50x50_q85.jpg)
main.c@1:2c52307d223f, 2010-12-02 (annotated)
- Committer:
- hugozijlmans
- Date:
- Thu Dec 02 12:32:18 2010 +0000
- Revision:
- 1:2c52307d223f
- Child:
- 2:f034e862af1f
Added RIT & Timer0 interrupt routines
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hugozijlmans | 1:2c52307d223f | 1 | #include "LPC17xx.h" |
hugozijlmans | 1:2c52307d223f | 2 | #include "core_cm3.h" |
hugozijlmans | 1:2c52307d223f | 3 | #include "cmsis_nvic.h" |
hugozijlmans | 1:2c52307d223f | 4 | #include "Timer0.h" |
hugozijlmans | 1:2c52307d223f | 5 | #include "main.h" |
hugozijlmans | 1:2c52307d223f | 6 | #include "LPC1768.h" |
hugozijlmans | 1:2c52307d223f | 7 | #include "MCPWM.h" |
hugozijlmans | 1:2c52307d223f | 8 | #include "RIT.h" |
hugozijlmans | 1:2c52307d223f | 9 | |
hugozijlmans | 1:2c52307d223f | 10 | // BSP defines see main.h |
hugozijlmans | 1:2c52307d223f | 11 | |
hugozijlmans | 1:2c52307d223f | 12 | int main(void); |
hugozijlmans | 1:2c52307d223f | 13 | void dispatcher(void); |
hugozijlmans | 1:2c52307d223f | 14 | |
hugozijlmans | 1:2c52307d223f | 15 | Tinterrupt_flags i_flags; |
hugozijlmans | 1:2c52307d223f | 16 | |
hugozijlmans | 1:2c52307d223f | 17 | int main(void) { |
hugozijlmans | 1:2c52307d223f | 18 | |
hugozijlmans | 1:2c52307d223f | 19 | // Set the correct PLL value to match CCLK |
hugozijlmans | 1:2c52307d223f | 20 | PLL0_init(); |
hugozijlmans | 1:2c52307d223f | 21 | |
hugozijlmans | 1:2c52307d223f | 22 | // Enable the driving of the onboard LEDs |
hugozijlmans | 1:2c52307d223f | 23 | LED_init(); |
hugozijlmans | 1:2c52307d223f | 24 | |
hugozijlmans | 1:2c52307d223f | 25 | // Set the timer0, enable it and connect to ISR |
hugozijlmans | 1:2c52307d223f | 26 | Timer0_init(); |
hugozijlmans | 1:2c52307d223f | 27 | |
hugozijlmans | 1:2c52307d223f | 28 | // Set the RIT, enable it and connect to ISR |
hugozijlmans | 1:2c52307d223f | 29 | RIT_init(); |
hugozijlmans | 1:2c52307d223f | 30 | |
hugozijlmans | 1:2c52307d223f | 31 | // Initialize MCPWM |
hugozijlmans | 1:2c52307d223f | 32 | //MCPWM_init(); |
hugozijlmans | 1:2c52307d223f | 33 | |
hugozijlmans | 1:2c52307d223f | 34 | // Start the dispatcher |
hugozijlmans | 1:2c52307d223f | 35 | dispatcher(); |
hugozijlmans | 1:2c52307d223f | 36 | |
hugozijlmans | 1:2c52307d223f | 37 | } |
hugozijlmans | 1:2c52307d223f | 38 | |
hugozijlmans | 1:2c52307d223f | 39 | void dispatcher(void) { |
hugozijlmans | 1:2c52307d223f | 40 | |
hugozijlmans | 1:2c52307d223f | 41 | while (1) { |
hugozijlmans | 1:2c52307d223f | 42 | |
hugozijlmans | 1:2c52307d223f | 43 | // When the timer0 interrupt occurred |
hugozijlmans | 1:2c52307d223f | 44 | if (i_flags.Timer0_int == 1) { |
hugozijlmans | 1:2c52307d223f | 45 | if ((FIOPIN & LED1)==LED1) |
hugozijlmans | 1:2c52307d223f | 46 | FIOCLR |= LED1; |
hugozijlmans | 1:2c52307d223f | 47 | else |
hugozijlmans | 1:2c52307d223f | 48 | FIOSET |= LED1; |
hugozijlmans | 1:2c52307d223f | 49 | |
hugozijlmans | 1:2c52307d223f | 50 | i_flags.Timer0_int = 0; |
hugozijlmans | 1:2c52307d223f | 51 | } |
hugozijlmans | 1:2c52307d223f | 52 | |
hugozijlmans | 1:2c52307d223f | 53 | // When the RIT interrupt occurred |
hugozijlmans | 1:2c52307d223f | 54 | if (i_flags.RIT_int == 1) { |
hugozijlmans | 1:2c52307d223f | 55 | if ((FIOPIN & LED2)==LED2) |
hugozijlmans | 1:2c52307d223f | 56 | FIOCLR |= LED2; |
hugozijlmans | 1:2c52307d223f | 57 | else |
hugozijlmans | 1:2c52307d223f | 58 | FIOSET |= LED2; |
hugozijlmans | 1:2c52307d223f | 59 | |
hugozijlmans | 1:2c52307d223f | 60 | i_flags.RIT_int = 0; |
hugozijlmans | 1:2c52307d223f | 61 | } |
hugozijlmans | 1:2c52307d223f | 62 | } |
hugozijlmans | 1:2c52307d223f | 63 | |
hugozijlmans | 1:2c52307d223f | 64 | } |