Skip to content

Commit 490afe0

Browse files
fixup! feat: add the STM32WL SUBGHZSPI to the SPI library
1 parent 4804d2e commit 490afe0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

libraries/SPI/src/SPI.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ class SUBGHZSPIClass : public SPIClass {
319319
void transfer(uint8_t pin, void *_buf, size_t _count, SPITransferMode _mode = SPI_LAST);
320320
void transfer(byte _pin, void *_bufout, void *_bufin, size_t _count, SPITransferMode _mode = SPI_LAST);
321321
void enableDebugPins(uint32_t mosi = DEBUG_SUBGHZSPI_MOSI, uint32_t miso = DEBUG_SUBGHZSPI_MISO, uint32_t sclk = DEBUG_SUBGHZSPI_SCLK, uint32_t ssel = DEBUG_SUBGHZSPI_SS);
322+
323+
using SPIClass::beginTransaction;
324+
using SPIClass::transfer;
325+
using SPIClass::transfer16;
322326
};
323327

324328
#endif

libraries/SPI/src/utility/spi_com.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)
238238
uint32_t pull = 0;
239239

240240
#if defined(SUBGHZSPI_BASE)
241-
if (handle->Instance != SUBGHZSPI) {
241+
if (obj->spi != SUBGHZSPI) {
242242
#endif
243243
// Determine the SPI to use
244244
SPI_TypeDef *spi_mosi = pinmap_peripheral(obj->pin_mosi, PinMap_SPI_MOSI);
@@ -262,19 +262,22 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)
262262
core_debug("ERROR: SPI pins mismatch\n");
263263
return;
264264
}
265-
266-
// Configure the SPI pins
267-
if (obj->pin_ssel != NC) {
268-
handle->Init.NSS = SPI_NSS_HARD_OUTPUT;
269-
} else {
270-
handle->Init.NSS = SPI_NSS_SOFT;
271-
}
272265
#if defined(SUBGHZSPI_BASE)
273266
} else {
274-
handle->Init.NSS = SPI_NSS_SOFT;
267+
if (obj->pin_mosi != NC || obj->pin_miso != NC || obj->pin_sclk != NC || obj->pin_ssel != NC) {
268+
core_debug("ERROR: SUBGHZ_SPI cannot define custom pins\n");
269+
return;
270+
}
275271
}
276272
#endif
277273

274+
// Configure the SPI pins
275+
if (obj->pin_ssel != NC) {
276+
handle->Init.NSS = SPI_NSS_HARD_OUTPUT;
277+
} else {
278+
handle->Init.NSS = SPI_NSS_SOFT;
279+
}
280+
278281
/* Fill default value */
279282
handle->Instance = obj->spi;
280283
handle->Init.Mode = SPI_MODE_MASTER;

0 commit comments

Comments
 (0)