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