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 comm_if_uart.c
10 * @brief The comm_if_uart.c file implements comm interface for the UART.
11 */
12 #include <stddef.h>
13 #include <stdint.h>
14 #include <stdbool.h>
15 #include "Driver_USART.h"
16 #include "comm_interface.h"
17 /*******************************************************************************
18 * Variables
19 ******************************************************************************/
20 /*******************************************************************************
21 * Prototypes
22 ******************************************************************************/
23
24 /*******************************************************************************
25 * Code
26 ******************************************************************************/
27
COMM_UART_GetCapabilities(comm_handle_t * pHandle)28 int32_t COMM_UART_GetCapabilities(comm_handle_t *pHandle)
29 {
30 // @todo the implementation.
31 return COMM_INTERFACE_OK;
32 }
33
COMM_UART_Init(comm_handle_t * pHandle,void * pCommInstance,COMM_Event_t event,void * pInitializeData)34 int32_t COMM_UART_Init(comm_handle_t *pHandle, void *pCommInstance, COMM_Event_t event, void *pInitializeData)
35 {
36 // @todo handle the pointers and validation properly.
37 pHandle->pComm = pCommInstance;
38 //@todo use the rest of argument properly.
39 // SDK CMSIS driver adoption; init call will be done by the user application.
40 //((ARM_DRIVER_USART *)(pHandle->pComm))->Initialize(event);
41 return COMM_INTERFACE_OK;
42 }
COMM_UART_Config(comm_handle_t * pHandle,void * pConfigData)43 int32_t COMM_UART_Config(comm_handle_t *pHandle, void *pConfigData)
44 {
45 // @todo the implementation.
46 comm_control_t *pControl = (comm_control_t *)pConfigData;
47 return ((ARM_DRIVER_USART *)(pHandle->pComm))->Control(pControl->control, pControl->arg);
48 }
COMM_UART_Send(comm_handle_t * pHandle,void * pData,uint32_t size)49 int32_t COMM_UART_Send(comm_handle_t *pHandle, void *pData, uint32_t size)
50 {
51 //@todo the validation of the pointer
52 return ((ARM_DRIVER_USART *)(pHandle->pComm))->Send(pData, size);
53 }
COMM_UART_Receive(comm_handle_t * pHandle,void * pData,uint32_t size)54 int32_t COMM_UART_Receive(comm_handle_t *pHandle, void *pData, uint32_t size)
55 {
56 //@todo the validation of the pointer
57 return ((ARM_DRIVER_USART *)(pHandle->pComm))->Receive(pData, size);
58 }
COMM_UART_GetStatus(comm_handle_t * pHandle)59 int32_t COMM_UART_GetStatus(comm_handle_t *pHandle)
60 {
61 //@todo the validation of the pointer
62 return pHandle->status;
63 }
64 // End USART Interface
65
66 comm_interface_t commUART = {
67 COMM_UART_GetCapabilities, COMM_UART_Init, COMM_UART_Config, COMM_UART_Send, COMM_UART_Receive, COMM_UART_GetStatus,
68 };
69