/***********************************************************************
 * Copyright (c)  2017 - 2022, Unicmicro Co.,Ltd .
 * All rights reserved.
 * Filename    : atim_encoder.c
 * Description : atim_encoder source file
 * Author(s)   : Hackett
 * version     : V1.0
 * Modify date : 2022-07-10
 ***********************************************************************/
#include  "atim_encoder.h"
#include  "uart0.h"
#include  "uart1.h"
#include  "uart2.h"
#include  "atimer.h"
#include  "gpio.h"


/************************************************************************
 * function   : atimer_encoder_pro
 * Description: atimer_encoder_pro atimer处理回调函数
 * input : none
 * return: none
 ************************************************************************/
void atimer_encoder_pro(void)
{
	if(atimer_get_status(ATIM_STATUS_CC1IF))
	{	
		printfS("atimer count value : %d \r\n", atimer_get_cnt());	
	}
}

/************************************************************************
 * function   : atimer_encoder_test
 * Description: 编码器模式
 * input : none
 * return: none
 ************************************************************************/
void atimer_encoder_test(void)
{
	printfS("start atimer encoder test! \r\n");
	
	gpio_init(GPIOF, PIN0, 7);		//PF0 ATIM_CH1
	gpio_init(GPIOF, PIN2, 10);		//PF2 ATIM_CH2
	atimer_module_enable();							//使能时钟并复位定时器0模块
	atimer_encoder_init(4800, 2, ATIM_ENCODER2);
	atimer_counter(ATIM_ENABLE);						//计数器使能
	atimer_irq(ATIM_CC1IE, ATIMER_IRQn, ATIM_ENABLE, atimer_encoder_pro);//允许捕捉/比较1中断,开启中断
}




