Rev 190 | Rev 245 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 190 | Rev 220 | ||
---|---|---|---|
1 | #ifndef _MKPROTOCOL_H |
1 | #ifndef _MKPROTOCOL_H |
2 | #define _MKPROTOCOL_H |
2 | #define _MKPROTOCOL_H |
3 | 3 | ||
4 | // slave addresses |
4 | // slave addresses |
5 | #define ANY_ADDRESS 0 |
5 | #define ANY_ADDRESS 0 |
6 | #define FC_ADDRESS 1 |
6 | #define FC_ADDRESS 1 |
7 | #define NC_ADDRESS 2 |
7 | #define NC_ADDRESS 2 |
8 | #define MK3MAG_ADDRESS 3 |
8 | #define MK3MAG_ADDRESS 3 |
9 | #define MKOSD_ADDRESS 4 |
9 | #define MKOSD_ADDRESS 4 |
- | 10 | #define BL_ADDRESS 5 |
|
10 | 11 | ||
11 | typedef struct |
12 | typedef struct |
12 | { |
13 | { |
13 | u8* pData; |
14 | u8* pData; |
14 | u16 Size; |
15 | u16 Size; |
15 | u16 DataBytes; |
16 | u16 DataBytes; |
16 | u16 Position; |
17 | u16 Position; |
17 | u8 Locked; |
18 | u8 Locked; |
18 | } __attribute__((packed)) Buffer_t; |
19 | } __attribute__((packed)) Buffer_t; |
19 | 20 | ||
20 | extern void Buffer_Init(Buffer_t* pBuffer, u8* pDataBuffer, u16 DataBufferSize); |
21 | extern void Buffer_Init(Buffer_t* pBuffer, u8* pDataBuffer, u16 DataBufferSize); |
21 | extern void Buffer_Clear(Buffer_t* pBuffer); |
22 | extern void Buffer_Clear(Buffer_t* pBuffer); |
22 | extern u8 Buffer_Copy(Buffer_t* pSrcBuffer, Buffer_t* pDstBuffer); |
23 | extern u8 Buffer_Copy(Buffer_t* pSrcBuffer, Buffer_t* pDstBuffer); |
23 | 24 | ||
24 | typedef struct |
25 | typedef struct |
25 | { |
26 | { |
26 | u8 Address; |
27 | u8 Address; |
27 | u8 CmdID; |
28 | u8 CmdID; |
28 | u8* pData; |
29 | u8* pData; |
29 | u16 DataLen; |
30 | u16 DataLen; |
30 | } __attribute__((packed)) SerialMsg_t; |
31 | } __attribute__((packed)) SerialMsg_t; |
31 | 32 | ||
32 | extern u8 MKProtocol_CollectSerialFrame(Buffer_t* pRxBuff, u8 c); |
33 | extern u8 MKProtocol_CollectSerialFrame(Buffer_t* pRxBuff, u8 c); |
33 | extern void MKProtocol_CreateSerialFrame(Buffer_t* pTxBuff, u8 CmdID, u8 Address, u8 numofbuffers , ...); //u8 *data, u8 len, ....; |
34 | extern void MKProtocol_CreateSerialFrame(Buffer_t* pTxBuff, u8 CmdID, u8 Address, u8 numofbuffers , ...); //u8 *data, u8 len, ....; |
34 | extern void MKProtocol_DecodeSerialFrameHeader(Buffer_t* pRxBuff, SerialMsg_t* pSerialMsg); |
35 | extern void MKProtocol_DecodeSerialFrameHeader(Buffer_t* pRxBuff, SerialMsg_t* pSerialMsg); |
35 | extern void MKProtocol_DecodeSerialFrameData(Buffer_t* pRxBuff, SerialMsg_t* pSerialMsg); |
36 | extern void MKProtocol_DecodeSerialFrameData(Buffer_t* pRxBuff, SerialMsg_t* pSerialMsg); |
36 | 37 | ||
37 | #endif // _MKPROTOCOL_H |
38 | #endif // _MKPROTOCOL_H |
38 | 39 |