1 /**
2 ****************************************************************************************
3 * @file app_qspi.c
4 * @author BLE Driver Team
5 * @brief HAL APP module driver.
6 ****************************************************************************************
7 * @attention
8 #####Copyright (c) 2019 GOODIX
9 All rights reserved.
10
11 Redistribution and use in source and binary forms, with or without
12 modification, are permitted provided that the following conditions are met:
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 * Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in the
17 documentation and/or other materials provided with the distribution.
18 * Neither the name of GOODIX nor the names of its contributors may be used
19 to endorse or promote products derived from this software without
20 specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33 ****************************************************************************************
34 */
35
36 /*
37 * INCLUDE FILES
38 *****************************************************************************************
39 */
40 #include <string.h>
41 #include "app_io.h"
42 #include "app_dma.h"
43 #include "app_pwr_mgmt.h"
44 #include "app_systick.h"
45 #include "platform_sdk.h"
46 #include "app_qspi.h"
47
48 #ifdef HAL_QSPI_MODULE_ENABLED
49
50 /*
51 * DEFINES
52 *****************************************************************************************
53 */
54
55 /********************************************************************
56 * QUAD_WRITE_32b_PATCH : just exist in QUAD/DATASIZE_32BITS/DMA scene
57 * if enable, MUST Control the CS By Software.
58 */
59 #define QSPI_QUAD_WRITE_32b_PATCH_EN 0u
60
61 /********************************************************************
62 * DATA Endian Mode Optional Value :
63 * 0 : data[0] | (data[1] << 8) | (data[2] << 16) | (data[3] << 24)
64 * 1 : data[1] | (data[0] << 8) | (data[3] << 16) | (data[2] << 24)
65 * 2 : data[3] | (data[2] << 8) | (data[1] << 16) | (data[0] << 24)
66 * 3 : data[2] | (data[3] << 8) | (data[0] << 16) | (data[1] << 24)
67 */
68 #define QSPI_QUAD_WRITE_DATA_ENDIAN_MODE 0u
69
70 /*
71 * STRUCT DEFINE
72 *****************************************************************************************
73 */
74
75 /**@brief App qspi state types. */
76 typedef enum {
77 APP_QSPI_INVALID = 0,
78 APP_QSPI_ACTIVITY,
79 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
80 APP_QSPI_SLEEP,
81 #endif
82 } app_qspi_state_t;
83
84 struct qspi_env_t {
85 app_qspi_evt_handler_t evt_handler;
86 qspi_handle_t handle;
87 app_qspi_mode_t use_mode;
88 app_qspi_pin_cfg_t pin_cfg;
89 int16_t dma_id;
90 app_qspi_state_t qspi_state;
91 bool start_flag;
92 volatile uint8_t rx_done;
93 volatile uint8_t tx_done;
94 volatile uint8_t user_mode;
95
96 #ifdef ENV_RTOS_USE_SEMP
97 APP_DRV_SEM_DECL(sem_tx);
98 APP_DRV_SEM_DECL(sem_rx);
99 #endif
100
101 #ifdef ENV_RTOS_USE_MUTEX
102 APP_DRV_MUTEX_DECL(mutex_sync);
103 APP_DRV_MUTEX_DECL(mutex_async);
104 #endif
105 };
106
107
108 /*
109 * LOCAL FUNCTION DECLARATION
110 *****************************************************************************************
111 */
112 static bool qspi_prepare_for_sleep(void);
113 static void qspi_sleep_canceled(void);
114 static void qspi_wake_up_ind(void);
115 static uint16_t qspi_gpio_config(app_qspi_pin_cfg_t pin_cfg);
116
117 /*
118 * LOCAL VARIABLE DEFINITIONS
119 *****************************************************************************************
120 */
121 static const IRQn_Type s_qspi_irq[APP_QSPI_ID_MAX] = { QSPI0_IRQn, QSPI1_IRQn };
122 static const uint32_t s_qspi_instance[APP_QSPI_ID_MAX] = { QSPI0_BASE, QSPI1_BASE };
123
124 struct qspi_env_t s_qspi_env[APP_QSPI_ID_MAX] = {
125 {
126 .evt_handler = NULL,
127 #ifdef ENV_RTOS_USE_SEMP
128 .sem_tx = NULL,
129 .sem_rx = NULL,
130 #endif
131 #ifdef ENV_RTOS_USE_MUTEX
132 .mutex_sync = NULL,
133 .mutex_async = NULL,
134 #endif
135 },
136 {
137 .evt_handler = NULL,
138 #ifdef ENV_RTOS_USE_SEMP
139 .sem_tx = NULL,
140 .sem_rx = NULL,
141 #endif
142 #ifdef ENV_RTOS_USE_MUTEX
143 .mutex_sync = NULL,
144 .mutex_async = NULL,
145 #endif
146 }
147 };
148 static bool s_sleep_cb_registered_flag = false;
149 static pwr_id_t s_qspi_pwr_id;
150
151 static const app_sleep_callbacks_t qspi_sleep_cb = {
152 .app_prepare_for_sleep = qspi_prepare_for_sleep,
153 .app_sleep_canceled = qspi_sleep_canceled,
154 .app_wake_up_ind = qspi_wake_up_ind
155 };
156
157 static inline void QSPI_SMART_CS_LOW(app_qspi_id_t id);
158 static inline void QSPI_SMART_CS_HIGH(app_qspi_id_t id);
159
QSPI_SMART_CS_LOW(app_qspi_id_t id)160 static inline void QSPI_SMART_CS_LOW(app_qspi_id_t id)
161 {
162 if (s_qspi_env[id].pin_cfg.cs.enable == APP_QSPI_PIN_ENABLE) {
163 app_io_write_pin(s_qspi_env[id].pin_cfg.cs.type,
164 s_qspi_env[id].pin_cfg.cs.pin,
165 APP_IO_PIN_RESET);
166 }
167 }
168
QSPI_SMART_CS_HIGH(app_qspi_id_t id)169 static inline void QSPI_SMART_CS_HIGH(app_qspi_id_t id)
170 {
171 if (s_qspi_env[id].pin_cfg.cs.enable == APP_QSPI_PIN_ENABLE) {
172 app_io_write_pin(s_qspi_env[id].pin_cfg.cs.type,
173 s_qspi_env[id].pin_cfg.cs.pin,
174 APP_IO_PIN_SET);
175 }
176 }
177
178 #ifdef ENV_RTOS_USE_MUTEX
179 static inline void APP_QSPI_DRV_SYNC_MUTEX_LOCK(app_qspi_id_t id);
180 static inline void APP_QSPI_DRV_SYNC_MUTEX_UNLOCK(app_qspi_id_t id);
181 static inline void APP_QSPI_DRV_ASYNC_MUTEX_LOCK(app_qspi_id_t id);
182 static inline void APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(app_qspi_id_t id);
183
APP_QSPI_DRV_SYNC_MUTEX_LOCK(app_qspi_id_t id)184 static inline void APP_QSPI_DRV_SYNC_MUTEX_LOCK(app_qspi_id_t id)
185 {
186 app_driver_mutex_pend(s_qspi_env[id].mutex_sync, MUTEX_WAIT_FOREVER);
187 }
188
APP_QSPI_DRV_SYNC_MUTEX_UNLOCK(app_qspi_id_t id)189 static inline void APP_QSPI_DRV_SYNC_MUTEX_UNLOCK(app_qspi_id_t id)
190 {
191 app_driver_mutex_post(s_qspi_env[id].mutex_sync);
192 }
193
APP_QSPI_DRV_ASYNC_MUTEX_LOCK(app_qspi_id_t id)194 static inline void APP_QSPI_DRV_ASYNC_MUTEX_LOCK(app_qspi_id_t id)
195 {
196 app_driver_mutex_pend(s_qspi_env[id].mutex_async, MUTEX_WAIT_FOREVER);
197 }
198
APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(app_qspi_id_t id)199 static inline void APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(app_qspi_id_t id)
200 {
201 app_driver_mutex_post(s_qspi_env[id].mutex_async);
202 }
203 #endif
204
205 /*
206 * LOCAL FUNCTION DEFINITIONS
207 *****************************************************************************************
208 */
qspi_prepare_for_sleep(void)209 static bool qspi_prepare_for_sleep(void)
210 {
211 hal_qspi_state_t state;
212 uint8_t i;
213
214 for (i = 0; i < APP_QSPI_ID_MAX; i++) {
215 if (s_qspi_env[i].qspi_state == APP_QSPI_ACTIVITY) {
216 state = hal_qspi_get_state(&s_qspi_env[i].handle);
217 if ((state != HAL_QSPI_STATE_RESET) && (state != HAL_QSPI_STATE_READY)) {
218 return false;
219 }
220
221 GLOBAL_EXCEPTION_DISABLE();
222 hal_qspi_suspend_reg(&s_qspi_env[i].handle);
223 GLOBAL_EXCEPTION_ENABLE();
224 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
225 s_qspi_env[i].qspi_state = APP_QSPI_SLEEP;
226 #endif
227 }
228 }
229
230 return true;
231 }
232
qspi_sleep_canceled(void)233 static void qspi_sleep_canceled(void)
234 {
235 }
236
qspi_wake_up_ind(void)237 SECTION_RAM_CODE static void qspi_wake_up_ind(void)
238 {
239 #ifndef APP_DRIVER_WAKEUP_CALL_FUN
240 uint8_t i;
241
242 for (i = 0; i < APP_QSPI_ID_MAX; i++) {
243 if (s_qspi_env[i].qspi_state == APP_QSPI_ACTIVITY) {
244 GLOBAL_EXCEPTION_DISABLE();
245 hal_qspi_resume_reg(&s_qspi_env[i].handle);
246 GLOBAL_EXCEPTION_ENABLE();
247
248 if (s_qspi_env[i].use_mode.type == APP_QSPI_TYPE_INTERRUPT ||
249 s_qspi_env[i].use_mode.type == APP_QSPI_TYPE_DMA) {
250 hal_nvic_clear_pending_irq(s_qspi_irq[i]);
251 hal_nvic_enable_irq(s_qspi_irq[i]);
252 }
253 }
254 }
255 #endif
256 }
257
258 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
qspi_wake_up(app_qspi_id_t id)259 static void qspi_wake_up(app_qspi_id_t id)
260 {
261 if (s_qspi_env[id].qspi_state == APP_QSPI_SLEEP) {
262 GLOBAL_EXCEPTION_DISABLE();
263 hal_qspi_resume_reg(&s_qspi_env[id].handle);
264 GLOBAL_EXCEPTION_ENABLE();
265
266 if (s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_INTERRUPT ||
267 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_DMA) {
268 hal_nvic_clear_pending_irq(s_qspi_irq[id]);
269 hal_nvic_enable_irq(s_qspi_irq[id]);
270 }
271 s_qspi_env[id].qspi_state = APP_QSPI_ACTIVITY;
272 }
273
274 if (s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_DMA) {
275 dma_wake_up(s_qspi_env[id].dma_id);
276 }
277 }
278 #endif
279
qspi_gpio_config(app_qspi_pin_cfg_t pin_cfg)280 static uint16_t qspi_gpio_config(app_qspi_pin_cfg_t pin_cfg)
281 {
282 app_io_init_t io_init = APP_IO_DEFAULT_CONFIG;
283 app_drv_err_t err_code = APP_DRV_SUCCESS;
284
285 io_init.mode = APP_IO_MODE_MUX;
286
287 if (pin_cfg.cs.enable == APP_QSPI_PIN_ENABLE) {
288 io_init.pull = pin_cfg.cs.pull;
289 io_init.mode = APP_IO_MODE_OUT_PUT;
290 io_init.pin = pin_cfg.cs.pin;
291 io_init.mux = APP_IO_MUX_7;
292 err_code = app_io_init(pin_cfg.cs.type, &io_init);
293 APP_DRV_ERR_CODE_CHECK(err_code);
294 app_io_write_pin(pin_cfg.cs.type, pin_cfg.cs.pin, APP_IO_PIN_SET);
295 }
296 if (pin_cfg.clk.enable == APP_QSPI_PIN_ENABLE) {
297 io_init.pull = pin_cfg.clk.pull;
298 io_init.pin = pin_cfg.clk.pin;
299 io_init.mux = pin_cfg.clk.mux;
300 err_code = app_io_init(pin_cfg.clk.type, &io_init);
301 APP_DRV_ERR_CODE_CHECK(err_code);
302 }
303 if (pin_cfg.io_0.enable == APP_QSPI_PIN_ENABLE) {
304 io_init.pull = pin_cfg.io_0.pull;
305 io_init.pin = pin_cfg.io_0.pin;
306 io_init.mux = pin_cfg.io_0.mux;
307 err_code = app_io_init(pin_cfg.io_0.type, &io_init);
308 APP_DRV_ERR_CODE_CHECK(err_code);
309 }
310 if (pin_cfg.io_1.enable == APP_QSPI_PIN_ENABLE) {
311 io_init.pull = pin_cfg.io_1.pull;
312 io_init.pin = pin_cfg.io_1.pin;
313 io_init.mux = pin_cfg.io_1.mux;
314 err_code = app_io_init(pin_cfg.io_1.type, &io_init);
315 APP_DRV_ERR_CODE_CHECK(err_code);
316 }
317 if (pin_cfg.io_2.enable == APP_QSPI_PIN_ENABLE) {
318 io_init.pull = pin_cfg.io_2.pull;
319 io_init.pin = pin_cfg.io_2.pin;
320 io_init.mux = pin_cfg.io_2.mux;
321 err_code = app_io_init(pin_cfg.io_2.type, &io_init);
322 APP_DRV_ERR_CODE_CHECK(err_code);
323 }
324 if (pin_cfg.io_3.enable == APP_QSPI_PIN_ENABLE) {
325 io_init.pull = pin_cfg.io_3.pull;
326 io_init.pin = pin_cfg.io_3.pin;
327 io_init.mux = pin_cfg.io_3.mux;
328 err_code = app_io_init(pin_cfg.io_3.type, &io_init);
329 APP_DRV_ERR_CODE_CHECK(err_code);
330 }
331
332 return err_code;
333 }
334
app_qspi_config_dma(app_qspi_params_t * p_params)335 static uint16_t app_qspi_config_dma(app_qspi_params_t *p_params)
336 {
337 app_dma_params_t dma_params = {DMA_Channel0, {0}};
338
339 dma_params.channel_number = p_params->use_mode.dma_channel;
340 dma_params.init.direction = DMA_MEMORY_TO_PERIPH;
341 dma_params.init.src_increment = DMA_SRC_INCREMENT;
342 dma_params.init.dst_increment = DMA_DST_NO_CHANGE;
343 dma_params.init.src_data_alignment = DMA_SDATAALIGN_BYTE;
344 dma_params.init.dst_data_alignment = DMA_DDATAALIGN_BYTE;
345 dma_params.init.mode = DMA_NORMAL;
346 dma_params.init.priority = DMA_PRIORITY_LOW;
347
348 s_qspi_env[p_params->id].dma_id = app_dma_init(&dma_params, NULL);
349 if (s_qspi_env[p_params->id].dma_id < 0) {
350 return APP_DRV_ERR_INVALID_PARAM;
351 }
352 s_qspi_env[p_params->id].handle.p_dma = app_dma_get_handle(s_qspi_env[p_params->id].dma_id);
353 s_qspi_env[p_params->id].handle.p_dma->p_parent = (void*)&s_qspi_env[p_params->id].handle;
354
355 return APP_DRV_SUCCESS;
356 }
357
app_qspi_event_call(qspi_handle_t * p_qspi,app_qspi_evt_type_t evt_type)358 static void app_qspi_event_call(qspi_handle_t *p_qspi, app_qspi_evt_type_t evt_type)
359 {
360 app_qspi_evt_t qspi_evt;
361 app_qspi_id_t id = APP_QSPI_ID_MAX;
362
363 if (p_qspi->p_instance == QSPI0) {
364 id = APP_QSPI_ID_0;
365 } else if (p_qspi->p_instance == QSPI1) {
366 id = APP_QSPI_ID_1;
367 }
368
369 qspi_evt.type = evt_type;
370 if (evt_type == APP_QSPI_EVT_ERROR) {
371 qspi_evt.data.error_code = p_qspi->error_code;
372 #ifdef ENV_RTOS_USE_SEMP
373 if (!s_qspi_env[id].user_mode) {
374 app_driver_sem_post_from_isr(s_qspi_env[id].sem_tx);
375 app_driver_sem_post_from_isr(s_qspi_env[id].sem_rx);
376 }
377 #endif
378 s_qspi_env[id].rx_done = 1;
379 s_qspi_env[id].tx_done = 1;
380 } else if (evt_type == APP_QSPI_EVT_TX_CPLT) {
381 qspi_evt.data.size = p_qspi->tx_xfer_size - p_qspi->tx_xfer_count;
382 #ifdef ENV_RTOS_USE_SEMP
383 if (!s_qspi_env[id].user_mode) {
384 app_driver_sem_post_from_isr(s_qspi_env[id].sem_tx);
385 }
386 #endif
387 s_qspi_env[id].tx_done = 1;
388 } else if (evt_type == APP_QSPI_EVT_RX_DATA) {
389 qspi_evt.data.size = p_qspi->rx_xfer_size - p_qspi->rx_xfer_count;
390 #ifdef ENV_RTOS_USE_SEMP
391 if (!s_qspi_env[id].user_mode) {
392 app_driver_sem_post_from_isr(s_qspi_env[id].sem_rx);
393 }
394 #endif
395 s_qspi_env[id].rx_done = 1;
396 }
397 s_qspi_env[id].start_flag = false;
398 QSPI_SMART_CS_HIGH(id);
399 if (s_qspi_env[id].evt_handler != NULL) {
400 s_qspi_env[id].evt_handler(&qspi_evt);
401 }
402 }
403
app_qspi_config_dma_qwrite_32b_patch(app_qspi_id_t id,bool enable_patch,uint32_t endian_mode)404 static void app_qspi_config_dma_qwrite_32b_patch(app_qspi_id_t id, bool enable_patch, uint32_t endian_mode)
405 {
406 #if defined(GR5515_D)
407 hal_qspi_config_dma_qwrite_32b_patch(&s_qspi_env[id].handle, enable_patch, endian_mode);
408 #endif
409 }
410
params_check(app_qspi_params_t * p_params)411 static uint16_t params_check(app_qspi_params_t *p_params)
412 {
413 uint8_t id = p_params->id;
414
415 if (p_params == NULL) {
416 return APP_DRV_ERR_POINTER_NULL;
417 }
418
419 if (id >= APP_QSPI_ID_MAX) {
420 return APP_DRV_ERR_INVALID_ID;
421 }
422
423 return APP_DRV_SUCCESS;
424 }
425
426 #ifdef ENV_RTOS_USE_SEMP
semp_init_config(uint8_t id)427 static uint16_t semp_init_config(uint8_t id)
428 {
429 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
430
431 if (s_qspi_env[id].sem_rx == NULL) {
432 app_err_code = app_driver_sem_init(&s_qspi_env[id].sem_rx);
433 APP_DRV_ERR_CODE_CHECK(app_err_code);
434 }
435 if (s_qspi_env[id].sem_tx == NULL) {
436 app_err_code = app_driver_sem_init(&s_qspi_env[id].sem_tx);
437 APP_DRV_ERR_CODE_CHECK(app_err_code);
438 }
439
440 return APP_DRV_SUCCESS;
441 }
442 #endif
443
444 #ifdef ENV_RTOS_USE_MUTEX
mutex_init_config(uint8_t id)445 static uint16_t mutex_init_config(uint8_t id)
446 {
447 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
448
449 if (s_qspi_env[id].mutex_async == NULL) {
450 app_err_code = app_driver_mutex_init(&s_qspi_env[id].mutex_async);
451 APP_DRV_ERR_CODE_CHECK(app_err_code);
452 }
453 if (s_qspi_env[id].mutex_sync == NULL) {
454 app_err_code = app_driver_mutex_init(&s_qspi_env[id].mutex_sync);
455 APP_DRV_ERR_CODE_CHECK(app_err_code);
456 }
457
458 return APP_DRV_SUCCESS;
459 }
460 #endif
461
sync_params_to_env(app_qspi_params_t * p_params,app_qspi_evt_handler_t evt_handler,uint8_t id)462 static void sync_params_to_env(app_qspi_params_t *p_params, app_qspi_evt_handler_t evt_handler, uint8_t id)
463 {
464 s_qspi_env[id].use_mode.type = p_params->use_mode.type;
465 s_qspi_env[id].use_mode.dma_channel = p_params->use_mode.dma_channel;
466 memcpy_s(&s_qspi_env[id].pin_cfg, sizeof (s_qspi_env[id].pin_cfg), &p_params->pin_cfg, sizeof(app_qspi_pin_cfg_t));
467 s_qspi_env[id].evt_handler = evt_handler;
468
469 memcpy_s(&s_qspi_env[id].handle.init, sizeof (s_qspi_env[id].handle.init), &p_params->init, sizeof(qspi_init_t));
470 s_qspi_env[id].handle.p_instance = (ssi_regs_t *)s_qspi_instance[id];
471 }
472
register_cb(void)473 static uint16_t register_cb(void)
474 {
475 if (!s_sleep_cb_registered_flag) { // register sleep callback
476 s_sleep_cb_registered_flag = true;
477 s_qspi_pwr_id = pwr_register_sleep_cb(&qspi_sleep_cb, APP_DRIVER_QSPI_WAPEUP_PRIORITY);
478 if (s_qspi_pwr_id < 0) {
479 return APP_DRV_ERR_INVALID_PARAM;
480 }
481 }
482
483 return APP_DRV_SUCCESS;
484 }
485
486 /*
487 * GLOBAL FUNCTION DEFINITIONS
488 ****************************************************************************************
489 */
app_qspi_init(app_qspi_params_t * p_params,app_qspi_evt_handler_t evt_handler)490 uint16_t app_qspi_init(app_qspi_params_t *p_params, app_qspi_evt_handler_t evt_handler)
491 {
492 uint8_t id = p_params->id;
493 app_drv_err_t app_err_code;
494 hal_status_t hal_err_code;
495
496 app_err_code = params_check(p_params);
497 APP_DRV_ERR_CODE_CHECK(app_err_code);
498
499 #ifdef ENV_RTOS_USE_SEMP
500 app_err_code = semp_init_config(id);
501 APP_DRV_ERR_CODE_CHECK(app_err_code);
502 #endif
503
504 #ifdef ENV_RTOS_USE_MUTEX
505 app_err_code = mutex_init_config(id);
506 APP_DRV_ERR_CODE_CHECK(app_err_code);
507 #endif
508
509 app_systick_init();
510 app_err_code = qspi_gpio_config(p_params->pin_cfg);
511 APP_DRV_ERR_CODE_CHECK(app_err_code);
512
513 if (p_params->use_mode.type == APP_QSPI_TYPE_DMA) {
514 GLOBAL_EXCEPTION_DISABLE();
515 app_err_code = app_qspi_config_dma(p_params);
516 GLOBAL_EXCEPTION_ENABLE();
517 APP_DRV_ERR_CODE_CHECK(app_err_code);
518 }
519
520 if (p_params->use_mode.type != APP_QSPI_TYPE_POLLING) {
521 hal_nvic_clear_pending_irq(s_qspi_irq[id]);
522 hal_nvic_enable_irq(s_qspi_irq[id]);
523 }
524
525 sync_params_to_env(p_params, evt_handler, id);
526
527 hal_err_code = hal_qspi_deinit(&s_qspi_env[id].handle);
528 HAL_ERR_CODE_CHECK(hal_err_code);
529
530 hal_err_code =hal_qspi_init(&s_qspi_env[id].handle);
531 HAL_ERR_CODE_CHECK(hal_err_code);
532
533 app_err_code = register_cb();
534 APP_DRV_ERR_CODE_CHECK(app_err_code);
535
536 s_qspi_env[id].qspi_state = APP_QSPI_ACTIVITY;
537 s_qspi_env[id].start_flag = false;
538
539 return APP_DRV_SUCCESS;
540 }
541
542 #ifdef ENV_RTOS_USE_SEMP
semp_deinit_config(uint8_t id)543 static void semp_deinit_config(uint8_t id)
544 {
545 if (s_qspi_env[id].sem_tx != NULL) {
546 app_driver_sem_deinit(s_qspi_env[id].sem_tx);
547 s_qspi_env[id].sem_tx = NULL;
548 }
549 if (s_qspi_env[id].sem_rx != NULL) {
550 app_driver_sem_deinit(s_qspi_env[id].sem_rx);
551 s_qspi_env[id].sem_rx = NULL;
552 }
553 }
554 #endif
555
556 #ifdef ENV_RTOS_USE_MUTEX
mutex_deinit_config(uint8_t id)557 static uint16_t mutex_deinit_config(uint8_t id)
558 {
559 if (s_qspi_env[id].mutex_sync != NULL) {
560 app_driver_mutex_deinit(s_qspi_env[id].mutex_sync);
561 s_qspi_env[id].mutex_sync = NULL;
562 }
563 if (s_qspi_env[id].mutex_async != NULL) {
564 app_driver_mutex_deinit(s_qspi_env[id].mutex_async);
565 s_qspi_env[id].mutex_async = NULL;
566 }
567 }
568 #endif
569
unregister_cb(void)570 static void unregister_cb(void)
571 {
572 GLOBAL_EXCEPTION_DISABLE();
573 if (s_qspi_env[APP_QSPI_ID_0].qspi_state == APP_QSPI_INVALID &&
574 s_qspi_env[APP_QSPI_ID_1].qspi_state == APP_QSPI_INVALID) {
575 pwr_unregister_sleep_cb(s_qspi_pwr_id);
576 s_sleep_cb_registered_flag = false;
577 }
578 GLOBAL_EXCEPTION_ENABLE();
579 }
580
app_qspi_deinit(app_qspi_id_t id)581 uint16_t app_qspi_deinit(app_qspi_id_t id)
582 {
583 app_drv_err_t app_err_code;
584 hal_status_t hal_err_code;
585
586 if ((id >= APP_QSPI_ID_MAX) || (s_qspi_env[id].qspi_state == APP_QSPI_INVALID)) {
587 return APP_DRV_ERR_INVALID_ID;
588 }
589
590 #ifdef ENV_RTOS_USE_SEMP
591 semp_deinit_config(id);
592 #endif
593
594 #ifdef ENV_RTOS_USE_MUTEX
595 mutex_deinit_config(id);
596 #endif
597
598 if (s_qspi_env[id].pin_cfg.cs.enable == APP_QSPI_PIN_ENABLE) {
599 app_err_code = app_io_deinit(s_qspi_env[id].pin_cfg.cs.type, s_qspi_env[id].pin_cfg.cs.pin);
600 APP_DRV_ERR_CODE_CHECK(app_err_code);
601 }
602 if (s_qspi_env[id].pin_cfg.clk.enable == APP_QSPI_PIN_ENABLE) {
603 app_err_code = app_io_deinit(s_qspi_env[id].pin_cfg.clk.type, s_qspi_env[id].pin_cfg.clk.pin);
604 APP_DRV_ERR_CODE_CHECK(app_err_code);
605 }
606 if (s_qspi_env[id].pin_cfg.io_0.enable == APP_QSPI_PIN_ENABLE) {
607 app_err_code = app_io_deinit(s_qspi_env[id].pin_cfg.io_0.type, s_qspi_env[id].pin_cfg.io_0.pin);
608 APP_DRV_ERR_CODE_CHECK(app_err_code);
609 }
610 if (s_qspi_env[id].pin_cfg.io_1.enable == APP_QSPI_PIN_ENABLE) {
611 app_err_code = app_io_deinit(s_qspi_env[id].pin_cfg.io_1.type, s_qspi_env[id].pin_cfg.io_1.pin);
612 APP_DRV_ERR_CODE_CHECK(app_err_code);
613 }
614 if (s_qspi_env[id].pin_cfg.io_2.enable == APP_QSPI_PIN_ENABLE) {
615 app_err_code = app_io_deinit(s_qspi_env[id].pin_cfg.io_2.type, s_qspi_env[id].pin_cfg.io_2.pin);
616 APP_DRV_ERR_CODE_CHECK(app_err_code);
617 }
618 if (s_qspi_env[id].pin_cfg.io_3.enable == APP_QSPI_PIN_ENABLE) {
619 app_err_code = app_io_deinit(s_qspi_env[id].pin_cfg.io_3.type, s_qspi_env[id].pin_cfg.io_3.pin);
620 APP_DRV_ERR_CODE_CHECK(app_err_code);
621 }
622 hal_nvic_disable_irq(s_qspi_irq[id]);
623 if (s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_DMA) {
624 app_dma_deinit(s_qspi_env[id].dma_id);
625 }
626 s_qspi_env[id].qspi_state = APP_QSPI_INVALID;
627 s_qspi_env[id].start_flag = false;
628
629 unregister_cb();
630
631 app_systick_deinit();
632
633 hal_err_code = hal_qspi_deinit(&s_qspi_env[id].handle);
634 HAL_ERR_CODE_CHECK(hal_err_code);
635
636 return APP_DRV_SUCCESS;
637 }
638
app_qspi_command_receive_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data,uint32_t timeout)639 uint16_t app_qspi_command_receive_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout)
640 {
641 hal_status_t err_code;
642
643 if (id >= APP_QSPI_ID_MAX ||
644 p_cmd == NULL ||
645 p_data == NULL ||
646 s_qspi_env[id].qspi_state == APP_QSPI_INVALID) {
647 return APP_DRV_ERR_INVALID_PARAM;
648 }
649
650 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
651 qspi_wake_up(id);
652 #endif
653
654 QSPI_SMART_CS_LOW(id);
655 err_code = hal_qspi_command_receive(&s_qspi_env[id].handle, p_cmd, p_data, timeout);
656 QSPI_SMART_CS_HIGH(id);
657 if (err_code != HAL_OK) {
658 return (uint16_t)err_code;
659 }
660
661 return APP_DRV_SUCCESS;
662 }
663
664 #ifdef ENV_RTOS_USE_SEMP
app_qspi_command_receive_sem_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)665 uint16_t app_qspi_command_receive_sem_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
666 {
667 hal_status_t err_code = HAL_OK;
668
669 #ifdef ENV_RTOS_USE_MUTEX
670 APP_QSPI_DRV_ASYNC_MUTEX_LOCK(id);
671 #endif
672
673 if (id >= APP_QSPI_ID_MAX ||
674 p_cmd == NULL ||
675 p_data == NULL ||
676 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
677 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
678 #ifdef ENV_RTOS_USE_MUTEX
679 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
680 #endif
681 return APP_DRV_ERR_INVALID_PARAM;
682 }
683
684 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
685 qspi_wake_up(id);
686 #endif
687
688 if (s_qspi_env[id].start_flag == false) {
689 s_qspi_env[id].start_flag = true;
690 QSPI_SMART_CS_LOW(id);
691 switch (s_qspi_env[id].use_mode.type) {
692 case APP_QSPI_TYPE_INTERRUPT:
693 err_code = hal_qspi_command_receive_it(&s_qspi_env[id].handle, p_cmd, p_data);
694 break;
695 case APP_QSPI_TYPE_DMA:
696 err_code = hal_qspi_command_receive_dma(&s_qspi_env[id].handle, p_cmd, p_data);
697 break;
698 default:
699 break;
700 }
701 if (HAL_OK != err_code) {
702 QSPI_SMART_CS_HIGH(id);
703 #ifdef ENV_RTOS_USE_MUTEX
704 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
705 #endif
706 s_qspi_env[id].start_flag = false;
707 return (uint16_t)err_code;
708 }
709 } else {
710 #ifdef ENV_RTOS_USE_MUTEX
711 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
712 #endif
713 return APP_DRV_ERR_BUSY;
714 }
715
716 app_driver_sem_pend(s_qspi_env[id].sem_rx, OS_WAIT_FOREVER);
717
718 #ifdef ENV_RTOS_USE_MUTEX
719 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
720 #endif
721
722 return APP_DRV_SUCCESS;
723 }
724
725 #endif
726
app_qspi_command_receive_high_speed_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)727 uint16_t app_qspi_command_receive_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
728 {
729 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
730 hal_status_t hal_err_code = HAL_OK;
731
732 if (id >= APP_QSPI_ID_MAX ||
733 p_cmd == NULL ||
734 p_data == NULL ||
735 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
736 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
737 return APP_DRV_ERR_INVALID_PARAM;
738 }
739
740 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
741 qspi_wake_up(id);
742 #endif
743
744 s_qspi_env[id].user_mode = 0x1;
745 s_qspi_env[id].rx_done = 0;
746 if (s_qspi_env[id].start_flag == false) {
747 s_qspi_env[id].start_flag = true;
748 QSPI_SMART_CS_LOW(id);
749 switch (s_qspi_env[id].use_mode.type) {
750 case APP_QSPI_TYPE_INTERRUPT:
751 hal_err_code = hal_qspi_command_receive_it(&s_qspi_env[id].handle, p_cmd, p_data);
752 break;
753 case APP_QSPI_TYPE_DMA:
754 hal_err_code = hal_qspi_command_receive_dma(&s_qspi_env[id].handle, p_cmd, p_data);
755 break;
756 default:
757 break;
758 }
759 if (HAL_OK != hal_err_code) {
760 QSPI_SMART_CS_HIGH(id);
761 app_err_code = (uint16_t)hal_err_code;
762 s_qspi_env[id].start_flag = false;
763 goto exit;
764 }
765 } else {
766 app_err_code = APP_DRV_ERR_BUSY;
767 goto exit;
768 }
769
770 while (s_qspi_env[id].rx_done == 0);
771
772 exit:
773 s_qspi_env[id].user_mode = 0x0;
774
775 return app_err_code;
776 }
777
778
app_qspi_command_receive_async(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)779 uint16_t app_qspi_command_receive_async(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
780 {
781 hal_status_t err_code = HAL_OK;
782
783 if (id >= APP_QSPI_ID_MAX ||
784 p_cmd == NULL ||
785 p_data == NULL ||
786 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
787 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
788 return APP_DRV_ERR_INVALID_PARAM;
789 }
790
791 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
792 qspi_wake_up(id);
793 #endif
794
795 if (s_qspi_env[id].start_flag == false) {
796 s_qspi_env[id].start_flag = true;
797 QSPI_SMART_CS_LOW(id);
798 switch (s_qspi_env[id].use_mode.type) {
799 case APP_QSPI_TYPE_INTERRUPT:
800 err_code = hal_qspi_command_receive_it(&s_qspi_env[id].handle, p_cmd, p_data);
801 break;
802 case APP_QSPI_TYPE_DMA:
803 err_code = hal_qspi_command_receive_dma(&s_qspi_env[id].handle, p_cmd, p_data);
804 break;
805 default:
806 break;
807 }
808 if (HAL_OK != err_code) {
809 QSPI_SMART_CS_HIGH(id);
810 s_qspi_env[id].start_flag = false;
811 return (uint16_t)err_code;
812 }
813 } else {
814 return APP_DRV_ERR_BUSY;
815 }
816
817 return APP_DRV_SUCCESS;
818 }
819
app_qspi_command_transmit_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data,uint32_t timeout)820 uint16_t app_qspi_command_transmit_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data, uint32_t timeout)
821 {
822 hal_status_t err_code;
823
824 if (id >= APP_QSPI_ID_MAX ||
825 p_cmd == NULL ||
826 p_data == NULL ||
827 s_qspi_env[id].qspi_state == APP_QSPI_INVALID) {
828 return APP_DRV_ERR_INVALID_PARAM;
829 }
830
831 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
832 qspi_wake_up(id);
833 #endif
834
835 QSPI_SMART_CS_LOW(id);
836 err_code = hal_qspi_command_transmit(&s_qspi_env[id].handle, p_cmd, p_data, timeout);
837 QSPI_SMART_CS_HIGH(id);
838 if (err_code != HAL_OK) {
839 return (uint16_t)err_code;
840 }
841
842 return APP_DRV_SUCCESS;
843 }
844
845 #ifdef ENV_RTOS_USE_SEMP
sem_sync_params_check(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)846 static uint16_t sem_sync_params_check(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
847 {
848 if (id >= APP_QSPI_ID_MAX ||
849 p_cmd == NULL ||
850 p_data == NULL ||
851 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
852 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
853 #ifdef ENV_RTOS_USE_MUTEX
854 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
855 #endif
856 return APP_DRV_ERR_INVALID_PARAM;
857 }
858 return APP_DRV_SUCCESS;
859 }
860
command_transmit_process(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)861 static hal_status_t command_transmit_process(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
862 {
863 hal_status_t err_code = HAL_OK;
864
865 switch (s_qspi_env[id].use_mode.type) {
866 case APP_QSPI_TYPE_INTERRUPT:
867 err_code = hal_qspi_command_transmit_it(&s_qspi_env[id].handle, p_cmd, p_data);
868 break;
869
870 case APP_QSPI_TYPE_DMA:
871 app_qspi_config_dma_qwrite_32b_patch(id, QSPI_QUAD_WRITE_32b_PATCH_EN,
872 QSPI_QUAD_WRITE_DATA_ENDIAN_MODE);
873 err_code = hal_qspi_command_transmit_dma(&s_qspi_env[id].handle, p_cmd, p_data);
874 app_qspi_config_dma_qwrite_32b_patch(id, 0, QSPI_QUAD_WRITE_DATA_ENDIAN_MODE);
875 break;
876
877 default:
878 break;
879 }
880 return err_code;
881 }
882 #endif
883
884 #ifdef ENV_RTOS_USE_SEMP
app_qspi_command_transmit_sem_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)885 uint16_t app_qspi_command_transmit_sem_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
886 {
887 app_drv_err_t app_err_code;
888 hal_status_t err_code = HAL_OK;
889
890 #ifdef ENV_RTOS_USE_MUTEX
891 APP_QSPI_DRV_ASYNC_MUTEX_LOCK(id);
892 #endif
893
894 app_err_code = sem_sync_params_check(id, p_cmd, p_data);
895 APP_DRV_ERR_CODE_CHECK(app_err_code);
896
897 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
898 qspi_wake_up(id);
899 #endif
900
901 if (s_qspi_env[id].start_flag == false) {
902 s_qspi_env[id].start_flag = true;
903 QSPI_SMART_CS_LOW(id);
904 err_code = command_transmit_process(id, p_cmd, p_data);
905 if (err_code != HAL_OK) {
906 QSPI_SMART_CS_HIGH(id);
907 #ifdef ENV_RTOS_USE_MUTEX
908 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
909 #endif
910 s_qspi_env[id].start_flag = false;
911 return (uint16_t)err_code;
912 }
913 } else {
914 #ifdef ENV_RTOS_USE_MUTEX
915 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
916 #endif
917 return APP_DRV_ERR_BUSY;
918 }
919
920 app_driver_sem_pend(s_qspi_env[id].sem_tx, OS_WAIT_FOREVER);
921
922 #ifdef ENV_RTOS_USE_MUTEX
923 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
924 #endif
925
926 return APP_DRV_SUCCESS;
927 }
928 #endif
929
930
app_qspi_command_transmit_high_speed_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)931 uint16_t app_qspi_command_transmit_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
932 {
933 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
934 hal_status_t hal_err_code = HAL_OK;
935
936 if (id >= APP_QSPI_ID_MAX ||
937 p_cmd == NULL ||
938 p_data == NULL ||
939 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
940 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
941 return APP_DRV_ERR_INVALID_PARAM;
942 }
943
944 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
945 qspi_wake_up(id);
946 #endif
947
948 s_qspi_env[id].user_mode = 0x1;
949 s_qspi_env[id].tx_done = 0;
950 if (s_qspi_env[id].start_flag == false) {
951 s_qspi_env[id].start_flag = true;
952 QSPI_SMART_CS_LOW(id);
953 switch (s_qspi_env[id].use_mode.type) {
954 case APP_QSPI_TYPE_INTERRUPT:
955 hal_err_code = hal_qspi_command_transmit_it(&s_qspi_env[id].handle, p_cmd, p_data);
956 break;
957
958 case APP_QSPI_TYPE_DMA:
959 app_qspi_config_dma_qwrite_32b_patch(id, QSPI_QUAD_WRITE_32b_PATCH_EN,
960 QSPI_QUAD_WRITE_DATA_ENDIAN_MODE);
961 hal_err_code = hal_qspi_command_transmit_dma(&s_qspi_env[id].handle, p_cmd, p_data);
962 app_qspi_config_dma_qwrite_32b_patch(id, 0, QSPI_QUAD_WRITE_DATA_ENDIAN_MODE);
963 break;
964
965 default:
966 break;
967 }
968 if (hal_err_code != HAL_OK) {
969 QSPI_SMART_CS_HIGH(id);
970 app_err_code = (uint16_t)hal_err_code;
971 s_qspi_env[id].start_flag = false;
972 goto exit;
973 }
974 } else {
975 app_err_code = APP_DRV_ERR_BUSY;
976 goto exit;
977 }
978
979 while (s_qspi_env[id].tx_done == 0);
980
981 exit:
982 s_qspi_env[id].user_mode = 0x0;
983
984 return app_err_code;
985 }
986
app_qspi_command_transmit_async(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint8_t * p_data)987 uint16_t app_qspi_command_transmit_async(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
988 {
989 hal_status_t err_code = HAL_OK;
990
991 if (id >= APP_QSPI_ID_MAX ||
992 p_cmd == NULL ||
993 p_data == NULL ||
994 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
995 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
996 return APP_DRV_ERR_INVALID_PARAM;
997 }
998
999 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1000 qspi_wake_up(id);
1001 #endif
1002
1003 if (s_qspi_env[id].start_flag == false) {
1004 s_qspi_env[id].start_flag = true;
1005 QSPI_SMART_CS_LOW(id);
1006 switch (s_qspi_env[id].use_mode.type) {
1007 case APP_QSPI_TYPE_INTERRUPT:
1008 err_code = hal_qspi_command_transmit_it(&s_qspi_env[id].handle, p_cmd, p_data);
1009 break;
1010
1011 case APP_QSPI_TYPE_DMA:
1012 app_qspi_config_dma_qwrite_32b_patch(id, QSPI_QUAD_WRITE_32b_PATCH_EN,
1013 QSPI_QUAD_WRITE_DATA_ENDIAN_MODE);
1014 err_code = hal_qspi_command_transmit_dma(&s_qspi_env[id].handle, p_cmd, p_data);
1015 app_qspi_config_dma_qwrite_32b_patch(id, 0, QSPI_QUAD_WRITE_DATA_ENDIAN_MODE);
1016 break;
1017
1018 default:
1019 break;
1020 }
1021 if (err_code != HAL_OK) {
1022 QSPI_SMART_CS_HIGH(id);
1023 s_qspi_env[id].start_flag = false;
1024 return (uint16_t)err_code;
1025 }
1026 } else {
1027 return APP_DRV_ERR_BUSY;
1028 }
1029
1030 return APP_DRV_SUCCESS;
1031 }
1032
app_qspi_command_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd,uint32_t timeout)1033 uint16_t app_qspi_command_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint32_t timeout)
1034 {
1035 hal_status_t err_code;
1036
1037 if (id >= APP_QSPI_ID_MAX ||
1038 p_cmd == NULL ||
1039 s_qspi_env[id].qspi_state == APP_QSPI_INVALID) {
1040 return APP_DRV_ERR_INVALID_PARAM;
1041 }
1042
1043 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1044 qspi_wake_up(id);
1045 #endif
1046 QSPI_SMART_CS_LOW(id);
1047 err_code = hal_qspi_command(&s_qspi_env[id].handle, p_cmd, timeout);
1048 QSPI_SMART_CS_HIGH(id);
1049 if (err_code != HAL_OK) {
1050 return (uint16_t)err_code;
1051 }
1052
1053 return APP_DRV_SUCCESS;
1054 }
1055
1056 #ifdef ENV_RTOS_USE_SEMP
app_qspi_command_sem_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd)1057 uint16_t app_qspi_command_sem_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd)
1058 {
1059 hal_status_t err_code;
1060
1061 #ifdef ENV_RTOS_USE_MUTEX
1062 APP_QSPI_DRV_ASYNC_MUTEX_LOCK(id);
1063 #endif
1064
1065 if (id >= APP_QSPI_ID_MAX ||
1066 p_cmd == NULL ||
1067 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1068 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1069 #ifdef ENV_RTOS_USE_MUTEX
1070 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1071 #endif
1072 return APP_DRV_ERR_INVALID_PARAM;
1073 }
1074
1075 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1076 qspi_wake_up(id);
1077 #endif
1078
1079 if (s_qspi_env[id].start_flag == false) {
1080 s_qspi_env[id].start_flag = true;
1081 QSPI_SMART_CS_LOW(id);
1082 switch (s_qspi_env[id].use_mode.type) {
1083 case APP_QSPI_TYPE_INTERRUPT:
1084 err_code = hal_qspi_command_it(&s_qspi_env[id].handle, p_cmd);
1085 break;
1086
1087 case APP_QSPI_TYPE_DMA:
1088 err_code = hal_qspi_command_dma(&s_qspi_env[id].handle, p_cmd);
1089 break;
1090
1091 default:
1092 break;
1093 }
1094 if (err_code != HAL_OK) {
1095 QSPI_SMART_CS_HIGH(id);
1096 #ifdef ENV_RTOS_USE_MUTEX
1097 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1098 #endif
1099 s_qspi_env[id].start_flag = false;
1100 return (uint16_t)err_code;
1101 }
1102 } else {
1103 #ifdef ENV_RTOS_USE_MUTEX
1104 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1105 #endif
1106 return APP_DRV_ERR_BUSY;
1107 }
1108
1109 app_driver_sem_pend(s_qspi_env[id].sem_tx, OS_WAIT_FOREVER);
1110
1111 #ifdef ENV_RTOS_USE_MUTEX
1112 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1113 #endif
1114
1115 return APP_DRV_SUCCESS;
1116 }
1117 #endif
1118
app_qspi_command_high_speed_sync(app_qspi_id_t id,app_qspi_command_t * p_cmd)1119 uint16_t app_qspi_command_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd)
1120 {
1121 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
1122 hal_status_t hal_err_code = HAL_OK;
1123
1124 if (id >= APP_QSPI_ID_MAX ||
1125 p_cmd == NULL ||
1126 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1127 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1128 return APP_DRV_ERR_INVALID_PARAM;
1129 }
1130
1131 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1132 qspi_wake_up(id);
1133 #endif
1134
1135 s_qspi_env[id].user_mode = 0x1;
1136 s_qspi_env[id].tx_done = 0;
1137 if (s_qspi_env[id].start_flag == false) {
1138 s_qspi_env[id].start_flag = true;
1139 QSPI_SMART_CS_LOW(id);
1140 switch (s_qspi_env[id].use_mode.type) {
1141 case APP_QSPI_TYPE_INTERRUPT:
1142 hal_err_code = hal_qspi_command_it(&s_qspi_env[id].handle, p_cmd);
1143 break;
1144
1145 case APP_QSPI_TYPE_DMA:
1146 hal_err_code = hal_qspi_command_dma(&s_qspi_env[id].handle, p_cmd);
1147 break;
1148
1149 default:
1150 break;
1151 }
1152 if (hal_err_code != HAL_OK) {
1153 QSPI_SMART_CS_HIGH(id);
1154 app_err_code = (uint16_t)hal_err_code;
1155 s_qspi_env[id].start_flag = false;
1156 goto exit;
1157 }
1158 } else {
1159 app_err_code = APP_DRV_ERR_BUSY;
1160 goto exit;
1161 }
1162
1163 while (s_qspi_env[id].tx_done == 0);
1164
1165 exit:
1166 s_qspi_env[id].user_mode = 0x0;
1167
1168 return app_err_code;
1169 }
1170
app_qspi_command_async(app_qspi_id_t id,app_qspi_command_t * p_cmd)1171 uint16_t app_qspi_command_async(app_qspi_id_t id, app_qspi_command_t *p_cmd)
1172 {
1173 hal_status_t err_code;
1174
1175 if (id >= APP_QSPI_ID_MAX ||
1176 p_cmd == NULL ||
1177 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1178 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1179 return APP_DRV_ERR_INVALID_PARAM;
1180 }
1181
1182 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1183 qspi_wake_up(id);
1184 #endif
1185
1186 if (s_qspi_env[id].start_flag == false) {
1187 s_qspi_env[id].start_flag = true;
1188 QSPI_SMART_CS_LOW(id);
1189 switch (s_qspi_env[id].use_mode.type) {
1190 case APP_QSPI_TYPE_INTERRUPT:
1191 err_code = hal_qspi_command_it(&s_qspi_env[id].handle, p_cmd);
1192 break;
1193
1194 case APP_QSPI_TYPE_DMA:
1195 err_code = hal_qspi_command_dma(&s_qspi_env[id].handle, p_cmd);
1196 break;
1197
1198 default:
1199 break;
1200 }
1201 if (err_code != HAL_OK) {
1202 QSPI_SMART_CS_HIGH(id);
1203 s_qspi_env[id].start_flag = false;
1204 return (uint16_t)err_code;
1205 }
1206 } else {
1207 return APP_DRV_ERR_BUSY;
1208 }
1209
1210 return APP_DRV_SUCCESS;
1211 }
1212
app_qspi_transmit_sync(app_qspi_id_t id,uint8_t * p_data,uint32_t length,uint32_t timeout)1213 uint16_t app_qspi_transmit_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length, uint32_t timeout)
1214 {
1215 hal_status_t err_code;
1216
1217 if (id >= APP_QSPI_ID_MAX ||
1218 p_data == NULL ||
1219 length == 0 ||
1220 s_qspi_env[id].qspi_state == APP_QSPI_INVALID) {
1221 return APP_DRV_ERR_INVALID_PARAM;
1222 }
1223
1224 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1225 qspi_wake_up(id);
1226 #endif
1227 QSPI_SMART_CS_LOW(id);
1228 err_code = hal_qspi_transmit(&s_qspi_env[id].handle, p_data, length, timeout);
1229 QSPI_SMART_CS_HIGH(id);
1230 if (err_code != HAL_OK) {
1231 return err_code;
1232 }
1233
1234 return APP_DRV_SUCCESS;
1235 }
1236
1237 #ifdef ENV_RTOS_USE_SEMP
app_qspi_transmit_sem_sync(app_qspi_id_t id,uint8_t * p_data,uint32_t length)1238 uint16_t app_qspi_transmit_sem_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
1239 {
1240 hal_status_t err_code = HAL_OK;
1241
1242 #ifdef ENV_RTOS_USE_MUTEX
1243 APP_QSPI_DRV_ASYNC_MUTEX_LOCK(id);
1244 #endif
1245
1246 if (id >= APP_QSPI_ID_MAX ||
1247 p_data == NULL ||
1248 length == 0 ||
1249 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1250 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1251 #ifdef ENV_RTOS_USE_MUTEX
1252 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1253 #endif
1254 return APP_DRV_ERR_INVALID_PARAM;
1255 }
1256
1257 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1258 qspi_wake_up(id);
1259 #endif
1260
1261 if (s_qspi_env[id].start_flag == false) {
1262 s_qspi_env[id].start_flag = true;
1263 QSPI_SMART_CS_LOW(id);
1264 switch (s_qspi_env[id].use_mode.type) {
1265 case APP_QSPI_TYPE_INTERRUPT:
1266 err_code = hal_qspi_transmit_it(&s_qspi_env[id].handle, p_data, length);
1267 break;
1268
1269 case APP_QSPI_TYPE_DMA:
1270 err_code = hal_qspi_transmit_dma(&s_qspi_env[id].handle, p_data, length);
1271 break;
1272
1273 default:
1274 break;
1275 }
1276
1277 if (err_code != HAL_OK) {
1278 QSPI_SMART_CS_HIGH(id);
1279 #ifdef ENV_RTOS_USE_MUTEX
1280 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1281 #endif
1282 s_qspi_env[id].start_flag = false;
1283 return (uint16_t)err_code;
1284 }
1285 } else {
1286 #ifdef ENV_RTOS_USE_MUTEX
1287 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1288 #endif
1289 return APP_DRV_ERR_BUSY;
1290 }
1291
1292 app_driver_sem_pend(s_qspi_env[id].sem_tx, OS_WAIT_FOREVER);
1293
1294 #ifdef ENV_RTOS_USE_MUTEX
1295 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1296 #endif
1297
1298 return APP_DRV_SUCCESS;
1299 }
1300 #endif
1301
app_qspi_transmit_high_speed_sync(app_qspi_id_t id,uint8_t * p_data,uint32_t length)1302 uint16_t app_qspi_transmit_high_speed_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
1303 {
1304 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
1305 hal_status_t hal_err_code = HAL_OK;
1306
1307 if (id >= APP_QSPI_ID_MAX ||
1308 p_data == NULL ||
1309 length == 0 ||
1310 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1311 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1312 return APP_DRV_ERR_INVALID_PARAM;
1313 }
1314
1315 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1316 qspi_wake_up(id);
1317 #endif
1318
1319 s_qspi_env[id].user_mode = 0x1;
1320 s_qspi_env[id].tx_done = 0;
1321 if (s_qspi_env[id].start_flag == false) {
1322 s_qspi_env[id].start_flag = true;
1323 QSPI_SMART_CS_LOW(id);
1324 switch (s_qspi_env[id].use_mode.type) {
1325 case APP_QSPI_TYPE_INTERRUPT:
1326 hal_err_code = hal_qspi_transmit_it(&s_qspi_env[id].handle, p_data, length);
1327 break;
1328
1329 case APP_QSPI_TYPE_DMA:
1330 hal_err_code = hal_qspi_transmit_dma(&s_qspi_env[id].handle, p_data, length);
1331 break;
1332
1333 default:
1334 break;
1335 }
1336
1337 if (hal_err_code != HAL_OK) {
1338 QSPI_SMART_CS_HIGH(id);
1339 app_err_code = (uint16_t)hal_err_code;
1340 s_qspi_env[id].start_flag = false;
1341 goto exit;
1342 }
1343 } else {
1344 app_err_code = APP_DRV_ERR_BUSY;
1345 goto exit;
1346 }
1347
1348 while (s_qspi_env[id].tx_done == 0);
1349
1350 exit:
1351 s_qspi_env[id].user_mode = 0x0;
1352
1353 return app_err_code;
1354 }
1355
app_qspi_transmit_async(app_qspi_id_t id,uint8_t * p_data,uint32_t length)1356 uint16_t app_qspi_transmit_async(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
1357 {
1358 hal_status_t err_code = HAL_OK;
1359
1360 if (id >= APP_QSPI_ID_MAX ||
1361 p_data == NULL ||
1362 length == 0 ||
1363 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1364 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1365 return APP_DRV_ERR_INVALID_PARAM;
1366 }
1367
1368 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1369 qspi_wake_up(id);
1370 #endif
1371
1372 if (s_qspi_env[id].start_flag == false) {
1373 s_qspi_env[id].start_flag = true;
1374 QSPI_SMART_CS_LOW(id);
1375 switch (s_qspi_env[id].use_mode.type) {
1376 case APP_QSPI_TYPE_INTERRUPT:
1377 err_code = hal_qspi_transmit_it(&s_qspi_env[id].handle, p_data, length);
1378 break;
1379
1380 case APP_QSPI_TYPE_DMA:
1381 err_code = hal_qspi_transmit_dma(&s_qspi_env[id].handle, p_data, length);
1382 break;
1383
1384 default:
1385 break;
1386 }
1387
1388 if (err_code != HAL_OK) {
1389 QSPI_SMART_CS_HIGH(id);
1390 s_qspi_env[id].start_flag = false;
1391 return (uint16_t)err_code;
1392 }
1393 } else {
1394 return APP_DRV_ERR_BUSY;
1395 }
1396
1397 return APP_DRV_SUCCESS;
1398 }
1399
app_qspi_receive_sync(app_qspi_id_t id,uint8_t * p_data,uint32_t length,uint32_t timeout)1400 uint16_t app_qspi_receive_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length, uint32_t timeout)
1401 {
1402 hal_status_t err_code;
1403
1404 if (id >= APP_QSPI_ID_MAX ||
1405 length == 0 ||
1406 p_data == NULL ||
1407 s_qspi_env[id].qspi_state == APP_QSPI_INVALID) {
1408 return APP_DRV_ERR_INVALID_PARAM;
1409 }
1410
1411 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1412 qspi_wake_up(id);
1413 #endif
1414 QSPI_SMART_CS_LOW(id);
1415 err_code = hal_qspi_receive(&s_qspi_env[id].handle, p_data, length, timeout);
1416 QSPI_SMART_CS_HIGH(id);
1417 if (err_code != HAL_OK) {
1418 return (uint16_t)err_code;
1419 }
1420
1421 return APP_DRV_SUCCESS;
1422 }
1423
1424 #ifdef ENV_RTOS_USE_SEMP
app_qspi_receive_sem_sync(app_qspi_id_t id,uint8_t * p_data,uint32_t length)1425 uint16_t app_qspi_receive_sem_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
1426 {
1427 hal_status_t err_code = HAL_OK;
1428
1429 #ifdef ENV_RTOS_USE_MUTEX
1430 APP_QSPI_DRV_ASYNC_MUTEX_LOCK(id);
1431 #endif
1432
1433 if (id >= APP_QSPI_ID_MAX ||
1434 length == 0 ||
1435 p_data == NULL ||
1436 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1437 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1438 #ifdef ENV_RTOS_USE_MUTEX
1439 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1440 #endif
1441 return APP_DRV_ERR_INVALID_PARAM;
1442 }
1443
1444 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1445 qspi_wake_up(id);
1446 #endif
1447
1448 if (s_qspi_env[id].start_flag == false) {
1449 s_qspi_env[id].start_flag = true;
1450 QSPI_SMART_CS_LOW(id);
1451 switch (s_qspi_env[id].use_mode.type) {
1452 case APP_QSPI_TYPE_INTERRUPT:
1453 err_code = hal_qspi_receive_it(&s_qspi_env[id].handle, p_data, length);
1454 break;
1455
1456 case APP_QSPI_TYPE_DMA:
1457 err_code = hal_qspi_receive_dma(&s_qspi_env[id].handle, p_data, length);
1458 break;
1459
1460 default:
1461 break;
1462 }
1463 if (err_code != HAL_OK) {
1464 QSPI_SMART_CS_HIGH(id);
1465 #ifdef ENV_RTOS_USE_MUTEX
1466 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1467 #endif
1468 s_qspi_env[id].start_flag = false;
1469 return (uint16_t)err_code;
1470 }
1471 } else {
1472 #ifdef ENV_RTOS_USE_MUTEX
1473 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1474 #endif
1475 return APP_DRV_ERR_BUSY;
1476 }
1477
1478 app_driver_sem_pend(s_qspi_env[id].sem_rx, OS_WAIT_FOREVER);
1479
1480 #ifdef ENV_RTOS_USE_MUTEX
1481 APP_QSPI_DRV_ASYNC_MUTEX_UNLOCK(id);
1482 #endif
1483
1484 return APP_DRV_SUCCESS;
1485 }
1486 #endif
1487
app_qspi_receive_high_speed_sync(app_qspi_id_t id,uint8_t * p_data,uint32_t length)1488 uint16_t app_qspi_receive_high_speed_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
1489 {
1490 app_drv_err_t app_err_code = APP_DRV_SUCCESS;
1491 hal_status_t hal_err_code = HAL_OK;
1492
1493 if (id >= APP_QSPI_ID_MAX ||
1494 length == 0 ||
1495 p_data == NULL ||
1496 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1497 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1498 return APP_DRV_ERR_INVALID_PARAM;
1499 }
1500
1501 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1502 qspi_wake_up(id);
1503 #endif
1504
1505 s_qspi_env[id].user_mode = 0x1;
1506 s_qspi_env[id].rx_done = 0;
1507 if (s_qspi_env[id].start_flag == false) {
1508 s_qspi_env[id].start_flag = true;
1509 QSPI_SMART_CS_LOW(id);
1510 switch (s_qspi_env[id].use_mode.type) {
1511 case APP_QSPI_TYPE_INTERRUPT:
1512 hal_err_code = hal_qspi_receive_it(&s_qspi_env[id].handle, p_data, length);
1513 break;
1514
1515 case APP_QSPI_TYPE_DMA:
1516 hal_err_code = hal_qspi_receive_dma(&s_qspi_env[id].handle, p_data, length);
1517 break;
1518
1519 default:
1520 break;
1521 }
1522 if (hal_err_code != HAL_OK) {
1523 QSPI_SMART_CS_HIGH(id);
1524 app_err_code = (uint16_t)hal_err_code;
1525 s_qspi_env[id].start_flag = false;
1526 goto exit;
1527 }
1528 } else {
1529 app_err_code = APP_DRV_ERR_BUSY;
1530 goto exit;
1531 }
1532
1533 while (s_qspi_env[id].rx_done == 0);
1534
1535 exit:
1536 s_qspi_env[id].user_mode = 0x0;
1537
1538 return app_err_code;
1539 }
1540
app_qspi_receive_async(app_qspi_id_t id,uint8_t * p_data,uint32_t length)1541 uint16_t app_qspi_receive_async(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
1542 {
1543 hal_status_t err_code = HAL_OK;
1544
1545 if (id >= APP_QSPI_ID_MAX ||
1546 length == 0 ||
1547 p_data == NULL ||
1548 s_qspi_env[id].qspi_state == APP_QSPI_INVALID ||
1549 s_qspi_env[id].use_mode.type == APP_QSPI_TYPE_POLLING) {
1550 return APP_DRV_ERR_INVALID_PARAM;
1551 }
1552
1553 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1554 qspi_wake_up(id);
1555 #endif
1556
1557 if (s_qspi_env[id].start_flag == false) {
1558 s_qspi_env[id].start_flag = true;
1559 QSPI_SMART_CS_LOW(id);
1560 switch (s_qspi_env[id].use_mode.type) {
1561 case APP_QSPI_TYPE_INTERRUPT:
1562 err_code = hal_qspi_receive_it(&s_qspi_env[id].handle, p_data, length);
1563 break;
1564
1565 case APP_QSPI_TYPE_DMA:
1566 err_code = hal_qspi_receive_dma(&s_qspi_env[id].handle, p_data, length);
1567 break;
1568
1569 default:
1570 break;
1571 }
1572 if (err_code != HAL_OK) {
1573 QSPI_SMART_CS_HIGH(id);
1574 s_qspi_env[id].start_flag = false;
1575 return (uint16_t)err_code;
1576 }
1577 } else {
1578 return APP_DRV_ERR_BUSY;
1579 }
1580
1581 return APP_DRV_SUCCESS;
1582 }
1583
app_qspi_get_handle(app_qspi_id_t id)1584 qspi_handle_t *app_qspi_get_handle(app_qspi_id_t id)
1585 {
1586 if (id >= APP_QSPI_ID_MAX ||
1587 s_qspi_env[id].qspi_state == APP_QSPI_INVALID) {
1588 return NULL;
1589 }
1590
1591 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
1592 qspi_wake_up(id);
1593 #endif
1594
1595 return &s_qspi_env[id].handle;
1596 }
1597
hal_qspi_error_callback(qspi_handle_t * p_qspi)1598 void hal_qspi_error_callback(qspi_handle_t *p_qspi)
1599 {
1600 app_qspi_event_call(p_qspi, APP_QSPI_EVT_ERROR);
1601 }
1602
hal_qspi_rx_cplt_callback(qspi_handle_t * p_qspi)1603 void hal_qspi_rx_cplt_callback(qspi_handle_t *p_qspi)
1604 {
1605 app_qspi_event_call(p_qspi, APP_QSPI_EVT_RX_DATA);
1606 }
1607
hal_qspi_tx_cplt_callback(qspi_handle_t * p_qspi)1608 void hal_qspi_tx_cplt_callback(qspi_handle_t *p_qspi)
1609 {
1610 app_qspi_event_call(p_qspi, APP_QSPI_EVT_TX_CPLT);
1611 }
1612
QSPI0_IRQHandler(void)1613 SECTION_RAM_CODE void QSPI0_IRQHandler(void)
1614 {
1615 #if FLASH_PROTECT_PRIORITY
1616 platform_interrupt_protection_push();
1617 #endif
1618 hal_qspi_irq_handler(&s_qspi_env[APP_QSPI_ID_0].handle);
1619 #if FLASH_PROTECT_PRIORITY
1620 platform_interrupt_protection_pop();
1621 #endif
1622 }
1623
QSPI1_IRQHandler(void)1624 SECTION_RAM_CODE void QSPI1_IRQHandler(void)
1625 {
1626 #if FLASH_PROTECT_PRIORITY
1627 platform_interrupt_protection_push();
1628 #endif
1629 hal_qspi_irq_handler(&s_qspi_env[APP_QSPI_ID_1].handle);
1630 #if FLASH_PROTECT_PRIORITY
1631 platform_interrupt_protection_pop();
1632 #endif
1633 }
1634
1635 #endif
1636