HWA
Bare metal programming with style
Class _uarta: Universal Asynchronous serial Receiver Transmitter

This class is used by:

Note
Synchronous mode of USART is not implemented.

Actions


configure:

hwa( configure, uart0,
// Transfer rate in bits per second
//
[ bps, BPS, ]
// Number of data bits in frame. Default is `8`.
//
[ databits, 5 | 6 | 7 | 8 | 9, ]
// Parity. Default is `none`.
//
[ parity, none, even, odd, ]
// Number of stop bits in frame. Default is `1`.
//
[ stopbits, 1 | 2, ]
// Whether the UART can receive. Default is `enabled`.
//
[ receiver, enabled | disabled, ]
// Whether the UART can transmit. Default is `enabled`.
//
[ transmitter, enabled | disabled, ] );

Data

The read returns the content of the data register but it does not verify that the transmit buffer of the UART is not empty before reading it. You may have to verify that a character has been received before reading the data register:

while ( ! hw( read, (uart0,irq, rxc ) ) ) {}
uint8_t byte = hw( read, uart0 );

The hw_write() instruction writes a character into the data registerbut it does not verify that the transmit buffer of the UART is not full before writing into it. You may have to verify this first:

while ( ! hw( read, (uart0,irq, txqnf ) ) ) {}
hw( write, uart0, '#' );

Status

The UART status contains the following flags:

uint8_t byte ;
hw_stat_t( uart0 ) st ; // Structure of UART status
st = hw( stat, uart0 ); // Read the status
if ( st.rxc ) // Reception complete?
byte = hw( read, uart0 );


hwa
#define hwa(...)
hwa( action, object [,...] ) stores an action for an object into a HWA context.
Definition: hwa_macros.h:552
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
hw_stat_t
#define hw_stat_t(object)
Declares the appropriate structure that holds the status of an object.
Definition: hwa_macros.h:711