2022-10-19 22:44:15 +08:00

554 lines
25 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/******************************************************************************************************************************************
* <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>: SWM320_uart.c
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: SWM320<32><30>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>UART<52><54><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>: http://www.synwit.com.cn/e/tool/gbook/?bid=1
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: û<>б<EFBFBD>дLIN<49><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĺ<D8B5><C4BA><EFBFBD>
* <20><EFBFBD><E6B1BE><EFBFBD><EFBFBD>: V1.1.0 2017<31><37>10<31><30>25<32><35>
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:
*
*
*******************************************************************************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
* REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
* FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
* -ECTION WITH THEIR PRODUCTS.
*
* COPYRIGHT 2012 Synwit Technology
*******************************************************************************************************************************************/
#include "SWM320.h"
#include "SWM320_uart.h"
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_Init()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART<52><54><EFBFBD>ڳ<EFBFBD>ʼ<EFBFBD><CABC>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* UART_InitStructure * initStruct <20><><EFBFBD><EFBFBD>UART<52><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨ֵ<E8B6A8>Ľṹ<C4BD><E1B9B9>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_Init(UART_TypeDef * UARTx, UART_InitStructure * initStruct)
{
switch((uint32_t)UARTx)
{
case ((uint32_t)UART0):
SYS->CLKEN |= (0x01 << SYS_CLKEN_UART0_Pos);
break;
case ((uint32_t)UART1):
SYS->CLKEN |= (0x01 << SYS_CLKEN_UART1_Pos);
break;
case ((uint32_t)UART2):
SYS->CLKEN |= (0x01 << SYS_CLKEN_UART2_Pos);
break;
case ((uint32_t)UART3):
SYS->CLKEN |= (0x01 << SYS_CLKEN_UART3_Pos);
break;
}
UART_Close(UARTx); //һЩ<D2BB>ؼ<EFBFBD><D8BC>Ĵ<EFBFBD><C4B4><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>ڴ<EFBFBD><DAB4>ڹر<DAB9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
UARTx->CTRL |= (0x01 << UART_CTRL_BAUDEN_Pos);
UARTx->BAUD &= ~UART_BAUD_BAUD_Msk;
UARTx->BAUD |= ((SystemCoreClock/16/initStruct->Baudrate - 1) << UART_BAUD_BAUD_Pos);
UARTx->CTRL &= ~(UART_CTRL_DATA9b_Msk | UART_CTRL_PARITY_Msk | UART_CTRL_STOP2b_Msk);
UARTx->CTRL |= (initStruct->DataBits << UART_CTRL_DATA9b_Pos) |
(initStruct->Parity << UART_CTRL_PARITY_Pos) |
(initStruct->StopBits << UART_CTRL_STOP2b_Pos);
/* <20><>SWM320<32>У<EFBFBD><D0A3><EFBFBD> RXLVL >= RXTHR ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>RXTHR<48><52><EFBFBD><EFBFBD>Ϊ0<CEAA>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ͻ<EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>
<20><><EFBFBD><EFBFBD>оƬ<D0BE>У<EFBFBD><D0A3><EFBFBD> RXLVL > RXTHR ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>SWM320<32><30>RXTHR<48><52><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A3AC>ͳһ<CDB3><EFBFBD><E2BAAF>API<50><49><EFBFBD><EFBFBD><EFBFBD>ォRXTHR<48><52><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>һ
*/
switch((uint32_t)UARTx) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NVIC <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RXTHR ʱ<><EFBFBD><E1B5BC>һֱ<D2BB><D6B1><EFBFBD><EFBFBD> ISR
{
case ((uint32_t)UART0): NVIC_DisableIRQ(UART0_IRQn); break;
case ((uint32_t)UART1): NVIC_DisableIRQ(UART1_IRQn); break;
case ((uint32_t)UART2): NVIC_DisableIRQ(UART2_IRQn); break;
case ((uint32_t)UART3): NVIC_DisableIRQ(UART3_IRQn); break;
}
UARTx->FIFO &= ~(UART_FIFO_RXTHR_Msk | UART_FIFO_TXTHR_Msk);
UARTx->FIFO |= ((initStruct->RXThreshold + 1) << UART_FIFO_RXTHR_Pos) |
(initStruct->TXThreshold << UART_FIFO_TXTHR_Pos);
UARTx->CTRL &= ~UART_CTRL_TOTIME_Msk;
UARTx->CTRL |= (initStruct->TimeoutTime << UART_CTRL_TOTIME_Pos);
UARTx->CTRL &= ~(UART_CTRL_RXIE_Msk | UART_CTRL_TXIE_Msk | UART_CTRL_TOIE_Msk);
UARTx->CTRL |= (initStruct->RXThresholdIEn << UART_CTRL_RXIE_Pos) |
(initStruct->TXThresholdIEn << UART_CTRL_TXIE_Pos) |
(initStruct->TimeoutIEn << UART_CTRL_TOIE_Pos);
switch((uint32_t)UARTx)
{
case ((uint32_t)UART0):
if(initStruct->RXThresholdIEn | initStruct->TXThresholdIEn | initStruct->TimeoutIEn)
{
NVIC_EnableIRQ(UART0_IRQn);
}
else
{
NVIC_DisableIRQ(UART0_IRQn);
}
break;
case ((uint32_t)UART1):
if(initStruct->RXThresholdIEn | initStruct->TXThresholdIEn | initStruct->TimeoutIEn)
{
NVIC_EnableIRQ(UART1_IRQn);
}
else
{
NVIC_DisableIRQ(UART1_IRQn);
}
break;
case ((uint32_t)UART2):
if(initStruct->RXThresholdIEn | initStruct->TXThresholdIEn | initStruct->TimeoutIEn)
{
NVIC_EnableIRQ(UART2_IRQn);
}
else
{
NVIC_DisableIRQ(UART2_IRQn);
}
break;
case ((uint32_t)UART3):
if(initStruct->RXThresholdIEn | initStruct->TXThresholdIEn | initStruct->TimeoutIEn)
{
NVIC_EnableIRQ(UART3_IRQn);
}
else
{
NVIC_DisableIRQ(UART3_IRQn);
}
break;
}
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_Open()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART<52><54><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_Open(UART_TypeDef * UARTx)
{
UARTx->CTRL |= (0x01 << UART_CTRL_EN_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_Close()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART<52><54><EFBFBD>ڹر<DAB9>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_Close(UART_TypeDef * UARTx)
{
UARTx->CTRL &= ~(0x01 << UART_CTRL_EN_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_WriteByte()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3<54><33>UART4
* uint32_t data Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5>ֽ<EFBFBD>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_WriteByte(UART_TypeDef * UARTx, uint32_t data)
{
UARTx->DATA = data;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_ReadByte()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>ȡһ<C8A1><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Valid
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>ȡֵ<C8A1><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3<54><33>UART4
* uint32_t * data <09><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: uint32_t 0 <20>޴<EFBFBD><DEB4><EFBFBD> UART_ERR_PARITY <20><>żУ<C5BC><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_ReadByte(UART_TypeDef * UARTx, uint32_t * data)
{
uint32_t reg = UARTx->DATA;
*data = (reg & UART_DATA_DATA_Msk);
if(reg & UART_DATA_PAERR_Msk) return UART_ERR_PARITY;
return 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_IsTXBusy()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART<52>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 UART<52><54><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <20><><EFBFBD><EFBFBD><EFBFBD>ѷ<EFBFBD><D1B7><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_IsTXBusy(UART_TypeDef * UARTx)
{
return (UARTx->CTRL & UART_CTRL_TXIDLE_Msk) ? 0 : 1;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_IsRXFIFOEmpty()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>FIFO<46>Ƿ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD><DDBF>Զ<EFBFBD>ȡ
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 <20><><EFBFBD><EFBFBD>FIFO<46><4F> 0 <20><><EFBFBD><EFBFBD>FIFO<46>ǿ<EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_IsRXFIFOEmpty(UART_TypeDef * UARTx)
{
return (UARTx->CTRL & UART_CTRL_RXNE_Msk) ? 0 : 1;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_IsTXFIFOFull()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>FIFO<46>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 <20><><EFBFBD><EFBFBD>FIFO<46><4F> 0 <20><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_IsTXFIFOFull(UART_TypeDef * UARTx)
{
return (UARTx->CTRL & UART_CTRL_TXFF_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_SetBaudrate()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* uint32_t baudrate Ҫ<><D2AA><EFBFBD>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>Ҫ<EFBFBD>ڴ<EFBFBD><DAB4>ڹ<EFBFBD><DAB9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>ʣ<EFBFBD>ʹ<EFBFBD>ô˺<C3B4><CBBA><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ȵ<EFBFBD><C8B5><EFBFBD>UART_Close()<29>رմ<D8B1><D5B4><EFBFBD>
******************************************************************************************************************************************/
void UART_SetBaudrate(UART_TypeDef * UARTx, uint32_t baudrate)
{
UARTx->BAUD &= ~UART_BAUD_BAUD_Msk;
UARTx->BAUD |= ((SystemCoreClock/16/baudrate - 1) << UART_BAUD_BAUD_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_GetBaudrate()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t <09><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_GetBaudrate(UART_TypeDef * UARTx)
{
return SystemCoreClock/16/(((UARTx->BAUD & UART_BAUD_BAUD_Msk) >> UART_BAUD_BAUD_Pos) + 1);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_CTSConfig()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART CTS<54><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* uint32_t enable 1 ʹ<><CAB9>CTS<54><53><EFBFBD><EFBFBD> 0 <20><>ֹCTS<54><53><EFBFBD><EFBFBD>
* uint32_t polarity 0 CTS<54><53><EFBFBD><EFBFBD>Ϊ<EFBFBD>ͱ<EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 CTS<54><53><EFBFBD><EFBFBD>Ϊ<EFBFBD>߱<EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_CTSConfig(UART_TypeDef * UARTx, uint32_t enable, uint32_t polarity)
{
UARTx->CTSCR &= ~(UART_CTSCR_EN_Msk | UART_CTSCR_POL_Msk);
UARTx->CTSCR |= (enable << UART_CTSCR_EN_Pos) |
(polarity << UART_CTSCR_POL_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_CTSLineState()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART CTS<54>ߵ<EFBFBD>ǰ״̬
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 0 CTS<54>ߵ<EFBFBD>ǰΪ<C7B0>͵<EFBFBD>ƽ 1 CTS<54>ߵ<EFBFBD>ǰΪ<C7B0>ߵ<EFBFBD>ƽ
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_CTSLineState(UART_TypeDef * UARTx)
{
return (UARTx->CTSCR & UART_CTSCR_STAT_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_RTSConfig()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART RTS<54><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* uint32_t enable 1 ʹ<><CAB9>RTS<54><53><EFBFBD><EFBFBD> 0 <20><>ֹRTS<54><53><EFBFBD><EFBFBD>
* uint32_t polarity 0 RTS<54><53><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 RTS<54><53><EFBFBD><EFBFBD><EFBFBD>߱<EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* uint32_t threshold RTS<54><53><EFBFBD>صĴ<D8B5><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ȡֵUART_RTS_1BYTE<54><45>UART_RTS_2BYTE<54><45>UART_RTS_4BYTE<54><45>UART_RTS_6BYTE
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_RTSConfig(UART_TypeDef * UARTx, uint32_t enable, uint32_t polarity, uint32_t threshold)
{
UARTx->RTSCR &= ~(UART_RTSCR_EN_Msk | UART_RTSCR_POL_Msk | UART_RTSCR_THR_Msk);
UARTx->RTSCR |= (enable << UART_RTSCR_EN_Pos) |
(polarity << UART_RTSCR_POL_Pos) |
(threshold << UART_RTSCR_THR_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_RTSLineState()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART RTS<54>ߵ<EFBFBD>ǰ״̬
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 0 RTS<54>ߵ<EFBFBD>ǰΪ<C7B0>͵<EFBFBD>ƽ 1 RTS<54>ߵ<EFBFBD>ǰΪ<C7B0>ߵ<EFBFBD>ƽ
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_RTSLineState(UART_TypeDef * UARTx)
{
return (UARTx->RTSCR & UART_RTSCR_STAT_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_LINConfig()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART LIN<49><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* uint32_t detectedIEn <09><><EFBFBD>⵽Break<61>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* uint32_t generatedIEn Break<61><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_LINConfig(UART_TypeDef * UARTx, uint32_t detectedIEn, uint32_t generatedIEn)
{
UARTx->LINCR &= ~(UART_LINCR_BRKDETIE_Msk | UART_LINCR_GENBRKIE_Msk);
UARTx->LINCR |= (detectedIEn << UART_LINCR_BRKDETIE_Pos) |
(generatedIEn << UART_LINCR_GENBRKIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_LINGenerate()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART LIN<49><4E><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD>Break
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_LINGenerate(UART_TypeDef * UARTx)
{
UARTx->LINCR |= (1 << UART_LINCR_GENBRK_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_LINIsDetected()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART LIN<49>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>⵽Break
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 <20><><EFBFBD>⵽LIN Break 0 δ<><CEB4><EFBFBD>⵽LIN Break
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_LINIsDetected(UART_TypeDef * UARTx)
{
return (UARTx->LINCR & UART_LINCR_BRKDETIF_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_LINIsGenerated()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART LIN Break<61>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 LIN Break <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 LIN Break<61><6B><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_LINIsGenerated(UART_TypeDef * UARTx)
{
return (UARTx->LINCR & UART_LINCR_GENBRKIF_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_ABRStart()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ʼ
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* uint32_t detectChar <09><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><E2A1A2><EFBFBD><EFBFBD><E3B2A8><EFBFBD>ʵļ<CAB5><C4BC><EFBFBD><EFBFBD>ַ<EFBFBD>
* 8λ<38><CEBB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȡֵ<C8A1><D6B5>0xFF<46><46>0xFE<46><45>0xF8<46><38>0x80<38><30><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EBB7A2>0xFF<46><46>0xFE<46><45>0xF8<46><38>0x80
* 9λ<39><CEBB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ȡֵ<C8A1><D6B5>0x1FF<46><46>0x1FE<46><45>0x1F8<46><38>0x180<38><30><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EBB7A2>0x1FF<46><46>0x1FE<46><45>0x1F8<46><38>0x180
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ܿ<EFBFBD><DCBF><EFBFBD><EFBFBD><EFBFBD>żУ<C5BC><D0A3>
******************************************************************************************************************************************/
void UART_ABRStart(UART_TypeDef * UARTx, uint32_t detectChar)
{
uint32_t bits;
if((detectChar == 0xFF) || (detectChar == 0x1FF)) bits = 0;
else if((detectChar == 0xFE) || (detectChar == 0x1FE)) bits = 1;
else if((detectChar == 0xF8) || (detectChar == 0x1F8)) bits = 2;
else if((detectChar == 0x80) || (detectChar == 0x180)) bits = 3;
else while(1);
UARTx->BAUD &= ~(UART_BAUD_ABREN_Msk | UART_BAUD_ABRBIT_Msk);
UARTx->BAUD |= (1 << UART_BAUD_ABREN_Pos) |
(bits << UART_BAUD_ABRBIT_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_ABRIsDone()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: UART <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 0 δ<><CEB4><EFBFBD><EFBFBD> UART_ABR_RES_OK <20><><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3>ҳɹ<D2B3> UART_ABR_RES_ERR <20><><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_ABRIsDone(UART_TypeDef * UARTx)
{
if(UARTx->BAUD & UART_BAUD_ABREN_Msk)
{
return 0;
}
else if(UARTx->BAUD & UART_BAUD_ABRERR_Msk)
{
return UART_ABR_RES_ERR;
}
else
{
return UART_ABR_RES_OK;
}
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTRXThresholdEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>RX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> >= RXThresholdʱ <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTRXThresholdEn(UART_TypeDef * UARTx)
{
UARTx->CTRL |= (0x01 << UART_CTRL_RXIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTRXThresholdDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>RX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> >= RXThresholdʱ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTRXThresholdDis(UART_TypeDef * UARTx)
{
UARTx->CTRL &= ~(0x01 << UART_CTRL_RXIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTRXThresholdStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>Ƿ<EFBFBD>RX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> >= RXThreshold
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 RX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> >= RXThreshold 0 RX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> < RXThreshold
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: RXIF = RXTHRF & RXIE
******************************************************************************************************************************************/
uint32_t UART_INTRXThresholdStat(UART_TypeDef * UARTx)
{
return (UARTx->BAUD & UART_BAUD_RXIF_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTXThresholdEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>TX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> <= TXThresholdʱ <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTTXThresholdEn(UART_TypeDef * UARTx)
{
UARTx->CTRL |= (0x01 << UART_CTRL_TXIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTXThresholdDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><>TX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> <= TXThresholdʱ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTTXThresholdDis(UART_TypeDef * UARTx)
{
UARTx->CTRL &= ~(0x01 << UART_CTRL_TXIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTXThresholdStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>Ƿ<EFBFBD>TX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> <= TXThreshold
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 TX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> <= TXThreshold 0 TX FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD> > TXThreshold
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: TXIF = TXTHRF & TXIE
******************************************************************************************************************************************/
uint32_t UART_INTTXThresholdStat(UART_TypeDef * UARTx)
{
return (UARTx->BAUD & UART_BAUD_TXIF_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTimeoutEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD>ʱʱ <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTTimeoutEn(UART_TypeDef * UARTx)
{
UARTx->CTRL |= (0x01 << UART_CTRL_TOIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTimeoutDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD>ʱʱ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTTimeoutDis(UART_TypeDef * UARTx)
{
UARTx->CTRL &= ~(0x01 << UART_CTRL_TOIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTimeoutStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><CBBD>ճ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TimeoutTime/(Baudrate/10) <20><>û<EFBFBD><C3BB><EFBFBD><EFBFBD>RX<52><58><EFBFBD>Ͻ<EFBFBD><CFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 <20><><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><CBBD>ճ<EFBFBD>ʱ 0 δ<><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ճ<EFBFBD>ʱ
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_INTTimeoutStat(UART_TypeDef * UARTx)
{
return (UARTx->BAUD & UART_BAUD_TOIF_Msk) ? 1 : 0;
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTXDoneEn()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTTXDoneEn(UART_TypeDef * UARTx)
{
UARTx->CTRL |= (0x01 << UART_CTRL_TXDOIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTXDoneDis()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<D0B6>ֹ
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: <20><>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
void UART_INTTXDoneDis(UART_TypeDef * UARTx)
{
UARTx->CTRL &= ~(0x01 << UART_CTRL_TXDOIE_Pos);
}
/******************************************************************************************************************************************
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: UART_INTTXDoneStat()
* <20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>: <09><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>״̬
* <20><> <20><>: UART_TypeDef * UARTx ָ<><D6B8>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>UART<52><54><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD>Чֵ<D0A7><D6B5><EFBFBD><EFBFBD>UART0<54><30>UART1<54><31>UART2<54><32>UART3
* <20><> <20><>: uint32_t 1 <20><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD> 0 <20><><EFBFBD><EFBFBD>FIFO<46><4F><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>δ<EFBFBD><CEB4>
* ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><>
******************************************************************************************************************************************/
uint32_t UART_INTTXDoneStat(UART_TypeDef * UARTx)
{
return (UARTx->BAUD & UART_BAUD_TXDOIF_Msk) ? 1 : 0;
}