GrumpyOldPizza / arduino-STM32L4

69 stars 60 forks source link

After SPI.end() it's not possible to re-enable SPI with SPI.begin() #21

Closed millerresearch closed 6 years ago

millerresearch commented 6 years ago

Short version: I think stm32l4_spi_disable() should set spi->state to SPI_STATE_INIT instead of SPI_STATE_NONE.

Long version: I've built a package which extends your arduino-STM32L4 platform to support the myStorm BlackIce, an open source board combining a STM32L433 with a Lattice ICE40 FPGA. Thanks to your wonderful work which has done all the heavy lifting for STM32L4, the myStorm package only needs to add a couple of board variant files, and a small library to assist with access to the FPGA.

On the BlackIce, the SPI pins used to configure circuit bitstreams into the FPGA are also multiplexed for other uses (eg driving a set of on-board LEDs). Therefore it would be useful to be able to call SPI.end(), reconfigure the SPI pins for GPIO, and then later call SPI.begin() to reclaim the pins for SPI use again. Unfortunately this doesn't work because stm32l4_spi_disable doesn't leave spi->state with the value stm32l4_spi_enable expects. With the change I've suggested above, it does work ... and this is consistent with some of the other drivers (eg i2c, uart) where the xxx_disable() routine leaves the device in INIT state.

GrumpyOldPizza commented 6 years ago

Sorry for the brief response. The fix for that got checked in last week.

On Oct 14, 2017 1:05 PM, "Richard Miller" notifications@github.com wrote:

Short version: I think stm32l4_spi_disable() should set spi->state to SPI_STATE_INIT instead of SPI_STATE_NONE.

Long version: I've built a package https://www.github.com/millerresearch/arduino-mystorm which extends your arduino-STM32L4 platform to support the myStorm BlackIce https://nanode0000.wordpress.com/2017/08/16/getting-started-with-mystorm-blackice/, an open source board combining a STM32L433 with a Lattice ICE40 FPGA. Thanks to your wonderful work which has done all the heavy lifting for STM32L4, the myStorm package only needs to add a couple of board variant files, and a small library to assist with access to the FPGA.

On the BlackIce, the SPI pins used to configure circuit bitstreams into the FPGA are also multiplexed for other uses (eg driving a set of on-board LEDs). Therefore it would be useful to be able to call SPI.end(), reconfigure the SPI pins for GPIO, and then later call SPI.begin() to reclaim the pins for SPI use again. Unfortunately this doesn't work because stm32l4_spi_disable doesn't leave spi->state with the value stm32l4_spi_enable expects. With the change I've suggested above, it does work ... and this is consistent with some of the other drivers (eg i2c, uart) where the xxx_disable() routine leaves the device in INIT state.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/GrumpyOldPizza/arduino-STM32L4/issues/21, or mute the thread https://github.com/notifications/unsubscribe-auth/AG4QfAuVYxUU9eQftz86IjsNncdLJJIdks5ssQYIgaJpZM4P5fg9 .

millerresearch commented 6 years ago

Thanks! I see now that I should check the github version to keep up to date, and not just rely on the Board Manager.