#ifndef _COMMON_H_
#define _COMMON_H_

/****************************** Ӳ ******************************/
/* ˳ͷ֧ܺΪ1ʼ˳ʱ */
/*  */
#define MOTOR_1_DIR 	( C7 )
#define MOTOR_1_PWM 	( PWM2_MODULE0_CHA_C6 )

#define MOTOR_2_DIR 	( D2 )
#define MOTOR_2_PWM 	( PWM2_MODULE3_CHB_D3 ) 

#define MOTOR_3_DIR 	( C9 )
#define MOTOR_3_PWM 	( PWM2_MODULE1_CHA_C8 ) 

/*  */
#define ENCODER_1_MODULE_NUM 	( QTIMER1_ENCODER2 )
#define ENCODER_1_CH1 			( QTIMER1_ENCODER2_CH1_C2 )
#define ENCODER_1_CH2 			( QTIMER1_ENCODER2_CH2_C24 )

#define ENCODER_2_MODULE_NUM 	( QTIMER1_ENCODER1 )
#define ENCODER_2_CH1 			( QTIMER1_ENCODER1_CH1_C0 )
#define ENCODER_2_CH2 			( QTIMER1_ENCODER1_CH2_C1 )

#define ENCODER_3_MODULE_NUM 	( QTIMER2_ENCODER1 )
#define ENCODER_3_CH1 			( QTIMER2_ENCODER1_CH1_C3 )
#define ENCODER_3_CH2 			( QTIMER2_ENCODER1_CH2_C4 )

/* 
궨
DIRΪߵƽʱ˳ʱת궨ֵΪ True
DIRΪߵƽʱʱת궨ֵΪ False
*/
#define MOTOR_1_FRONT_DIR 	( True )
#define MOTOR_2_FRONT_DIR 	( True )
#define MOTOR_3_FRONT_DIR 	( False )

/* 
궨
ռʱתʱֵΪ궨ֵΪ True
ռʱʱֵΪ궨ֵΪ False
*/
#define CURRENT_1_FRONT_DIR ( False )
#define CURRENT_2_FRONT_DIR ( True )
#define CURRENT_3_FRONT_DIR ( False )

/* 
궨
ʱתʱֵΪ궨ֵΪ True
ʱתʱֵΪ궨ֵΪ False
*/
#define ENCODER_1_FRONT_DIR ( False )
#define ENCODER_2_FRONT_DIR ( False )
#define ENCODER_3_FRONT_DIR ( False )

/* 
Ƿ궨
תʱZΪ궨ֵΪ True
תʱZΪ궨ֵΪ False
*/
#define IMU_X_FRONT_DIR ( False )
#define IMU_Y_FRONT_DIR ( False )
#define IMU_Z_FRONT_DIR ( False )

/*  */
#define UP_PIN 		( C13 )
#define DOWN_PIN 	( C15 )
#define LEFT_PIN 	( C12 )
#define RIGHT_PIN 	( C14 )
#define PRESS_PIN 	( C11 )

/* AIͷ0  */
#define AI_CAMERA_0_UART_INDEX				( UART_4 )                              
#define AI_CAMERA_0_UART_BAUDRATE         	( 115200 )                            
#define AI_CAMERA_0_UART_TX_PIN           	( UART4_TX_C16 )                       
#define AI_CAMERA_0_UART_RX_PIN           	( UART4_RX_C17 ) 

#define AI_CAMERA_MERGE			// AIͷں
/* AIͷ1  */
#define AI_CAMERA_1_UART_INDEX			    ( UART_1 )                              
#define AI_CAMERA_1_UART_BAUDRATE           ( 115200 )                            
#define AI_CAMERA_1_UART_TX_PIN             ( UART1_TX_B12 )                       
#define AI_CAMERA_1_UART_RX_PIN             ( UART1_RX_B13 ) 
#ifndef AI_CAMERA_MERGE
/* AIͷ2  */
#define AI_CAMERA_2_UART_INDEX			    ( UART_2 )                              
#define AI_CAMERA_2_UART_BAUDRATE           ( 115200 )                            
#define AI_CAMERA_2_UART_TX_PIN             ( UART2_TX_B18 )                       
#define AI_CAMERA_2_UART_RX_PIN             ( UART2_RX_B19 ) 
#endif

