1 /*! 2 * \file uart-usb-board.h 3 * 4 * \brief Target board UART over USB 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_USB_BOARD_H__ 24 #define __UART_USB_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 UartUsbInit( Uart_t *obj, UartId_t uartId, PinNames tx, PinNames rx ); 42 43 /*! 44 * \brief Initializes the UART object and USB peripheral 45 * 46 * \param [IN] obj UART object 47 * \param [IN] mode Mode of operation for the UART 48 * \param [IN] baudrate UART baudrate 49 * \param [IN] wordLength packet length 50 * \param [IN] stopBits stop bits setup 51 * \param [IN] parity packet parity 52 * \param [IN] flowCtrl UART flow control 53 */ 54 void UartUsbConfig( Uart_t *obj, UartMode_t mode, uint32_t baudrate, WordLength_t wordLength, StopBits_t stopBits, Parity_t parity, FlowCtrl_t flowCtrl ); 55 56 /*! 57 * \brief DeInitializes the UART object and USB peripheral 58 * 59 * \param [IN] obj UART object 60 */ 61 void UartUsbDeInit( Uart_t *obj ); 62 63 /*! 64 * \brief Checks if the cable is connected or not 65 * 66 * \retval connected [0: Not connected, 1: Connected] 67 */ 68 uint8_t UartUsbIsUsbCableConnected( void ); 69 70 /*! 71 * \brief Sends a buffer to the UART 72 * 73 * \param [IN] obj UART object 74 * \param [IN] buffer Buffer to be sent 75 * \param [IN] size Buffer size 76 * \retval status [0: OK, 1: Busy, 2: Fail] 77 */ 78 uint8_t UartUsbPutBuffer( Uart_t *obj, uint8_t *buffer, uint16_t size ); 79 80 /*! 81 * \brief Sends a character to the UART 82 * 83 * \param [IN] obj UART object 84 * \param [IN] data Character to be sent 85 * \retval status [0: OK, 1: Busy, 2: Fail] 86 */ 87 uint8_t UartUsbPutChar( Uart_t *obj, uint8_t data ); 88 89 /*! 90 * \brief Gets a character from the UART 91 * 92 * \param [IN] obj UART object 93 * \param [IN] data Received character 94 * \retval status [0: OK, 1: Busy, 2: Fail] 95 */ 96 uint8_t UartUsbGetChar( Uart_t *obj, uint8_t *data ); 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif // __UART_USB_BOARD_H__ 103