diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-27 07:53:52 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-28 08:54:47 +0200 |
commit | 6732e9b7c0984f1095b186c3da241629530db6ef (patch) | |
tree | c4f49c70398852e3c67126ec13ccd0a7d23dd5ab | |
parent | a2f5c09aee34766d0a65f1a2f109db00337157e4 (diff) |
use new APBUART
-rw-r--r-- | bsps/include/grlib/apbuart.h | 2 | ||||
-rw-r--r-- | bsps/shared/grlib/uart/apbuart_polled.c | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/bsps/include/grlib/apbuart.h b/bsps/include/grlib/apbuart.h index 8eeb01f388..d2b7b12a41 100644 --- a/bsps/include/grlib/apbuart.h +++ b/bsps/include/grlib/apbuart.h @@ -61,7 +61,7 @@ extern "C" { #endif -/* Generated from spec:/dev/grlib/if/apbuart-inbyte-polled */ +/* Generated from spec:/dev/grlib/if/apbuart-inbyte-nonblocking */ /** * @ingroup RTEMSDeviceGRLIBAPBUART diff --git a/bsps/shared/grlib/uart/apbuart_polled.c b/bsps/shared/grlib/uart/apbuart_polled.c index 80213433bb..f877d00cb0 100644 --- a/bsps/shared/grlib/uart/apbuart_polled.c +++ b/bsps/shared/grlib/uart/apbuart_polled.c @@ -55,12 +55,18 @@ void apbuart_outbyte_polled( apbuart *regs, char ch) int apbuart_inbyte_nonblocking( apbuart *regs ) { + uint32_t status; + + status = grlib_load_32( ®s->status ); + /* Clear errors, writes to non-error flags are ignored */ - grlib_store_32( ®s->status, 0 ); + status &= ~( APBUART_STATUS_FE | APBUART_STATUS_PE | APBUART_STATUS_OV | + APBUART_STATUS_BR ); + grlib_store_32( ®s->status, status ); - if ( ( grlib_load_32( ®s->status ) & APBUART_STATUS_DR ) == 0 ) { + if ( ( status & APBUART_STATUS_DR ) == 0 ) { return -1; } - return (uint8_t) grlib_load_32( ®s->data ); + return (int) APBUART_DATA_DATA_GET( grlib_load_32( ®s->data ) ); } |