diff --git a/bsl/csl/interfaces/timer.h b/bsl/csl/interfaces/timer.h index 69a7e2f..0d453f1 100644 --- a/bsl/csl/interfaces/timer.h +++ b/bsl/csl/interfaces/timer.h @@ -46,6 +46,20 @@ typedef enum { onePulse } timerMode_t; +/*! + * Output compare modes. + */ +typedef enum { + frozen, /*!< Pin update is **de-activated** even when a compare match happens */ + high_on_match, /*!< Pin goes **high** when a compare match occurs */ + low_on_match, /*!< Pin goes **low** when a compare match occurs */ + toggle, /*!< Pin **toggles** when a compare match occurs */ + inactive_force_high, /*!< Pin if forced **high** */ + inactive_force_low, /*!< Pin if forced **low** */ + pwm_normal, /*!< Standart PWM mode */ + pwm_inverted /*!< Inverted PWM mode */ +}; + /*! * Reset the timer to its default state. */ @@ -69,7 +83,15 @@ 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 timerInitCounter( timerNo_t timer, + uint32_t prescaler, + uint32_t period, + timerCountDirection_t direction); + +void timerInitPwm( timerNo_t timer, + uint32_t prescaler, + uint32_t period, + timerCountDirection_t direction); void timerSetHz(timerNo_t timer, uint16_t hz); void timerSetMs(timerNo_t timer, uint16_t ms); diff --git a/bsl/csl/stm32f042/Src/timer.c b/bsl/csl/stm32f042/Src/timer.c index b2fd084..1c18330 100644 --- a/bsl/csl/stm32f042/Src/timer.c +++ b/bsl/csl/stm32f042/Src/timer.c @@ -89,15 +89,14 @@ void timerClearUpdateInterrupt(timerNo_t timer) /* Second stage configuration */ -void timerInit( timerNo_t timer, - uint32_t prescaler, - uint32_t period, - timerCountDirection_t direction, - timerMode_t mode) +void timerInitCounter ( timerNo_t timer, + uint32_t prescaler, + uint32_t period, + timerCountDirection_t direction) { timerActivateBus(timer); timerReset(timer); - timerSetMode(timer, mode); + timerSetMode(timer, counter); timerSetCountDirection(timer,direction); timerSetPrescaler(timer, prescaler); timerSetAutoReload(timer, period); diff --git a/main.cpp b/main.cpp index fc1341f..84f3638 100644 --- a/main.cpp +++ b/main.cpp @@ -8,7 +8,7 @@ void timer_test(timerNo_t timer, pinNo_t pin) { - timerInit(timer, 4000, 999, downCounting, counter); + timerInitCounter(timer, 4000, 999, downCounting); timerSart(timer); for(int i = 0; i < 10 ; i++)