RA8875 SPI TFT

PHOTO EMBED

Fri Jul 15 2022 18:32:21 GMT+0000 (Coordinated Universal Time)

Saved by @jon_robinson_72

----------------------------------------------------------------------------------*/
/*
From here it's better don't touch anithing, everithing has been tuned for maximum speed.
Only DUE or any AVR 8bit (like uno) can have some troubles with particular old libraries
because the use of fast port handle, in that case....
On Arduino DUE and other 8 bit Arduino MCU you can disable the fast CS port 
by commenting #define _FASTSSPORT, this will force to use the classic digitalWrite.

*/
/* Accordly RA8875 datasheet the READ cycles and WRITE cycles have different speed:
System clock/3(only write cycle), System clock/6(with read cycle)
MAXSPISPEED parameters it's also related to MCU features so it probably need to be tuned.
Not all MCU are capable to work at those speeds. Following parameters worked with both board I have.
After som mail exchange with RAiO I solved the dilemma behind SPI speed limit:
The RA8875 has limitation of 12Mhz SPI but this has been set because not all internal macros
can run over that speed, the library automatically deal with this  so I was able to go over 20Mhz!
At that speed you need to short cables as much you can, provide clean supply and good decoupling!
DO NOT Exceed 23Mhz for RA8875! It will result in garbage on screen or run very slow.
*/

#if defined(SPI_HAS_TRANSACTION)
//SPI transaction enabled library----------------------
	const static uint32_t MAXSPIREADSPEED  = 6000000UL;  //Read don't go higher than 22000000!;
	#if defined(__MK20DX128__) || defined(__MK20DX256__)  || defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1062__)
		const static uint32_t MAXSPISPEED	= 18000000UL;  //don't go higher than 22000000!;
	#elif defined(__MKL26Z64__)							 //[Teensy LC] (12 or 24 Mhz max)
		const static uint32_t MAXSPISPEED	= 12000000UL;	 //default SPI main speed TeensyLC
		const static uint32_t MAXSPISPEED2	= 22000000UL;  //don't go higher than 22000000!;
	#elif defined(___DUESTUFF)							 //[DUE]
		const static uint32_t MAXSPISPEED	= 15000000UL;  // try experiment higher values but NOT over 22000000!
		//#define _FASTSSPORT
	#elif defined(ESP8266)	
		const static uint32_t MAXSPISPEED	= 8000000UL;  //don't go higher than 22000000!;
		//#define _FASTSSPORT
	#elif defined(SPARK)
		const static uint32_t MAXSPISPEED	= 8000000UL;  //don't go higher than 22000000!;
	// TODO: add more CPU here!
	#else												 //rest of the world (UNO, etc)
		const static uint32_t MAXSPISPEED	= 10000000UL;  //be careful, higher values result in extremely slow rendering!
		#define _FASTSSPORT
	#endif
#else
content_copyCOPY

https://forum.pjrc.com/threads/62797-RA8875-SPI-Teensy-4-0-can-I-get-a-little-speedup