mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
411 lines
8.6 KiB
C
411 lines
8.6 KiB
C
|
/********************************** (C) COPYRIGHT *******************************
|
|||
|
* File Name : CH57x_uart.h
|
|||
|
* Author : WCH
|
|||
|
* Version : V1.2
|
|||
|
* Date : 2021/11/17
|
|||
|
* Description
|
|||
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
|||
|
* SPDX-License-Identifier: Apache-2.0
|
|||
|
*******************************************************************************/
|
|||
|
|
|||
|
#ifndef __CH58x_UART_H__
|
|||
|
#define __CH58x_UART_H__
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
/**
|
|||
|
* @brief LINE error and status define
|
|||
|
*/
|
|||
|
#define STA_ERR_BREAK RB_LSR_BREAK_ERR // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define STA_ERR_FRAME RB_LSR_FRAME_ERR // <20><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
|||
|
#define STA_ERR_PAR RB_LSR_PAR_ERR // <20><>żУ<C5BC><D0A3>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
|||
|
#define STA_ERR_FIFOOV RB_LSR_OVER_ERR // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
#define STA_TXFIFO_EMP RB_LSR_TX_FIFO_EMP // <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>FIFO<46>գ<EFBFBD><D5A3><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䷢<EFBFBD><E4B7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define STA_TXALL_EMP RB_LSR_TX_ALL_EMP // <20><>ǰ<EFBFBD><C7B0><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><DDB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define STA_RECV_DATA RB_LSR_DATA_RDY // <20><>ǰ<EFBFBD>н<EFBFBD><D0BD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
/**
|
|||
|
* @brief Configuration UART TrigByte num
|
|||
|
*/
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
UART_1BYTE_TRIG = 0, // 1<>ֽڴ<D6BD><DAB4><EFBFBD>
|
|||
|
UART_2BYTE_TRIG, // 2<>ֽڴ<D6BD><DAB4><EFBFBD>
|
|||
|
UART_4BYTE_TRIG, // 4<>ֽڴ<D6BD><DAB4><EFBFBD>
|
|||
|
UART_7BYTE_TRIG, // 7<>ֽڴ<D6BD><DAB4><EFBFBD>
|
|||
|
|
|||
|
} UARTByteTRIGTypeDef;
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART0_DefInit(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param baudrate - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART0_BaudRateCfg(uint32_t baudrate);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD> refer to UARTByteTRIGTypeDef
|
|||
|
*/
|
|||
|
void UART0_ByteTrigCfg(UARTByteTRIGTypeDef b);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - <EFBFBD>жϿ<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
|||
|
* @param i - <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* RB_IER_MODEM_CHG - <EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD>仯<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> UART0 ֧<EFBFBD>֣<EFBFBD>
|
|||
|
* RB_IER_LINE_STAT - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·״̬<EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_THR_EMPTY - <EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD>ּĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_RECV_RDY - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
*/
|
|||
|
void UART0_INTCfg(FunctionalState s, uint8_t i);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
*/
|
|||
|
void UART0_Reset(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART0_CLR_RXFIFO() (R8_UART0_FCR |= RB_FCR_RX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART0_CLR_TXFIFO() (R8_UART0_FCR |= RB_FCR_TX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*/
|
|||
|
#define UART0_GetITFlag() (R8_UART0_IIR & RB_IIR_INT_MASK)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰͨѶ״̬
|
|||
|
*
|
|||
|
* @return refer to LINE error and status define
|
|||
|
*/
|
|||
|
#define UART0_GetLinSTA() (R8_UART0_LSR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART0_SendByte(b) (R8_UART0_THR = b)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param l - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART0_SendString(uint8_t *buf, uint16_t l);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART0_RecvByte() (R8_UART0_RBR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
uint16_t UART0_RecvString(uint8_t *buf);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART1_DefInit(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param baudrate - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART1_BaudRateCfg(uint32_t baudrate);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD> refer to UARTByteTRIGTypeDef
|
|||
|
*/
|
|||
|
void UART1_ByteTrigCfg(UARTByteTRIGTypeDef b);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - <EFBFBD>жϿ<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
|||
|
* @param i - <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* RB_IER_MODEM_CHG - <EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD>仯<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> UART0 ֧<EFBFBD>֣<EFBFBD>
|
|||
|
* RB_IER_LINE_STAT - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·״̬<EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_THR_EMPTY - <EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD>ּĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_RECV_RDY - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
*/
|
|||
|
void UART1_INTCfg(FunctionalState s, uint8_t i);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
*/
|
|||
|
void UART1_Reset(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART1_CLR_RXFIFO() (R8_UART1_FCR |= RB_FCR_RX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART1_CLR_TXFIFO() (R8_UART1_FCR |= RB_FCR_TX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*/
|
|||
|
#define UART1_GetITFlag() (R8_UART1_IIR & RB_IIR_INT_MASK)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰͨѶ״̬
|
|||
|
*
|
|||
|
* @return refer to LINE error and status define
|
|||
|
*/
|
|||
|
#define UART1_GetLinSTA() (R8_UART1_LSR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART1_SendByte(b) (R8_UART1_THR = b)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param l - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART1_SendString(uint8_t *buf, uint16_t l);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART1_RecvByte() (R8_UART1_RBR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
uint16_t UART1_RecvString(uint8_t *buf);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART2_DefInit(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param baudrate - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART2_BaudRateCfg(uint32_t baudrate);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD> refer to UARTByteTRIGTypeDef
|
|||
|
*/
|
|||
|
void UART2_ByteTrigCfg(UARTByteTRIGTypeDef b);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - <EFBFBD>жϿ<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
|||
|
* @param i - <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* RB_IER_MODEM_CHG - <EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD>仯<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> UART0 ֧<EFBFBD>֣<EFBFBD>
|
|||
|
* RB_IER_LINE_STAT - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·״̬<EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_THR_EMPTY - <EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD>ּĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_RECV_RDY - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
*/
|
|||
|
void UART2_INTCfg(FunctionalState s, uint8_t i);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
*/
|
|||
|
void UART2_Reset(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART2_CLR_RXFIFO() (R8_UART2_FCR |= RB_FCR_RX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART2_CLR_TXFIFO() (R8_UART2_FCR |= RB_FCR_TX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*/
|
|||
|
#define UART2_GetITFlag() (R8_UART2_IIR & RB_IIR_INT_MASK)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰͨѶ״̬
|
|||
|
*
|
|||
|
* @return refer to LINE error and status define
|
|||
|
*/
|
|||
|
#define UART2_GetLinSTA() (R8_UART2_LSR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART2_SendByte(b) (R8_UART2_THR = b)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param l - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART2_SendString(uint8_t *buf, uint16_t l);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART2_RecvByte() (R8_UART2_RBR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
uint16_t UART2_RecvString(uint8_t *buf);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART3_DefInit(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param baudrate - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART3_BaudRateCfg(uint32_t baudrate);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD> refer to UARTByteTRIGTypeDef
|
|||
|
*/
|
|||
|
void UART3_ByteTrigCfg(UARTByteTRIGTypeDef b);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param s - <EFBFBD>жϿ<EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ж<EFBFBD>
|
|||
|
* @param i - <EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* RB_IER_MODEM_CHG - <EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD>仯<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> UART0 ֧<EFBFBD>֣<EFBFBD>
|
|||
|
* RB_IER_LINE_STAT - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·״̬<EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_THR_EMPTY - <EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><EFBFBD>ּĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
* RB_IER_RECV_RDY - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
|
|||
|
*/
|
|||
|
void UART3_INTCfg(FunctionalState s, uint8_t i);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|||
|
*/
|
|||
|
void UART3_Reset(void);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART3_CLR_RXFIFO() (R8_UART3_FCR |= RB_FCR_RX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FIFO
|
|||
|
*/
|
|||
|
#define UART3_CLR_TXFIFO() (R8_UART3_FCR |= RB_FCR_TX_FIFO_CLR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ǰ<EFBFBD>жϱ<EFBFBD>־
|
|||
|
*/
|
|||
|
#define UART3_GetITFlag() (R8_UART3_IIR & RB_IIR_INT_MASK)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>ǰͨѶ״̬
|
|||
|
*
|
|||
|
* @return refer to LINE error and status define
|
|||
|
*/
|
|||
|
#define UART3_GetLinSTA() (R8_UART3_LSR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param b <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART3_SendByte(b) (R8_UART3_THR = b)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><EFBFBD>ֽڷ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
* @param l - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
void UART3_SendString(uint8_t *buf, uint16_t l);
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*/
|
|||
|
#define UART3_RecvByte() (R8_UART3_RBR)
|
|||
|
|
|||
|
/**
|
|||
|
* @brief <EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
|||
|
*
|
|||
|
* @param buf - <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD>Ż<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|||
|
*
|
|||
|
* @return <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
*/
|
|||
|
uint16_t UART3_RecvString(uint8_t *buf);
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif // __CH58x_UART_H__
|