Skip to content

Commit 44a1de2

Browse files
committed
Accelerate QSPI read/write operations by DMA
Support all STM32 Families with QSPI/OSPI HAL API
1 parent d53849f commit 44a1de2

File tree

22 files changed

+927
-252
lines changed

22 files changed

+927
-252
lines changed

targets/TARGET_STM/TARGET_STM32F4/objects.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "stm32f4xx_ll_rtc.h"
2929
#include "stm32f4xx_ll_rcc.h"
3030

31+
#include "stm_dma_info.h"
32+
3133
#ifdef __cplusplus
3234
extern "C" {
3335
#endif
@@ -150,6 +152,7 @@ struct qspi_s {
150152
PinName io3;
151153
PinName sclk;
152154
PinName ssel;
155+
bool dmaInitialized;
153156
};
154157
#endif
155158

targets/TARGET_STM/TARGET_STM32F4/stm_dma_info.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ static const DMALinkInfo SPIRxDMALinks[] = {
4848
{2, 6, 1}, // SPI6 Rx is DMA2 Stream 6 Channel 1
4949
};
5050

51+
/// Mapping from QSPI index to DMA link info
52+
static const DMALinkInfo QSPIDMALinks[] = {
53+
{2, 7, 3}, // QUADSPI is DMA2 Stream 7 Channel 3
54+
};
55+
5156
#endif //MBED_OS_STM_DMA_INFO_H

targets/TARGET_STM/TARGET_STM32F7/objects.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include "stm32f7xx_ll_pwr.h"
4343
#include "stm32f7xx_ll_rcc.h"
4444

45+
#include "stm_dma_info.h"
46+
4547
#ifdef __cplusplus
4648
extern "C" {
4749
#endif
@@ -124,6 +126,7 @@ struct qspi_s {
124126
PinName io3;
125127
PinName sclk;
126128
PinName ssel;
129+
bool dmaInitialized;
127130
};
128131
#endif
129132

targets/TARGET_STM/TARGET_STM32F7/stm_dma_info.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ static const DMALinkInfo SPIRxDMALinks[] = {
4848
{2, 6, 1}, // SPI6 Rx is DMA2 Stream 6 Channel 1
4949
};
5050

51+
/// Mapping from QSPI index to DMA link info
52+
static const DMALinkInfo QSPIDMALinks[] = {
53+
{2, 7, 3}, // QUADSPI is DMA2 Stream 7 Channel 3
54+
};
55+
5156
#endif //MBED_OS_STM_DMA_INFO_H

targets/TARGET_STM/TARGET_STM32G4/objects.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "stm32g4xx_ll_rtc.h"
2727
#include "stm32g4xx_ll_rcc.h"
2828

29+
#include "stm_dma_info.h"
30+
2931
#ifdef __cplusplus
3032
extern "C" {
3133
#endif
@@ -106,6 +108,7 @@ struct qspi_s {
106108
PinName io3;
107109
PinName sclk;
108110
PinName ssel;
111+
bool dmaInitialized;
109112
};
110113
#endif
111114

targets/TARGET_STM/TARGET_STM32G4/stm_dma_info.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@ static const DMALinkInfo SPIRxDMALinks[] = {
4444
#endif
4545
};
4646

47+
/// Mapping from QSPI index to DMA link info
48+
static const DMALinkInfo QSPIDMALinks[] = {
49+
#if defined(QUADSPI)
50+
{1, 7, DMA_REQUEST_QUADSPI },
51+
#endif
52+
};
4753

4854
#endif //MBED_OS_STM_DMA_INFO_H

targets/TARGET_STM/TARGET_STM32H7/objects.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "stm32h7xx_ll_pwr.h"
3232
#include "stm32h7xx_ll_system.h"
3333

34+
#include "stm_dma_info.h"
35+
3436
#ifdef __cplusplus
3537
extern "C" {
3638
#endif
@@ -94,6 +96,8 @@ struct qspi_s {
9496
PinName io3;
9597
PinName sclk;
9698
PinName ssel;
99+
IRQn_Type qspiIRQ;
100+
bool dmaInitialized;
97101
};
98102
#endif
99103

@@ -112,6 +116,8 @@ struct ospi_s {
112116
PinName sclk;
113117
PinName ssel;
114118
PinName dqs;
119+
IRQn_Type ospiIRQ;
120+
bool dmaInitialized;
115121
};
116122
#endif
117123

targets/TARGET_STM/TARGET_STM32H7/stm_dma_info.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,17 @@ static const DMALinkInfo SPIRxDMALinks[] = {
4242
{2, 0, DMA_REQUEST_SPI5_RX},
4343
};
4444

45+
/// Mapping from QSPI/OSPI index to DMA link info
46+
#if defined(OCTOSPI1)
47+
static const DMALinkInfo OSPIDMALinks[] = {
48+
{4, 0, MDMA_REQUEST_OCTOSPI1_FIFO_TH},
49+
{4, 1, MDMA_REQUEST_OCTOSPI2_FIFO_TH}
50+
};
51+
#else
52+
static const DMALinkInfo QSPIDMALinks[] = {
53+
{4, 0, MDMA_REQUEST_QUADSPI_FIFO_TH},
54+
};
55+
#endif
56+
4557

4658
#endif //MBED_OS_STM_DMA_INFO_H

targets/TARGET_STM/TARGET_STM32L4/objects.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "stm32l4xx_ll_pwr.h"
3232
#include "stm32l4xx_ll_rcc.h"
3333

34+
#include "stm_dma_utils.h"
35+
3436
#ifdef __cplusplus
3537
extern "C" {
3638
#endif
@@ -106,6 +108,7 @@ struct can_s {
106108
struct qspi_s {
107109
#if defined(OCTOSPI1)
108110
OSPI_HandleTypeDef handle;
111+
IRQn_Type qspiIRQ;
109112
#else
110113
QSPI_HandleTypeDef handle;
111114
#endif
@@ -116,6 +119,7 @@ struct qspi_s {
116119
PinName io3;
117120
PinName sclk;
118121
PinName ssel;
122+
bool dmaInitialized;
119123
};
120124
#endif
121125

@@ -134,6 +138,8 @@ struct ospi_s {
134138
PinName sclk;
135139
PinName ssel;
136140
PinName dqs;
141+
IRQn_Type ospiIRQ;
142+
bool dmaInitialized;
137143
};
138144
#endif
139145

targets/TARGET_STM/TARGET_STM32L4/stm_dma_info.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ static const DMALinkInfo SPIRxDMALinks[] = {
4040
{1, 6, DMA_REQUEST_SPI3_RX}
4141
};
4242

43+
/// Mapping from OSPI index to DMA link info
44+
static const DMALinkInfo OSPIDMALinks[] = {
45+
{1, 7, DMA_REQUEST_OCTOSPI1},
46+
{2, 1, DMA_REQUEST_OCTOSPI2},
47+
};
48+
4349
#else
4450

4551

@@ -60,6 +66,11 @@ static const DMALinkInfo SPIRxDMALinks[] = {
6066
{2, 1, 3} // SPI3 Rx is DMA2 Ch1 Request 3
6167
};
6268

69+
/// Mapping from QSPI index to DMA link info
70+
static const DMALinkInfo QSPIDMALinks[] = {
71+
{2, 7, 3}, // QUADSPI is DMA2 Ch7 Request 3
72+
};
73+
6374
#endif
6475

6576
#endif //MBED_OS_STM_DMA_INFO_H

0 commit comments

Comments
 (0)