B. Example codes for host integration
The following code is an example implementation of a function to transmit data using a 2 Byte
length field in the command frame. For demonstration reasons the Proteus-III has been
taken. The full function codes of all radio modules are available in the Wireless Connectivity
SDK (
#define
CMD_PAYLOAD_MAX 964
typedef struct
{
uint8_t
Stx;
uint8_t
Cmd;
uint16_t Length;
/* LSB first */
uint8_t
Data[CMD_PAYL1];
/* +1 for CRC8 */
} CMD_Frame_t;
#define
CMD_OFFSET_TO_DATAFIELD 4
#define
CMD_OVERHEAD (CMD_OFFSET_TO_DA1)
bool ProteusIII_Transmit( uint8_t *PayloadP, uint16_t length)
{
/* fill request message with STX, command byte and length field */
CMD_Frame_t CMD_Frame;
CMD_Frame.Stx = CMD_STX;
/* 0x02 */
CMD_Frame.Cmd = ProteusIII_CMD_DATA_REQ;
/* 0x04 */
CMD_Frame.Length = length;
/* fill request message with user payload */
memcpy(CMD_Frame.Data, PayloadP, length);
/* fill request message with CRC8 */
CMD_Frame.Data[CMD_Frame.Length] = Get_CRC8(&CMD_Frame, CMD_Frame.
CMD_OFFSET_TO_DATAFIELD);
/* transmit full message via UART to radio module */
UART_SendBytes(&CMD_Frame, (CMD_Frame. CMD_OVERHEAD));
/* wait for response message from radio module */
return
UART_Wait_for_Response(CMD_WAIT_TIME, ProteusIII_CMD_TXCOMPLETE_RSP,
CMD_Status_Success, true);
}
Code 2: Example function implementation for radio modules with 2 byte length field
Proteus-III reference manual version 1.3
© August 2020
www.we-online.com/wireless-connectivity
225