ISSDK  1.8
IoT Sensing Software Development Kit
comm_interface.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-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 comm_interface.h
10 * @brief The comm_interface.h file describes the interface definition for the
11  communication interface. Each commaunication instance needs to implement comm interface.
12 */
13 
14 #ifndef COMM_INTERFACE_H_
15 #define COMM_INTERFACE_H_
16 #include <stddef.h>
17 #include <stdint.h>
18 #include <stdbool.h>
19 
20 #define COMM_INTERFACE_OK 0 ///< Operation succeeded
21 
22 /*******************************************************************************
23  * Definitions
24  ******************************************************************************/
25 
26 /* @brief This defines the communication interface handle
27  */
28 typedef struct _comm_handle_
29 {
30  void *pComm; /*!< pointer to a specific communication channel.*/
31  uint32_t status; /*!< Current Comm status.*/
33 
34 /* @brief This defines the communication interface control config
35  */
36 typedef struct _comm_control_
37 {
38  uint32_t control; /*!< The Control TAG.*/
39  uint32_t arg; /*!< The Control Arguement value.*/
41 
42 /* @brief This defines the different commmunication types
43  */
44 typedef enum _comm_type_
45 {
51 } comm_type_t;
52 
53 /* @brief This defines the different commmunication types
54  */
56 {
57  COMM_BLOCKING, // Blocking Read and Write Calls
58  COMM_NONBLOCKING, // NonBlocking Read and Write Calls
60 
61 /* Interface functions Signature.*/
62 typedef void (*COMM_Event_t)(uint32_t event); /*< Pointer to Comm Event.*/
63 /*! @brief The interface function to get the capability of the communication interface.*/
65 /*! @brief The interface function to initialize the communication interface.*/
66 typedef int32_t(COMM_Init_t)(comm_handle_t *pHandle, void *pCommInstance, COMM_Event_t event, void *pInitializeData);
67 /*! @brief The interface function to configure the communication interface.*/
68 typedef int32_t(COMM_Config_t)(comm_handle_t *pHandle, void *pConfigData);
69 /*! @brief The interface function to send data through the communication interface.*/
70 typedef int32_t(COMM_Send_t)(comm_handle_t *pHandle, void *pData, uint32_t size);
71 /*! @brief The interface function to receive data through the communication interface.*/
72 typedef int32_t(COMM_Receive_t)(comm_handle_t *pHandle, void *pData, uint32_t size);
73 /*! @brief The interface function to get the status of the comm.*/
75 
76 /* @brief This defines the function pointers for the comm interface.
77  */
78 typedef struct _comm_interface_
79 {
80  COMM_GetCapabilities_t *GetCapabilities; /*!< Pointer to the communication GetCapabilities() function. */
81  COMM_Init_t *Init; /*!< Pointer to the communication Initialize() function. */
82  COMM_Config_t *Configure; /*!< Pointer to the communication Configure() function. */
83  COMM_Send_t *Send; /*!< Pointer to the communication send() function. */
84  COMM_Receive_t *Receive; /*!< Pointer to the communication receive() function. */
85  COMM_GetStatus_t *GetStatus; /*!< Pointer to the adapter GetStatus() function. */
87 #endif // COMM_INTERFACE_H_
uint32_t size
COMM_Init_t * Init
void(* COMM_Event_t)(uint32_t event)
uint32_t status
int32_t() COMM_Receive_t(comm_handle_t *pHandle, void *pData, uint32_t size)
The interface function to receive data through the communication interface.
COMM_GetCapabilities_t * GetCapabilities
COMM_GetStatus_t * GetStatus
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
int32_t() COMM_GetCapabilities_t(comm_handle_t *pHandle)
The interface function to get the capability of the communication interface.
struct _comm_interface_ comm_interface_t
_comm_instance_type_
int32_t() COMM_GetStatus_t(comm_handle_t *pHandle)
The interface function to get the status of the comm.
struct _comm_handle_ comm_handle_t
int32_t() COMM_Config_t(comm_handle_t *pHandle, void *pConfigData)
The interface function to configure the communication interface.
COMM_Config_t * Configure
enum _comm_instance_type_ comm_instance_type_t
COMM_Receive_t * Receive
uint32_t control
struct _comm_control_ comm_control_t
_comm_type_
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.
enum _comm_type_ comm_type_t
int32_t() COMM_Send_t(comm_handle_t *pHandle, void *pData, uint32_t size)
The interface function to send data through the communication interface.
COMM_Send_t * Send