1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

set default baudrate to 38400

This commit is contained in:
Stefan Lankes 2017-06-03 08:16:19 +02:00
parent 8ce912ef03
commit 1c477aaa60
2 changed files with 22 additions and 21 deletions

View file

@ -154,12 +154,8 @@ int uart_puts(const char *text)
static int uart_config(void)
{
/*
* enable FIFOs
* clear RX and TX FIFO
* set irq trigger to 8 bytes
*/
write_to_uart(UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_1);
if (!uartport)
return 0;
/* disable interrupts */
write_to_uart(UART_IER, 0);
@ -176,15 +172,21 @@ static int uart_config(void)
write_to_uart(UART_LCR, lcr);
/*
* set baudrate to 9600
* set baudrate to 38400
*/
uint32_t divisor = 1843200 / 9600; //115200;
write_to_uart(UART_DLL, divisor & 0xff);
write_to_uart(UART_DLM, (divisor >> 8) & 0xff);
write_to_uart(UART_DLL, 0x03);
write_to_uart(UART_DLM, 0x00);
/* set DLAB=0 */
write_to_uart(UART_LCR, lcr & (~UART_LCR_DLAB));
/*
* enable FIFOs
* clear RX and TX FIFO
* set irq trigger to 8 bytes
*/
write_to_uart(UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_1);
return 0;
}

View file

@ -150,13 +150,6 @@ static int uart_config(void)
if (!uartport)
return 0;
/*
* enable FIFOs
* clear RX and TX FIFO
* set irq trigger to 8 bytes
*/
write_to_uart(UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_1);
/* disable interrupts */
write_to_uart(UART_IER, 0);
@ -172,15 +165,21 @@ static int uart_config(void)
write_to_uart(UART_LCR, lcr);
/*
* set baudrate to 9600
* set baudrate to 38400
*/
uint32_t divisor = 1843200 / 9600; // 115200;
write_to_uart(UART_DLL, divisor & 0xff);
write_to_uart(UART_DLM, (divisor >> 8) & 0xff);
write_to_uart(UART_DLL, 0x03);
write_to_uart(UART_DLM, 0x00);
/* set DLAB=0 */
write_to_uart(UART_LCR, lcr & (~UART_LCR_DLAB));
/*
* enable FIFOs
* clear RX and TX FIFO
* set irq trigger to 8 bytes
*/
write_to_uart(UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT | UART_FCR_TRIGGER_1);
return 0;
}