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