/* ̲*/
#define ENCODER_LINE_NUM		(float)(4096)			// 
#define GEAR_RATIO 				(float)(4.22)			// ֱȣ ת/ת (4.22*1/1)
#define WHEEL_CIRCUMFERENCE 	(float)(18.6047584)		// ܳcm
#define RADIUS					(float)(9.5244294)		// ĵ־루cm
#define GYRO_Z_RATE				(float)()				// 

/*  */
#define BUZZER_PIN 		(PWM4_MODULE3_CHA_C31)

/* Ҷȴ */
#define GRAYSCALE_SENSOR_PIN	(ADC1_CH5_B16)

/* ѹ */
#define BAT_VOLTAGE_PIN				(ADC1_CH4_B15)		// صѹ

/*  */
#define CURRENT_1_PIN				(ADC1_CH10_B21)		// 1 
#define CURRENT_2_PIN				(ADC1_CH3_B14)		// 2 
#define CURRENT_3_PIN				(ADC1_CH12_B23)		// 3 
#define CURRENT_RATIO				(float)(49.6485)		// ѹ-ϵѹ/ a=4096 / 3.3 * 20 * 0.002

/*  */
#define SUPPLEMENT_LAMP_EN_PIN				(B10)		// PWM
#define SUPPLEMENT_LAMP_DIN_PIN				(B9)		// ͨ

/*********************************************************************/

/****************************** Ԥ ******************************/

#define FUZZY_SPEED_AND_CURRENT      						// ͣģٶȻ+FUZZY_SPEED_AND_CURRENT;ٶȻ+SPEED_AND_CURRENT;ٶȻSPEED
#define BOX_NUM_MAX 50										// 

/***********************************************************************/

/****************************** AIͷ ******************************/

#define AI_CAMERA_0_IMAGE_WIDTH		( 160 )			// AIͷ0 ͼ
#define AI_CAMERA_0_IMAGE_HIGHT		( 120 )			// AIͷ0 ͼ߶
#define AI_CAMERA_0_OFFSET 			(  5 )			// AIͷ0 ͼƫ
#define AI_CAMERA_0_IMAGE_RATE		(float)(  1  ) 	// AIͷ0 ͼӦAI׷

/**************************************************************************/

/****************************** ˵ ******************************/

#define SCREEN_KIND 			(1)		// Ļѡ 0:tft180 1:ips200 
#define MENU_ROW_PITCH 20	// ˵м
#define MAX_ROW 16			// 
#define DATA_MAX_COL 150	// 

/***********************************************************************/

/****************************** жϲ ******************************/

#define SENSOR_SOLVE_IT_CH 						( PIT_CH0 ) 			// ֵ/ȡжϺ
#define SENSOR_SOLVE_IT_TIME 					( 5 ) 					// ֵ/ȡж ms
#define CONTROL_IT_CH 							( PIT_CH1 )				// жϺ
#define CONTROL_IT_TIME  						( 5 )					// ж ms
#define TIMER_IT_CH 							( PIT_CH2 )				// ʱжϺ
#define TIMER_IT_TIME							( 5 )					// ʱж ms
#define MENU_KEY_SCAN_IT_CH 					( PIT_CH3 )				// ɨжϺ
#define MENU_KEY_SCAN_IT_TIME					( 40 )  				// ɨж ms
#define AI_CAMERA_0_UART_PRIORITY     			( LPUART4_IRQn )  		// AIͷ0 ڽжϺ
#define AI_CAMERA_1_UART_PRIORITY     			( LPUART1_IRQn )  		// AIͷ1 ڽжϺ
#define AI_CAMERA_2_UART_PRIORITY     			( LPUART2_IRQn )  		// AIͷ1 ڽжϺ

/*********************************************************************/

/* C׼ */
#include "math.h"

/* ɿͷļ */
#include "zf_common_headfile.h"
#include "zf_common_debug.h"
#include "isr.h"

/* DOGͷļ */
#include "DOG_motor.h"
#include "DOG_data.h"
#include "DOG_vofa.h"
#include "DOG_sensor.h"
#include "DOG_solve.h"
#include "DOG_cv.h"
#include "DOG_path.h"
#include "DOG_filter.h"
#include "DOG_pid.h"
#include "DOG_timer.h"
#include "DOG_rwr.h"
//#include "DOG_menu.h"

/* ûͷļ */
#include "debug.h"
#include "menu.h"
#include "menu_data.h"
#include "ai.h"
#include "control.h"
#include "fsm.h"


#endif