164 lines
5.4 KiB
C
164 lines
5.4 KiB
C
#ifndef _user_H_
|
||
#define _user_H_
|
||
|
||
|
||
#define SAMPLE_INTERVAL 50 // 50ms采样周期
|
||
#define BLINK_TIMEOUT (1000 / SAMPLE_INTERVAL) // 1秒稳定确认
|
||
#define BLINK_WINDOW (1000 / SAMPLE_INTERVAL) // 1秒闪烁检测窗口
|
||
#define STABLE_CONFIRM_TIME (1000 / SAMPLE_INTERVAL) // 1秒闪烁检测窗口
|
||
#define MIN_BLINKS 2
|
||
|
||
#define MATCH_TIME (2000 / SAMPLE_INTERVAL)//对频时间
|
||
#define MATCH_WAIT_TIME (1000 / SAMPLE_INTERVAL)//对频完,等待时间
|
||
|
||
#define CHANGE_TIME (200 / SAMPLE_INTERVAL)//对频时间
|
||
|
||
#define MATCH_CMD 0xDB//对频命令
|
||
#define CHANGE_CMD 0xBD//切换命令
|
||
|
||
|
||
#define uint32_t ulong
|
||
#define uint16_t uword
|
||
#define uint8_t ubyte
|
||
|
||
#define int16_t signed int
|
||
|
||
|
||
#define DF_SwTx 6
|
||
#define DF_SwRx 7
|
||
#define DF_SwRxPwm 8
|
||
#define DF_SwTx1 10
|
||
|
||
|
||
#define dfCmd_01 UnInfCan_1.BitData.D21 //KGF1
|
||
#define dfCmd_02 UnInfCan_1.BitData.D22 //KGF2
|
||
#define dfCmd_03 UnInfCan_1.BitData.D23 //KGF3
|
||
#define dfCmd_04 UnInfCan_1.BitData.D24 //KGF4
|
||
#define dfCmd_05 UnInfCan_1.BitData.D25 //KGF5
|
||
#define dfCmd_06 UnInfCan_1.BitData.D26 //KGF6
|
||
#define dfCmd_07 UnInfCan_1.BitData.D27 //KGF7
|
||
#define dfCmd_08 UnInfCan_1.BitData.D28 //KGF8
|
||
#define dfCmd_09 UnInfCan_1.BitData.D29 //KGF9
|
||
#define dfCmd_10 UnInfCan_1.BitData.D30 //KGF10
|
||
#define dfCmd_11 UnInfCan_1.BitData.D31 //KGF11
|
||
#define dfCmd_12 UnInfCan_1.BitData.D32 //KGF12
|
||
#define dfCmd_13 UnInfCan_1.BitData.D33 //KGF13
|
||
#define dfCmd_14 UnInfCan_1.BitData.D34 //KGF14
|
||
#define dfCmd_15 UnInfCan_1.BitData.D35 //KGF15
|
||
#define dfCmd_16 UnInfCan_1.BitData.D36 //KGF16
|
||
|
||
#define dfOut_01 SwOut09 //KGF1
|
||
#define dfOut_02 SwOut10 //KGF2
|
||
#define dfOut_03 SwOut04 //KGF3
|
||
#define dfOut_04 SwOut03 //KGF4
|
||
#define dfOut_05 SwOut06 //KGF5
|
||
#define dfOut_06 SwOut05 //KGF6
|
||
#define dfOut_07 SwOut15 //KGF7
|
||
#define dfOut_08 SwOut16 //KGF8
|
||
#define dfOut_09 SwOut13 //KGF9
|
||
#define dfOut_10 SwOut14 //KGF10
|
||
#define dfOut_11 SwOut08 //KGF11
|
||
#define dfOut_12 SwOut07 //KGF12
|
||
#define dfOut_13 SwOut02 //KGF13
|
||
#define dfOut_14 SwOut01 //KGF14
|
||
#define dfOut_15 SwOut11 //KGF15
|
||
#define dfOut_16 SwOut12 //KGF16
|
||
|
||
#define dfPwmH 10 //PWMμ???μ???ê±??£?10£?10ms×óóò£???ì?Dèòa2aê?20181227
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#define DF_ZeroValue 1000//?ù?Yò£???÷£???0ê±êy?Y?a1022
|
||
|
||
#define DF_Speed UnRemoteControlOutput_1.bit_data.speed//?ù?è
|
||
#define DF_Curvature UnRemoteControlOutput_1.bit_data.curvature//×aí?
|
||
#define DF_Reserve UnRemoteControlOutput_1.bit_data.reserve1//±£á?
|
||
#define DF_SwA UnRemoteControlOutput_1.bit_data.switch_a//DF_SwA
|
||
#define DF_SwB UnRemoteControlOutput_1.bit_data.switch_b//DF_SwB
|
||
#define DF_SwC UnRemoteControlOutput_1.bit_data.switch_c//DF_SwC
|
||
#define DF_SwD UnRemoteControlOutput_1.bit_data.switch_d//DF_SwD
|
||
#define DF_RCHSta UnRemoteControlOutput_1.bit_data.enable//ê?±úê1?ü×′ì?
|
||
|
||
//#define DF_RCHEmSwSta UnRCH_1.BitData.RCHBit07//?±í£?a1?×′ì?ê1?ü×′ì?
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// ?¨ò?2¢3?ê??ˉ SBus ?a???á11ì?
|
||
typedef struct {
|
||
uint16_t channels[16]; // ′?′¢16??í¨μàμ??a???á1?
|
||
uint8_t flags; // ±ê??×??ú
|
||
} SBusData;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// ?óê?ò£???÷ê?è?
|
||
typedef struct _StrRemoteControlOutput
|
||
{
|
||
//-----·¢?íêy?Y0x12000023----------------------------------------------
|
||
signed int speed : 16; // ?ú?ê
|
||
signed int curvature : 16; // ?ù?è
|
||
|
||
|
||
unsigned int reserve1 : 16; // ò£???á
|
||
|
||
unsigned int switch_a : 1; // SwA
|
||
unsigned int switch_b : 2; // SwB ?±í£?a1? 1êí·? 0/2ê??±í£
|
||
unsigned int switch_c : 2; // SwC ?£ê??a1? 1×??ˉ 0/2ê?ê??ˉ
|
||
unsigned int switch_d : 1; // SwD é?μ??a1? ?è?ì°′?ù3¤°′
|
||
unsigned int reserve2 : 1; // ±£á?
|
||
unsigned int reserve3 : 1; // ±£á?
|
||
|
||
unsigned int enable : 8; // ê1?ü
|
||
} StrRemoteControlInput;
|
||
|
||
typedef union _UnRemoteControlInput
|
||
{
|
||
StrRemoteControlInput bit_data; // ê1ó??¨ò?μ??á11ì?±?á???
|
||
uint8_t arr[sizeof(StrRemoteControlInput)]; // í¨1y?á11ì?ààDíè·?¨′óD?
|
||
} UnRemoteControlOutput;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//---ía2?òaê1ó?±?á?éù?÷---------------------------------------------------------------------
|
||
extern UnSwOut UnSwOut_1;
|
||
extern UnInfCan UnInfCan_1;
|
||
extern uword CntCan_1;
|
||
extern bit FlgCan_1;
|
||
|
||
extern ubyte rxbuf[25];
|
||
extern ubyte uart2RxFlag;
|
||
extern ubyte can_error_cnt;
|
||
|
||
|
||
void CanRXTX(void);
|
||
void SwSample(void);
|
||
void LedDr(void);
|
||
void RTCProcess(void);
|
||
void CanErrorProcess(void);
|
||
void CanTransmit(ubyte index,ubyte *buf);
|
||
SBusData* parseSBusData(const uint8_t *input_data);
|
||
void sbusCanDecode(void);
|
||
|
||
#endif |