The original problem was that the code defined the registers and mask as 8 bits, when the T4.x ones are 32 bits. So it only worked on a subset of pins.
So first fix would be to simply define these values as 32 bits. But doing so leaves you code at risk as the Set/Clear code in this library is not atomic,
Example: *clkPort |= clkPinMask;
So if something happens in the small time window after the time the register is retrieved and then manipulated and written back, such as an interrupt.
Or maybe if other hardware is driving the pin. These changes would be
clobbered by the above code.
Not sure how many other boards (if any) may be hit by the same issue.
It is not an issue with T3.x as the Teensy code uses the M3/M4 bitband support, so for each pin there is a unique memory address for it and these operations are atomic.
Note: the Arm M7 does not support bitbands. However in these caseAtomic code can be written for the T4.x by instead using the DR register of the IO port, you use the DR_SET, DR_CLEAR, DR_TOGGLE registers instead which do as the names imply
the do that operation only those pins who have a 1 bit set to the value...
These two methods are similar to beginTransaction() and endTransaction(),
but, as the name implies, with CS management. They are both public, as
beginTransaction() and endTransaction() are too.
The functions fast pin-I/O uses are currently missing, so don't define BUSIO_USE_FAST_PINIO. Also, we need typedef for BitOrder, but it refuses to compile without also including Arduino.h, at least under PlatformIO.
Testing for the define from build.board is not a good test (I recently updated them to refer to the specific part, instead of just the number of pins, for example) - instead, test for the MEGATINYCORE define, which is defined by Arduino.h and will always be there , and will be for all future versions of megaTinyCore. Also added a test for DxCore, which supports the new AVR Dx-series parts, and does SPI bit order in the same way. I confirmed that the examples now compile again on megaTinyCore with this change - and now compile for DxCore as well
As many (all?) ARM Cortex based chips, Infineon xmc boards also need
this quirk for BusIO to compile.
Original commit: 4921ca2cea ("Update Adafruit_SPIDevice.h")
XMC for arduino: https://github.com/Infineon/XMC-for-Arduino