/** ****************************************************************************** * @file : FPx.h * @brief : Header for FPx.c file. * This file contains the function defines of the FPx . ****************************************************************************** */ #ifndef __FPX_H__ #define __FPX_H__ #include "main.h" enum enCMD_TYPE { CMD_0_QUERY =0, CMD_1=0x1, // CMD_2=0x2, // CMD_3_EXCHG=0x3, // CMD_4=0x4, // CMD_5=0x5, // CMD_6=0x6, // CMD_7_END=0x7, // }; typedef struct tagFPxPinStat { unsigned short OE:1; unsigned short RST:1; unsigned short SYN:1; unsigned short ACK:1; unsigned short SEL:1; }stFPxPinStat; #define RST_PORT GPIOB #define RST_PIN LL_GPIO_PIN_9 #define SYN_PORT GPIOF #define SYN_PIN LL_GPIO_PIN_6 #define ACK_PORT GPIOA #define ACK_PIN LL_GPIO_PIN_11 #define FPxDE_PORT GPIOF #define FPxDE_PIN LL_GPIO_PIN_7 #define OE_PORT GPIOB #define OE_PIN LL_GPIO_PIN_6 #define SEL_PORT GPIOB #define SEL_PIN LL_GPIO_PIN_8 #define FPX_WX_NUM 16 #define FPX_WY_NUM 16 #define GetRSTPin() LL_GPIO_IsInputPinSet(RST_PORT,RST_PIN) #define GetSYNPin() LL_GPIO_IsInputPinSet(SYN_PORT,SYN_PIN) #define GetOEPin() LL_GPIO_IsInputPinSet(OE_PORT,OE_PIN) #define GetSELPin() (1) //LL_GPIO_IsInputPinSet(SEL_PORT,SEL_PIN) #define GetACKPin() LL_GPIO_IsInputPinSet(ACK_PORT,ACK_PIN) #define SetACKPin_0() LL_GPIO_ResetOutputPin(ACK_PORT,ACK_PIN) #define SetACKPin_1() LL_GPIO_SetOutputPin(ACK_PORT,ACK_PIN) #define SetFPxDEPin_0() LL_GPIO_ResetOutputPin(FPxDE_PORT,FPxDE_PIN) #define SetFPxDEPin_1() LL_GPIO_SetOutputPin(FPxDE_PORT,FPxDE_PIN) typedef void *(*FPxCBFuncDef) (int nEvent, void * pBuf, int); //callback func ,prama s is void *,void *,int; return void *; // extern uint8_t PktBuf1[64]; extern uint8_t PktBuf2[64]; extern uint8_t PktLen1; extern uint8_t PktLen2; typedef struct tagFPxStat{ uint8_t bConfiged; uint8_t nConfigStationId; uint8_t nInputBytes; uint8_t nOutputBytes; uint8_t bReceiving; uint8_t nReceivedLen; uint8_t bSending; uint8_t bSentLen; volatile uint8_t oldSYN; int RSTCount0; int bFirstReq; FPxCBFuncDef FPxCBFunc; uint8_t bFPxCallBackFuncSet; }stFPxStat; extern stFPxStat FPxStat; #pragma anon_unions typedef struct tagFPxMem{ union { unsigned short WLX[16]; //ÐéÄâµÄXºÍY£¬Ô¶³ÌͨѶʱӳÉäÓᣠunsigned char WLXB[32]; //ÐéÄâµÄXºÍY£¬Ô¶³ÌͨѶʱӳÉäÓᣠ}; union { unsigned short WLY[16]; //ÐéÄâµÄXºÍY£¬Ô¶³ÌͨѶʱӳÉäÓᣠunsigned char WLYB[32]; //ÐéÄâµÄXºÍY£¬Ô¶³ÌͨѶʱӳÉäÓᣠ}; }stFPxMem; extern stFPxMem FPxMem; typedef struct tagFPxQuRplyPkt { uint8_t Hdr1; uint8_t nInputBytes; uint8_t nOutputBytes; uint8_t nParam1; uint8_t nBCC; uint8_t End1; }stFPxQuRplyPkt, *pFPxQuRplyPkt; typedef struct tagFPxEXGRplyPkt { uint8_t Hdr1; uint8_t nInputBytes[6]; uint8_t nBCC; uint8_t End1; }stFPxEXGRplyPkt, * pFPxEXGRplyPkt; uint8_t FPx_Init(int nChilds); uint8_t FPx_SetIOCount(int nInputBytes, int nOutputBytes); uint8_t FPx_Proc(void); uint8_t FPxCalBCC(uint8_t* pBuf, uint8_t len1); uint8_t FPxCheckPkt(uint8_t * pBuf, uint8_t len1); uint8_t FPxParsePkt(uint8_t * pBuf, uint8_t len1); uint8_t FPxSendPkt(uint8_t * pBuf, uint8_t len1); int FPxSetCallBackFunc(FPxCBFuncDef Func1); enum enumFPxCallBackEvent { evFPxNone = 0, evFPxCreate = 1, evFPxConnected = 2, evFPxDisConnected = 3, evFPxClosed = 4, evFPxStateChange =5, evFPxTimeSync=6, evFPxDataUpdate =7, }; #endif /* __FPX_H__ */