@Frank - SPISettings and SPI.beginTransaction() - The other option would be to move the functionality around. That is don't have all of the stuff to compute ccr and tcr in that code...
But instead if necessary compute it within the beginTransaction...
I did this sort of quick and dirty within my FlexIO SPI implementation:
The whole implementation of the SPISettings:
Code:
class FlexSPISettings {
public:
FlexSPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) : _clock(clock),
_bitOrder(bitOrder), _dataMode(dataMode) {};
uint32_t _clock;
uint8_t _bitOrder;
uint8_t _dataMode;
};
And the FlexSPI::beginTransaction has code that does stuff like:
Code:
void FlexSPI::beginTransaction(FlexSPISettings settings) {
#ifdef SPI_TRANSACTION_MISMATCH_LED
if (inTransactionFlag) {
pinMode(SPI_TRANSACTION_MISMATCH_LED, OUTPUT);
digitalWrite(SPI_TRANSACTION_MISMATCH_LED, HIGH);
}
_in_transaction_flag = 1;
#endif
// right now pretty stupid
if ((settings._clock != _clock) || (settings._dataMode != _dataMode )) {
_clock = settings._clock;
_dataMode = settings._dataMode;
uint32_t clock_speed = _pflex->computeClockRate() / 2; // get speed divide by
uint32_t div = clock_speed / _clock;
...
Potentially the above could be cleaned up by adding some public functions like
inline uint32_t clock() {return _clock;} ...
Just an idea. wondering what you all think? I personally think it will probably reduce code size and probably speed up the T4 SPI by a hair...
Edit: And if we did something like that, could share the SPISettings with the Flex IO SPI code.
Edit2: I did a quick and dirty version of this...
Looks like it actually grows the code some putting all of the stuff into beginTransaction... I would probably move some/all of this into spi.cpp...
But speed wise, I ran our hacked up version of ili9341_t3n graphic test program (requires updated code to run on T4).
Without changes:
Code:
ILI9341 Test!
Display Power Mode: 0x80
MADCTL Mode: 0x80
Pixel Format: 0x87
Image Format: 0x7
Self Diagnostic: 0x87
Benchmark Time (microseconds)
Screen fill 245388
Text 12923
Lines 85415
Horiz/Vert Lines 21411
Rectangles (outline) 13747
Rectangles (filled) 504228
Circles (filled) 84719
Circles (outline) 72371
Triangles (outline) 20134
Triangles (filled) 180512
Rounded rects (outline) 31275
Rounded rects (filled) 562301
Done!
With changes:
Code:
ILI9341 Test!
Display Power Mode: 0x80
MADCTL Mode: 0x80
Pixel Format: 0x87
Image Format: 0x87
Self Diagnostic: 0x87
Benchmark Time (microseconds)
Screen fill 245230
Text 12653
Lines 85456
Horiz/Vert Lines 21388
Rectangles (outline) 13737
Rectangles (filled) 503832
Circles (filled) 83910
Circles (outline) 71028
Triangles (outline) 20075
Triangles (filled) 179844
Rounded rects (outline) 30850
Rounded rects (filled) 561661
Done!
Again only sped up a touch... Is it worth it?