-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
Current OutputPort::write() code:
void write(port_data_t value) {
atomic {
// read-modify-write cycle
port_data_t v = port::port_output_read();
port_data_t shifted = value << start_bit;
v |= shifted & mask;
v &= (shifted | ~mask);
port::port_output_write(v);
}
}
On chips that have an output toggle feature, this can probably be sped up significantly using the clever XOR-based trick that I first saw in the RPi Pico SDK (https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/hardware_gpio/include/hardware/gpio.h#L719 )
the new code would not need "atomic", and would look something like:
void write(port_data_t value) {
port_data_t v = port::port_output_read();
port_data_t shifted = value << start_bit;
v ^= shifted;
port::port_output_toggle(v & mask);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels