_iob
objects are groups of one or more consecutive pins inside the same port.
Relatives
port
: the GPIO port the I/O pertains to.
Interface
HW_ADDRESS()
returns an address for an I/O definition, computed as:
address_of_port + (number_of_bits-1)*16 + position_of_lsb
Ports are mapped every 0x0400 bytes in memory.
#if HW_ADDRESS(LED) == HW_ADDRESS((porta,9))
#else
#endif
HW_BITS()
returns the number of bits of an I/O definition:
#if (HW_ADDRESS((porta,3)) != -1) && (HW_BITS((porta,3)) != 1)
# error HWA is damaged!
#endif
HW_POSITION()
returns the position of the least significant bit:
#if (HW_ADDRESS((porta,3)) != -1) && (HW_POSITION((porta,3)) != 3)
# HWA is damaged!
#endif
hw|
hwa( configure, (porta,0),
[ function, gpio, ]
mode, digital_input | digital_input_floating
| digital_input_pullup
| digital_input_pulldown
| analog_input
| digital_output | digital_output_pushpull
| digital_output_opendrain,
[ frequency, low | lowest
| medium
| fast
| high | highest ] );
uint8_t value =
hw( read, (porta,0) );
Toggles one or several consecutive pins at once.
- Note
toggle
is not atomic: it reads the ODR, then sets/resets the relevant bits through the BSRR. The ODR is not written directly.
hwa( toggle, (porta,0) );
hwa( toggle, (porta,4) );
hw|
hwa( write, (porta,0), 0 );
- Note
- HWA does not write the ODR of the port. It writes the BSRR so that atomicity is guaranted and concurrent tasks can write different pins of the port without conflict.