ISSDK  1.8
IoT Sensing Software Development Kit
host_interface_service.c
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.c
10 * @brief The dhost_interface_servicec file implements host interface functions
11 */
12 #include <stddef.h>
13 #include <stdint.h>
14 #include <string.h>
15 #include <stdbool.h>
16 #include "host_interface_service.h"
17 
18 /*******************************************************************************
19  * Variables
20  ******************************************************************************/
22 
23 /*******************************************************************************
24  * Functions
25  *****************************************************************************/
27  comm_type_t type,
28  void *pCommInstance,
29  comm_instance_type_t inType,
30  Host_Event_t event,
31  void *pInData)
32 {
34 
35  if (type == COMM_UART)
36  {
37  pHandle->pCommInterface = &commUART;
38  }
39  comm_interface_t *pCommInt = pHandle->pCommInterface;
40  pHandle->event = event;
41  pHandle->pInData = pInData;
42  pHandle->instanceType = inType;
43  // call interface function with appropriate comm instance.
44  status = pCommInt->Init(&pHandle->commHandle, (void *)pCommInstance, pHandle->event, pHandle->pInData);
45 
46  return status;
47 }
48 
49 int32_t HOST_Configure(host_interface_handle_t *pHandle, void *pConfigData)
50 {
52 
53  comm_interface_t *pCommInt = pHandle->pCommInterface;
54  status = pCommInt->Configure(&pHandle->commHandle, pConfigData);
55  return status;
56 }
57 
58 int32_t HOST_Send(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t size)
59 {
61 
62  comm_interface_t *pCommInt = pHandle->pCommInterface;
63  status = pCommInt->Send(&pHandle->commHandle, pData, size);
64  return status;
65 }
66 
68  host_interface_handle_t *pHandle, uint8_t *pData, uint32_t *pRecvSize, uint32_t size, BlockRead_t process)
69 {
71 
72  comm_interface_t *pCommInt = pHandle->pCommInterface;
73  // Call Host Data format specified callback for block read data
74  if ((process != NULL) && (pHandle->instanceType == COMM_BLOCKING))
75  {
76  process(pHandle, pData);
77  status = HOST_INTERFACE_OK;
78  }
79  else
80  {
81  status = pCommInt->Receive(&pHandle->commHandle, pData, size);
82  }
83  return status;
84 }
uint32_t size
COMM_Init_t * Init
comm_interface_t commUART
Definition: comm_if_uart.c:66
int32_t status
The host_interface_service.h file describes the structures and definitions for the host...
#define HOST_INTERFACE_OK
comm_instance_type_t instanceType
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.
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.
void(* BlockRead_t)(host_interface_handle_t *pHandle, void *pData)
COMM_Config_t * Configure
enum _comm_instance_type_ comm_instance_type_t
COMM_Receive_t * Receive
int32_t HOST_Send(host_interface_handle_t *pHandle, uint8_t *pData, uint32_t size)
The function to Send the data to the host.
int32_t HOST_Configure(host_interface_handle_t *pHandle, void *pConfigData)
The function to Configure the Host.
comm_interface_t * pCommInterface
enum _comm_type_ comm_type_t
COMM_Send_t * Send