Skip to content

add the STM32WL SUGGHZSPI to the SPI library #1803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cores/arduino/stm32/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ typedef enum {
PZ_13 = (PortZ << 4) + 0x0D,
PZ_14 = (PortZ << 4) + 0x0E,
PZ_15 = (PortZ << 4) + 0x0F,
#endif
#if defined SUBGHZSPI_BASE
SUBGHZSPI_MOSI = (PortSUBGHZSPI << 4) + 0x00,
SUBGHZSPI_MISO = (PortSUBGHZSPI << 4) + 0x01,
SUBGHZSPI_SCLK = (PortSUBGHZSPI << 4) + 0x02,
#endif
// Specific pin name
PADC_BASE = PNAME_ANALOG_INTERNAL_BASE,
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/stm32/PortNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ typedef enum {
#endif
#if defined GPIOZ_BASE
PortZ,
#endif
#if defined SUBGHZSPI_BASE
PortSUBGHZSPI,
#endif
PortEND,
LastPort = PortEND - 1
Expand Down
16 changes: 16 additions & 0 deletions libraries/SPI/src/utility/spi_com.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ void spi_init(spi_t *obj, uint32_t speed, spi_mode_e mode, uint8_t msb)
}
#endif

#if defined SUBGHZSPI_BASE
if (handle->Instance == SUBGHZSPI) {
__HAL_RCC_SUBGHZSPI_CLK_ENABLE();
__HAL_RCC_SUBGHZSPI_FORCE_RESET();
__HAL_RCC_SUBGHZSPI_RELEASE_RESET();
}
#endif

HAL_SPI_Init(handle);

/* In order to set correctly the SPI polarity we need to enable the peripheral */
Expand Down Expand Up @@ -448,6 +456,14 @@ void spi_deinit(spi_t *obj)
__HAL_RCC_SPI6_CLK_DISABLE();
}
#endif

#if defined SUBGHZSPI_BASE
if (handle->Instance == SUBGHZSPI) {
__HAL_RCC_SUBGHZSPI_FORCE_RESET();
__HAL_RCC_SUBGHZSPI_RELEASE_RESET();
__HAL_RCC_SUBGHZSPI_CLK_DISABLE();
}
#endif
}

/**
Expand Down
3 changes: 3 additions & 0 deletions libraries/SrcWrapper/src/stm32/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ void pin_function(PinName pin, int function)
uint32_t ll_pin = STM_LL_GPIO_PIN(pin);
uint32_t ll_mode = 0;

/* if pin doesn't need configuring, skip it */
if (function < 0) return;

if (pin == (PinName)NC) {
Error_Handler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ WEAK const PinMap PinMap_SPI_MOSI[] = {
{PA_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{SUBGHZSPI_MOSI, SUBGHZSPI, -1},
{NC, NP, 0}
};
#endif
Expand All @@ -169,6 +170,7 @@ WEAK const PinMap PinMap_SPI_MISO[] = {
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{SUBGHZSPI_MISO, SUBGHZSPI, -1},
{NC, NP, 0}
};
#endif
Expand All @@ -180,6 +182,7 @@ WEAK const PinMap PinMap_SPI_SCLK[] = {
{PA_8, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{SUBGHZSPI_SCLK, SUBGHZSPI, -1},
{NC, NP, 0}
};
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ const PinName digitalPin[] = {
PC_13, // D25
PC_14, // D26
PC_15, // D27
PH_3 // D28
PH_3, // D28
SUBGHZSPI_MOSI,
SUBGHZSPI_MISO,
SUBGHZSPI_SCLK
};

// Analog (Ax) pin number array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
#define PC14 26
#define PC15 27
#define PH3 28
#define PINSUBGHZSPIMOSI 29
#define PINSUBGHZSPIMISO 30
#define PINSUBGHZSPISCK 31

// Alternate pins number
#define PA1_ALT1 (PA1 | ALT1)
Expand All @@ -52,7 +55,7 @@
#define PA7_ALT1 (PA7 | ALT1)
#define PB8_ALT1 (PB8 | ALT1)

#define NUM_DIGITAL_PINS 29
#define NUM_DIGITAL_PINS 32
#define NUM_ANALOG_INPUTS 9

// On-board LED pin number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ WEAK const PinMap PinMap_SPI_MOSI[] = {
{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_SPI2)},
{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{SUBGHZSPI_MOSI, SUBGHZSPI, -1},
{NC, NP, 0}
};
#endif
Expand All @@ -198,6 +199,7 @@ WEAK const PinMap PinMap_SPI_MISO[] = {
{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{SUBGHZSPI_MISO, SUBGHZSPI, -1},
{NC, NP, 0}
};
#endif
Expand All @@ -211,6 +213,7 @@ WEAK const PinMap PinMap_SPI_SCLK[] = {
{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{SUBGHZSPI_SCLK, SUBGHZSPI, -1},
{NC, NP, 0}
};
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ const PinName digitalPin[] = {
PC_13, // D39
PC_14, // D40
PC_15, // D41
PH_3 // D42
PH_3, // D42
SUBGHZSPI_MOSI,
SUBGHZSPI_MISO,
SUBGHZSPI_SCLK
};

// Analog (Ax) pin number array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
#define PC14 40
#define PC15 41
#define PH3 42
#define PINSUBGHZSPIMOSI 43
#define PINSUBGHZSPIMISO 44
#define PINSUBGHZSPISCK 45

// Alternate pins number
#define PA1_ALT1 (PA1 | ALT1)
Expand All @@ -67,7 +70,7 @@
#define PB8_ALT1 (PB8 | ALT1)
#define PB9_ALT1 (PB9 | ALT1)

#define NUM_DIGITAL_PINS 43
#define NUM_DIGITAL_PINS 46
#define NUM_ANALOG_INPUTS 12

// On-board LED pin number
Expand Down