URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Go to most recent revision |
Show entire file |
Details |
Blame |
View Log
Rev 1394 |
Rev 1396 |
Line 54... |
Line 54... |
|
|
/* Number of clock cycles (one clock cycle is one call to the uart_clock())
|
/* Number of clock cycles (one clock cycle is one call to the uart_clock())
|
before a single character is transmitted or received. */
|
before a single character is transmitted or received. */
|
static unsigned long char_clks(int dll, int dlh, int lcr)
|
static unsigned long char_clks(int dll, int dlh, int lcr)
|
{
|
{
|
float bauds_per_char = 1.;
|
unsigned int bauds_per_char = 2;
|
unsigned long char_clks = ((dlh << 8) + dll);
|
unsigned long char_clks = ((dlh << 8) + dll);
|
|
|
if (lcr & UART_LCR_PARITY)
|
if (lcr & UART_LCR_PARITY)
|
bauds_per_char = bauds_per_char + 1.;
|
bauds_per_char += 2;
|
|
|
/* stop bits 1 or two */
|
/* stop bits 1 or two */
|
if (lcr & UART_LCR_STOP)
|
if (lcr & UART_LCR_STOP)
|
bauds_per_char = bauds_per_char + 2.;
|
bauds_per_char += 4;
|
else
|
else
|
if ((lcr & 0x3) != 0)
|
if ((lcr & 0x3) != 0)
|
bauds_per_char = bauds_per_char + 1.;
|
bauds_per_char += 2;
|
else
|
else
|
bauds_per_char = bauds_per_char + 1.5;
|
bauds_per_char += 3;
|
|
|
bauds_per_char = bauds_per_char + (5. + (lcr & 0x3));
|
bauds_per_char += 10 + ((lcr & 0x3) << 1);
|
|
|
return char_clks * bauds_per_char;
|
return (char_clks * bauds_per_char) >> 1;
|
}
|
}
|
|
|
/* Set a specific UART register with value. */
|
/* Set a specific UART register with value. */
|
void uart_write_byte(oraddr_t addr, uint32_t value, void *dat)
|
void uart_write_byte(oraddr_t addr, uint32_t value, void *dat)
|
{
|
{
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.