/* * @Description: * @Date: 2022-01-06 16:25:34 * @LastEditors: CK.Zh * @LastEditTime: 2022-01-07 12:28:05 * @FilePath: /rt-thread/bsp/hc32l073/Libraries/HC32L073_StdPeriph_Driver/inc/uart.h */ /****************************************************************************** * 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 "hc32l07x.h" #ifdef __cplusplus extern "C" { #endif /** ****************************************************************************** ** \defgroup UartGroup Universal Asynchronous Receiver/Transmitter (UART) ** ******************************************************************************/ //@{ /******************************************************************************/ /* Global pre-processor symbols/macros ('#define') */ /******************************************************************************/ /****************************************************************************** * Global type definitions ******************************************************************************/ /** ****************************************************************************** **\brief uart通道选择 ******************************************************************************/ /** ****************************************************************************** ** \brief uart多机模式地址帧/数据帧或者奇偶校验 ******************************************************************************/ typedef enum en_uart_mmdorck { UartMskDataOrAddr = 0u, ///<多机模式时,通过读写SBUF[8]决定帧为数据帧或地址帧 UartMskEven = 0x4u, ///<非多机模式偶校验 UartMskOdd = 0x8u, ///<非多机模式奇校验 }en_uart_mmdorck_t; /** ****************************************************************************** ** \brief uart多机模式及从机地址和地址掩码配置 ******************************************************************************/ typedef struct stc_uart_multimode { uint8_t u8SlaveAddr; ///<从机地址 uint8_t u8SaddEn; ///<从及地址掩码 }stc_uart_multimode_t; /** ****************************************************************************** ** \brief uart 四种工作模式选择 ******************************************************************************/ typedef enum en_uart_mode { UartMskMode0 = 0x00u, ///<模式0 UartMskMode1 = 0x40u, ///<模式1 UartMskMode2 = 0x80u, ///<模式2 UartMskMode3 = 0xc0u, ///<模式3 } en_uart_mode_t; /** ****************************************************************************** ** \brief uart stop长度选择 ******************************************************************************/ typedef enum en_uart_stop { UartMsk1bit = 0x0000u, ///<1位停止位 UartMsk1_5bit = 0x4000u, ///<1.5位停止位 UartMsk2bit = 0x8000u, ///<2位停止位 } en_uart_stop_t; /** ****************************************************************************** ** \brief uart 功能使能 ******************************************************************************/ typedef enum en_uart_func { UartRenFunc = 4u, ///<0-TX; ///<1-非mode0模式代表RX&TX ,mode0模式代表RX; UartDmaRxFunc = 16u, ///