/****************************************************************************** * Copyright (C) 2017, Huada Semiconductor Co.,Ltd All rights reserved. * * This software is owned and published by: * Huada Semiconductor Co.,Ltd ("HDSC"). * * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT. * * This software contains source code for use with HDSC * components. This software is licensed by HDSC to be adapted only * for use in systems utilizing HDSC components. HDSC shall not be * responsible for misuse or illegal use of this software for devices not * supported herein. HDSC is providing this software "AS IS" and will * not be responsible for issues arising from incorrect user implementation * of the software. * * Disclaimer: * HDSC MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE, * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS), * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING, * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED * WARRANTY OF NONINFRINGEMENT. * HDSC SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA, * SAVINGS OR PROFITS, * EVEN IF Disclaimer HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED * FROM, THE SOFTWARE. * * This software may be replicated in part or whole for the licensed use, * with the restriction that this Disclaimer and Copyright notice must be * included with each copy of this software, whether used in part or whole, * at all times. */ /*****************************************************************************/ /** \file uart.h ** ** Headerfile for UART functions ** ** ** History: ** - 2017-05-10 Cathy First Version ** *****************************************************************************/ #ifndef __UART_H__ #define __UART_H__ /***************************************************************************** * Include files *****************************************************************************/ #include "ddl.h" #include "interrupts_hc32l136.h" #ifdef __cplusplus extern "C" { #endif /** ****************************************************************************** ** \defgroup UartGroup Universal Asynchronous Receiver/Transmitter (UART) ** ******************************************************************************/ //@{ /******************************************************************************/ /* Global pre-processor symbols/macros ('#define') */ /******************************************************************************/ /****************************************************************************** * Global type definitions ******************************************************************************/ /** ****************************************************************************** **\brief uart通道选择 ******************************************************************************/ typedef enum en_uart_channel { UARTCH0 = 0u, ///<串口0 UARTCH1 = 1u, ///<串口1 }en_uart_channel_t; /** ****************************************************************************** ** \brief uart多主机模式地址帧/数据帧或者奇偶校验 ******************************************************************************/ typedef enum en_uart_mmdorck { UartDataOrAddr = 0u, ///<多主机模式时,通过读写SBUF[8]决定帧为数据帧或地址帧 UartEven = 1u, ///<非多主机模式偶校验 UartOdd = 2u, ///<非多主机模式奇校验 }en_uart_mmdorck_t; /** ****************************************************************************** ** \brief uart多主机模式配置 ******************************************************************************/ typedef enum en_uart_multimode { UartNormal = 0u, ///<正常工作模式 UartMulti = 1u, ///<多主机工作模式 }en_uart_multimode_t; /** ****************************************************************************** ** \brief uart多主机模式及从机地址和地址掩码配置 ******************************************************************************/ typedef struct stc_uart_multimode { en_uart_multimode_t enMulti_mode; ///<多主机模式配置 uint8_t u8SlaveAddr; ///<从机地址 uint8_t u8SaddEn; ///<从及地址掩码 }stc_uart_multimode_t; /** ****************************************************************************** ** \brief uart 四种工作模式选择 ******************************************************************************/ typedef enum en_uart_mode { UartMode0 = 0u, ///<模式0 UartMode1 = 1u, ///<模式1 UartMode2 = 2u, ///<模式2 UartMode3 = 3u, ///<模式3 } en_uart_mode_t; /** ****************************************************************************** ** \brief uart stop长度选择 ******************************************************************************/ typedef enum en_uart_stop { Uart1bit = 0u, ///<1位停止位 Uart15bit = 1u, ///<1.5位停止位 Uart2bit = 2u, ///<2位停止位 } en_uart_stop_t; /** ****************************************************************************** ** \brief uart 功能使能 ******************************************************************************/ typedef enum en_uart_func { UartTx = 0u, ///