app_qspi.h
Go to the documentation of this file.
1
52 #ifndef _APP_QSPI_H_
53 #define _APP_QSPI_H_
54
55 #include "gr55xx_hal.h"
56 #include "app_io.h"
57 #include "app_drv_error.h"
58 #include "app_rtos_cfg.h"
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 #ifdef HAL_QSPI_MODULE_ENABLED
65
70 #define APP_QSPI_PIN_ENABLE 1
71 #define APP_QSPI_PIN_DISABLE 0
82 typedef enum
83 {
84 APP_QSPI_ID_0,
85 APP_QSPI_ID_1,
86 APP_QSPI_ID_MAX
87 } app_qspi_id_t;
88
92 typedef enum
93 {
94 APP_QSPI_TYPE_INTERRUPT,
95 APP_QSPI_TYPE_POLLING,
96 APP_QSPI_TYPE_DMA,
97 APP_QSPI_TYPE_MAX,
98 } app_qspi_type_t;
99
103 typedef enum
104 {
105 APP_QSPI_EVT_ERROR,
106 APP_QSPI_EVT_TX_CPLT,
107 APP_QSPI_EVT_RX_DATA,
108 } app_qspi_evt_type_t;
118 typedef struct
119 {
120 app_io_type_t type;
121 app_io_mux_t mux;
122 uint32_t pin;
124 app_io_pull_t pull;
125 uint8_t enable;
126 } app_qspi_pin_t;
127
131 typedef struct
132 {
133 app_qspi_pin_t cs;
134 app_qspi_pin_t clk;
135 app_qspi_pin_t io_0;
136 app_qspi_pin_t io_1;
137 app_qspi_pin_t io_2;
138 app_qspi_pin_t io_3;
139 } app_qspi_pin_cfg_t;
140
144 typedef struct
145 {
146 app_qspi_type_t type;
147 dma_channel_t dma_channel;
148 } app_qspi_mode_t;
149
153 typedef struct
154 {
155 app_qspi_id_t id;
156 app_qspi_pin_cfg_t pin_cfg;
157 app_qspi_mode_t use_mode;
158 qspi_init_t init;
159 } app_qspi_params_t;
160
169 typedef qspi_command_t app_qspi_command_t;
179 typedef struct
180 {
181 app_qspi_evt_type_t type;
182 union
183 {
184 uint32_t error_code;
185 uint16_t size;
186 } data;
187 } app_qspi_evt_t;
196 typedef void (*app_qspi_evt_handler_t)(app_qspi_evt_t *p_evt);
200 /* Exported functions --------------------------------------------------------*/
218 uint16_t app_qspi_init(app_qspi_params_t *p_params, app_qspi_evt_handler_t evt_handler);
219
229 uint16_t app_qspi_deinit(app_qspi_id_t id);
230
243 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);
244
256 uint16_t app_qspi_command_receive_async(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data);
257
270 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);
271
283 uint16_t app_qspi_command_transmit_async(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data);
284
296 uint16_t app_qspi_command_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint32_t timeout);
297
308 uint16_t app_qspi_command_async(app_qspi_id_t id, app_qspi_command_t *p_cmd);
309
322 uint16_t app_qspi_transmit_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length, uint32_t timeout);
323
335 uint16_t app_qspi_transmit_async(app_qspi_id_t id, uint8_t *p_data, uint32_t length);
336
349 uint16_t app_qspi_receive_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length, uint32_t timeout);
350
362 uint16_t app_qspi_receive_async(app_qspi_id_t id, uint8_t *p_data, uint32_t length);
363
375 uint16_t app_qspi_transmit_in_qpi_async(app_qspi_id_t id, uint32_t data_width, uint8_t *p_data, uint32_t length);
376
386 qspi_handle_t *app_qspi_get_handle(app_qspi_id_t id);
387
388 #ifdef ENV_RTOS_USE_SEMP
389
401 uint16_t app_qspi_command_receive_sem_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data);
402
414 uint16_t app_qspi_command_transmit_sem_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data);
415
426 uint16_t app_qspi_command_sem_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd);
427
439 uint16_t app_qspi_transmit_sem_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length);
440
452 uint16_t app_qspi_receive_sem_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length);
453
454 #endif
455
467 uint16_t app_qspi_command_receive_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data);
468
480 uint16_t app_qspi_command_transmit_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data);
481
492 uint16_t app_qspi_command_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd);
493
505 uint16_t app_qspi_transmit_high_speed_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length);
506
518 uint16_t app_qspi_receive_high_speed_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length);
519
522 #endif
523
524 #ifdef __cplusplus
525 }
526 #endif
527
528 #endif
529
app_qspi_command_receive_sync
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)
Receive an amount of data with the specified instruction, address and dummy cycles in blocking mode.
app_qspi_command_t
qspi_command_t app_qspi_command_t
QSPI command structure definition.
Definition: app_qspi.h:169
app_qspi_evt_t::size
uint16_t size
Definition: app_qspi.h:185
app_qspi_get_handle
qspi_handle_t * app_qspi_get_handle(app_qspi_id_t id)
Return the QSPI handle.
app_qspi_pin_t::pull
app_io_pull_t pull
Definition: app_qspi.h:124
app_qspi_params_t::id
app_qspi_id_t id
Definition: app_qspi.h:155
APP_QSPI_ID_1
@ APP_QSPI_ID_1
Definition: app_qspi.h:85
APP_QSPI_TYPE_MAX
@ APP_QSPI_TYPE_MAX
Definition: app_qspi.h:97
APP_QSPI_TYPE_DMA
@ APP_QSPI_TYPE_DMA
Definition: app_qspi.h:96
app_qspi_mode_t
QSPI operate mode Enumerations definition.
Definition: app_qspi.h:145
app_qspi_command_high_speed_sync
uint16_t app_qspi_command_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd)
[High speed] Transmit only instruction in blocking mode.
app_qspi_transmit_async
uint16_t app_qspi_transmit_async(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode at standard SPI with Interrupt.
app_qspi_pin_cfg_t::io_3
app_qspi_pin_t io_3
Definition: app_qspi.h:138
app_qspi_pin_t
QSPI IO configuration Structures.
Definition: app_qspi.h:119
app_qspi_command_transmit_async
uint16_t app_qspi_command_transmit_async(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
Receive an amount of data with the specified instruction, address and dummy cycles in non-blocking mo...
app_qspi_type_t
app_qspi_type_t
QSPI operating mode Enumerations definition.
Definition: app_qspi.h:93
APP_QSPI_ID_0
@ APP_QSPI_ID_0
Definition: app_qspi.h:84
app_qspi_command_transmit_high_speed_sync
uint16_t app_qspi_command_transmit_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
[High speed] Receive an amount of data with the specified instruction, address and dummy cycles in bl...
app_qspi_evt_t
QSPI event structure definition.
Definition: app_qspi.h:180
app_io_pull_t
app_io_pull_t
GPIO pull Enumerations definition.
Definition: app_io.h:187
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:141
app_qspi_deinit
uint16_t app_qspi_deinit(app_qspi_id_t id)
De-initialize the APP QSPI DRIVER peripheral.
app_qspi_receive_high_speed_sync
uint16_t app_qspi_receive_high_speed_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
[High speed] Receive an amount of data in blocking mode with standard SPI.
_qspi_init_t
QSPI init Structure definition.
Definition: gr55xx_hal_qspi.h:103
APP_QSPI_EVT_ERROR
@ APP_QSPI_EVT_ERROR
Definition: app_qspi.h:105
APP_QSPI_TYPE_POLLING
@ APP_QSPI_TYPE_POLLING
Definition: app_qspi.h:95
app_qspi_pin_cfg_t::cs
app_qspi_pin_t cs
Definition: app_qspi.h:133
app_qspi_evt_t::error_code
uint32_t error_code
Definition: app_qspi.h:184
_qspi_command_t
QSPI command Structure definition.
Definition: gr55xx_hal_qspi.h:166
app_qspi_pin_t::mux
app_io_mux_t mux
Definition: app_qspi.h:121
APP_QSPI_EVT_RX_DATA
@ APP_QSPI_EVT_RX_DATA
Definition: app_qspi.h:107
app_qspi_id_t
app_qspi_id_t
QSPI module Enumerations definition.
Definition: app_qspi.h:83
app_io.h
Header file containing functions prototypes of GPIO app library.
app_qspi_pin_cfg_t
QSPI configuration Structures.
Definition: app_qspi.h:132
app_qspi_evt_handler_t
void(* app_qspi_evt_handler_t)(app_qspi_evt_t *p_evt)
QSPI event callback definition.
Definition: app_qspi.h:196
app_qspi_command_receive_async
uint16_t app_qspi_command_receive_async(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
Receive an amount of data with the specified instruction, address and dummy cycles in non-blocking mo...
app_qspi_command_sync
uint16_t app_qspi_command_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint32_t timeout)
Transmit only instruction in blocking mode.
app_qspi_pin_t::pin
uint32_t pin
Definition: app_qspi.h:122
app_qspi_mode_t::type
app_qspi_type_t type
Definition: app_qspi.h:146
app_qspi_params_t::use_mode
app_qspi_mode_t use_mode
Definition: app_qspi.h:157
app_qspi_pin_t::enable
uint8_t enable
Definition: app_qspi.h:125
app_qspi_receive_sync
uint16_t app_qspi_receive_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length, uint32_t timeout)
Receive an amount of data in blocking mode with standard SPI.
app_qspi_pin_cfg_t::io_1
app_qspi_pin_t io_1
Definition: app_qspi.h:136
APP_QSPI_EVT_TX_CPLT
@ APP_QSPI_EVT_TX_CPLT
Definition: app_qspi.h:106
app_qspi_params_t::init
qspi_init_t init
Definition: app_qspi.h:158
app_qspi_params_t::pin_cfg
app_qspi_pin_cfg_t pin_cfg
Definition: app_qspi.h:156
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_qspi_command_async
uint16_t app_qspi_command_async(app_qspi_id_t id, app_qspi_command_t *p_cmd)
Transmit instruction in non-blocking mode with Interrupt.
app_qspi_receive_async
uint16_t app_qspi_receive_async(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode at standard SPI with Interrupt.
app_qspi_transmit_in_qpi_async
uint16_t app_qspi_transmit_in_qpi_async(app_qspi_id_t id, uint32_t data_width, uint8_t *p_data, uint32_t length)
Transmit an amount of data in QPI mode (Async Mode).
app_qspi_command_receive_high_speed_sync
uint16_t app_qspi_command_receive_high_speed_sync(app_qspi_id_t id, app_qspi_command_t *p_cmd, uint8_t *p_data)
[High speed] Receive an amount of data with the specified instruction, address and dummy cycles in bl...
app_qspi_pin_cfg_t::clk
app_qspi_pin_t clk
Definition: app_qspi.h:134
APP_QSPI_ID_MAX
@ APP_QSPI_ID_MAX
Definition: app_qspi.h:86
app_qspi_evt_type_t
app_qspi_evt_type_t
APP QSPI Event Type.
Definition: app_qspi.h:104
app_qspi_transmit_high_speed_sync
uint16_t app_qspi_transmit_high_speed_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length)
[High speed] Transmit an amount of data in blocking mode with standard SPI.
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_qspi_evt_t::type
app_qspi_evt_type_t type
Definition: app_qspi.h:181
app_qspi_mode_t::dma_channel
dma_channel_t dma_channel
Definition: app_qspi.h:147
app_qspi_transmit_sync
uint16_t app_qspi_transmit_sync(app_qspi_id_t id, uint8_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in blocking mode with standard SPI.
app_qspi_pin_cfg_t::io_2
app_qspi_pin_t io_2
Definition: app_qspi.h:137
app_rtos_cfg.h
Header file of app rtos config code.
app_drv_error.h
Header file of app driver error code.
app_qspi_pin_t::type
app_io_type_t type
Definition: app_qspi.h:120
app_qspi_init
uint16_t app_qspi_init(app_qspi_params_t *p_params, app_qspi_evt_handler_t evt_handler)
Initialize the APP QSPI DRIVER according to the specified parameters in the app_qspi_params_t and app...
_qspi_handle
QSPI handle Structure definition.
Definition: gr55xx_hal_qspi.h:123
app_qspi_command_transmit_sync
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)
Receive an amount of data with the specified instruction, address and dummy cycles in blocking mode.
app_qspi_params_t
QSPI parameters structure definition.
Definition: app_qspi.h:154
app_qspi_pin_cfg_t::io_0
app_qspi_pin_t io_0
Definition: app_qspi.h:135
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93
APP_QSPI_TYPE_INTERRUPT
@ APP_QSPI_TYPE_INTERRUPT
Definition: app_qspi.h:94