47 lines
560 B
C
47 lines
560 B
C
/*
|
|
* tim14.c
|
|
*
|
|
* Created on: Feb 29, 2024
|
|
* Author: Francesco Gritti
|
|
*/
|
|
|
|
#include "mcu.h"
|
|
|
|
|
|
|
|
|
|
#ifdef tim14_timer
|
|
|
|
|
|
|
|
void TIM14_init (void) {
|
|
|
|
RCC_TIM14_CLK_ENABLE ();
|
|
|
|
TIM14->CR1 = 0x0000;
|
|
TIM14->DIER |= TIM_DIER_UIE_Msk;
|
|
TIM14->CNT = 0x0000;
|
|
TIM14->PSC = 24-1;
|
|
TIM14->ARR = 1000-1;
|
|
|
|
|
|
NVIC_SetPriority (TIM14_IRQn, 3);
|
|
NVIC_EnableIRQ (TIM14_IRQn);
|
|
|
|
// enable timer
|
|
TIM14->CR1 |= TIM_CR1_CEN_Msk;
|
|
}
|
|
|
|
__attribute__ ((weak)) void tim14_callback (void);
|
|
|
|
void TIM14_IRQHandler (void) {
|
|
|
|
TIM14->SR &= ~TIM_SR_UIF;
|
|
tim14_callback ();
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|