mmarchetti / DirectIO

Fast, simple I/O library for Arduino
GNU Lesser General Public License v3.0
116 stars 27 forks source link

Use PINx to toggle pins. #27

Open timower opened 4 years ago

timower commented 4 years ago

Currently DirectIO uses a read, flip, write sequence to toggle output pins. This can be done faster by using the PINx registers (on some targets?). See section 14.2.2 of the ATMega328 manual:

14.2.2 Toggling the Pin Writing a logic one to PINxn toggles the value of PORTxn, independent on the value of DDRxn. Note that the SBI instruction can be used to toggle one single bit in a port.

WestfW commented 1 year ago

Toggle capability is also present in SAM and SAMD