1 /*!
2  * \file      uart.c
3  *
4  * \brief     UART driver implementation
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013-2017 Semtech
16  *
17  * \endcode
18  *
19  * \author    Miguel Luis ( Semtech )
20  *
21  * \author    Gregory Cristian ( Semtech )
22  */
23 #include "uart-board.h"
24 #include "uart.h"
25 
UartInit(Uart_t * obj,UartId_t uartId,PinNames tx,PinNames rx)26 void UartInit( Uart_t *obj, UartId_t uartId, PinNames tx, PinNames rx )
27 {
28     if( obj->IsInitialized == false )
29     {
30         obj->IsInitialized = true;
31         UartMcuInit( obj, uartId, tx, rx );
32     }
33 }
34 
UartConfig(Uart_t * obj,UartMode_t mode,uint32_t baudrate,WordLength_t wordLength,StopBits_t stopBits,Parity_t parity,FlowCtrl_t flowCtrl)35 void UartConfig( Uart_t *obj, UartMode_t mode, uint32_t baudrate, WordLength_t wordLength, StopBits_t stopBits, Parity_t parity, FlowCtrl_t flowCtrl )
36 {
37     UartMcuConfig( obj, mode, baudrate, wordLength, stopBits, parity, flowCtrl );
38 }
39 
UartDeInit(Uart_t * obj)40 void UartDeInit( Uart_t *obj )
41 {
42     obj->IsInitialized = false;
43     UartMcuDeInit( obj );
44 }
45 
UartPutChar(Uart_t * obj,uint8_t data)46 uint8_t UartPutChar( Uart_t *obj, uint8_t data )
47 {
48      return UartMcuPutChar( obj, data );
49 }
50 
UartGetChar(Uart_t * obj,uint8_t * data)51 uint8_t UartGetChar( Uart_t *obj, uint8_t *data )
52 {
53     return UartMcuGetChar( obj, data );
54 }
55 
UartPutBuffer(Uart_t * obj,uint8_t * buffer,uint16_t size)56 uint8_t UartPutBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size )
57 {
58     return UartMcuPutBuffer( obj, buffer, size );
59 }
60 
UartGetBuffer(Uart_t * obj,uint8_t * buffer,uint16_t size,uint16_t * nbReadBytes)61 uint8_t UartGetBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size, uint16_t *nbReadBytes )
62 {
63     return UartMcuGetBuffer( obj, buffer, size, nbReadBytes );
64 }
65