-
Notifications
You must be signed in to change notification settings - Fork 514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPI Slave implementation for Photon and Electron (STM32F2) #882
Conversation
@@ -84,6 +91,9 @@ void HAL_SPI_DMA_Transfer(HAL_SPI_Interface spi, void* tx_buffer, void* rx_buffe | |||
bool HAL_SPI_Is_Enabled_Old(); | |||
bool HAL_SPI_Is_Enabled(HAL_SPI_Interface spi); | |||
void HAL_SPI_Info(HAL_SPI_Interface spi, hal_spi_info_t* info, void* reserved); | |||
void HAL_SPI_Set_Callback_On_Select(HAL_SPI_Interface spi, HAL_SPI_Select_UserCallback cb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add void* as a reserved parameter to these so we can extend later.
Could you please rebase on develop and resolve the conflicts. |
@m-mcgowan Done! |
SPI Slave implementation for Photon and Electron (STM32F2)
Hello. My naive attempts at using the Photon SPI as a slave seem to stall after the first transfer. I see in the wiring tests I ought to be able to learn from that example. Using this invocation:
My "USE_SPI=SPI USE_CS=A2 " didn't go where they should because it fails:
When I just edit the two test programs to force in the defines: #ifndef USE_SPI #ifndef USE_CS The sources compile without error - but the link phase fails with a multiple define problem: It should not matter, but I am using SuSE LEAP and my make is If anyone can help me get this test running I would be happy to add a setup readme to the directory. I THINK this ought to be a very useful example as there seems to be more than enough confusion about using the Photo in slave mode. Thanks. |
Implements #814 on Photon and Electron
Wiring SPI API changes:
void SPIClass::begin(SPI_Mode mode, uint16_t);
void SPIClass::onSelect(wiring_spi_select_callback_t user_callback);
void SPIClass::transferCancel();
int32_t SPIClass::available();
Basic usage example:
https://gist.github.com/avtolstoy/1bbd34a7e69f563d5d37
There are also two test applications in
user/tests/wiring/spi_master_slave
spi_master
andspi_slave
that showcase usage.A couple of notes:
transfer()
can be safely called before a Slave Select event occurstransfer()
can be safely provided with larger buffer size (transfer length). When Master deselects the Slave or application callstransferCancel()
SPI peripheral will be disabled, transfer user callback will still be called to indicate end of DMA transfer, application can then check the actual transfer length by callingSPIClass::available()
SPIClass::available()
, which will report actual number of bytes clocked in/out.byte SPIClass::transfer(byte)
is not supported in Slave mode