Page MenuHomec4science

incr_encoder.h
No OneTemporary

File Metadata

Created
Fri, Nov 1, 11:18

incr_encoder.h

#ifndef __INCR_ENCODERS_H
#define __INCR_ENCODERS_H
#include "../main.h"
#define CODER_A_Pin GPIO_Pin_0
#define CODER_A_Port GPIOA
#define CODER_A_PinSource GPIO_PinSource0
#define CODER_B_Pin GPIO_Pin_1
#define CODER_B_Port GPIOA
#define CODER_B_PinSource GPIO_PinSource1
#define CODER_I_Pin GPIO_Pin_3
#define CODER_I_Port GPIOE
#define CODER_RESOLUTION ((uint32_t)2000) // Number of increments per turn.
/** @defgroup Encoder Driver / Incremental encoder
* @brief Driver for an incremental encoder.
*
* This driver uses a timer of the STM32, configured as a quadrature decoder.
*
* Call enc_Init() first in the initialization code. Then, call enc_GetPosition() to
* get the decoded value.
* The output value is the paddle position in degrees, taking the reduction
* ratio into account.
*
* @addtogroup Encoder
* @{
*/
void enc_Init(void);
float32_t enc_GetPosition(void);
void enc_SetPosition(float32_t newPosition);
/**
* @}
*/
#endif

Event Timeline