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