SmartRC-CC1101-Driver-Lib icon indicating copy to clipboard operation
SmartRC-CC1101-Driver-Lib copied to clipboard

Hability to share SPI with TFT and Other devices

Open bmorcelli opened this issue 1 year ago • 0 comments

The original state of this library doens't allow us to share the SPI bus with other devices, such as TFT and SD Card.

I am working on Bruce Firmware, and wanted to use this library to control a CC1101 and faced this issue, so I found a way to solve this problem and make the lib work on devices such as M5Cardputer (sharing SPI bus with SD Card using a SdCard Sniffer) and finally with Lyligo T-Embed CC1101 (CC1101 is mounted sharing the bus with Display and SD Card)

The changes I've made are:

  • Created a SPIClass instance for the library, for better control of the bus,
  • Added a function called setSPIinstance(SPIClass sspi)*, where you can specify which SPI class to use when sharing the SPI bus (This instance must have been initialized before using init() function)
  • Added a function called getSPIinstance(), if ou want to specify the other device to use the CC1101 instance after starting CC1101 (in this case is good to turn off a logic called BeginEndLogic.
  • If no Instance was specified, the Init function will point to the SPIClass of the library, and using the SPI.begin(..) and SPI.end() Logic that is used atm.
  • this logic can be activated and deactivated using setBeginEndLogic(bool), and the state of this logic using getBeginEndLogic();

Thank you for this lib, I hope my contribuitions can make the difference in your projects.

bmorcelli avatar Nov 07 '24 11:11 bmorcelli