165 lines
6.1 KiB
C
165 lines
6.1 KiB
C
#ifndef _user_H_
|
||
#define _user_H_
|
||
|
||
|
||
#define SAMPLE_INTERVAL 50 // 50ms<6D><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
#define BLINK_TIMEOUT (1000 / SAMPLE_INTERVAL) // 1<><31><EFBFBD>ȶ<EFBFBD>ȷ<EFBFBD><C8B7>
|
||
#define BLINK_WINDOW (1000 / SAMPLE_INTERVAL) // 1<><31><EFBFBD><EFBFBD>˸<EFBFBD><CBB8>ⴰ<EFBFBD><E2B4B0>
|
||
#define STABLE_CONFIRM_TIME (1000 / SAMPLE_INTERVAL) // 1<><31><EFBFBD><EFBFBD>˸<EFBFBD><CBB8>ⴰ<EFBFBD><E2B4B0>
|
||
#define MIN_BLINKS 2
|
||
|
||
#define MATCH_TIME (2000 / SAMPLE_INTERVAL)//<2F><>Ƶʱ<C6B5><CAB1>
|
||
#define MATCH_WAIT_TIME (1000 / SAMPLE_INTERVAL)//<2F><>Ƶ<EFBFBD>꣬<EFBFBD>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>
|
||
|
||
#define CHANGE_TIME (200 / SAMPLE_INTERVAL)//<2F><>Ƶʱ<C6B5><CAB1>
|
||
|
||
#define MATCH_CMD 0xDB//<2F><>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
|
||
#define CHANGE_CMD 0xBD//<2F>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
|
||
#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<57><4D>???<3F><>???<3F><><EFBFBD><EFBFBD>??<3F><>?10<31><30>?10ms<6D><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>???<3F><>?D<><44><EFBFBD><EFBFBD>a2a<32><61>?20181227
|
||
|
||
|
||
|
||
|
||
|
||
|
||
#define DF_ZeroValue 1000//?<3F><>?Y<><59><EFBFBD><EFBFBD>???<3F>¡<EFBFBD>???0<><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y?Y?a1022
|
||
|
||
#define DF_Speed UnRemoteControlOutput_1.bit_data.speed//?<3F><>?<3F><>
|
||
#define DF_Curvature UnRemoteControlOutput_1.bit_data.curvature//<2F><>a<EFBFBD><61>?
|
||
#define DF_Reserve UnRemoteControlOutput_1.bit_data.reserve1//<2F><><EFBFBD>ꨢ?
|
||
#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//<2F><>?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1?<3F><><EFBFBD><EFBFBD><EFBFBD>䨬?
|
||
|
||
//#define DF_RCHEmSwSta UnRCH_1.BitData.RCHBit07//?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?a1?<3F><><EFBFBD>䨬?<3F><>1?<3F><><EFBFBD><EFBFBD><EFBFBD>䨬?
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// ?<3F><><EFBFBD><EFBFBD>?2<><32>3?<3F><>??<3F><> SBus ?a???<3F><>11<31><31>?
|
||
typedef struct {
|
||
uint16_t channels[16]; // <20><>?<3F><><EFBFBD>16??<3F><><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><CCA8><EFBFBD>??a???<3F><>1?
|
||
uint8_t flags; // <20><><EFBFBD><EFBFBD>??<3F><>??<3F><>
|
||
} SBusData;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// ?<3F><><EFBFBD><EFBFBD>?<3F><><EFBFBD><EFBFBD>???<3F>¨<EFBFBD>?<3F><>?
|
||
typedef struct _StrRemoteControlOutput
|
||
{
|
||
//-----<2D><><EFBFBD><EFBFBD>?<3F><><EFBFBD><EFBFBD>y?Y0x12000023----------------------------------------------
|
||
signed int speed : 16; // ?<3F><>?<3F><>
|
||
signed int curvature : 16; // ?<3F><>?<3F><>
|
||
|
||
|
||
unsigned int reserve1 : 16; // <20><><EFBFBD><EFBFBD>???<3F><>
|
||
|
||
unsigned int switch_a : 1; // SwA
|
||
unsigned int switch_b : 2; // SwB ?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?a1? 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? 0/2<><32>??<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
unsigned int switch_c : 2; // SwC ?<3F>??a1? 1<><31>??<3F><> 0/2<><32>?<3F><>??<3F><>
|
||
unsigned int switch_d : 1; // SwD <20><>?<3F><>??a1? ?<3F><>?<3F><><EFBFBD><EFBFBD><EFBFBD>?<3F><>3<EFBFBD><33><EFBFBD><EFBFBD>
|
||
unsigned int reserve2 : 1; // <20><><EFBFBD>ꨢ?
|
||
unsigned int reserve3 : 1; // <20><><EFBFBD>ꨢ?
|
||
|
||
unsigned int enable : 8; // <20><>1?<3F><>
|
||
} StrRemoteControlInput;
|
||
|
||
typedef union _UnRemoteControlInput
|
||
{
|
||
StrRemoteControlInput bit_data; // <20><>1<EFBFBD><31>??<3F><><EFBFBD><EFBFBD>?<3F><>??<3F><>11<31><31>?<3F><>?<3F><>???
|
||
uint8_t arr[sizeof(StrRemoteControlInput)]; // <20><><EFBFBD><EFBFBD>1y?<3F><>11<31><31>?<3F><><EFBFBD><EFBFBD>D<EFBFBD><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<3F><><EFBFBD>䨮D?
|
||
} UnRemoteControlOutput;
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//---<2D><>a2?<3F><>a<EFBFBD><61>1<EFBFBD><31>?<3F><>?<3F><>?<3F><><EFBFBD><EFBFBD>?<3F><>---------------------------------------------------------------------
|
||
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;
|
||
extern ubyte RestartDataFlg1;
|
||
extern ubyte RestartDataFlg2;
|
||
|
||
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 |