23 #include "fsl_common.h"    51         case ARM_USART_EVENT_RECEIVE_COMPLETE:
    54         case ARM_USART_EVENT_SEND_COMPLETE:
    68         if (gHostChannelParams[stream].slaveAddress == slaveAddress)
    88     if (pStreamingPacket == NULL)
   100 uint8_t 
Host_IO_Init(ARM_DRIVER_USART *pDrv, 
void *pBus, 
void *pDevInfo, 
void *spiSlaveParams, uint16_t slaveAddress)
   102     static uint8_t streamID = 0;
   125     gHostChannelParams[streamID].
pCommDrv = pBus;
   126     gHostChannelParams[streamID].
deviceInfo = pDevInfo;
   127     gHostChannelParams[streamID].
slaveAddress = slaveAddress;
   130     gHostChannelParams[streamID].
pSPIparams = spiSlaveParams;
   138     size_t encodedSize = 0;
   139     static uint8_t *pMsgEncoded = NULL;
   150             pMsgEncoded = malloc(size * 2); 
   154             pMsgEncoded = malloc(size * 4); 
   159             pMsgEncoded = malloc(size);
   160             memcpy(pMsgEncoded, pMsg, size);
   167     HOST_Send(&gHostHandle, pMsgEncoded, encodedSize);
   212     bool bCmdSuccess = 
false, bMessageReceived = 
false;
   213     uint8_t *pMsgResponse = NULL;
   243     if (bMessageReceived)
   247             dataLength = gHostRxPkt.
mIndex;
   253                 if (process_host_command)
   259                 if (bCmdSuccess == 
false)
   287             pMsgResponse = malloc(responseSize);
   297                 if (process_host_command)
   300                                          gHostRxBuff + HOST_MSG_CMD_SLAVE_ADDR_OFFSET, NULL, &dataLength, 0);
   303                 if (gHostChannelParams[deviceID].pCommDrv &&
   304                     gHostRxPkt.
mIndex - HOST_MSG_CMD_SLAVE_ADDR_OFFSET >= dataLength)
   306                     if (gHostChannelParams[deviceID].pSPIparams)
   309                             gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
   316                             gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
   321                 if (ARM_DRIVER_OK == status)
   338                 if (gHostChannelParams[deviceID].pCommDrv)
   340                     if (gHostChannelParams[deviceID].pSPIparams)
   343                             gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
   345                             gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET], pMsgResponse + responseSize);
   350                             gHostChannelParams[deviceID].pCommDrv, gHostChannelParams[deviceID].deviceInfo,
   352                             gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET], pMsgResponse + responseSize);
   355                 if (process_host_command)
   358                                          gHostRxBuff + HOST_MSG_CMD_SLAVE_ADDR_OFFSET, pMsgResponse + responseSize,
   359                                          &dataLength, 
gHostRxBuff[HOST_MSG_CMD_LENGTH_OFFSET]);
   361                 if (ARM_DRIVER_OK == status)
   374                 if (process_host_command)
 
volatile bool bUartRxPendingMsg
 
uint8_t getSlaveIndex(uint8_t slaveAddress)
 
uint8_t Host_IO_Init(ARM_DRIVER_USART *pDrv, void *pBus, void *pDevInfo, void *spiSlaveParams, uint16_t slaveAddress)
 
void Host_IO_Receive(host_cmd_proc_fn_t process_host_command, uint8_t encoding)
 
#define HOST_PRO_CMD_WR_ACK_TAG
 
#define HOST_PRO_CMD_R_REG_TAG
 
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. 
 
The host_io_uart.h file contains the Host Protocol interface definitions and configuration. 
 
#define HOST_PRO_CMD_WR_NAK_TAG
Bit aligned values for Host Protocol Command Interface Status IDs (Bit 7). 
 
The register_io_spi.h file declares low-level interface functions for reading and writing sensor regi...
 
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_INTERFACE_VERSION
 
void HOST_SignalEvent_t(uint32_t event)
Defines the HOST UART signal event handler. 
 
This structure holds information to receive a packet of data to the host. 
 
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream. 
 
The format_json.h file describes the structures and definitions for the data-format standard JSON...
 
The register_io_i2c.h file declares low-level interface functions for reading and writing sensor regi...
 
bool process_host_command(uint8_t tag, uint8_t *hostCommand, uint8_t *hostResponse, size_t *hostMsgSize, size_t respBufferSize)
 
bool HDLC_Process_Rx_Byte(uint8_t c, host_rx_packet_t *pHostRxPkt)
 
void Host_IO_Add_ISO_Header(uint8_t streamID, uint8_t *pStreamingPacket, size_t sizePayload)
 
#define HOST_PRO_CMD_W_REG_TAG
 
This structure holds information regarding the Encoding and RLI interface parameters. 
 
size_t HDLC_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size)
 
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. 
 
uint8_t gHostRxBuff[HOST_RX_BUF_LEN]
 
void Host_IO_Send(uint8_t *pMsg, size_t size, uint8_t encoding)
 
The data_format_hdlc.h file contains the Host interface definitions and configuration. 
 
#define HOST_PRO_INT_DEV_TAG
 
#define HOST_PRO_INT_ISO_TAG
 
host_channel_params_t gHostChannelParams[MAX_HOST_STREAMS]
 
int32_t HOST_Send(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t size)
The function to Send the data to the host. 
 
size_t JSON_Process_Tx_Msg(const uint8_t *pBuffer, uint8_t *pMsg, size_t size)
 
int32_t HOST_Configure(host_interface_handle_t *pHandle, void *pConfigData)
The function to Configure the Host. 
 
comm_interface_t * pCommInterface
 
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 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. 
 
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. 
 
volatile bool bUartTxComplete
 
host_rx_packet_t gHostRxPkt
 
#define HOST_PRO_INT_CMD_TAG
Bit aligned values for Host Protocol Interface IDs (Bits 5-6). 
 
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. 
 
volatile bool bUartErrorMsg
 
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...
 
host_interface_handle_t gHostHandle