diff --git a/bsl/csl/interfaces/timer.h b/bsl/csl/interfaces/timer.h index 94db6c4..fe4dfd3 100644 --- a/bsl/csl/interfaces/timer.h +++ b/bsl/csl/interfaces/timer.h @@ -38,7 +38,6 @@ typedef enum { counter, inputCapture, outputCompare, - pwm, onePulse } timerMode_t; @@ -55,7 +54,6 @@ uint8_t timerGetUpdateInterrupt(timerNo_t timer); void timerClearUpdateInterrupt(timerNo_t timer); void timerClearCounter(timerNo_t timer); - /* Second stage configuration */ void timerInit(timerNo_t timer, uint32_t prescaler, uint32_t period, timerCountDirection_t direction, timerMode_t mode); void timerSetHz(timerNo_t timer, uint16_t hz); diff --git a/bsl/csl/stm32f042/Device/hardwareDescription.h b/bsl/csl/stm32f042/Device/hardwareDescription.h index 9bd13bc..7e18dd6 100644 --- a/bsl/csl/stm32f042/Device/hardwareDescription.h +++ b/bsl/csl/stm32f042/Device/hardwareDescription.h @@ -194,6 +194,15 @@ static const uint8_t timerBus_En_bitPos[MAX_TIMER_CHANNEL_COUNT] = { RCC_APB2ENR_TIM17EN_Pos }; +static const uint8_t timerBus_Rst_bitPos[MAX_TIMER_CHANNEL_COUNT] = { + RCC_APB2RSTR_TIM1RST_Pos, + RCC_APB1RSTR_TIM2RST_Pos, + RCC_APB1RSTR_TIM3RST_Pos, + RCC_APB1RSTR_TIM14RST_Pos, + RCC_APB2RSTR_TIM16RST_Pos, + RCC_APB2RSTR_TIM17RST_Pos +}; + static const uint8_t timerBus_No[MAX_TIMER_CHANNEL_COUNT] = { 2, 1, @@ -203,15 +212,6 @@ static const uint8_t timerBus_No[MAX_TIMER_CHANNEL_COUNT] = { 2 }; -static const uint32_t timerMaxCounter[MAX_TIMER_CHANNEL_COUNT] = { - 0xFFFF, /*!< Timer 1 has a 16 bit counter */ - 0xFFFFFFFF, /*!< Timer 2 has a 32 bit counter */ - 0xFFFF, /*!< Timer 3 has a 16 bit counter */ - 0xFFFF, /*!< Timer 14 has a 16 bit counter */ - 0xFFFF, /*!< Timer 16 has a 16 bit counter */ - 0xFFFF /*!< Timer 17 has a 16 bit counter */ -}; - #ifdef __cplusplus } #endif diff --git a/bsl/csl/stm32f042/Src/timer.c b/bsl/csl/stm32f042/Src/timer.c index 904f97e..f7a0379 100644 --- a/bsl/csl/stm32f042/Src/timer.c +++ b/bsl/csl/stm32f042/Src/timer.c @@ -5,7 +5,14 @@ void timerReset(timerNo_t timer) { - // To implement RM page 116 + if(timerBus_No[timer]==1) + { + RCC->APB1RSTR |= (1<APB1RSTR &=~ (1<APB2RSTR |= (1<APB2RSTR &=~ (1<