HWA
Bare metal programming with style
Class _usarta: Universal Synchronous Asynchronous Receiver Transmitter

_usarta objects are universal synchronous asynchronous receivers transmitters.

_usarta objects support several modes:

Actions

configure:

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

Counter used as encoder:

hw | hwa ( configure, encoder(counter2),
);

read:

uint16_t v = hw( read, usart1 );

Interrupts

hw | hwa ( turn, (systick,irq), on | off );


if ( hw( read, (systick,irq) ) // Reading the flag clears it
hw(toggle,LED);


Registers

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
LED
#define LED
X.
Definition: bluepill.h:55