on test and not completed based on nucleo_hello_encoder library
Fork of Nucleo_Hello_Encoder by
Diff: Encoder/CounterInit.cpp
- Revision:
- 1:3d2fffa6e19f
- Child:
- 2:70f92ce7d983
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Encoder/CounterInit.cpp Tue Sep 29 06:42:15 2015 +0000 @@ -0,0 +1,18 @@ +#include "mbed.h" + +void CounterInit(TIM_IC_InitTypeDef counterSet, TIM_HandleTypeDef timer, TIM_TypeDef *TIMx, uint32_t maxcount) +{ + timer.Instance = TIMx; + timer.Init.Period = maxcount; + timer.Init.CounterMode = TIM_COUNTERMODE_UP; + timer.Init.Prescaler = 0; + timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; + timer.Init.RepetitionCounter = 0; + + counterSet.ICFilter = 0; + counterSet.ICPolarity = TIM_ICPOLARITY_RISING; + counterSet.ICPrescaler = TIM_ICPSC_DIV1; + counterSet.ICSelection = TIM_ICSELECTION_DIRECTTI; + +} +