mirror of
https://github.com/olofk/serv.git
synced 2025-04-20 03:47:09 -04:00
Ignore initial garbage in verilator UART decoder
This commit is contained in:
parent
574464a33b
commit
57b4fca05f
1 changed files with 8 additions and 4 deletions
|
@ -47,22 +47,26 @@ void uart_init(uart_context_t *context, uint32_t baud_rate) {
|
|||
|
||||
void do_uart(uart_context_t *context, bool rx) {
|
||||
if (context->state == 0) {
|
||||
if (rx)
|
||||
context->state++;
|
||||
}
|
||||
else if (context->state == 1) {
|
||||
if (!rx) {
|
||||
context->last_update = main_time + context->baud_t/2;
|
||||
context->state++;
|
||||
}
|
||||
}
|
||||
else if(context->state == 1) {
|
||||
else if(context->state == 2) {
|
||||
if (main_time > context->last_update) {
|
||||
context->last_update += context->baud_t;
|
||||
context->ch = 0;
|
||||
context->state++;
|
||||
}
|
||||
}
|
||||
else if (context->state < 10) {
|
||||
else if (context->state < 11) {
|
||||
if (main_time > context->last_update) {
|
||||
context->last_update += context->baud_t;
|
||||
context->ch |= rx << (context->state-2);
|
||||
context->ch |= rx << (context->state-3);
|
||||
context->state++;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +74,7 @@ void do_uart(uart_context_t *context, bool rx) {
|
|||
if (main_time > context->last_update) {
|
||||
context->last_update += context->baud_t;
|
||||
putchar(context->ch);
|
||||
context->state=0;
|
||||
context->state=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue