]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/tests/KL25Z/lptmr/main.cpp
3 volatile unsigned int ticks
= 0;
5 DigitalOut
led(LED_BLUE
);
7 extern "C" void lptmr_isr(void) {
8 // write 1 to TCF to clear the LPT timer compare flag
9 LPTMR0
->CSR
|= LPTMR_CSR_TCF_MASK
;
16 SIM
->SCGC5
|= SIM_SCGC5_LPTMR_MASK
;
24 /* Enable interrupt */
25 LPTMR0
->CSR
|= LPTMR_CSR_TIE_MASK
;
27 /* Set interrupt handler */
28 NVIC_SetVector(LPTimer_IRQn
, (uint32_t)lptmr_isr
);
29 NVIC_EnableIRQ(LPTimer_IRQn
);
31 /* select LPO for RTC and LPTMR */
32 LPTMR0
->PSR
= LPTMR_PSR_PCS(3); // ERCLK32K -> 8MHz
33 LPTMR0
->PSR
|= LPTMR_PSR_PRESCALE(2); // divide by 8
36 LPTMR0
->CSR
|= LPTMR_CSR_TEN_MASK
;
42 printf("%d\n", ticks
);
46 printf("%d\n", ticks
);