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, ]
[ mode, digital_input | digital_input_floating
| 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 );