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_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
367
368 #ifdef ENV_RTOS_USE_SEMP
369
384 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);
385
398 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);
399
414 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);
415
428 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);
429
430 #endif
431
441 spi_handle_t *app_spi_v2_get_handle(app_spi_id_t id);
442
443
447 #endif
448
449 #ifdef __cplusplus
450 }
451 #endif
452
453 #endif
454
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_v2.h:99
APP_SPI_ID_MAX
@ APP_SPI_ID_MAX
Definition: app_spi_v2.h:89
APP_SPI_ID_SLAVE
@ APP_SPI_ID_SLAVE
Definition: app_spi_v2.h:87
app_spi_v2_receive_dma_sync
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)
Receive in master mode an amount of data in dma mode, without inst & addr.
app_spi_v2_deinit
uint16_t app_spi_v2_deinit(app_spi_id_t id)
De-initialize the APP SPI DRIVER peripheral.
APP_SPI_TYPE_DMA
@ APP_SPI_TYPE_DMA
Definition: app_spi_v2.h:98
app_spi_evt_handler_t
void(* app_spi_evt_handler_t)(app_spi_evt_t *p_evt)
SPI event callback definition.
Definition: app_spi_v2.h:190
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_DATAWIDTH_8BIT
@ APP_SPI_DATAWIDTH_8BIT
Definition: app_spi_v2.h:107
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_v2_receive_poll_sync
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)
Receive in master or slave mode an amount of data in blocking mode , without inst & addr.
app_spi_v2_get_handle
spi_handle_t * app_spi_v2_get_handle(app_spi_id_t id)
Return the SPI handle.
APP_SPI_ID_MASTER
@ APP_SPI_ID_MASTER
Definition: app_spi_v2.h:88
APP_SPI_TYPE_POLLING
@ APP_SPI_TYPE_POLLING
Definition: app_spi_v2.h:97
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_v2.h:120
app_spi_id_t
app_spi_id_t
SPI module Enumerations definition.
Definition: app_spi_v2.h:86
app_spi_v2_receive_with_ia_dma_sync
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)
app_spi_v2_transmit_receive_8bit_poll_sync
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)
Transmits then Receive an amount of data in blocking mode in master mode .
app_spi_pin_t
SPI IO Structures.
Definition: app_spi.h:123
app_spi_v2_transmit_with_ia_poll_sync
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)
Transmits an amount of data in blocking mode in master mode , with inst & addr.
app_spi_params_t::rx_sample_delay
uint32_t rx_sample_delay
Definition: app_spi_v2.h:170
APP_SPI_DATAWIDTH_32BIT
@ APP_SPI_DATAWIDTH_32BIT
Definition: app_spi_v2.h:108
app_spi_v2_init
uint16_t app_spi_v2_init(app_spi_params_t *p_params, app_spi_evt_handler_t evt_handler)
Initialize the APP SPI DRIVER according to the specified parameters in the app_spi_params_t and app_s...
app_spi_v2_transmit_poll_sync
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)
Transmits in master or slave mode an amount of data in blocking mode, without inst & addr.
app_spi_evt_type_t
app_spi_evt_type_t
SPI event Enumerations definition.
Definition: app_spi_v2.h:116
app_spi_type_t
app_spi_type_t
SPI operating mode Enumerations definition.
Definition: app_spi_v2.h:96
APP_SPI_EVT_TX_CPLT
@ APP_SPI_EVT_TX_CPLT
Definition: app_spi_v2.h:118
APP_SPI_EVT_RX_DATA
@ APP_SPI_EVT_RX_DATA
Definition: app_spi_v2.h:119
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_spi_datawidth_t
app_spi_datawidth_t
SPI operating mode Enumerations definition.
Definition: app_spi_v2.h:106
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_spi_v2_transmit_dma_sync
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)
Transmits in master mode an amount of data in dma mode, without inst & addr.
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_v2.h:117
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93
app_spi_v2_receive_with_ia_poll_sync
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)
Receivean amount of data in blocking mode in master mode with instruction and address .
app_spi_v2_transmit_with_ia_dma_sync
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)
Transmits in master mode an amount of data in dma mode, with inst & addr.
app_spi_mode_t
SPI operate mode Enumerations definition.
Definition: app_spi.h:147