_ioa
objects are groups of one or more consecutive pins inside the same GPIO 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 0x0400 bytes away 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
Actions
hw( configure, ... ) configures one set of consecutive pins in the same port assuming the gpio
function:
hw( 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, 2MHz | lowest
| 10MHz
| 50MHz | highest ]
);
hwa( configure, ... ) configures one set of consecutive pins in the same port, can set alternate function (remapping):
hwa( configure, (porta,0),
[ function, gpio
| (controller,...), ]
mode, digital_input | digital_input_floating
| digital_input_pullup
| digital_input_pulldown
| analog_input
| digital_output | digital_output_pushpull
| digital_output_opendrain,
[ frequency, 2MHz | lowest
| 10MHz
| 50MHz | highest ]
);
- Note
- You can not map one signal to multiple pins.
read
:
uint8_t value =
hw( read, (porta,0) );
write
:
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.
toggle
: 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) );