Skip to content

Commit d282c81

Browse files
0xc0170maciejbocianski
authored andcommitted
QSPI: add STM32L4 support
Disco IoT board support for QSPI. As it does not have dual flash support in QSPI, we need to fix qspi hal implementation.
1 parent ae7bb17 commit d282c81

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_DISCO_L475VG_IOT01A/PeripheralNames.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ typedef enum {
8383
CAN_1 = (int)CAN1_BASE
8484
} CANName;
8585

86+
typedef enum {
87+
QSPI_1 = (int)QSPI_R_BASE,
88+
} QSPIName;
89+
8690
#ifdef __cplusplus
8791
}
8892
#endif

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/TARGET_DISCO_L475VG_IOT01A/PeripheralPins.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,27 @@ MBED_WEAK const PinMap PinMap_CAN_TD[] = {
340340
{PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, // Connected to PMOD_SPI2_SCK
341341
{NC, NC, 0}
342342
};
343+
344+
MBED_WEAK const PinMap PinMap_QSPI_DATA[] = {
345+
{PE_12, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
346+
{PE_13, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
347+
{PE_14, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
348+
{PE_15, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
349+
{PA_6, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
350+
{PA_7, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
351+
{PB_0, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
352+
{PB_1, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
353+
{NC, NC, 0}
354+
};
355+
356+
MBED_WEAK const PinMap PinMap_QSPI_SCLK[] = {
357+
{PE_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
358+
{PB_10, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
359+
{NC, NC, 0}
360+
};
361+
362+
MBED_WEAK const PinMap PinMap_QSPI_SSEL[] = {
363+
{PE_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
364+
{PB_11, QSPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QUADSPI)},
365+
{NC, NC, 0}
366+
};

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L475xG/objects.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ struct trng_s {
5858
RNG_HandleTypeDef handle;
5959
};
6060

61+
struct qspi_s {
62+
QSPI_HandleTypeDef handle;
63+
};
64+
6165
#include "common_objects.h"
6266

6367
#ifdef __cplusplus

targets/TARGET_STM/qspi_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ qspi_status_t qspi_init(qspi_t *obj, PinName io0, PinName io1, PinName io2, PinN
142142
obj->handle.Init.FlashSize = POSITION_VAL(QSPI_FLASH_SIZE_DEFAULT) - 1;
143143
obj->handle.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_5_CYCLE;
144144
obj->handle.Init.ClockMode = QSPI_CLOCK_MODE_0;
145+
#ifdef QSPI_DUALFLASH_ENABLE
145146
obj->handle.Init.FlashID = QSPI_FLASH_ID_1;
146147
obj->handle.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
148+
#endif
147149

148150
obj->handle.Init.ClockMode = mode == 0 ? QSPI_CLOCK_MODE_0 : QSPI_CLOCK_MODE_3;
149151

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@
21452145
"supported_form_factors": ["ARDUINO"],
21462146
"detect_code": ["0764"],
21472147
"macros_add": ["USBHOST_OTHER", "TWO_RAM_REGIONS"],
2148-
"device_has_add": ["ANALOGOUT", "CAN", "SERIAL_FC", "TRNG", "FLASH"],
2148+
"device_has_add": ["ANALOGOUT", "CAN", "SERIAL_FC", "TRNG", "FLASH", "QSPI"],
21492149
"release_versions": ["2", "5"],
21502150
"device_name": "STM32L475VG",
21512151
"bootloader_supported": true

0 commit comments

Comments
 (0)