These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
EMAC/uIP/lpc17xx_port/clock-arch.c@0:bf7b9fba3924, 2011-03-20 (annotated)
- Committer:
- frank26080115
- Date:
- Sun Mar 20 05:38:56 2011 +0000
- Revision:
- 0:bf7b9fba3924
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
frank26080115 | 0:bf7b9fba3924 | 1 | #include "clock-arch.h" |
frank26080115 | 0:bf7b9fba3924 | 2 | #include "LPC17xx.h" |
frank26080115 | 0:bf7b9fba3924 | 3 | |
frank26080115 | 0:bf7b9fba3924 | 4 | __IO clock_time_t Ticks; |
frank26080115 | 0:bf7b9fba3924 | 5 | |
frank26080115 | 0:bf7b9fba3924 | 6 | #define LED_PIN (1<<6) |
frank26080115 | 0:bf7b9fba3924 | 7 | |
frank26080115 | 0:bf7b9fba3924 | 8 | /* SysTick timer interrupt handler */ |
frank26080115 | 0:bf7b9fba3924 | 9 | void SysTick_Handler (void) |
frank26080115 | 0:bf7b9fba3924 | 10 | { |
frank26080115 | 0:bf7b9fba3924 | 11 | ++Ticks; |
frank26080115 | 0:bf7b9fba3924 | 12 | if (!(Ticks & 0x07)){ |
frank26080115 | 0:bf7b9fba3924 | 13 | LPC_GPIO2->FIOPIN ^= LED_PIN; |
frank26080115 | 0:bf7b9fba3924 | 14 | } |
frank26080115 | 0:bf7b9fba3924 | 15 | } |
frank26080115 | 0:bf7b9fba3924 | 16 | |
frank26080115 | 0:bf7b9fba3924 | 17 | /* Timer init */ |
frank26080115 | 0:bf7b9fba3924 | 18 | void clock_init(void) |
frank26080115 | 0:bf7b9fba3924 | 19 | { |
frank26080115 | 0:bf7b9fba3924 | 20 | Ticks = 0; |
frank26080115 | 0:bf7b9fba3924 | 21 | |
frank26080115 | 0:bf7b9fba3924 | 22 | // NXP: Initialize System tick timer |
frank26080115 | 0:bf7b9fba3924 | 23 | // Generate interrupt each SYSTICK_PERIOD microsecond |
frank26080115 | 0:bf7b9fba3924 | 24 | if (SysTick_Config((SystemCoreClock/CLOCK_CONF_SECOND))){ |
frank26080115 | 0:bf7b9fba3924 | 25 | // Capture error |
frank26080115 | 0:bf7b9fba3924 | 26 | while (1); |
frank26080115 | 0:bf7b9fba3924 | 27 | } |
frank26080115 | 0:bf7b9fba3924 | 28 | } |
frank26080115 | 0:bf7b9fba3924 | 29 | |
frank26080115 | 0:bf7b9fba3924 | 30 | /* returned The current clock time, measured in system ticks */ |
frank26080115 | 0:bf7b9fba3924 | 31 | clock_time_t clock_time(void) |
frank26080115 | 0:bf7b9fba3924 | 32 | { |
frank26080115 | 0:bf7b9fba3924 | 33 | return(Ticks); |
frank26080115 | 0:bf7b9fba3924 | 34 | } |