ISSDK  1.7
IoT Sensing Software Development Kit
host_io_uart.c
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36  * @file host_io_uart.c
37  * @brief The host_io_uart.c file contains definitions for UART based streaming interface
38  * for sending and reseiving messages to and from Host using ISSDK Host Protocol.
39  */
40 
41 /*******************************************************************************
42  * Standard C Includes
43  ******************************************************************************/
44 #include <stdlib.h>
45 
46 /*******************************************************************************
47  * SDK Includes
48  ******************************************************************************/
49 #include "fsl_common.h"
50 
51 /*******************************************************************************
52  * ISSDK Includes
53  ******************************************************************************/
54 #include "host_io_uart.h"
55 #include "register_io_i2c.h"
56 #include "register_io_spi.h"
57 #include "data_format_hdlc.h"
58 #include "data_format_json.h"
59 
60 /*******************************************************************************
61  * Global Variables
62  ******************************************************************************/
68 
69 /*******************************************************************************
70  * Functions
71  ******************************************************************************/
72 /* Callback functions to handle incomming messages form the Host over UART. */
73 void HOST_SignalEvent_t(uint32_t event)
74 {
75  switch (event)
76  {
77  case ARM_USART_EVENT_RECEIVE_COMPLETE:
78  bUartRxPendingMsg = true;
79  break;
80  case ARM_USART_EVENT_SEND_COMPLETE:
81  bUartTxComplete = true;
82  break;
83  default:
84  bUartErrorMsg = true;
85  break;
86  }
87 }
88 
89 /* Function to lookup slave handle. */
90 uint8_t getSlaveIndex(uint8_t slaveAddress)
91 {
92  for (uint8_t stream = 0; stream < MAX_HOST_STREAMS; stream++)
93  {
94  if (gHostChannelParams[stream].slaveAddress == slaveAddress)
95  {
96  return stream;
97  }
98  }
99 
100  /* If Address in not recognised, default to the first stream. */
101  return 0;
102 }
103 
104 /* Function to populate Streaming Packet Header.
105  * Outgoing Iso Packet Format: (As per ISSDK Host Protocol Definition)
106  * Byte 0 : (Start Byte) HDLC Frame START MARKER. (Will be added by HDLC_Process_Tx_Msg())
107  * Byte 1 : Frame TAG (Interface)
108  * Byte 2 : Length (Payload Length)
109  * Byte 3+: Payload (Depending upon sensor sample length + 1 for Stream ID)
110  * Byte E : (End Byte) HDLC Frame STOP MARKER. (Will be added by HDLC_Process_Tx_Msg())
111  */
112 void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
113 {
114  if (pStreamingPacket == NULL)
115  {
116  return;
117  }
118 
119  pStreamingPacket[HOST_MSG_HDR_TAG_OFFSET] = HOST_PRO_INT_ISO_TAG;
120  pStreamingPacket[HOST_ISO_LEN_MSB_OFFSET] = (sizePayload + 1) >> 8; /* Size of Sample + Stream ID */
121  pStreamingPacket[HOST_ISO_LEN_LSB_OFFSET] = (sizePayload + 1) & 0x00FF; /* Size of Sample + Stream ID */
122  pStreamingPacket[HOST_ISO_PAYLOAD_OFFSET] = streamID;
123 }
124 
125 /* Function to get Stream ID, set Encoding and configure RLI related parameters. */
126 uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
127 {
128  static uint8_t streamID = 0;
129 
130  /* Configure the UART callback if not already configured. */
131  if (gHostHandle.pCommInterface == NULL)
132  {
133  HOST_Initialize(&gHostHandle, COMM_UART, (void *)pDrv, COMM_NONBLOCKING, HOST_SignalEvent_t, NULL);
134  do /* Flush RX buffer. */
135  {
136  bUartRxPendingMsg = false;
137  HOST_Receive(&gHostHandle, &gUartRxBuff, NULL, 1, NULL);
138  } while (bUartRxPendingMsg);
139  bUartTxComplete = true; /* Reset TX Flag. */
140  bUartErrorMsg = false; /* Reset Error Flag. */
141  }
142 
143  /* Host has to be accesible by 1 UART interface for all subscriptions
144  * and Number of streams less than MAX. */
145  if (gHostHandle.commHandle.pComm != pDrv || streamID == MAX_HOST_STREAMS)
146  {
147  return 0;
148  }
149 
150  /* Save the I2C/SPI Bus handle. */
151  gHostChannelParams[streamID].pCommDrv = pBus;
152  gHostChannelParams[streamID].deviceInfo = pDevInfo;
153  gHostChannelParams[streamID].slaveAddress = slaveAddress;
154 
155  /* If device type is I2C, Slave Handle will be NULL. */
156  gHostChannelParams[streamID].pSPIparams = spiSlaveParams;
157 
158  return ++streamID;
159 }
160 
161 /* Function to send bytes to Host over UART. */
162 void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
163 {
164  size_t encodedSize = 0;
165  static uint8_t *pMsgEncoded = NULL;
166 
167  while (bUartTxComplete == false)
168  {
169  __NOP(); /* Wait if the previous Tx is still Pending. */
170  }
171  free(pMsgEncoded);
172 
173  switch (encoding)
174  {
175  case HOST_FORMAT_HDLC:
176  pMsgEncoded = malloc(size * 2); /* Allocate 2x the size to compensate for escape characters. */
177  encodedSize = HDLC_Process_Tx_Msg(pMsg, pMsgEncoded, size); /* Get the Encoded Message. */
178  break;
179  case HOST_FORMAT_JSON:
180  pMsgEncoded = malloc(size * 4); /* Allocate 4x the size to compensate for string character encoding. */
181  encodedSize = JSON_Process_Tx_Msg(pMsg, pMsgEncoded, size); /* Get the Encoded Message. */
182  break;
183  case HOST_FORMAT_PLAIN:
184  default:
185  pMsgEncoded = malloc(size);
186  memcpy(pMsgEncoded, pMsg, size);
187  encodedSize = size;
188  break;
189  }
190 
191  /* Send message to Host. */
192  bUartTxComplete = false;
193  HOST_Send(&gHostHandle, pMsgEncoded, encodedSize);
194 }
195 
196 /* Function to check Rx and process received bytes and (re)enable UART Rx.
197  * Command Types Supported :
198  * 1) Write App Data - Start/Stop Streaming.
199  * 2) Write Register Data - Register Address and Value.
200  * 3) Read Register Data - Start Address and Number of Bytes.
201  * 4) Read Device Info - Return Major/Minor + Board and Shield Names.
202  *
203  * Incoming Message Format (Host Commands): (As per ISSDK Host Protocol Definition)
204  * Byte 0 : Frame TAG (Interface|Command)
205  * Byte 1 : Sequence ID (Random Txn Identifier)
206  * Byte 2 : Length MSB (Payload Length MSB)
207  * Byte 3 : Length LSB (Payload Length LSB)
208  * Byte 4+: Payload
209  *
210  * Outgoing Respone Format (Host Commands): (As per ISSDK Host Protocol Definition)
211  * Byte 0 : Frame TAG (Status|Interface|Command)
212  * Byte 1 : Sequence ID (Random Txn Identifier)
213  * Byte 2 : Length MSB (Payload Length MSB)
214  * Byte 3 : Length LSB (Payload Length LSB)
215  * Byte 4+: Payload (Optional, depending upon requested operation)
216  *
217  * Incoming Message Format (ISO Command): (As per ISSDK Host Protocol Definition)
218  * Byte 0 : Frame TAG (Interface)
219  * Byte 1 : Length MSB (Payload Length MSB)
220  * Byte 2 : Length LSB (Payload Length LSB)
221  * Byte 3+: Payload
222  *
223  * Incoming Message Format (Device Info): (As per ISSDK Host Protocol Definition)
224  * Byte 0 : Frame TAG (Interface)
225  *
226  * Outgoing Respone Format (Device Info): (As per ISSDK Host Protocol Definition)
227  * Byte 0 : Frame TAG (Interface)
228  * Byte 1 : Version ID (ISSDK : Major | Minor Numbers)
229  * Byte 2 : Length of Board Name (Optional : populated by user callback)
230  * Byte 3 : Length of Shield Name (Optional : populated by user callback)
231  * Byte 4+: Payload (Board Name + Board Name) (Optional : populated by user callback)
232  */
234 {
236  comm_control_t rxAbort = {.control = ARM_USART_ABORT_RECEIVE, .arg = 0};
237  size_t dataLength, responseSize = HOST_RSP_HDR_LEN;
238  bool bCmdSuccess = false, bMessageReceived = false;
239  uint8_t *pMsgResponse = NULL;
240 
241  /* If error flag is set ABORT and RESTART transaction. */
242  if (bUartErrorMsg)
243  {
244  bUartErrorMsg = false;
245  bUartRxPendingMsg = false;
246  HOST_Configure(&gHostHandle, &rxAbort);
247  HOST_Receive(&gHostHandle, &gUartRxBuff, NULL, 1, NULL);
248  }
249 
250  if (bUartRxPendingMsg)
251  {
252  switch (encoding)
253  {
254  case HOST_FORMAT_HDLC:
255  bMessageReceived = HDLC_Process_Rx_Byte(gUartRxBuff, &gHostRxPkt);
256  break;
257  case HOST_FORMAT_JSON:
258  bMessageReceived = JSON_Process_Rx_Byte(gUartRxBuff, &gHostRxPkt);
259  break;
260  default:
261  break;
262  }
263 
264  bUartErrorMsg = false;
265  bUartRxPendingMsg = false;
266  HOST_Receive(&gHostHandle, &gUartRxBuff, NULL, 1, NULL);
267  }
268 
269  if (bMessageReceived)
270  {
271  do
272  {
273  dataLength = gHostRxPkt.mIndex;
274  /* Check if it is a 1-byte Device Info Message from Host. */
275  if ((gHostRxBuff[HOST_MSG_HDR_TAG_OFFSET] & HOST_PRO_INT_DEV_TAG) && (dataLength == 1))
276  { /* Allocate memory for response packet for this command and populate the payload. */
277  pMsgResponse = malloc(HOST_DEV_RSP_LEN);
278  dataLength = 0; /* Incoming Payload is Zero. */
279  if (process_host_command)
280  { /* Call the user callback to proces the user specific payload. */
282  pMsgResponse + HOST_DEV_LEN_STR_OFFSET, &dataLength,
284  }
285  if (bCmdSuccess == false)
286  {
287  dataLength = 0;
288  }
289 
290  responseTag = HOST_PRO_INT_DEV_TAG;
291  responseSize = HOST_DEV_LEN_STR_OFFSET + dataLength;
292  break;
293  }
294  dataLength = (((uint16_t)gHostRxBuff[HOST_ISO_LEN_MSB_OFFSET] << 8) | gHostRxBuff[HOST_ISO_LEN_LSB_OFFSET]);
295  /* Check if it is an ISO Message from Host and has > 0 Byte payload. */
296  if ((gHostRxBuff[HOST_MSG_HDR_TAG_OFFSET] & HOST_PRO_INT_ISO_TAG) && (dataLength > 0))
297  {
298  if (dataLength == (gHostRxPkt.mIndex - HOST_ISO_PAYLOAD_OFFSET) && process_host_command)
299  { /* Call the user callback to proces the user specific payload if packet integrity is valid. */
301  NULL, /* No buffer since no response for ISO Messages. */
302  &dataLength, 0);
303  }
304  return; /* No response for ISO Messages. */
305  }
306 
307  dataLength = (((uint16_t)gHostRxBuff[HOST_MSG_LEN_MSB_OFFSET] << 8) | gHostRxBuff[HOST_MSG_LEN_LSB_OFFSET]);
308  if (dataLength != (gHostRxPkt.mIndex - HOST_MSG_CMD_OPC_OFFSET)) /* Ensure packet integrity */
309  {
310  return; /* Drop corrupted and duplicate packets */
311  }
312  /* Allocate memory for response packet for this command. */
313  pMsgResponse = malloc(responseSize);
314 
315  /* Check if it is a Command from Host to Write Register Data and has 3+ Byte payload (SlaveAddress,
316  * RegisterAddress and ValuesToWrite). */
318  (dataLength >= 3))
319  {
320  int32_t status = ARM_DRIVER_ERROR;
321  /* Fetch the slave bus handle using known Slave Address. */
323  if (process_host_command)
324  { /* Call the user callback to enable user pre-proces the register write payload (if required). */
326  gHostRxBuff + HOST_MSG_CMD_SLAVE_ADDR_OFFSET, NULL, &dataLength, 0);
327  }
328  /* Confirm payload has enough number of bytes to write. */
329  if (gHostChannelParams[deviceID].pCommDrv &&
330  gHostRxPkt.mIndex - HOST_MSG_CMD_SLAVE_ADDR_OFFSET >= dataLength)
331  {
332  if (gHostChannelParams[deviceID].pSPIparams)
333  {
334  status = Register_SPI_BlockWrite(
335  gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
336  gHostChannelParams[deviceID].pSPIparams, gHostRxBuff[HOST_MSG_CMD_REGIS_ADDR_OFFSET],
337  gHostRxBuff + HOST_MSG_CMD_VALUE_OFFSET, dataLength - 2);
338  }
339  else
340  {
341  status = Register_I2C_BlockWrite(
342  gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
343  gHostRxBuff[HOST_MSG_CMD_SLAVE_ADDR_OFFSET], gHostRxBuff[HOST_MSG_CMD_REGIS_ADDR_OFFSET],
344  gHostRxBuff + HOST_MSG_CMD_VALUE_OFFSET, dataLength - 2);
345  }
346  }
347  if (ARM_DRIVER_OK == status)
348  {
349  responseTag |= HOST_PRO_CMD_WR_ACK_TAG;
350  }
351  break;
352  }
353  /* Check if it is a Command from Host to Read Register Data and has 3 Byte payload (SlaveAddress,
354  * RegisterAddress and BytesToRead). */
356  (dataLength == 3))
357  {
358  int32_t status = ARM_DRIVER_ERROR;
359  /* Fetch the slave bus handle using known Slave Address. */
361  /* Allocate memory as per updated size of response packet for this command. */
362  free(pMsgResponse);
363  pMsgResponse = malloc(responseSize + gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET]);
364  if (gHostChannelParams[deviceID].pCommDrv)
365  {
366  if (gHostChannelParams[deviceID].pSPIparams)
367  {
368  status = Register_SPI_Read(
369  gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
370  gHostChannelParams[deviceID].pSPIparams, gHostRxBuff[HOST_MSG_CMD_REGIS_ADDR_OFFSET],
371  gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET], pMsgResponse + responseSize);
372  }
373  else
374  {
375  status = Register_I2C_Read(
376  gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
377  gHostRxBuff[HOST_MSG_CMD_SLAVE_ADDR_OFFSET], gHostRxBuff[HOST_MSG_CMD_REGIS_ADDR_OFFSET],
378  gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET], pMsgResponse + responseSize);
379  }
380  }
381  if (process_host_command)
382  { /* Call the user callback to enable user post-process the register read payload (if required). */
384  gHostRxBuff + HOST_MSG_CMD_SLAVE_ADDR_OFFSET, pMsgResponse + responseSize,
385  &dataLength, gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET]);
386  }
387  if (ARM_DRIVER_OK == status)
388  {
389  responseTag |= HOST_PRO_CMD_WR_ACK_TAG;
390  responseSize += gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET];
391  }
392  break;
393  }
394  /* Check if it is a Command from Host for Read/Write Configuration or User defined and has > 0 Byte payload.
395  */
396  if ((gHostRxBuff[HOST_MSG_HDR_TAG_OFFSET] & HOST_PRO_INT_CMD_TAG) && (dataLength > 0))
397  { /* Allocate memory for max possible response packet size for this command and populate the payload. */
398  free(pMsgResponse);
399  pMsgResponse = malloc(HOST_CMD_RSP_LEN);
400  if (process_host_command)
401  { /* Call the user callback to proces the user specific payload. */
404  pMsgResponse + HOST_MSG_CMD_OPC_OFFSET, &dataLength,
406  }
407  if (bCmdSuccess)
408  {
409  responseTag |= HOST_PRO_CMD_WR_ACK_TAG;
410  }
411  else
412  {
413  dataLength = 0;
414  }
415 
416  responseSize = HOST_MSG_CMD_OPC_OFFSET + dataLength;
417  break;
418  }
419  } while (false);
420 
421  /* Populate the response packet header. */
422  pMsgResponse[HOST_MSG_HDR_TAG_OFFSET] = responseTag;
423  if (responseTag == HOST_PRO_INT_DEV_TAG)
424  {
426  }
427  else
428  {
430  pMsgResponse[HOST_MSG_LEN_MSB_OFFSET] = (responseSize - HOST_RSP_HDR_LEN) >> 8;
431  pMsgResponse[HOST_MSG_LEN_LSB_OFFSET] = (responseSize - HOST_RSP_HDR_LEN) & 0xFF;
432  }
433 
434  /* Send response to Host. */
435  Host_IO_Send(pMsgResponse, responseSize, encoding);
436  free(pMsgResponse);
437  }
438 }
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
#define HOST_RSP_HDR_LEN
Definition: host_io_uart.h:53
bool JSON_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt)
Function to handle incomming JSON encoded bytes form the Host over UART.
void HOST_SignalEvent_t(uint32_t event)
Defines the HOST UART signal event handler.
Definition: host_io_uart.c:73
This structure holds information regarding the Encoding and RLI interface parameters.
Definition: host_io_uart.h:62
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
Definition: host_io_uart.c:233
#define HOST_PRO_CMD_W_REG_TAG
Definition: host_io_uart.h:91
int32_t HOST_Configure(host_interface_handle_t *pHandle, void *pConfigData)
The function to Configure the Host.
uint8_t gUartRxBuff
Definition: host_io_uart.c:64
int32_t Register_SPI_BlockWrite(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pWriteParams, uint8_t offset, const uint8_t *pBuffer, uint8_t bytesToWrite)
The interface function to block write to a sensor register.
int32_t status
volatile bool bUartErrorMsg
Definition: host_io_uart.c:67
The format_json.h file describes the structures and definitions for the data-format standard JSON...
int32_t HOST_Initialize(host_interface_handle_t *pHandle, comm_type_t type, void *pCommInstance, comm_instance_type_t inType, Host_Event_t event, void *pInData)
The function to Initialize the Host.
#define HOST_PRO_INT_DEV_TAG
Definition: host_io_uart.h:85
int32_t HOST_Receive(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t *pRecvSize, uint32_t size, BlockRead_t process)
The function to receive data from the host.
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6).
Definition: host_io_uart.h:83
#define HOST_CMD_RSP_LEN
Definition: host_io_uart.h:55
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
host_channel_params_t gHostChannelParams[MAX_HOST_STREAMS]
Definition: host_io_uart.c:66
#define HOST_PRO_CMD_WR_ACK_TAG
Definition: host_io_uart.h:96
bool(* host_cmd_proc_fn_t)(uint8_t, uint8_t *, uint8_t *, size_t *, size_t)
The Host Command Process Function ([IN]Command TAG, [IN]Commad Buffer, [OUT]Response Buffer...
Definition: host_io_uart.h:72
The data_format_hdlc.h file contains the Host interface definitions and configuration.
host_interface_handle_t gHostHandle
Definition: host_io_uart.c:63
volatile bool bUartRxPendingMsg
Definition: host_io_uart.c:67
host_rx_packet_t gHostRxPkt
Definition: host_io_uart.c:65
This structure holds information to receive a packet of data to the host.
Definition: host_io_uart.h:75
#define HOST_INTERFACE_VERSION
comm_interface_t * pCommInterface
#define HOST_RX_BUF_LEN
Definition: host_io_uart.h:52
int32_t Register_I2C_BlockWrite(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, const uint8_t *pBuffer, uint8_t bytesToWrite)
The interface function to write a sensor register.
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
Definition: host_io_uart.c:112
#define HOST_PRO_CMD_WR_NAK_TAG
Bit aligned values for Host Protocol Command Interface Status IDs (Bit 7).
Definition: host_io_uart.h:95
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
Definition: host_io_uart.c:162
#define HOST_PRO_CMD_R_REG_TAG
Definition: host_io_uart.h:92
#define MAX_HOST_STREAMS
Definition: host_io_uart.h:56
volatile bool bUartTxComplete
Definition: host_io_uart.c:67
uint32_t control
#define HOST_PRO_INT_ISO_TAG
Definition: host_io_uart.h:84
size_t HDLC_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size)
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
bool HDLC_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt)
uint32_t size
uint8_t getSlaveIndex(uint8_t slaveAddress)
Definition: host_io_uart.c:90
int32_t Register_SPI_Read(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pReadParams, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
int32_t Register_I2C_Read(ARM_DRIVER_I2C *pCommDrv, registerDeviceInfo_t *devInfo, uint16_t slaveAddress, uint8_t offset, uint8_t length, uint8_t *pOutBuffer)
The interface function to read a sensor register.
#define HOST_DEV_RSP_LEN
Definition: host_io_uart.h:54
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
Definition: host_io_uart.c:126
The host_io_uart.h file contains the Host Protocol interface definitions and configuration.
uint8_t gHostRxBuff[HOST_RX_BUF_LEN]
Definition: host_io_uart.c:64
uint8_t * pRxbuf
Definition: host_io_uart.h:79
size_t JSON_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size)
int32_t HOST_Send(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t size)
The function to Send the data to the host.
The register_io_spi.h file declares low-level interface functions for reading and writing sensor regi...