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 #if defined(HAL_SPI_MODULE_ENABLED) || defined(HAL_SPIM_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 * @note: 1. When the SPI device is configured as a Slave mode,
82 * the pull-up or pull-down mode of the CS pin should be set according to the clock polarity:
83 * if the clock polarity is configured for low level active, the CS pin should be configured as pull-up mode;
84 * if the clock polarity is configured for high level active, the CS pin should be configured as pull-down mode.
85 * 2. It is recommended that when initializing the SPI Slave device,
86 * the SPI Master device should first be initialized and in a stable state to avoid interference
87 * to the Slave device from I/O signal changes during the Master device's initialization.
88 */
89 typedef enum
90 {
91 #ifndef APP_SPI_NOT_SUPPORT_SLAVE
92 APP_SPI_ID_SLAVE, /**< SPI slave module. */
93 APP_SPI_ID_MASTER, /**< SPI master module. */
94 #else
95 APP_SPI_ID_MASTER0, /**< SPI master 0 module. */
96 APP_SPI_ID_MASTER1, /**< SPI master 1 module. */
97 APP_SPI_ID_MASTER2, /**< SPI master 2 module. */
98 #endif
99 APP_SPI_ID_MAX, /**< Only for check parameter, not used as input parameters. */
100 } app_spi_id_t;
101
102
103 /**
104 * @brief SPI event Enumerations definition
105 */
106 typedef enum
107 {
108 APP_SPI_EVT_ERROR, /**< Error reported by UART peripheral. */
109 APP_SPI_EVT_TX_CPLT, /**< Requested TX transfer completed. */
110 APP_SPI_EVT_RX_CPLT, /**< Requested RX transfer completed. */
111 APP_SPI_EVT_TX_RX_CPLT, /**< Requested TX/RX transfer completed. */
112 APP_SPI_EVT_ABORT, /**< Abort reported by SPI peripheral. */
113 } app_spi_evt_type_t;
114 /** @} */
115
116 /** @addtogroup APP_SPI_STRUCTURES Structures
117 * @{
118 */
119 /**
120 * @brief SPI IO Structures
121 */
122 typedef struct
123 {
124 app_io_type_t type; /**< Specifies the type of SPI IO. */
125 app_io_mux_t mux; /**< Specifies the Peripheral to be connected to the selected pins. */
126 uint32_t pin; /**< Specifies the IO pins to be configured.
127 This parameter can be any value of @ref GR5xxx_pins. */
128 app_io_mode_t mode; /**< Specifies the mode for the selected pins. */
129 app_io_pull_t pull; /**< Specifies the Pull-up or Pull-Down activation for the selected pins. */
130 uint8_t enable; /**< Enable or disable the pin. */
131 } app_spi_pin_t;
132
133 /**
134 * @brief SPI IO configuration Structures
135 */
136 typedef struct
137 {
138 app_spi_pin_t cs; /**< Set the configuration of SPI CS pin. */
139 app_spi_pin_t clk; /**< Set the configuration of SPI CLK pin. */
140 app_spi_pin_t mosi; /**< Set the configuration of SPI MOSI pin. */
141 app_spi_pin_t miso; /**< Set the configuration of SPI MISO pin. */
142 } app_spi_pin_cfg_t;
143
144 /**
145 * @brief SPI configuration definition.
146 */
147 typedef struct
148 {
149 dma_regs_t * tx_dma_instance; /**< Specifies the TX DMA instance. */
150 dma_regs_t * rx_dma_instance; /**< Specifies the RX DMA instance. */
151 dma_channel_t tx_dma_channel; /**< Specifies the dma channel of SPI TX. */
152 dma_channel_t rx_dma_channel; /**< Specifies the dma channel of SPI RX. */
153 #ifndef APP_SPI_GR551X_LEGACY
154 uint32_t wait_timeout_ms; /**< Specifies timeout time of polling and dead wait, ms. */
155 uint32_t extend; /**< Specifies extend segment, to use */
156 #endif
157 } app_spi_dma_cfg_t;
158
159 /**
160 * @brief SPI event structure definition
161 */
162 typedef struct
163 {
164 app_spi_evt_type_t type; /**< Type of event. */
165 union
166 {
167 uint32_t error_code; /**< SPI Error code . */
168 uint16_t size; /**< SPI transmitted/received counter. */
169 } data; /**< SPI data. */
170 } app_spi_evt_t;
171
172 /** @} */
173
174 /** @addtogroup APP_SPI_TYPEDEFS Type definitions
175 * @{
176 */
177 /**
178 * @brief SPI event callback definition
179 */
180 typedef void (*app_spi_evt_handler_t)(app_spi_evt_t *p_evt);
181
182 /** @} */
183
184 /** @addtogroup APP_SPI_ENUM Enumerations
185 * @{
186 */
187 /**@brief App spi state types. */
188 typedef enum
189 {
190 APP_SPI_INVALID = 0,
191 APP_SPI_ACTIVITY,
192 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
193 APP_SPI_SLEEP,
194 #endif
195 } app_spi_state_t;
196
197 /**@brief App spi dma state types. */
198 typedef enum
199 {
200 APP_SPI_DMA_INVALID = 0,
201 APP_SPI_DMA_ACTIVITY,
202 } app_spi_dma_state_t;
203
204 /** @} */
205
206 /** @addtogroup APP_SPI_STRUCTURES Structures
207 * @{
208 */
209 /**
210 * @brief SPI device structure definition
211 */
212 typedef struct
213 {
214 app_spi_evt_handler_t evt_handler; /**< SPI event callback. */
215 spi_handle_t handle; /**< SPI handle Structure. */
216 app_spi_pin_cfg_t *p_pin_cfg; /**< SPI IO configuration Structures. */
217 dma_id_t dma_id[2]; /**< DMA id. */
218 app_spi_state_t spi_state; /**< App spi state types. */
219 app_spi_dma_state_t spi_dma_state; /**< App spi dma state types. */
220 volatile bool start_flag; /**< start flag. */
221 volatile bool is_soft_cs; /**< soft cs. */
222 #ifdef APP_SPI_GR551X_LEGACY
223 volatile uint8_t rx_done; /**< rx done. */
224 volatile uint8_t tx_done; /**< tx done. */
225 #endif
226 } spi_env_t;
227
228 /**
229 * @brief SPI parameters structure definition
230 */
231 typedef struct
232 {
233 app_spi_id_t id; /**< specified SPI module ID. */
234 app_spi_pin_cfg_t pin_cfg; /**< the pin configuration information for the specified SPI module. */
235 app_spi_dma_cfg_t dma_cfg; /**< SPI DMA configuration. */
236 spi_init_t init; /**< SPI communication parameters. */
237 bool is_soft_cs; /**< config whether to control CS signal by software */
238 spi_env_t spi_env; /**< SPI device structure definition. */
239 } app_spi_params_t;
240
241 /** @} */
242
243 /* Exported functions --------------------------------------------------------*/
244 /** @addtogroup APP_SPI_DRIVER_FUNCTIONS Functions
245 * @{
246 */
247 /**
248 ****************************************************************************************
249 * @brief Initialize the APP SPI DRIVER according to the specified parameters
250 * in the app_spi_params_t and app_spi_evt_handler_t.
251 * @note If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode
252 * is set, you can't use interrupt mode.
253 *
254 * @param[in] p_params: Pointer to app_spi_params_t parameter which contains the
255 * configuration information for the specified SPI module.
256 * @param[in] evt_handler: SPI user callback function.
257 *
258 *
259 * @return Result of initialization.
260 ****************************************************************************************
261 */
262 uint16_t app_spi_init(app_spi_params_t *p_params, app_spi_evt_handler_t evt_handler);
263
264 /**
265 ****************************************************************************************
266 * @brief De-initialize the APP SPI DRIVER peripheral.
267 *
268 * @param[in] id: De-initialize for a specific ID.
269 *
270 * @return Result of De-initialization.
271 ****************************************************************************************
272 */
273 uint16_t app_spi_deinit(app_spi_id_t id);
274
275 /**
276 ****************************************************************************************
277 * @brief Abort spi communication with Interrupt.
278 *
279 * @param[in] id: SPI module ID.
280 *
281 * @return Result of operation.
282 ****************************************************************************************
283 */
284 uint16_t app_spi_abort(app_spi_id_t id);
285
286 /**
287 ****************************************************************************************
288 * @brief SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc
289 * @note DO NOT Support interrupt mode
290 * @param[in] id : just support APP_SPI_ID_MASTER
291 * @param[in] instruction : 1-byte instruction phase
292 * @param[in] address : 3-byte address phase
293 * @param[in] p_data : pointer to transmit buffer
294 * @param[in] data_length : length of buffer, unit in byte
295 *
296 * @return APP_DRV_* in app_drv_error.h
297 ****************************************************************************************
298 */
299 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);
300
301 /**
302 ****************************************************************************************
303 * @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
304 *
305 * @param[in] id : just support APP_SPI_ID_MASTER
306 * @param[in] instruction : 1-byte instruction phase
307 * @param[in] address : 3-byte address phase
308 * @param[in] dummy_bytes : dummy bytes, 0 ~ 4
309 * @param[in] p_data : pointer to transmit buffer
310 * @param[in] data_length : length of buffer, unit in byte
311 *
312 * @return APP_DRV_* in app_drv_error.h
313 ****************************************************************************************
314 */
315 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);
316
317 /**
318 ****************************************************************************************
319 * @brief Receive in master or slave mode an amount of data in blocking mode.
320 *
321 * @param[in] id: which SPI module want to receive.
322 * @param[in] p_data: Pointer to data buffer
323 * @param[in] size: Amount of data to be sent
324 * @param[in] timeout: Timeout duration
325 *
326 * @return Result of operation.
327 ****************************************************************************************
328 */
329 uint16_t app_spi_receive_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout);
330
331 /**
332 ****************************************************************************************
333 * @brief Receive in master or slave mode an amount of data in non-blocking mode with Interrupt
334 *
335 * @param[in] id: which SPI module want to receive.
336 * @param[in] p_data: Pointer to data buffer
337 * @param[in] size: Amount of data to be sent
338 *
339 * @return Result of operation.
340 ****************************************************************************************
341 */
342 uint16_t app_spi_receive_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
343
344 /**
345 ****************************************************************************************
346 * @brief Transmits in master or slave mode an amount of data in blocking mode.
347 *
348 * @param[in] id: which SPI module want to transmit.
349 * @param[in] p_data: Pointer to data buffer
350 * @param[in] size: Amount of data to be sent
351 * @param[in] timeout: Timeout duration
352 *
353 * @return Result of operation.
354 ****************************************************************************************
355 */
356 uint16_t app_spi_transmit_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout);
357
358 /**
359 ****************************************************************************************
360 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt
361 *
362 * @param[in] id: which SPI module want to transmit.
363 * @param[in] p_data: Pointer to data buffer
364 * @param[in] size: Amount of data to be sent
365 *
366 * @return Result of operation.
367 ****************************************************************************************
368 */
369 uint16_t app_spi_transmit_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
370
371 /**
372 ****************************************************************************************
373 * @brief Transmits and receive in master or slave mode an amount of data in blocking mode.
374 *
375 * @param[in] id: which SPI module want to transmit.
376 * @param[in] p_tx_data: Pointer to tx data buffer
377 * @param[in] p_rx_data: Pointer to rx data buffer
378 * @param[in] size: Amount of data to be sent and receive
379 * @param[in] timeout: Timeout duration
380 *
381 * @return Result of operation.
382 ****************************************************************************************
383 */
384 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);
385
386 /**
387 ****************************************************************************************
388 * @brief Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt
389 *
390 * @param[in] id: which SPI module want to transmit.
391 * @param[in] p_tx_data: Pointer to tx data buffer
392 * @param[in] p_rx_data: Pointer to rx data buffer
393 * @param[in] size: Amount of data to be sent and receive
394 *
395 * @return Result of operation.
396 ****************************************************************************************
397 */
398 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);
399
400 /**
401 ****************************************************************************************
402 * @brief Read an amount of data from EEPROM in blocking mode.
403 *
404 * @param[in] id: which SPI module want to transmit.
405 * @param[in] p_tx_data: Pointer to transmission data buffer
406 * @param[out] p_rx_data: Pointer to reception data buffer
407 * @param[in] tx_size: Amount of data to be sent in bytes
408 * @param[in] rx_size: Amount of data to be received in bytes
409 * @param[in] timeout: Timeout duration
410 *
411 * @return Result of operation.
412 ****************************************************************************************
413 */
414 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);
415
416 /**
417 ****************************************************************************************
418 * @brief Read an amount of data from EEPROM in non-blocking mode with Interrupt.
419 *
420 * @param[in] id: which SPI module want to transmit.
421 * @param[in] p_tx_data: Pointer to transmission data buffer
422 * @param[out] p_rx_data: Pointer to reception data buffer
423 * @param[in] tx_size: Amount of data to be sent in bytes
424 * @param[in] rx_size: Amount of data to be received in bytes
425 *
426 * @return Result of operation.
427 ****************************************************************************************
428 */
429 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);
430
431 /**
432 ****************************************************************************************
433 * @brief Return the SPI handle.
434 *
435 * @param[in] id: SPI Channel ID.
436 *
437 * @return Pointer to the specified ID's SPI handle.
438 ****************************************************************************************
439 */
440 spi_handle_t *app_spi_get_handle(app_spi_id_t id);
441
442 #ifdef APP_SPI_GR551X_LEGACY
443 /**
444 ****************************************************************************************
445 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with DMA
446 *
447 * @param[in] id: which SPI module want to transmit.
448 * @param[in] p_cmd_data: Pointer to command data buffer
449 * @param[in] p_tx_data: Pointer to transmission data buffer
450 * @param[in] cmd_size: Amount of command data to be sent in bytes
451 * @param[in] tx_size: Amount of data to be sent in bytes
452 *
453 * @return Result of operation.
454 ****************************************************************************************
455 */
456 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);
457
458 /**
459 ****************************************************************************************
460 * @brief Read an amount of data from EEPROM in non-blocking mode with DMA.
461 *
462 * @param[in] id: which SPI module want to transmit.
463 * @param[in] p_cmd_data: Pointer to command data buffer
464 * @param[out] p_rx_data: Pointer to reception data buffer
465 * @param[in] cmd_size: Amount of command data to be sent in bytes
466 * @param[in] rx_size: Amount of data to be received in bytes
467 *
468 * @return Result of operation.
469 ****************************************************************************************
470 */
471 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);
472
473 /**
474 ****************************************************************************************
475 * @brief [High speed] Receive 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_receive_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
485
486 /**
487 ****************************************************************************************
488 * @brief [High speed] Transmit in master or slave mode an amount of data in blocking mode.
489 *
490 * @param[in] id: which SPI module want to receive.
491 * @param[in] p_data: Pointer to data buffer
492 * @param[in] size: Amount of data to be sent
493 *
494 * @return Result of operation.
495 ****************************************************************************************
496 */
497 uint16_t app_spi_transmit_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
498 #endif
499
500 /** @} */
501
502 #endif
503
504 #ifdef __cplusplus
505 }
506 #endif
507
508 #endif
509
510 /** @} */
511
512 /** @} */
513
514 /** @} */
515
app_spi_pin_cfg_t
SPI IO configuration Structures.
Definition: app_spi.h:137
_spi_handle
SPI handle Structure definition.
Definition: hal_spi.h:192
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
Definition: app_spi.h:99
app_spi_params_t::pin_cfg
app_spi_pin_cfg_t pin_cfg
Definition: app_spi.h:234
APP_SPI_DMA_INVALID
@ APP_SPI_DMA_INVALID
Definition: app_spi.h:200
spi_env_t::p_pin_cfg
app_spi_pin_cfg_t * p_pin_cfg
Definition: app_spi.h:216
app_spi_pin_cfg_t::mosi
app_spi_pin_t mosi
Definition: app_spi.h:140
APP_SPI_ID_SLAVE
@ APP_SPI_ID_SLAVE
Definition: app_spi.h:92
app_spi_dma_state_t
app_spi_dma_state_t
App spi dma state types.
Definition: app_spi.h:199
app_spi_dma_cfg_t::rx_dma_channel
dma_channel_t rx_dma_channel
Definition: app_spi.h:152
spi_env_t::start_flag
volatile bool start_flag
Definition: app_spi.h:220
spi_env_t
SPI device structure definition.
Definition: app_spi.h:213
app_spi_dma_cfg_t::extend
uint32_t extend
Definition: app_spi.h:155
app_spi_params_t
SPI parameters structure definition.
Definition: app_spi.h:232
_spi_init
SPI init Structure definition.
Definition: hal_spi.h:105
app_spi_evt_t
SPI event structure definition.
Definition: app_spi.h:163
app_io_pull_t
app_io_pull_t
GPIO pull Enumerations definition.
Definition: app_io.h:176
spi_env_t::is_soft_cs
volatile bool is_soft_cs
Definition: app_spi.h:221
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:142
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
Definition: app_spi.h:219
app_spi_pin_cfg_t::clk
app_spi_pin_t clk
Definition: app_spi.h:139
app_spi_evt_t::error_code
uint32_t error_code
Definition: app_spi.h:167
app_io_mode_t
app_io_mode_t
GPIO mode Enumerations definition.
Definition: app_io.h:156
app_spi_pin_t::mode
app_io_mode_t mode
Definition: app_spi.h:128
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_dma_cfg_t::tx_dma_instance
dma_regs_t * tx_dma_instance
Definition: app_spi.h:149
app_spi_pin_t::type
app_io_type_t type
Definition: app_spi.h:124
app_spi_pin_t::enable
uint8_t enable
Definition: app_spi.h:130
APP_SPI_ID_MASTER
@ APP_SPI_ID_MASTER
Definition: app_spi.h:93
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
Definition: app_spi.h:233
spi_env_t::handle
spi_handle_t handle
Definition: app_spi.h:215
APP_SPI_EVT_RX_CPLT
@ APP_SPI_EVT_RX_CPLT
Definition: app_spi.h:110
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:190
spi_env_t::evt_handler
app_spi_evt_handler_t evt_handler
Definition: app_spi.h:214
APP_SPI_DMA_ACTIVITY
@ APP_SPI_DMA_ACTIVITY
Definition: app_spi.h:201
app_spi_id_t
app_spi_id_t
SPI module Enumerations definition.
Definition: app_spi.h:90
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:189
app_spi_pin_cfg_t::cs
app_spi_pin_t cs
Definition: app_spi.h:138
app_spi_dma_cfg_t::wait_timeout_ms
uint32_t wait_timeout_ms
Definition: app_spi.h:154
APP_SPI_EVT_TX_RX_CPLT
@ APP_SPI_EVT_TX_RX_CPLT
Definition: app_spi.h:111
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
Definition: app_spi.h:164
app_spi_pin_t
SPI IO Structures.
Definition: app_spi.h:123
app_spi_params_t::is_soft_cs
bool is_soft_cs
Definition: app_spi.h:237
app_spi_evt_type_t
app_spi_evt_type_t
SPI event Enumerations definition.
Definition: app_spi.h:107
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_EVT_TX_CPLT
@ APP_SPI_EVT_TX_CPLT
Definition: app_spi.h:109
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.
app_spi_pin_cfg_t::miso
app_spi_pin_t miso
Definition: app_spi.h:141
app_dma.h
Header file containing functions prototypes of DMA app library.
app_spi_evt_t::size
uint16_t size
Definition: app_spi.h:168
app_spi_dma_cfg_t::tx_dma_channel
dma_channel_t tx_dma_channel
Definition: app_spi.h:151
app_spi_dma_cfg_t
SPI configuration definition.
Definition: app_spi.h:148
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:248
app_spi_pin_t::pull
app_io_pull_t pull
Definition: app_spi.h:129
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
Definition: app_spi.h:218
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:191
APP_SPI_EVT_ABORT
@ APP_SPI_EVT_ABORT
Definition: app_spi.h:112
app_drv_error.h
Header file of app driver error code.
app_spi_params_t::dma_cfg
app_spi_dma_cfg_t dma_cfg
Definition: app_spi.h:235
app_drv_config.h
Header file of app driver config code.
app_spi_params_t::init
spi_init_t init
Definition: app_spi.h:236
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
Definition: app_spi.h:108
app_spi_dma_cfg_t::rx_dma_instance
dma_regs_t * rx_dma_instance
Definition: app_spi.h:150
app_spi_params_t::spi_env
spi_env_t spi_env
Definition: app_spi.h:238
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
Definition: app_spi.h:125
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: hal_dma.h:95
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
Definition: app_spi.h:126