Commit 17cf18b
committed
T4.x - Software SPI - don't use FAST_PINIO
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...1 parent 4ca0493 commit 17cf18b
1 file changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
43 | 55 | | |
44 | 56 | | |
45 | 57 | | |
| |||
0 commit comments