app_spi.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file app_spi.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of SPI app library.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 ****************************************************************************************
36 */
37
38 /** @addtogroup PERIPHERAL Peripheral Driver
39 * @{
40 */
41
42 /** @addtogroup APP_DRIVER APP DRIVER
43 * @{
44 */
45
46 /** @defgroup APP_SPI SPI
47 * @brief SPI APP module driver.
48 * @{
49 */
50
51
52 #ifndef _APP_SPI_H_
53 #define _APP_SPI_H_
54
55 #include "app_io.h"
56 #include "app_dma.h"
57 #include "app_drv_error.h"
58 #include "app_drv_config.h"
59 #include <stdbool.h>
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 #ifdef HAL_SPI_MODULE_ENABLED
65
66 /** @addtogroup APP_SPI_DEFINE Defines
67 * @{
68 */
69
70 #define APP_SPI_PIN_ENABLE 1 /**< SPI pin enable */
71 #define APP_SPI_PIN_DISABLE 0 /**< SPI pin disable */
72
73 /** @} */
74
75 /** @addtogroup APP_SPI_ENUM Enumerations
76 * @{
77 */
78
79 /**
80 * @brief SPI module Enumerations definition
81 */
82 typedef enum
83 {
84 APP_SPI_ID_SLAVE, /**< SPI slave module. */
85 APP_SPI_ID_MASTER, /**< SPI master module. */
86 APP_SPI_ID_MAX, /**< Only for check parameter, not used as input parameters. */
87 } app_spi_id_t;
88
89
90 /**
91 * @brief SPI event Enumerations definition
92 */
93 typedef enum
94 {
95 APP_SPI_EVT_ERROR, /**< Error reported by UART peripheral. */
96 APP_SPI_EVT_TX_CPLT, /**< Requested TX transfer completed. */
97 APP_SPI_EVT_RX_CPLT, /**< Requested RX transfer completed. */
98 APP_SPI_EVT_TX_RX_CPLT, /**< Requested TX/RX transfer completed. */
99 APP_SPI_EVT_ABORT, /**< Abort reported by SPI peripheral. */
100 } app_spi_evt_type_t;
101 /** @} */
102
103 /** @addtogroup APP_SPI_STRUCTURES Structures
104 * @{
105 */
106 /**
107 * @brief SPI IO Structures
108 */
109 typedef struct
110 {
111 app_io_type_t type; /**< Specifies the type of SPI IO. */
112 app_io_mux_t mux; /**< Specifies the Peripheral to be connected to the selected pins. */
113 uint32_t pin; /**< Specifies the IO pins to be configured.
114 This parameter can be any value of @ref GR5xxx_pins. */
115 app_io_mode_t mode; /**< Specifies the mode for the selected pins. */
116 app_io_pull_t pull; /**< Specifies the Pull-up or Pull-Down activation for the selected pins. */
117 uint8_t enable; /**< Enable or disable the pin. */
118 } app_spi_pin_t;
119
120 /**
121 * @brief SPI IO configuration Structures
122 */
123 typedef struct
124 {
125 app_spi_pin_t cs; /**< Set the configuration of SPI CS pin. */
126 app_spi_pin_t clk; /**< Set the configuration of SPI CLK pin. */
127 app_spi_pin_t mosi; /**< Set the configuration of SPI MOSI pin. */
128 app_spi_pin_t miso; /**< Set the configuration of SPI MISO pin. */
129 } app_spi_pin_cfg_t;
130
131 /**
132 * @brief SPI configuration definition.
133 */
134 typedef struct
135 {
136 dma_regs_t * tx_dma_instance; /**< Specifies the TX DMA instance. */
137 dma_regs_t * rx_dma_instance; /**< Specifies the RX DMA instance. */
138 dma_channel_t tx_dma_channel; /**< Specifies the dma channel of SPI TX. */
139 dma_channel_t rx_dma_channel; /**< Specifies the dma channel of SPI RX. */
140 #if (APP_DRIVER_CHIP_TYPE != APP_DRIVER_GR551X)
141 uint32_t wait_timeout_ms; /**< Specifies timeout time of polling and dead wait, ms. */
142 uint32_t extend; /**< Specifies extend segment, to use */
143 #endif
144 } app_spi_dma_cfg_t;
145
146 /**
147 * @brief SPI event structure definition
148 */
149 typedef struct
150 {
151 app_spi_evt_type_t type; /**< Type of event. */
152 union
153 {
154 uint32_t error_code; /**< SPI Error code . */
155 uint16_t size; /**< SPI transmitted/received counter. */
156 } data; /**< SPI data. */
157 } app_spi_evt_t;
158
159 /** @} */
160
161 /** @addtogroup APP_SPI_TYPEDEFS Type definitions
162 * @{
163 */
164 /**
165 * @brief SPI event callback definition
166 */
167 typedef void (*app_spi_evt_handler_t)(app_spi_evt_t *p_evt);
168
169 /** @} */
170
171 /** @addtogroup APP_SPI_ENUM Enumerations
172 * @{
173 */
174 /**@brief App spi state types. */
175 typedef enum
176 {
177 APP_SPI_INVALID = 0,
178 APP_SPI_ACTIVITY,
179 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
180 APP_SPI_SLEEP,
181 #endif
182 } app_spi_state_t;
183
184 /**@brief App spi dma state types. */
185 typedef enum
186 {
187 APP_SPI_DMA_INVALID = 0,
188 APP_SPI_DMA_ACTIVITY,
189 } app_spi_dma_state_t;
190
191 /** @} */
192
193 /** @addtogroup APP_SPI_STRUCTURES Structures
194 * @{
195 */
196 /**
197 * @brief SPI device structure definition
198 */
199 typedef struct
200 {
201 app_spi_evt_handler_t evt_handler; /**< SPI event callback. */
202 spi_handle_t handle; /**< SPI handle Structure. */
203 app_spi_pin_cfg_t *p_pin_cfg; /**< SPI IO configuration Structures. */
204 dma_id_t dma_id[2]; /**< DMA id. */
205 app_spi_state_t spi_state; /**< App spi state types. */
206 app_spi_dma_state_t spi_dma_state; /**< App spi dma state types. */
207 volatile bool start_flag; /**< start flag. */
208 volatile bool is_soft_cs; /**< soft cs. */
209 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR551X)
210 volatile uint8_t rx_done; /**< rx done. */
211 volatile uint8_t tx_done; /**< tx done. */
212 #endif
213 } spi_env_t;
214
215 /**
216 * @brief SPI parameters structure definition
217 */
218 typedef struct
219 {
220 app_spi_id_t id; /**< specified SPI module ID. */
221 app_spi_pin_cfg_t pin_cfg; /**< the pin configuration information for the specified SPI module. */
222 app_spi_dma_cfg_t dma_cfg; /**< SPI DMA configuration. */
223 spi_init_t init; /**< SPI communication parameters. */
224 bool is_soft_cs; /**< config whether to control CS signal by software */
225 spi_env_t spi_env; /**< SPI device structure definition. */
226 } app_spi_params_t;
227
228 /** @} */
229
230 /* Exported functions --------------------------------------------------------*/
231 /** @addtogroup APP_SPI_DRIVER_FUNCTIONS Functions
232 * @{
233 */
234 /**
235 ****************************************************************************************
236 * @brief Initialize the APP SPI DRIVER according to the specified parameters
237 * in the app_spi_params_t and app_spi_evt_handler_t.
238 * @note If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode
239 * is set, you can't use interrupt mode.
240 *
241 * @param[in] p_params: Pointer to app_spi_params_t parameter which contains the
242 * configuration information for the specified SPI module.
243 * @param[in] evt_handler: SPI user callback function.
244 *
245 *
246 * @return Result of initialization.
247 ****************************************************************************************
248 */
249 uint16_t app_spi_init(app_spi_params_t *p_params, app_spi_evt_handler_t evt_handler);
250
251 /**
252 ****************************************************************************************
253 * @brief De-initialize the APP SPI DRIVER peripheral.
254 *
255 * @param[in] id: De-initialize for a specific ID.
256 *
257 * @return Result of De-initialization.
258 ****************************************************************************************
259 */
260 uint16_t app_spi_deinit(app_spi_id_t id);
261
262 /**
263 ****************************************************************************************
264 * @brief Abort spi communication with Interrupt.
265 *
266 * @param[in] id: SPI module ID.
267 *
268 * @return Result of operation.
269 ****************************************************************************************
270 */
271 uint16_t app_spi_abort(app_spi_id_t id);
272
273 /**
274 ****************************************************************************************
275 * @brief SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc
276 * @note DO NOT Support interrupt mode
277 * @param[in] id : just support APP_SPI_ID_MASTER
278 * @param[in] instruction : 1-byte instruction phase
279 * @param[in] address : 3-byte address phase
280 * @param[in] p_data : pointer to transmit buffer
281 * @param[in] data_length : length of buffer, unit in byte
282 *
283 * @return APP_DRV_* in app_drv_error.h
284 ****************************************************************************************
285 */
286 uint16_t app_spim_transmit_with_ia(app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t * p_data, uint16_t data_length);
287
288 /**
289 ****************************************************************************************
290 * @brief SPI master receive with 1-byte inst and 3-byte addr and 0~4 dummy Byte, can use to read flash/display/eeprom, etc
291 *
292 * @param[in] id : just support APP_SPI_ID_MASTER
293 * @param[in] instruction : 1-byte instruction phase
294 * @param[in] address : 3-byte address phase
295 * @param[in] dummy_bytes : dummy bytes, 0 ~ 4
296 * @param[in] p_data : pointer to transmit buffer
297 * @param[in] data_length : length of buffer, unit in byte
298 *
299 * @return APP_DRV_* in app_drv_error.h
300 ****************************************************************************************
301 */
302 uint16_t app_spim_receive_with_ia(app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t dummy_bytes, uint8_t * p_data, uint16_t data_length);
303
304 /**
305 ****************************************************************************************
306 * @brief Receive in master or slave mode an amount of data in blocking mode.
307 *
308 * @param[in] id: which SPI module want to receive.
309 * @param[in] p_data: Pointer to data buffer
310 * @param[in] size: Amount of data to be sent
311 * @param[in] timeout: Timeout duration
312 *
313 * @return Result of operation.
314 ****************************************************************************************
315 */
316 uint16_t app_spi_receive_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout);
317
318 /**
319 ****************************************************************************************
320 * @brief Receive in master or slave mode an amount of data in non-blocking mode with Interrupt
321 *
322 * @param[in] id: which SPI module want to receive.
323 * @param[in] p_data: Pointer to data buffer
324 * @param[in] size: Amount of data to be sent
325 *
326 * @return Result of operation.
327 ****************************************************************************************
328 */
329 uint16_t app_spi_receive_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
330
331 /**
332 ****************************************************************************************
333 * @brief Transmits in master or slave mode an amount of data in blocking mode.
334 *
335 * @param[in] id: which SPI module want to transmit.
336 * @param[in] p_data: Pointer to data buffer
337 * @param[in] size: Amount of data to be sent
338 * @param[in] timeout: Timeout duration
339 *
340 * @return Result of operation.
341 ****************************************************************************************
342 */
343 uint16_t app_spi_transmit_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout);
344
345 /**
346 ****************************************************************************************
347 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt
348 *
349 * @param[in] id: which SPI module want to transmit.
350 * @param[in] p_data: Pointer to data buffer
351 * @param[in] size: Amount of data to be sent
352 *
353 * @return Result of operation.
354 ****************************************************************************************
355 */
356 uint16_t app_spi_transmit_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
357
358 /**
359 ****************************************************************************************
360 * @brief Transmits and receive in master or slave mode an amount of data in blocking mode.
361 *
362 * @param[in] id: which SPI module want to transmit.
363 * @param[in] p_tx_data: Pointer to tx data buffer
364 * @param[in] p_rx_data: Pointer to rx data buffer
365 * @param[in] size: Amount of data to be sent and receive
366 * @param[in] timeout: Timeout duration
367 *
368 * @return Result of operation.
369 ****************************************************************************************
370 */
371 uint16_t app_spi_transmit_receive_sync(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size, uint32_t timeout);
372
373 /**
374 ****************************************************************************************
375 * @brief Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt
376 *
377 * @param[in] id: which SPI module want to transmit.
378 * @param[in] p_tx_data: Pointer to tx data buffer
379 * @param[in] p_rx_data: Pointer to rx data buffer
380 * @param[in] size: Amount of data to be sent and receive
381 *
382 * @return Result of operation.
383 ****************************************************************************************
384 */
385 uint16_t app_spi_transmit_receive_async(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size);
386
387 /**
388 ****************************************************************************************
389 * @brief Read an amount of data from EEPROM in blocking mode.
390 *
391 * @param[in] id: which SPI module want to transmit.
392 * @param[in] p_tx_data: Pointer to transmission data buffer
393 * @param[out] p_rx_data: Pointer to reception data buffer
394 * @param[in] tx_size: Amount of data to be sent in bytes
395 * @param[in] rx_size: Amount of data to be received in bytes
396 * @param[in] timeout: Timeout duration
397 *
398 * @return Result of operation.
399 ****************************************************************************************
400 */
401 uint16_t app_spi_read_eeprom_sync(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size, uint32_t timeout);
402
403 /**
404 ****************************************************************************************
405 * @brief Read an amount of data from EEPROM in non-blocking mode with Interrupt.
406 *
407 * @param[in] id: which SPI module want to transmit.
408 * @param[in] p_tx_data: Pointer to transmission data buffer
409 * @param[out] p_rx_data: Pointer to reception data buffer
410 * @param[in] tx_size: Amount of data to be sent in bytes
411 * @param[in] rx_size: Amount of data to be received in bytes
412 *
413 * @return Result of operation.
414 ****************************************************************************************
415 */
416 uint16_t app_spi_read_eeprom_async(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size);
417
418 /**
419 ****************************************************************************************
420 * @brief Return the SPI handle.
421 *
422 * @param[in] id: SPI Channel ID.
423 *
424 * @return Pointer to the specified ID's SPI handle.
425 ****************************************************************************************
426 */
427 spi_handle_t *app_spi_get_handle(app_spi_id_t id);
428
429 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR551X)
430 /**
431 ****************************************************************************************
432 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with DMA
433 *
434 * @param[in] id: which SPI module want to transmit.
435 * @param[in] p_cmd_data: Pointer to command data buffer
436 * @param[in] p_tx_data: Pointer to transmission data buffer
437 * @param[in] cmd_size: Amount of command data to be sent in bytes
438 * @param[in] tx_size: Amount of data to be sent in bytes
439 *
440 * @return Result of operation.
441 ****************************************************************************************
442 */
443 uint16_t app_spi_write_memory_async(app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_tx_data, uint32_t cmd_size, uint32_t tx_size);
444
445 /**
446 ****************************************************************************************
447 * @brief Read an amount of data from EEPROM in non-blocking mode with DMA.
448 *
449 * @param[in] id: which SPI module want to transmit.
450 * @param[in] p_cmd_data: Pointer to command data buffer
451 * @param[out] p_rx_data: Pointer to reception data buffer
452 * @param[in] cmd_size: Amount of command data to be sent in bytes
453 * @param[in] rx_size: Amount of data to be received in bytes
454 *
455 * @return Result of operation.
456 ****************************************************************************************
457 */
458 uint16_t app_spi_read_memory_async(app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_rx_data, uint32_t cmd_size, uint32_t rx_size);
459
460 /**
461 ****************************************************************************************
462 * @brief [High speed] Receive in master or slave mode an amount of data in blocking mode.
463 *
464 * @param[in] id: which SPI module want to receive.
465 * @param[in] p_data: Pointer to data buffer
466 * @param[in] size: Amount of data to be sent
467 *
468 * @return Result of operation.
469 ****************************************************************************************
470 */
471 uint16_t app_spi_receive_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
472
473 /**
474 ****************************************************************************************
475 * @brief [High speed] Transmit in master or slave mode an amount of data in blocking mode.
476 *
477 * @param[in] id: which SPI module want to receive.
478 * @param[in] p_data: Pointer to data buffer
479 * @param[in] size: Amount of data to be sent
480 *
481 * @return Result of operation.
482 ****************************************************************************************
483 */
484 uint16_t app_spi_transmit_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
485 #endif
486
487 /** @} */
488
489 #endif
490
491 #ifdef __cplusplus
492 }
493 #endif
494
495 #endif
496
497 /** @} */
498
499 /** @} */
500
501 /** @} */
502
app_spi_pin_cfg_t
SPI IO configuration Structures.
Definition: app_spi.h:124
_spi_handle
SPI handle Structure definition.
Definition: gr55xx_hal_spi.h:135
app_spi_deinit
uint16_t app_spi_deinit(app_spi_id_t id)
De-initialize the APP SPI DRIVER peripheral.
APP_SPI_ID_MAX
@ APP_SPI_ID_MAX
Only for check parameter, not used as input parameters.
Definition: app_spi.h:86
app_spi_params_t::pin_cfg
app_spi_pin_cfg_t pin_cfg
the pin configuration information for the specified SPI module.
Definition: app_spi.h:221
app_spi_receive_high_speed_sync
uint16_t app_spi_receive_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size)
[High speed] Receive in master or slave mode an amount of data in blocking mode.
app_spi_transmit_high_speed_sync
uint16_t app_spi_transmit_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size)
[High speed] Transmit in master or slave mode an amount of data in blocking mode.
APP_SPI_DMA_INVALID
@ APP_SPI_DMA_INVALID
Definition: app_spi.h:187
spi_env_t::p_pin_cfg
app_spi_pin_cfg_t * p_pin_cfg
SPI IO configuration Structures.
Definition: app_spi.h:203
app_spi_pin_cfg_t::mosi
app_spi_pin_t mosi
Set the configuration of SPI MOSI pin.
Definition: app_spi.h:127
APP_SPI_ID_SLAVE
@ APP_SPI_ID_SLAVE
SPI slave module.
Definition: app_spi.h:84
app_spi_dma_state_t
app_spi_dma_state_t
App spi dma state types.
Definition: app_spi.h:186
app_spi_dma_cfg_t::rx_dma_channel
dma_channel_t rx_dma_channel
Specifies the dma channel of SPI RX.
Definition: app_spi.h:139
spi_env_t::start_flag
volatile bool start_flag
start flag.
Definition: app_spi.h:207
spi_env_t
SPI device structure definition.
Definition: app_spi.h:200
app_spi_read_memory_async
uint16_t app_spi_read_memory_async(app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_rx_data, uint32_t cmd_size, uint32_t rx_size)
Read an amount of data from EEPROM in non-blocking mode with DMA.
app_spi_params_t
SPI parameters structure definition.
Definition: app_spi.h:219
_spi_init
SPI init Structure definition.
Definition: gr55xx_hal_spi.h:104
app_spi_evt_t
SPI event structure definition.
Definition: app_spi.h:150
app_io_pull_t
app_io_pull_t
GPIO pull Enumerations definition.
Definition: app_io.h:183
spi_env_t::is_soft_cs
volatile bool is_soft_cs
soft cs.
Definition: app_spi.h:208
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:147
app_spi_init
uint16_t app_spi_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_spim_transmit_with_ia
uint16_t app_spim_transmit_with_ia(app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t *p_data, uint16_t data_length)
SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom,...
spi_env_t::spi_dma_state
app_spi_dma_state_t spi_dma_state
App spi dma state types.
Definition: app_spi.h:206
app_spi_pin_cfg_t::clk
app_spi_pin_t clk
Set the configuration of SPI CLK pin.
Definition: app_spi.h:126
app_spi_evt_t::error_code
uint32_t error_code
SPI Error code .
Definition: app_spi.h:154
app_io_mode_t
app_io_mode_t
GPIO mode Enumerations definition.
Definition: app_io.h:163
app_spi_pin_t::mode
app_io_mode_t mode
Specifies the mode for the selected pins.
Definition: app_spi.h:115
app_spi_transmit_receive_async
uint16_t app_spi_transmit_receive_async(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size)
Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt.
app_spi_write_memory_async
uint16_t app_spi_write_memory_async(app_spi_id_t id, uint8_t *p_cmd_data, uint8_t *p_tx_data, uint32_t cmd_size, uint32_t tx_size)
Transmits in master or slave mode an amount of data in non-blocking mode with DMA.
app_spi_dma_cfg_t::tx_dma_instance
dma_regs_t * tx_dma_instance
Specifies the TX DMA instance.
Definition: app_spi.h:136
app_spi_pin_t::type
app_io_type_t type
Specifies the type of SPI IO.
Definition: app_spi.h:111
app_spi_pin_t::enable
uint8_t enable
Enable or disable the pin.
Definition: app_spi.h:117
APP_SPI_ID_MASTER
@ APP_SPI_ID_MASTER
SPI master module.
Definition: app_spi.h:85
app_spi_transmit_receive_sync
uint16_t app_spi_transmit_receive_sync(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size, uint32_t timeout)
Transmits and receive in master or slave mode an amount of data in blocking mode.
app_io.h
Header file containing functions prototypes of GPIO app library.
app_spi_params_t::id
app_spi_id_t id
specified SPI module ID.
Definition: app_spi.h:220
spi_env_t::handle
spi_handle_t handle
SPI handle Structure.
Definition: app_spi.h:202
APP_SPI_EVT_RX_CPLT
@ APP_SPI_EVT_RX_CPLT
Requested RX transfer completed.
Definition: app_spi.h:97
app_spi_get_handle
spi_handle_t * app_spi_get_handle(app_spi_id_t id)
Return the SPI handle.
APP_SPI_INVALID
@ APP_SPI_INVALID
Definition: app_spi.h:177
spi_env_t::evt_handler
app_spi_evt_handler_t evt_handler
SPI event callback.
Definition: app_spi.h:201
APP_SPI_DMA_ACTIVITY
@ APP_SPI_DMA_ACTIVITY
Definition: app_spi.h:188
app_spi_id_t
app_spi_id_t
SPI module Enumerations definition.
Definition: app_spi.h:83
app_spi_transmit_sync
uint16_t app_spi_transmit_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout)
Transmits in master or slave mode an amount of data in blocking mode.
app_spi_state_t
app_spi_state_t
App spi state types.
Definition: app_spi.h:176
app_spi_pin_cfg_t::cs
app_spi_pin_t cs
Set the configuration of SPI CS pin.
Definition: app_spi.h:125
APP_SPI_EVT_TX_RX_CPLT
@ APP_SPI_EVT_TX_RX_CPLT
Requested TX/RX transfer completed.
Definition: app_spi.h:98
app_spi_receive_async
uint16_t app_spi_receive_async(app_spi_id_t id, uint8_t *p_data, uint16_t size)
Receive in master or slave mode an amount of data in non-blocking mode with Interrupt.
app_spi_evt_t::type
app_spi_evt_type_t type
Type of event.
Definition: app_spi.h:151
app_spi_pin_t
SPI IO Structures.
Definition: app_spi.h:110
app_spi_params_t::is_soft_cs
bool is_soft_cs
config whether to control CS signal by software
Definition: app_spi.h:224
app_spi_evt_type_t
app_spi_evt_type_t
SPI event Enumerations definition.
Definition: app_spi.h:94
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:167
APP_SPI_EVT_TX_CPLT
@ APP_SPI_EVT_TX_CPLT
Requested TX transfer completed.
Definition: app_spi.h:96
app_spi_receive_sync
uint16_t app_spi_receive_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout)
Receive in master or slave mode an amount of data in blocking mode.
spi_env_t::tx_done
volatile uint8_t tx_done
tx done.
Definition: app_spi.h:211
app_spi_pin_cfg_t::miso
app_spi_pin_t miso
Set the configuration of SPI MISO pin.
Definition: app_spi.h:128
app_dma.h
Header file containing functions prototypes of DMA app library.
spi_env_t::rx_done
volatile uint8_t rx_done
rx done.
Definition: app_spi.h:210
app_spi_evt_t::size
uint16_t size
SPI transmitted/received counter.
Definition: app_spi.h:155
app_spi_dma_cfg_t::tx_dma_channel
dma_channel_t tx_dma_channel
Specifies the dma channel of SPI TX.
Definition: app_spi.h:138
app_spi_dma_cfg_t
SPI configuration definition.
Definition: app_spi.h:135
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:255
app_spi_pin_t::pull
app_io_pull_t pull
Specifies the Pull-up or Pull-Down activation for the selected pins.
Definition: app_spi.h:116
app_spi_abort
uint16_t app_spi_abort(app_spi_id_t id)
Abort spi communication with Interrupt.
spi_env_t::spi_state
app_spi_state_t spi_state
App spi state types.
Definition: app_spi.h:205
app_spi_read_eeprom_async
uint16_t app_spi_read_eeprom_async(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size)
Read an amount of data from EEPROM in non-blocking mode with Interrupt.
APP_SPI_ACTIVITY
@ APP_SPI_ACTIVITY
Definition: app_spi.h:178
APP_SPI_EVT_ABORT
@ APP_SPI_EVT_ABORT
Abort reported by SPI peripheral.
Definition: app_spi.h:99
app_drv_error.h
Header file of app driver error code.
app_spi_params_t::dma_cfg
app_spi_dma_cfg_t dma_cfg
SPI DMA configuration.
Definition: app_spi.h:222
app_drv_config.h
Header file of app driver config code.
app_spi_params_t::init
spi_init_t init
SPI communication parameters.
Definition: app_spi.h:223
app_spim_receive_with_ia
uint16_t app_spim_receive_with_ia(app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t dummy_bytes, uint8_t *p_data, uint16_t data_length)
SPI master receive with 1-byte inst and 3-byte addr and 0~4 dummy Byte, can use to read flash/display...
APP_SPI_EVT_ERROR
@ APP_SPI_EVT_ERROR
Error reported by UART peripheral.
Definition: app_spi.h:95
app_spi_dma_cfg_t::rx_dma_instance
dma_regs_t * rx_dma_instance
Specifies the RX DMA instance.
Definition: app_spi.h:137
app_spi_params_t::spi_env
spi_env_t spi_env
SPI device structure definition.
Definition: app_spi.h:225
dma_id_t
int16_t dma_id_t
DMA id definition.
Definition: app_dma.h:98
app_spi_pin_t::mux
app_io_mux_t mux
Specifies the Peripheral to be connected to the selected pins.
Definition: app_spi.h:112
app_spi_transmit_async
uint16_t app_spi_transmit_async(app_spi_id_t id, uint8_t *p_data, uint16_t size)
Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt.
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93
app_spi_read_eeprom_sync
uint16_t app_spi_read_eeprom_sync(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_size, uint32_t rx_size, uint32_t timeout)
Read an amount of data from EEPROM in blocking mode.
app_spi_pin_t::pin
uint32_t pin
Specifies the IO pins to be configured.
Definition: app_spi.h:113