ISSDK  1.7
IoT Sensing Software Development Kit
comm_interface.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015-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 comm_interface.h
36 * @brief The comm_interface.h file describes the interface definition for the
37  communication interface. Each commaunication instance needs to implement comm interface.
38 */
39 
40 #ifndef COMM_INTERFACE_H_
41 #define COMM_INTERFACE_H_
42 #include <stddef.h>
43 #include <stdint.h>
44 #include <stdbool.h>
45 
46 #define COMM_INTERFACE_OK 0 ///< Operation succeeded
47 
48 /*******************************************************************************
49  * Definitions
50  ******************************************************************************/
51 
52 /* @brief This defines the communication interface handle
53  */
54 typedef struct _comm_handle_
55 {
56  void *pComm; /*!< pointer to a specific communication channel.*/
57  uint32_t status; /*!< Current Comm status.*/
59 
60 /* @brief This defines the communication interface control config
61  */
62 typedef struct _comm_control_
63 {
64  uint32_t control; /*!< The Control TAG.*/
65  uint32_t arg; /*!< The Control Arguement value.*/
67 
68 /* @brief This defines the different commmunication types
69  */
70 typedef enum _comm_type_
71 {
77 } comm_type_t;
78 
79 /* @brief This defines the different commmunication types
80  */
82 {
83  COMM_BLOCKING, // Blocking Read and Write Calls
84  COMM_NONBLOCKING, // NonBlocking Read and Write Calls
86 
87 /* Interface functions Signature.*/
88 typedef void (*COMM_Event_t)(uint32_t event); /*< Pointer to Comm Event.*/
89 /*! @brief The interface function to get the capability of the communication interface.*/
91 /*! @brief The interface function to initialize the communication interface.*/
92 typedef int32_t(COMM_Init_t)(comm_handle_t *pHandle, void *pCommInstance, COMM_Event_t event, void *pInitializeData);
93 /*! @brief The interface function to configure the communication interface.*/
94 typedef int32_t(COMM_Config_t)(comm_handle_t *pHandle, void *pConfigData);
95 /*! @brief The interface function to send data through the communication interface.*/
96 typedef int32_t(COMM_Send_t)(comm_handle_t *pHandle, void *pData, uint32_t size);
97 /*! @brief The interface function to receive data through the communication interface.*/
98 typedef int32_t(COMM_Receive_t)(comm_handle_t *pHandle, void *pData, uint32_t size);
99 /*! @brief The interface function to get the status of the comm.*/
101 
102 /* @brief This defines the function pointers for the comm interface.
103  */
104 typedef struct _comm_interface_
105 {
106  COMM_GetCapabilities_t *GetCapabilities; /*!< Pointer to the communication GetCapabilities() function. */
107  COMM_Init_t *Init; /*!< Pointer to the communication Initialize() function. */
108  COMM_Config_t *Configure; /*!< Pointer to the communication Configure() function. */
109  COMM_Send_t *Send; /*!< Pointer to the communication send() function. */
110  COMM_Receive_t *Receive; /*!< Pointer to the communication receive() function. */
111  COMM_GetStatus_t *GetStatus; /*!< Pointer to the adapter GetStatus() function. */
113 #endif // COMM_INTERFACE_H_
COMM_GetCapabilities_t * GetCapabilities
int32_t() COMM_GetStatus_t(comm_handle_t *pHandle)
The interface function to get the status of the comm.
int32_t() COMM_Send_t(comm_handle_t *pHandle, void *pData, uint32_t size)
The interface function to send data through the communication interface.
int32_t() COMM_Init_t(comm_handle_t *pHandle, void *pCommInstance, COMM_Event_t event, void *pInitializeData)
The interface function to initialize the communication interface.
struct _comm_interface_ comm_interface_t
int32_t() COMM_Receive_t(comm_handle_t *pHandle, void *pData, uint32_t size)
The interface function to receive data through the communication interface.
int32_t() COMM_Config_t(comm_handle_t *pHandle, void *pConfigData)
The interface function to configure the communication interface.
_comm_type_
struct _comm_handle_ comm_handle_t
uint32_t control
COMM_Send_t * Send
_comm_instance_type_
enum _comm_instance_type_ comm_instance_type_t
COMM_Receive_t * Receive
COMM_Config_t * Configure
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() COMM_GetCapabilities_t(comm_handle_t *pHandle)
The interface function to get the capability of the communication interface.
struct _comm_control_ comm_control_t
enum _comm_type_ comm_type_t
uint32_t status
void(* COMM_Event_t)(uint32_t event)
COMM_Init_t * Init
COMM_GetStatus_t * GetStatus