32 lines
758 B
C
32 lines
758 B
C
#ifndef ENCODER_H
|
|
#define ENCODER_H
|
|
|
|
#ifdef STM32G030xx
|
|
#include "stm32g0xx_hal.h"
|
|
#endif
|
|
|
|
#ifdef STM32F030xx
|
|
#include "stm32f0xx_hal.h"
|
|
#endif
|
|
|
|
typedef struct DS_Encoder
|
|
{
|
|
GPIO_TypeDef *PortEncSignal1, *PortEncSignal2;
|
|
uint16_t PinEncSignal1, PinEncSignal2;
|
|
int8_t State;
|
|
int8_t Direction;
|
|
uint32_t PrevTick;
|
|
|
|
uint8_t ValueSignal1, ValueSignal2;
|
|
TIM_HandleTypeDef *hTim;
|
|
}DS_Encoder;
|
|
|
|
void DS_EncoderInitTim(DS_Encoder *Encoder, TIM_HandleTypeDef *hTim);
|
|
|
|
void DS_EncoderInit(DS_Encoder *Encoder, GPIO_TypeDef* PortEncSignal1, uint16_t PinEncSignal1, GPIO_TypeDef* PortEncSignal2, uint16_t PinEncSignal2);
|
|
|
|
void DS_EncoderUpdate(DS_Encoder *Encoder);
|
|
|
|
int8_t DS_EncoderGetState(DS_Encoder *Encoder);
|
|
|
|
#endif //ENCODER_H
|