Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Nucleo_Hello_Encoder by
Diff: Encoder/EncoderInit.cpp
- Revision:
- 1:cd7b42c99ff8
- Parent:
- 0:ee5cb967aa17
diff -r ee5cb967aa17 -r cd7b42c99ff8 Encoder/EncoderInit.cpp
--- a/Encoder/EncoderInit.cpp Sat Jan 10 20:06:07 2015 +0000
+++ b/Encoder/EncoderInit.cpp Sun Oct 04 11:58:58 2015 +0000
@@ -1,32 +1,33 @@
#include "mbed.h"
-void EncoderInit(TIM_Encoder_InitTypeDef encoder, TIM_HandleTypeDef timer, TIM_TypeDef *TIMx, uint32_t maxcount, uint32_t encmode)
+void EncoderInit(TIM_Encoder_InitTypeDef * encoder, TIM_HandleTypeDef * timer, TIM_TypeDef * TIMx, uint32_t maxcount, uint32_t encmode)
{
- timer.Instance = TIMx;
- timer.Init.Period = maxcount;
- timer.Init.CounterMode = TIM_COUNTERMODE_UP;
- timer.Init.Prescaler = 0;
- timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- encoder.EncoderMode = encmode;
+ timer->Instance = TIMx;
+ timer->Init.Period = maxcount;
+ timer->Init.CounterMode = TIM_COUNTERMODE_UP;
+ timer->Init.Prescaler = 0;
+ timer->Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- encoder.IC1Filter = 0x0F;
- encoder.IC1Polarity = TIM_INPUTCHANNELPOLARITY_RISING;
- encoder.IC1Prescaler = TIM_ICPSC_DIV4;
- encoder.IC1Selection = TIM_ICSELECTION_DIRECTTI;
+ encoder->EncoderMode = encmode;
- encoder.IC2Filter = 0x0F;
- encoder.IC2Polarity = TIM_INPUTCHANNELPOLARITY_FALLING;
- encoder.IC2Prescaler = TIM_ICPSC_DIV4;
- encoder.IC2Selection = TIM_ICSELECTION_DIRECTTI;
+ encoder->IC1Filter = 0x0F;
+ encoder->IC1Polarity = TIM_INPUTCHANNELPOLARITY_RISING;
+ encoder->IC1Prescaler = TIM_ICPSC_DIV4;
+ encoder->IC1Selection = TIM_ICSELECTION_DIRECTTI;
+
+ encoder->IC2Filter = 0x0F;
+ encoder->IC2Polarity = TIM_INPUTCHANNELPOLARITY_FALLING;
+ encoder->IC2Prescaler = TIM_ICPSC_DIV4;
+ encoder->IC2Selection = TIM_ICSELECTION_DIRECTTI;
- if (HAL_TIM_Encoder_Init(&timer, &encoder) != HAL_OK) {
+ if (HAL_TIM_Encoder_Init(timer, encoder) != HAL_OK) {
printf("Couldn't Init Encoder\r\n");
while (1) {}
}
- if(HAL_TIM_Encoder_Start(&timer,TIM_CHANNEL_1)!=HAL_OK) {
+ if(HAL_TIM_Encoder_Start(timer,TIM_CHANNEL_1)!=HAL_OK) {
printf("Couldn't Start Encoder\r\n");
while (1) {}
}
