app_spi_v2.h
Go to the documentation of this file.
1
50 #ifndef _APP_SPI_V2_H_
51 #define _APP_SPI_V2_H_
52
53 #include "gr55xx_hal.h"
54 #include "app_io.h"
55 #include "app_drv_error.h"
56 #include "app_rtos_cfg.h"
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 #ifdef HAL_SPI_V2_MODULE_ENABLED
63
64
65 #ifdef _APP_SPI_H_
66 #error "NOT Support USING app_spi AND app_spi_v2 AT The Same Time !!!"
67 #endif
68
73 #define APP_SPI_PIN_ENABLE 1
74 #define APP_SPI_PIN_DISABLE 0
85 typedef enum
86 {
87 APP_SPI_ID_SLAVE,
88 APP_SPI_ID_MASTER,
89 APP_SPI_ID_MAX,
90 } app_spi_id_t;
91
95 typedef enum
96 {
97 APP_SPI_TYPE_POLLING,
98 APP_SPI_TYPE_DMA,
99 APP_SPI_TYPE_MAX,
100 } app_spi_type_t;
101
105 typedef enum
106 {
107 APP_SPI_DATAWIDTH_8BIT = 0x00,
108 APP_SPI_DATAWIDTH_32BIT,
109 } app_spi_datawidth_t;
110
111
115 typedef enum
116 {
117 APP_SPI_EVT_ERROR,
118 APP_SPI_EVT_TX_CPLT,
119 APP_SPI_EVT_RX_DATA,
120 APP_SPI_EVT_TX_RX,
121 } app_spi_evt_type_t;
130 typedef struct
131 {
132 app_io_type_t type;
133 app_io_mux_t mux;
134 uint32_t pin;
136 app_io_pull_t pull;
137 uint8_t enable;
138 } app_spi_pin_t;
139
143 typedef struct
144 {
145 app_spi_pin_t cs;
146 app_spi_pin_t clk;
147 app_spi_pin_t mosi;
148 app_spi_pin_t miso;
149 } app_spi_pin_cfg_t;
150
154 typedef struct
155 {
156 app_spi_type_t type;
157 dma_channel_t tx_dma_channel;
158 dma_channel_t rx_dma_channel;
159 } app_spi_mode_t;
160
164 typedef struct
165 {
166 app_spi_id_t id;
167 app_spi_pin_cfg_t pin_cfg;
168 app_spi_mode_t use_mode;
169 spi_init_t init;
170 uint32_t rx_sample_delay;
172 } app_spi_params_t;
173
177 typedef struct
178 {
179 app_spi_evt_type_t type;
180 union
181 {
182 uint32_t error_code;
183 uint16_t size;
184 } data;
185 } app_spi_evt_t;
186
190 typedef void (*app_spi_evt_handler_t)(app_spi_evt_t *p_evt);
191
194 /* Exported functions --------------------------------------------------------*/
213 uint16_t app_spi_v2_init(app_spi_params_t *p_params, app_spi_evt_handler_t evt_handler);
214
224 uint16_t app_spi_v2_deinit(app_spi_id_t id);
225
226
240 uint16_t app_spi_v2_transmit_poll_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t *p_data, uint16_t size, uint32_t timeout);
241
257 uint16_t app_spi_v2_transmit_with_ia_poll_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t inst, uint32_t addr, uint8_t *p_data, uint16_t size, uint32_t timeout);
258
272 uint16_t app_spi_v2_receive_poll_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t *p_data, uint16_t size, uint32_t timeout);
273
289 uint16_t app_spi_v2_receive_with_ia_poll_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t inst, uint32_t addr, uint8_t *p_data, uint16_t size, uint32_t timeout);
290
305 uint16_t app_spi_v2_transmit_receive_8bit_poll_sync(app_spi_id_t id, uint8_t *tx_data, uint16_t tx_size, uint8_t *rx_data, uint16_t rx_size, uint32_t timeout);
306
319 uint16_t app_spi_v2_transmit_dma_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t *p_data, uint16_t size);
320
335 uint16_t app_spi_v2_transmit_with_ia_dma_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t inst, uint32_t addr, uint8_t *p_data, uint16_t size);
336
349 uint16_t app_spi_v2_receive_dma_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t *p_data, uint16_t size);
350
365 uint16_t app_spi_v2_receive_with_ia_dma_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t inst, uint32_t addr, uint8_t *p_data, uint16_t size);
366
379 uint16_t app_spi_v2_cs_toggle_transmit_dma_sync(app_spi_id_t id, uint32_t data_width, uint8_t *p_data, uint16_t size);
380
393 uint16_t app_spi_v2_cs_toggle_transmit_dma_async(app_spi_id_t id, uint32_t data_width, uint8_t *p_data, uint16_t size);
394
395 #ifdef ENV_RTOS_USE_SEMP
396
411 uint16_t app_spi_v2_transmit_with_ia_dma_sem_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t inst, uint32_t addr, uint8_t *p_data, uint16_t size);
412
425 uint16_t app_spi_v2_transmit_dma_sem_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t *p_data, uint16_t size);
426
441 uint16_t app_spi_v2_receive_with_ia_dma_sem_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t inst, uint32_t addr, uint8_t *p_data, uint16_t size);
442
455 uint16_t app_spi_v2_receive_dma_sem_sync(app_spi_id_t id, app_spi_datawidth_t data_width, uint8_t *p_data, uint16_t size);
456
457 #endif
458
468 spi_handle_t *app_spi_v2_get_handle(app_spi_id_t id);
469
470
474 #endif
475
476 #ifdef __cplusplus
477 }
478 #endif
479
480 #endif
481
app_spi_pin_cfg_t
SPI IO configuration Structures.
Definition: app_spi.h:136
_spi_handle
SPI handle Structure definition.
Definition: gr55xx_hal_spi.h:135
APP_SPI_TYPE_MAX
@ APP_SPI_TYPE_MAX
Definition: app_spi.h:101
APP_SPI_ID_MAX
@ APP_SPI_ID_MAX
Definition: app_spi.h:90
APP_SPI_ID_SLAVE
@ APP_SPI_ID_SLAVE
Definition: app_spi.h:88
APP_SPI_TYPE_DMA
@ APP_SPI_TYPE_DMA
Definition: app_spi.h:100
app_spi_evt_handler_t
void(* app_spi_evt_handler_t)(app_spi_evt_t *p_evt)
SPI event callback definition.
Definition: app_spi.h:180
app_spi_params_t
SPI parameters structure definition.
Definition: app_spi.h:157
_spi_init
SPI init Structure definition.
Definition: gr55xx_hal_spi.h:104
app_spi_evt_t
SPI event structure definition.
Definition: app_spi.h:168
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_SPI_ID_MASTER
@ APP_SPI_ID_MASTER
Definition: app_spi.h:89
APP_SPI_TYPE_POLLING
@ APP_SPI_TYPE_POLLING
Definition: app_spi.h:99
app_io.h
Header file containing functions prototypes of GPIO app library.
APP_SPI_EVT_TX_RX
@ APP_SPI_EVT_TX_RX
Definition: app_spi.h:112
app_spi_id_t
app_spi_id_t
SPI module Enumerations definition.
Definition: app_spi.h:87
app_spi_pin_t
SPI IO Structures.
Definition: app_spi.h:123
app_spi_evt_type_t
app_spi_evt_type_t
SPI event Enumerations definition.
Definition: app_spi.h:108
app_spi_type_t
app_spi_type_t
SPI operating mode Enumerations definition.
Definition: app_spi.h:97
APP_SPI_EVT_TX_CPLT
@ APP_SPI_EVT_TX_CPLT
Definition: app_spi.h:110
APP_SPI_EVT_RX_DATA
@ APP_SPI_EVT_RX_DATA
Definition: app_spi.h:111
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_rtos_cfg.h
Header file of app rtos config code.
app_drv_error.h
Header file of app driver error code.
APP_SPI_EVT_ERROR
@ APP_SPI_EVT_ERROR
Definition: app_spi.h:109
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93
app_spi_mode_t
SPI operate mode Enumerations definition.
Definition: app_spi.h:147