-
-
Notifications
You must be signed in to change notification settings - Fork 429
Marlin SPI Review
Marlin born with a few peripheral using SPI. But now, we have a lot of concurrent devices sharing SPI.
For one SPI peripheral work, it needs prepare the spi device with ALL this parameters, before each spi usage:
- SPI device
- Speed
- Bit Order
- Data Mode
A lot of current Marlin code rely upon HAL to configure the SPI. But it leads to a problem: the current HAL code only handles ONE spi device at time. So, the client code must ensure that the SPI is properly configure before the use.
This review try to search for every spi usage to check if it's doing all the SPI setup before the use.
uses spiXXXX functions available in HAL call spiInit before use the spi
!!! rely on the spiInit to configure ALL spi paramenters for SD !!!
uses spiXXXX functions available in HAL call spiBegin+spiInit ONLY ONCE in the init of the code
!!! don't call any begin or init to send/recv data !!!
uses spiXXXX functions available in HAL call spiBegin+spiInit before use the spi
!!! rely on the spiInit to configure ALL spi paramenters !!!
rely on the spiInit to configure the correct spi paramenters (media player)
use global SPI object. Have its own SPISettings instance and use beginTransaction. (good)
!!! rely on global SPI object to select the correct spi device !!!
uses spiXXXX functions available in HAL call spiBegin+spiInit ONLY ONCE in the init of the LCD setup
!!! don't call any begin or init to send data to LCD !!!
As a lot of code rely upon spiInit function, here is the status of that function in each HAL.
!!! Note: the current spiXXXX functions ONLY works with ONE spi device !!!
spiInit function configure ALL spi parameters to the HAL default.
!!! problem: spiXXXX functions alter the SPI global object