mirror of https://github.com/ARMmbed/mbed-os.git
STM32: SPI: Do not enable SPI during Init if 3W
Enabling SPI causes the clock to be output by default. Most devices will not care about extra clock cycles, especially as long as chip select is not active, nevertheless this may cause side issues with other devices especially during init phase. This was actually the case with a 3 wire device (LPS22HB sensor).pull/4975/head
parent
4f20cfc0be
commit
57371ea591
|
@ -75,7 +75,14 @@ void init_spi(spi_t *obj)
|
|||
error("Cannot initialize SPI");
|
||||
}
|
||||
|
||||
__HAL_SPI_ENABLE(handle);
|
||||
/* In case of standard 4 wires SPI,PI can be kept enabled all time
|
||||
* and SCK will only be generated during the write operations. But in case
|
||||
* of 3 wires, it should be only enabled during rd/wr unitary operations,
|
||||
* which is handled inside STM32 HAL layer.
|
||||
*/
|
||||
if (handle->Init.Direction == SPI_DIRECTION_2LINES) {
|
||||
__HAL_SPI_ENABLE(handle);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel)
|
||||
|
|
Loading…
Reference in New Issue