|
|
@ -30,10 +30,6 @@ void timerDisableTimer(timerNo_t timer)
|
|
|
|
BASE->CR1 &=~ 0x01; //all the timers have the same CEN bit in CR1 register pos 0
|
|
|
|
BASE->CR1 &=~ 0x01; //all the timers have the same CEN bit in CR1 register pos 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void timerSetClkSource(timerNo_t timer, clkSources_t clk)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void timerSetMode(timerNo_t timer, timerMode_t mode)
|
|
|
|
void timerSetMode(timerNo_t timer, timerMode_t mode)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -82,18 +78,32 @@ void timerClearUpdateInterrupt(timerNo_t timer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Second stage configuration */
|
|
|
|
/* Second stage configuration */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Bus Clock
|
|
|
|
|
|
|
|
* ------------------------------ = Duty (Hz)
|
|
|
|
|
|
|
|
* (Prescaler-1) * (Period-1)
|
|
|
|
|
|
|
|
*/
|
|
|
|
void timerSetHz(timerNo_t timer, uint16_t hz)
|
|
|
|
void timerSetHz(timerNo_t timer, uint16_t hz)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32_t prescaler;
|
|
|
|
uint32_t prescaler = 8000000;
|
|
|
|
uint32_t period;
|
|
|
|
uint32_t period = 0;
|
|
|
|
|
|
|
|
uint32_t temp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do{
|
|
|
|
|
|
|
|
prescaler = prescaler / 10;
|
|
|
|
|
|
|
|
}while(prescaler > 0xffff);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do{
|
|
|
|
|
|
|
|
period = period + 1;
|
|
|
|
|
|
|
|
temp = 8000000/(prescaler*(period));
|
|
|
|
|
|
|
|
}while(temp >= hz);
|
|
|
|
|
|
|
|
|
|
|
|
timerActivateBus(timer);
|
|
|
|
timerActivateBus(timer);
|
|
|
|
timerSetPrescaler(timer, 1599);
|
|
|
|
timerSetPrescaler(timer, prescaler-1);
|
|
|
|
timerSetAutoReload(timer, 9999);
|
|
|
|
timerSetAutoReload(timer, period-1);
|
|
|
|
timerClearCounter(timer);
|
|
|
|
timerClearCounter(timer);
|
|
|
|
timerEnableTimer(timer);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void timerSetMs(timerNo_t timer, uint16_t ms)
|
|
|
|
void timerSetMs(timerNo_t timer, uint16_t ms)
|
|
|
|