pl011: Fix baud divisor, enable fifo.
* Correct the baud calculations * Be sure to enable fifo mode
This commit is contained in:
@@ -76,19 +76,21 @@ UartPL011::ReadUart(uint32 reg)
|
|||||||
void
|
void
|
||||||
UartPL011::InitPort(uint32 baud)
|
UartPL011::InitPort(uint32 baud)
|
||||||
{
|
{
|
||||||
|
// Calculate baud divisor
|
||||||
|
uint32 baudDivisor = BOARD_UART_CLOCK / (16 * baud);
|
||||||
|
uint32 remainder = BOARD_UART_CLOCK % (16 * baud);
|
||||||
|
uint32 baudFractional = ((8 * remainder) / baud) >> 1
|
||||||
|
+ ((8 * remainder) / baud) & 1;
|
||||||
|
|
||||||
// Disable UART
|
// Disable UART
|
||||||
Disable();
|
Disable();
|
||||||
|
|
||||||
// Calculate baud divisor
|
|
||||||
uint16 baudDivisor = BOARD_UART_CLOCK / (16 * baud);
|
|
||||||
uint16 baudFractional = BOARD_UART_CLOCK % (16 * baud);
|
|
||||||
|
|
||||||
// Set baud divisor
|
// Set baud divisor
|
||||||
WriteUart(PL011_IBRD, baudDivisor);
|
WriteUart(PL011_IBRD, baudDivisor);
|
||||||
WriteUart(PL011_FBRD, baudFractional);
|
WriteUart(PL011_FBRD, baudFractional);
|
||||||
|
|
||||||
// Set LCR
|
// Set LCR 8n1, enable fifo
|
||||||
WriteUart(PL011_LCRH, PL01x_LCRH_WLEN_8);
|
WriteUart(PL011_LCRH, PL01x_LCRH_WLEN_8 | PL01x_LCRH_FEN);
|
||||||
|
|
||||||
// Enable UART
|
// Enable UART
|
||||||
Enable();
|
Enable();
|
||||||
@@ -131,8 +133,8 @@ UartPL011::PutChar(char c)
|
|||||||
{
|
{
|
||||||
if (fUARTEnabled == true) {
|
if (fUARTEnabled == true) {
|
||||||
WriteUart(PL01x_DR, (unsigned int)c);
|
WriteUart(PL01x_DR, (unsigned int)c);
|
||||||
while (ReadUart(PL01x_FR) & PL01x_FR_TXFF);
|
// Empty the transmit buffer
|
||||||
// wait for the last char to get out
|
FlushTx();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user