HWA
Bare metal programming with style
Class _iob: General Purpose I/O definition

A class _iob object is a single or a group of consecutive pins inside the same I/O port.

Instructions that do not produce C code:

The HW_BN() instruction returns the number of bits of an I/O definition:

#if (HW_ADDRESS((porta,3)) != -1) && (HW_BN((porta,3)) != 1)
# HWA is damaged!
#endif

For a group of consecutive pins, the hw_bp() instruction gives the position of the least significant bit:

#if hw_id((porta,3)) && (hw_bp((porta,3)) != 3)
# HWA is damaged!
#endif

Configuration

configure:

hw | hwa( configure, gpio16,
[ function, gpio, ] // Default
[ mode, digital_input | digital_input_floating // Default
| digital_input_pulldown
| digital_input_pulldown_when_awake
| digital_output | digital_output_pushpull
[ pulldown off
| when_awake
| on, ] );

State

The instruction read returns the state of the I/O object:

uint8_t value = hw( read, gpio0 );

The instruction hw_write() changes the state of the I/O object:

hw( write, gpio0, value );
hwa( write, gpio0, value );
hw( toggle, gpio0 ); // Toggle one or several consecutive pins at once


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