@@ -318,18 +318,23 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)
318
318
handle -> Init .MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_ENABLE ; /* Recommended setting to avoid glitches */
319
319
#endif
320
320
321
- /* Configure SPI GPIO pins */
322
- pinmap_pinout (obj -> pin_mosi , PinMap_SPI_MOSI );
323
- pinmap_pinout (obj -> pin_miso , PinMap_SPI_MISO );
324
- pinmap_pinout (obj -> pin_sclk , PinMap_SPI_SCLK );
325
- /*
326
- * According the STM32 Datasheet for SPI peripheral we need to PULLDOWN
327
- * or PULLUP the SCK pin according the polarity used.
328
- */
329
- pull = (handle -> Init .CLKPolarity == SPI_POLARITY_LOW ) ? GPIO_PULLDOWN : GPIO_PULLUP ;
330
- pin_PullConfig (get_GPIO_Port (STM_PORT (obj -> pin_sclk )), STM_LL_GPIO_PIN (obj -> pin_sclk ), pull );
331
- pinmap_pinout (obj -> pin_ssel , PinMap_SPI_SSEL );
332
-
321
+ #if defined(SUBGHZSPI_BASE )
322
+ if ((handle -> Instance != SUBGHZSPI ) || (obj -> subghzspi_dbg )) {
323
+ #endif
324
+ /* Configure SPI GPIO pins */
325
+ pinmap_pinout (obj -> pin_mosi , PinMap_SPI_MOSI );
326
+ pinmap_pinout (obj -> pin_miso , PinMap_SPI_MISO );
327
+ pinmap_pinout (obj -> pin_sclk , PinMap_SPI_SCLK );
328
+ /*
329
+ * According the STM32 Datasheet for SPI peripheral we need to PULLDOWN
330
+ * or PULLUP the SCK pin according the polarity used.
331
+ */
332
+ pull = (handle -> Init .CLKPolarity == SPI_POLARITY_LOW ) ? GPIO_PULLDOWN : GPIO_PULLUP ;
333
+ pin_PullConfig (get_GPIO_Port (STM_PORT (obj -> pin_sclk )), STM_LL_GPIO_PIN (obj -> pin_sclk ), pull );
334
+ pinmap_pinout (obj -> pin_ssel , PinMap_SPI_SSEL );
335
+ #if defined(SUBGHZSPI_BASE )
336
+ }
337
+ #endif
333
338
#if defined SPI1_BASE
334
339
// Enable SPI clock
335
340
if (handle -> Instance == SPI1 ) {
@@ -379,6 +384,14 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)
379
384
}
380
385
#endif
381
386
387
+ #if defined SUBGHZSPI_BASE
388
+ if (handle -> Instance == SUBGHZSPI ) {
389
+ __HAL_RCC_SUBGHZSPI_CLK_ENABLE ();
390
+ __HAL_RCC_SUBGHZSPI_FORCE_RESET ();
391
+ __HAL_RCC_SUBGHZSPI_RELEASE_RESET ();
392
+ }
393
+ #endif
394
+
382
395
HAL_SPI_Init (handle );
383
396
384
397
/* In order to set correctly the SPI polarity we need to enable the peripheral */
@@ -448,6 +461,14 @@ void spi_deinit(spi_t *obj)
448
461
__HAL_RCC_SPI6_CLK_DISABLE ();
449
462
}
450
463
#endif
464
+
465
+ #if defined SUBGHZSPI_BASE
466
+ if (handle -> Instance == SUBGHZSPI ) {
467
+ __HAL_RCC_SUBGHZSPI_FORCE_RESET ();
468
+ __HAL_RCC_SUBGHZSPI_RELEASE_RESET ();
469
+ __HAL_RCC_SUBGHZSPI_CLK_DISABLE ();
470
+ }
471
+ #endif
451
472
}
452
473
453
474
/**
0 commit comments