Timer.c : modified the timerInit to timerInitCounter as we want to add dieffretn init cof differen timer modes

interrupts
key 3 years ago
parent c68c8fd33d
commit b8c2355049

@ -46,6 +46,20 @@ typedef enum {
onePulse onePulse
} timerMode_t; } 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. * Reset the timer to its default state.
*/ */
@ -69,7 +83,15 @@ void timerClearUpdateInterrupt(timerNo_t timer);
void timerClearCounter(timerNo_t timer); void timerClearCounter(timerNo_t timer);
/* Second stage configuration */ /* 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 timerSetHz(timerNo_t timer, uint16_t hz);
void timerSetMs(timerNo_t timer, uint16_t ms); void timerSetMs(timerNo_t timer, uint16_t ms);

@ -89,15 +89,14 @@ void timerClearUpdateInterrupt(timerNo_t timer)
/* Second stage configuration */ /* Second stage configuration */
void timerInit( timerNo_t timer, void timerInitCounter ( timerNo_t timer,
uint32_t prescaler, uint32_t prescaler,
uint32_t period, uint32_t period,
timerCountDirection_t direction, timerCountDirection_t direction)
timerMode_t mode)
{ {
timerActivateBus(timer); timerActivateBus(timer);
timerReset(timer); timerReset(timer);
timerSetMode(timer, mode); timerSetMode(timer, counter);
timerSetCountDirection(timer,direction); timerSetCountDirection(timer,direction);
timerSetPrescaler(timer, prescaler); timerSetPrescaler(timer, prescaler);
timerSetAutoReload(timer, period); timerSetAutoReload(timer, period);

@ -8,7 +8,7 @@
void timer_test(timerNo_t timer, pinNo_t pin) void timer_test(timerNo_t timer, pinNo_t pin)
{ {
timerInit(timer, 4000, 999, downCounting, counter); timerInitCounter(timer, 4000, 999, downCounting);
timerSart(timer); timerSart(timer);
for(int i = 0; i < 10 ; i++) for(int i = 0; i < 10 ; i++)

Loading…
Cancel
Save