#ifndef __BSP_ENCODER_H__
#define __BSP_ENCODER_H__
#include "main.h"
#include "user_config.h"
#include <stdbool.h>
#include <stdint.h>

#define ENCODER_PPR        500
#ifndef ENCODER_MAX_COUNT
#define ENCODER_MAX_COUNT  (0xFFFF)
#endif
extern volatile int32_t  encoder_tim_overflow_count;

#if (USING_SOFT_ENCODER == 1)
#define ENCODER_GPIO_RCC_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
#define ENCODER_GPIO_PHASE_A_Port GPIOA
#define ENCODER_GPIO_PHASE_A_Pin GPIO_PIN_0
#define ENCODER_GPIO_PHASE_B_Port GPIOA
#define ENCODER_GPIO_PHASE_B_Pin GPIO_PIN_1
#endif

void pm_encoder_init(void);
void pm_encoder_start(void);

void pm_encoder_stop(void);

int32_t pm_encoder_get_count(void);

bool pm_encoder_counting_down(void);

uint32_t pm_encoder_get_cpr(void);

#endif // __PM_ENCODER_H__
