HWA
Bare metal programming with style

A HWA register object is a set of consecutive bits (1 or more). It can correspond to a hardware register or to one or two subsets of one or two hardware registers.

A register object is accessed through the object it pertains to, using the path notation: (object, register).

Register objects give access to subsets of their content using the path notation:

HW_ADDRESS() gives the address of a register object if it corresponds to a single hardware register:

addr = HW_ADDRESS( (counter0,cs) )

HW_POSITION() gives the position of the least significant bit in the corresponding hardware register:

addr = HW_POSITION( (counter0,cs) )

HW_BITS() gives the number of bits of a register:

addr = HW_BITS( (counter0,cs) )

Interface

Operations on registers can use the hw(...) instruction to act immediatly, or the transactional machanism with hwa(...).

// Read register `wgm` of `counter0`:
//
uint8_t x = hw( read, (counter0,wgm) );
// Store bits 7 & 6 of register `pin` of `porta`
// in bits 1 & 0 of `x`:
//
uint8_t x = hw( read, (porta,pin,2,6) );
// write register `wgm` of `counter0`:
//
hw( write, (counter0,wgm), 2 );
// Set bits 5 & 4, and reset bits 3 & 2 of
// register `ddr` of `porta`:
//
hw( write, (porta,ddr,4,2), 0x0C );
// Toggle bit 1 of register `port` of `porta`:
//
hw( toggle, (porta,port,1) );
HW_BITS
#define HW_BITS(...)
Definition: hwa_1.h:500
HW_POSITION
#define HW_POSITION(...)
Returns the position of the least significant bit of an object.
Definition: hwa_1.h:557
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523
HW_ADDRESS
#define HW_ADDRESS(...)
Returns the address of an object or -1 if the object does not exist.
Definition: hwa_1.h:454