/****************************************************************************** * Copyright (C) 2021, Xiaohua Semiconductor Co., Ltd. All rights reserved. * * This software component is licensed by XHSC under BSD 3-Clause license * (the "License"); You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ******************************************************************************/ /****************************************************************************** * @file uart.h * * @brief Header file for UART functions * * @author MADS Team * ******************************************************************************/ #ifndef __UART_H__ #define __UART_H__ /***************************************************************************** * Include files *****************************************************************************/ #include "ddl.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, ///