ISSDK  1.8
IoT Sensing Software Development Kit
host_interface_service.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 /**
9 * @file host_interface_service.h
10 * @brief The host_interface_service.h file describes the structures and definitions for the host.
11 */
12 
13 #ifndef HOST_INTERFACE_SERVICE_H_
14 #define HOST_INTERFACE_SERVICE_H_
15 #include <stddef.h>
16 #include <stdint.h>
17 #include <stdbool.h>
18 #include "comm_interface.h"
19 
20 #define HOST_INTERFACE_OK 0
21 #define HOST_INTERFACE_VERSION ((1 << 4) | (0 & 0xF)) // Host Interface Version 1.0
22 
23 /*******************************************************************************
24  * Definitions
25  ******************************************************************************/
26 /* Interface functions Signature.*/
27 typedef void (*Host_Event_t)(uint32_t event); /*< Pointer to Host Event.*/
28 
29 /* @brief This defines the handle to host
30  */
32 {
34  void *pInData; /*!< Input data for the callback .*/
35  uint32_t status; /*!< Current Comm status.*/
36  comm_handle_t commHandle; /*!< pointer to a specific communication channel.*/
37  Host_Event_t event; /*!< Host Event callback: Future implementaion .*/
38  comm_instance_type_t instanceType; /*!< COMM Instance Type .*/
40 
41 /* @brief This defines the host interface config structure
42  */
44 {
45  uint32_t tbd; // tbd
46 
48 
49 /* @brief This defines the host interface based events
50  */
51 #define HOST_INTERFACE_EVENT_SEND_COMPLETE \
52  (1UL << 0) ///< Send completed. Completed the data transfer. Useful for Asynchronous, non blocking calls
53 #define HOST_INTERFACE_EVENT_RECEIVE_COMPLETE \
54  (1UL << 1) ///< Receive completed, Receved specifed bytes of data. Useful for Asynchronous, non blocking calls
55 
56 typedef void (*BlockRead_t)(host_interface_handle_t *pHandle, void *pData); /*< Pointer to block read function.
57 User can implement start and end packet detection logic to determine unknown receive length.
58 This basically a data-interchangbility format dependent such as HDLC, JSON etc..*/
59 /******************************************************************************/
60 /*! @brief The function to Initialize the Host
61  * @details It initialize the host for the specified communucation channel and data format service.
62 
63  * @param[in] pHandle - pointer to the interface handle
64  * @param[in] type- host communication type
65  * @param[in] pCommInstance - pointer to a communication object.
66  * @param[in] inType - instanceType.
67  * @param[in] event - event handler callback
68  * @param[in] pInData - input data to underlying layers
69  * @return ::HOST_Initialize() returns the status .
70  *
71  * @Constraints None
72  *
73  * @Reentrant Yes
74  */
76  comm_type_t type,
77  void *pCommInstance,
78  comm_instance_type_t inType,
80  void *pInData);
81 
82 /******************************************************************************/
83 /*! @brief The function to Configure the Host
84  * @details TBD
85 
86  * @param[in] pHandle - pointer to the interface handle
87  * @param[in] pConfigData - Host configuration information
88  * @return ::HOST_Configure() returns the status .
89  *
90  * @Constraints None
91  *
92  * @Reentrant Yes
93  */
94 int32_t HOST_Configure(host_interface_handle_t *pHandle, void *pConfigData);
95 /******************************************************************************/
96 /*! @brief The function to Send the data to the host
97  * @details TBD
98 
99  * @param[in] pHandle - pointer to the interface handle
100  * @param[in] pData - pointer to a data to send
101  * @param[in] size - number of byte to send
102  * @return ::HOST_Send() returns the status .
103  *
104  * @Constraints None
105  *
106  * @Reentrant Yes
107  */
108 int32_t HOST_Send(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t size);
109 
110 /*! @brief The function to receive data from the host.
111  * @details BlockRead callback function will be called only if Host is initialized with Blocking Call communication
112  instance,
113  refer comm_instance_type_t inType HOST_Initialize() function.
114  If the host is initialized with blocking communication instance, This call will be blocked until
115  BlockRead_t process returns provided BlockRead_t process is not NULL
116  else it will be blocked until specified number of requested bytes are received. User can implement own
117  logic to separate packet start and end de-limiter in
118  BlockRead_t process to determine a stream or use provided Block Read function in the each Data Format.
119  If the host is intialized with NonBlocking Communication instance. This call will be immediately
120  returns and Users Needs to Syschronous data based on
121  Host event HOST_INTERFACE_EVENT_RECEIVE_COMPLETE.
122  * @param[in] pHandle - pointer to the interface handle.
123  * @param[out] pData - pointer to data to be received.
124  * @param[out] pRecvSize - number of byte received. This field is for the future use.
125  * @param[in] size - Nnumber of byte intend to receive, if user know. This argument has no impact if "BlockRead_t
126  process" is not NULL and communication instance is Blocking
127  * @param[in] process - process function for the block data read. NOTE: This parameter is not valid, if
128  communication Read function is Nonblocking.
129  The logic in the callback can start and end packet data detection to get the unknown receive length stream data from
130  the host.
131 
132  * @return ::HOST_Receive() returns the status .
133  *
134  * @Constraints None
135  *
136  * @Reentrant Yes
137  */
138 // Note: Signature of this function may change based on the implementation and usability.
140  host_interface_handle_t *pHandle, uint8_t *pData, uint32_t *pRecvSize, uint32_t size, BlockRead_t process);
141 
142 #endif // HOST_INTERFACE_SERVICE_H_
uint32_t size
int32_t HOST_Configure(host_interface_handle_t *pHandle, void *pConfigData)
The function to Configure the Host.
comm_instance_type_t instanceType
void(* Host_Event_t)(uint32_t event)
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
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.
The comm_interface.h file describes the interface definition for the communication interface...
void(* BlockRead_t)(host_interface_handle_t *pHandle, void *pData)
struct _host_interface_config_ host_interface_config_t
enum _comm_instance_type_ comm_instance_type_t
int32_t HOST_Send(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t size)
The function to Send the data to the host.
comm_interface_t * pCommInterface
struct _host_interface_handle_ host_interface_handle_t
enum _comm_type_ comm_type_t
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.