/*********************************************************************************************************************
* TC264 Opensourec Library TC264 Դ⣩һڹٷ SDK ӿڵĵԴ
* Copyright (c) 2022 SEEKFREE ɿƼ
*
* ļ TC264 Դһ
*
* TC264 Դ 
* Ըᷢ GPLGNU General Public License GNUͨù֤
*  GPL ĵ3棨 GPL3.0ѡģκκİ汾·/޸
*
* Դķϣܷãδκεı֤
* ûԻʺض;ı֤
* ϸμ GPL
*
* ӦյԴͬʱյһ GPL ĸ
* ûУ<https://www.gnu.org/licenses/>
*
* ע
* Դʹ GPL3.0 Դ֤Э Ϊİ汾
* Ӣİ libraries/doc ļµ GPL3_permission_statement.txt ļ
* ֤ libraries ļ ļµ LICENSE ļ
* ӭλʹò ޸ʱ뱣ɿƼİȨ
*
* ļ          zf_driver_encoder
* ˾          ɶɿƼ޹˾
* 汾Ϣ          鿴 libraries/doc ļ version ļ 汾˵
*           ADS v1.9.4
* ƽ̨          TC264D
*           https://seekfree.taobao.com/
*
* ޸ļ¼
*                               ע
* 2022-09-15       pudding            first version
********************************************************************************************************************/

#ifndef _zf_driver_encoder_h_
#define _zf_driver_encoder_h_

#include "zf_common_typedef.h"

// öٶ岻û޸
typedef enum // öٱ
{
    TIM2_ENCODER_CH1_P00_7,      // T2ʱ ſѡΧ
    TIM2_ENCODER_CH1_P33_7,

    TIM3_ENCODER_CH1_P02_6,      // T3ʱ ſѡΧ

    TIM4_ENCODER_CH1_P02_8,      // T4ʱ ſѡΧ

    TIM5_ENCODER_CH1_P21_7,      // T5ʱ ſѡΧ
    TIM5_ENCODER_CH1_P10_3,

    TIM6_ENCODER_CH1_P20_3,      // T6ʱ ſѡΧ
    TIM6_ENCODER_CH1_P10_2,
}encoder_channel1_enum;

// öٶ岻û޸
typedef enum // öٱ
{
    TIM2_ENCODER_CH2_P00_8,     // T2ʱ ſѡΧ
    TIM2_ENCODER_CH2_P33_6,

    TIM3_ENCODER_CH2_P02_7,     // T3ʱ ſѡΧ

    TIM4_ENCODER_CH2_P00_9,     // T4ʱ ſѡΧ
    TIM4_ENCODER_CH2_P33_5,

    TIM5_ENCODER_CH2_P21_6,     // T5ʱ ſѡΧ
    TIM5_ENCODER_CH2_P10_1,

    TIM6_ENCODER_CH2_P20_0,     // T6ʱ ſѡΧ
}encoder_channel2_enum;

typedef enum  // ö ʱ
{
    TIM2_ENCODER,
    TIM3_ENCODER,
    TIM4_ENCODER,
    TIM5_ENCODER,
    TIM6_ENCODER,
}encoder_index_enum;

//==================================================== ====================================================
int16 encoder_get_count     (encoder_index_enum encoder_n);
void  encoder_clear_count   (encoder_index_enum encoder_n);

void  encoder_quad_init     (encoder_index_enum encoder_n, encoder_channel1_enum count_pin, encoder_channel2_enum dir_pin);
void  encoder_dir_init      (encoder_index_enum encoder_n, encoder_channel1_enum ch1_pin, encoder_channel2_enum ch2_pin);
//==================================================== ====================================================

#endif
