|
|
|
@ -5,8 +5,7 @@
|
|
|
|
|
|
|
|
|
|
void timerReset(timerNo_t timer)
|
|
|
|
|
{
|
|
|
|
|
// reset via RCC_APBxRSTR Register
|
|
|
|
|
|
|
|
|
|
// To implement RM page 116
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timerActivateBus(timerNo_t timer)
|
|
|
|
@ -16,23 +15,22 @@ void timerActivateBus(timerNo_t timer)
|
|
|
|
|
RCC->APB1ENR |= (1<<timerBus_En_bitPos[timer]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RCC->APB2ENR |= (1<<timerBus_En_bitPos[timer]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timerEnableTimer(timerNo_t timer)
|
|
|
|
|
void timerEnable(timerNo_t timer)
|
|
|
|
|
{
|
|
|
|
|
BASE->CR1 |= 0x01; //all the timers have the same CEN bit in CR1 register pos 0
|
|
|
|
|
BASE->CR1 |= TIM_CR1_CEN; //all the timers have the same CEN bit in CR1 register pos 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timerDisableTimer(timerNo_t timer)
|
|
|
|
|
void timerDisable(timerNo_t timer)
|
|
|
|
|
{
|
|
|
|
|
BASE->CR1 &=~ 0x01; //all the timers have the same CEN bit in CR1 register pos 0
|
|
|
|
|
BASE->CR1 &=~ TIM_CR1_CEN; //all the timers have the same CEN bit in CR1 register pos 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void timerSetMode(timerNo_t timer, timerMode_t mode)
|
|
|
|
|
{
|
|
|
|
|
//Implement
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timerSetCountDirection(timerNo_t timer, timerCountDirection_t direction)
|
|
|
|
@ -77,8 +75,21 @@ void timerClearUpdateInterrupt(timerNo_t timer)
|
|
|
|
|
BASE->SR &= ~1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Second stage configuration */
|
|
|
|
|
|
|
|
|
|
/* Second stage configuration */
|
|
|
|
|
void timerInit( timerNo_t timer,
|
|
|
|
|
uint32_t prescaler,
|
|
|
|
|
uint32_t period,
|
|
|
|
|
timerCountDirection_t direction,
|
|
|
|
|
timerMode_t mode)
|
|
|
|
|
{
|
|
|
|
|
timerActivateBus(timer);
|
|
|
|
|
timerReset(timer);
|
|
|
|
|
timerSetMode(mode);
|
|
|
|
|
timerSetCountDirection(timer,direction);
|
|
|
|
|
timerSetPrescaler(timer, prescaler);
|
|
|
|
|
timerSetAutoReload(timer, period);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Bus Clock
|
|
|
|
|
* ------------------------------ = Duty (Hz)
|
|
|
|
@ -100,7 +111,6 @@ void timerSetHz(timerNo_t timer, uint16_t hz)
|
|
|
|
|
temp = 8000000/(prescaler*(period));
|
|
|
|
|
}while(temp >= hz);
|
|
|
|
|
|
|
|
|
|
timerActivateBus(timer);
|
|
|
|
|
timerSetPrescaler(timer, prescaler-1);
|
|
|
|
|
timerSetAutoReload(timer, period-1);
|
|
|
|
|
timerClearCounter(timer);
|
|
|
|
@ -124,12 +134,18 @@ void timerSetPs(timerNo_t timer, uint16_t ps)
|
|
|
|
|
|
|
|
|
|
void timerSart(timerNo_t timer)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
timerEnable(timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timerHalt(timerNo_t timer)
|
|
|
|
|
{
|
|
|
|
|
timerDisable(timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timerStop(timerNo_t timer)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
timerDisable(timer);
|
|
|
|
|
timerClearCounter(timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t timerGetCount(timerNo_t timer)
|
|
|
|
|