1 /*!
2  * \file      uart-board.h
3  *
4  * \brief     Target board 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 #ifndef __UART_BOARD_H__
24 #define __UART_BOARD_H__
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 #include <stdint.h>
32 #include "uart.h"
33 
34 /*!
35  * \brief Initializes the UART object and MCU peripheral
36  *
37  * \param [IN] obj  UART object
38  * \param [IN] tx   UART Tx pin name to be used
39  * \param [IN] rx   UART Rx pin name to be used
40  */
41 void UartMcuInit( Uart_t *obj, UartId_t uartId, PinNames tx, PinNames rx );
42 
43 /*!
44  * \brief Configures the UART object and MCU peripheral
45  *
46  * \remark UartInit function must be called first.
47  *
48  * \param [IN] obj          UART object
49  * \param [IN] mode         Mode of operation for the UART
50  * \param [IN] baudrate     UART baudrate
51  * \param [IN] wordLength   packet length
52  * \param [IN] stopBits     stop bits setup
53  * \param [IN] parity       packet parity
54  * \param [IN] flowCtrl     UART flow control
55  */
56 void UartMcuConfig( Uart_t *obj, UartMode_t mode, uint32_t baudrate, WordLength_t wordLength, StopBits_t stopBits, Parity_t parity, FlowCtrl_t flowCtrl );
57 
58 /*!
59  * \brief DeInitializes the UART object and MCU pins
60  *
61  * \param [IN] obj  UART object
62  */
63 void UartMcuDeInit( Uart_t *obj );
64 
65 /*!
66  * \brief Sends a character to the UART
67  *
68  * \param [IN] obj   UART object
69  * \param [IN] data  Character to be sent
70  * \retval status    [0: OK, 1: Busy]
71  */
72 uint8_t UartMcuPutChar( Uart_t *obj, uint8_t data );
73 
74 /*!
75  * \brief Sends a buffer to the UART
76  *
77  * \param [IN] obj    UART object
78  * \param [IN] buffer Buffer to be sent
79  * \param [IN] size   Buffer size
80  * \retval status     [0: OK, 1: Busy]
81  */
82 uint8_t UartMcuPutBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size );
83 
84 /*!
85  * \brief Gets a character from the UART
86  *
87  * \param [IN] obj   UART object
88  * \param [IN] data  Received character
89  * \retval status    [0: OK, 1: Busy]
90  */
91 uint8_t UartMcuGetChar( Uart_t *obj, uint8_t *data );
92 
93 /*!
94  * \brief Gets a character from the UART
95  *
96  * \param [IN] obj          UART object
97  * \param [IN] buffer       Received buffer
98  * \param [IN] size         Number of bytes to be received
99  * \param [OUT] nbReadBytes Number of bytes really read
100  * \retval status           [0: OK, 1: Busy]
101  */
102 uint8_t UartMcuGetBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size, uint16_t *nbReadBytes );
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif // __UART_BOARD_H__
109