/*
 * usr_gpio.h
 *
 *  Created on: 2022��4��11��
 *      Author: amos
 */

#ifndef USR_MOTMOR_H_
#define USR_MOTMOR_H_

#include "onechip_include_header.h"
/*************************************/
#define MOTOR_OPTIC_PORT PF//光开
#define MOTOR_OPTIC_PIN  BIT5//光开
#define MOTOR_OPTIC_INT_CH  5//光开
#define MOTOR_OPTIC()  (PF5)  //按键
#define KYE_PORT  PA //按键
#define KYE_PIN  BIT15 //按键
#define KYE_INT_CH  15//光开
#define KYE()  PA15 //按键
#define MOTOR_CH_REV_MASK PWM_CH_4_MASK 
#define MOTOR_CH_REV	4
#define MOTOR_CH_FWD_MASK PWM_CH_5_MASK 
#define MOTOR_CH_FWD	5 

#define MOTOR_CHECK_SPEED	60
#define MOTOR_MOVEFORM_OPTIC_TIM	10
#define MOTOR_LOOP_TIM	100

#define MOTOR_SWING_TIM	100

typedef enum {
	MOTOR_REV = 0,
	MOTOR_FWD = 1,
}MOTOR_DIR;
void KYE_IRQHandler(void);
void OPTO_IRQHandler(void);
void Motor_Init(void);
uint32_t Motor_Check(uint32_t swing);
uint32_t Motor_mix(uint32_t time,uint32_t speed,uint32_t swing,uint32_t swingtimeRight, uint32_t swingtimePause);
uint32_t Read_Motor(void);
uint32_t Motor_mix_work(void);
uint32_t Motor_Run_Continue(uint32_t speed);
uint32_t Motor_idle(void);
uint32_t print_home_time(void);


/***********************************/
#endif /* USR_MOTMOR_H_ */
