mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #5565 from LMESTM/fix_slave_3wires
STM32: SPI 3 wires mode not supported in SPI slavepull/5586/merge
commit
45e9e4cab3
|
|
@ -29,6 +29,7 @@
|
|||
*/
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "mbed_debug.h"
|
||||
#include "spi_api.h"
|
||||
|
||||
#if DEVICE_SPI
|
||||
|
|
@ -286,6 +287,16 @@ void spi_format(spi_t *obj, int bits, int mode, int slave)
|
|||
|
||||
handle->Init.Mode = (slave) ? SPI_MODE_SLAVE : SPI_MODE_MASTER;
|
||||
|
||||
if (slave && (handle->Init.Direction == SPI_DIRECTION_1LINE)) {
|
||||
/* SPI slave implemtation in MBED does not support the 3 wires SPI.
|
||||
* (e.g. when MISO is not connected). So we're forcing slave in
|
||||
* 2LINES mode. As MISO is not connected, slave will only read
|
||||
* from master, and cannot write to it. Inform user.
|
||||
*/
|
||||
debug("3 wires SPI slave not supported - slave will only read\r\n");
|
||||
handle->Init.Direction = SPI_DIRECTION_2LINES;
|
||||
}
|
||||
|
||||
init_spi(obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue