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

A class _ioa 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_BITS((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_ADDRESS((porta,3)) != -1) && (HW_POSITION((porta,3)) != 3)
# HWA is damaged!
#endif

Configuration

Actions

configure:

hw | hwa( configure, gpio0,
[ function, gpio, ] // Default
[ mode, digital_input | digital_input_floating // Default
| digital_input_pullup
| digital_input_pullup_when_awake
| digital_input_pullup_when_sleeping
| digital_output | digital_output_pushpull
| digital_output_when_awake | digital_output_pushpull_when_awake
| digital_output_when_sleeping | digital_output_pushpull_when_sleeping
| analog_input,
[ pullup, off
| when_awake
| when_sleeping
| on, ] );


// ALTERNATE_FUNCTION is a signal name, such as 'int0' or '(uart0,tx)'.
//
hw | hwa( configure, (porta,0),
function, ALTERNATE_FUNCTION );


State

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

uint8_t value = hw( read, gpio0 );

write:

hw( write, gpio0, value );


hwa( write, gpio0, value );


toggle:

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