📄 uart.c
字号:
/******************************************************************************/
//
// Name: BF532-based EZ-KIT UART Setup
//
/******************************************************************************
Purpose: The file sets up the UART port for serial port transfers.
The Baud rate is setup at 115.2kbps
where Baud rate = SCLK/(16*Divisor) and SCLK = 75.6 MHz
*********************************************************************************/
#include <cdefBF533.h>
void Init_UART(void)
{
/*****************************************************************************
* First of all, enable UART clock.
****************************************************************************/
*pUART_GCTL |= UCEN;
*pUART_LCR |= DLAB; // Reset the UART and enable access to DLL
*pUART_DLL = 0x0029; // Set the Baud rate to be 115.2kbps
// *pUART_DLL = 0x0052; // Set the Baud rate to be 57.6kbps
*pUART_DLH = 0;
*pUART_LCR = 0x0003; // 8-bit, no parity, 1 STOP bit
}
void UART_PUTC(char TXD)
{
// Make sure the Transmit Hold Reg is empty first
while ((*pUART_LSR & 0x0020) == 0);
*pUART_THR = (unsigned short) TXD;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -