Skip to content

Commit 1647582

Browse files
committed
TARGET_STM: SPI: add pulse on master transmissions
Add a pulse when using hardware chip select for SPI transmissions. CS is at low level when a transmission is on-going. Be careful, this is not compatible with all modes. It will work only if PHA is 0, ie spi mode is 0 or 2. See stm32xx reference manual, chapter "NSS pulse mode" for more details. Fix #10671 Signed-off-by: Vincent Veron <[email protected]>
1 parent 19e7622 commit 1647582

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

targets/TARGET_STM/stm_spi_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,14 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
182182
if (ssel != NC) {
183183
pinmap_pinout(ssel, PinMap_SPI_SSEL);
184184
handle->Init.NSS = SPI_NSS_HARD_OUTPUT;
185+
#if defined(SPI_NSS_PULSE_ENABLE)
186+
handle->Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
187+
#endif
185188
} else {
186189
handle->Init.NSS = SPI_NSS_SOFT;
190+
#if defined(SPI_NSS_PULSE_DISABLE)
191+
handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
192+
#endif
187193
}
188194

189195
/* Fill default value */
@@ -206,7 +212,6 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
206212
handle->Init.TIMode = SPI_TIMODE_DISABLE;
207213

208214
#if TARGET_STM32H7
209-
handle->Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
210215
handle->Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_ENABLE;
211216
handle->Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
212217
#endif

0 commit comments

Comments
 (0)