Merge pull request #5565 from LMESTM/fix_slave_3wires

STM32: SPI 3 wires mode not supported in SPI slave
pull/5586/merge
Martin Kojtal 2017-11-30 18:11:16 +00:00 committed by GitHub
commit 45e9e4cab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -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);
}