ISSDK  1.7
IoT Sensing Software Development Kit
comm_if_uart.c
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 comm_if_uart.c
36 * @brief The comm_if_uart.c file implements comm interface for the UART.
37 */
38 #include <stddef.h>
39 #include <stdint.h>
40 #include <stdbool.h>
41 #include "Driver_USART.h"
42 #include "comm_interface.h"
43 /*******************************************************************************
44  * Variables
45  ******************************************************************************/
46 /*******************************************************************************
47 * Prototypes
48 ******************************************************************************/
49 
50 /*******************************************************************************
51  * Code
52  ******************************************************************************/
53 
55 {
56  // @todo the implementation.
57  return COMM_INTERFACE_OK;
58 }
59 
60 int32_t COMM_UART_Init(comm_handle_t *pHandle, void *pCommInstance, COMM_Event_t event, void *pInitializeData)
61 {
62  // @todo handle the pointers and validation properly.
63  pHandle->pComm = pCommInstance;
64  //@todo use the rest of argument properly.
65  // SDK CMSIS driver adoption; init call will be done by the user application.
66  //((ARM_DRIVER_USART *)(pHandle->pComm))->Initialize(event);
67  return COMM_INTERFACE_OK;
68 }
69 int32_t COMM_UART_Config(comm_handle_t *pHandle, void *pConfigData)
70 {
71  // @todo the implementation.
72  comm_control_t *pControl = (comm_control_t *)pConfigData;
73  return ((ARM_DRIVER_USART *)(pHandle->pComm))->Control(pControl->control, pControl->arg);
74 }
75 int32_t COMM_UART_Send(comm_handle_t *pHandle, void *pData, uint32_t size)
76 {
77  //@todo the validation of the pointer
78  return ((ARM_DRIVER_USART *)(pHandle->pComm))->Send(pData, size);
79 }
80 int32_t COMM_UART_Receive(comm_handle_t *pHandle, void *pData, uint32_t size)
81 {
82  //@todo the validation of the pointer
83  return ((ARM_DRIVER_USART *)(pHandle->pComm))->Receive(pData, size);
84 }
86 {
87  //@todo the validation of the pointer
88  return pHandle->status;
89 }
90 // End USART Interface
91 
94 };
comm_interface_t commUART
Definition: comm_if_uart.c:92
int32_t COMM_UART_Config(comm_handle_t *pHandle, void *pConfigData)
Definition: comm_if_uart.c:69
int32_t COMM_UART_Send(comm_handle_t *pHandle, void *pData, uint32_t size)
Definition: comm_if_uart.c:75
int32_t COMM_UART_Init(comm_handle_t *pHandle, void *pCommInstance, COMM_Event_t event, void *pInitializeData)
Definition: comm_if_uart.c:60
#define COMM_INTERFACE_OK
Operation succeeded.
uint32_t control
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 COMM_UART_Receive(comm_handle_t *pHandle, void *pData, uint32_t size)
Definition: comm_if_uart.c:80
uint32_t status
int32_t COMM_UART_GetCapabilities(comm_handle_t *pHandle)
Definition: comm_if_uart.c:54
void(* COMM_Event_t)(uint32_t event)
int32_t COMM_UART_GetStatus(comm_handle_t *pHandle)
Definition: comm_if_uart.c:85