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 inistall. */
137 dma_regs_t * rx_dma_instance; /**< Specifies the RX DMA inistall. */
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 timout 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 * @brief SPI event callback definition
160 */
161 typedef void (*app_spi_evt_handler_t)(app_spi_evt_t *p_evt);
162
163 /**@brief App spi state types. */
164 typedef enum
165 {
166 APP_SPI_INVALID = 0,
167 APP_SPI_ACTIVITY,
168 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
169 APP_SPI_SLEEP,
170 #endif
171 } app_spi_state_t;
172
173 /**@brief App spi dma state types. */
174 typedef enum
175 {
176 APP_SPI_DMA_INVALID = 0,
177 APP_SPI_DMA_ACTIVITY,
178 } app_spi_dma_state_t;
179
180 /**
181 * @brief SPI device structure definition
182 */
183 typedef struct
184 {
185 app_spi_evt_handler_t evt_handler; /**< SPI event callback. */
186 spi_handle_t handle; /**< SPI handle Structure. */
187 app_spi_pin_cfg_t *p_pin_cfg; /**< SPI IO configuration Structures. */
188 dma_id_t dma_id[2]; /**< DMA id. */
189 app_spi_state_t spi_state; /**< App spi state types. */
190 app_spi_dma_state_t spi_dma_state; /**< App spi dma state types. */
191 volatile bool start_flag; /**< start flag. */
192 volatile bool is_soft_cs; /**< soft cs. */
193 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR551X)
194 volatile uint8_t rx_done; /**< rx done. */
195 volatile uint8_t tx_done; /**< tx done. */
196 #endif
197 } spi_env_t;
198
199 /**
200 * @brief SPI parameters structure definition
201 */
202 typedef struct
203 {
204 app_spi_id_t id; /**< specified SPI module ID. */
205 app_spi_pin_cfg_t pin_cfg; /**< the pin configuration information for the specified SPI module. */
206 app_spi_dma_cfg_t dma_cfg; /**< SPI DMA configuration. */
207 spi_init_t init; /**< SPI communication parameters. */
208 bool is_soft_cs; /**< config whether to control CS signal by software */
209 spi_env_t spi_env; /**< SPI device structure definition. */
210 } app_spi_params_t;
211
212 /** @} */
213
214 /* Exported functions --------------------------------------------------------*/
215 /** @addtogroup APP_SPI_DRIVER_FUNCTIONS Functions
216 * @{
217 */
218 /**
219 ****************************************************************************************
220 * @brief Initialize the APP SPI DRIVER according to the specified parameters
221 * in the app_spi_params_t and app_spi_evt_handler_t.
222 * @note If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode
223 * is set, you can't use interrupt mode.
224 *
225 * @param[in] p_params: Pointer to app_spi_params_t parameter which contains the
226 * configuration information for the specified SPI module.
227 * @param[in] evt_handler: SPI user callback function.
228 *
229 *
230 * @return Result of initialization.
231 ****************************************************************************************
232 */
233 uint16_t app_spi_init(app_spi_params_t *p_params, app_spi_evt_handler_t evt_handler);
234
235 /**
236 ****************************************************************************************
237 * @brief De-initialize the APP SPI DRIVER peripheral.
238 *
239 * @param[in] id: De-initialize for a specific ID.
240 *
241 * @return Result of De-initialization.
242 ****************************************************************************************
243 */
244 uint16_t app_spi_deinit(app_spi_id_t id);
245
246 /**
247 ****************************************************************************************
248 * @brief Abort spi communication with Interrupt.
249 *
250 * @param[in] id: SPI module ID.
251 *
252 * @return Result of operation.
253 ****************************************************************************************
254 */
255 uint16_t app_spi_abort(app_spi_id_t id);
256
257 /**
258 ****************************************************************************************
259 * @brief SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc
260 * @note DO NOT Support interrupt mode
261 * @param[in] id : just support APP_SPI_ID_MASTER
262 * @param[in] instruction : 1-byte instruction phase
263 * @param[in] address : 3-byte address phase
264 * @param[in] p_data : pointer to transmit buffer
265 * @param[in] data_length : length of buffer, unit in byte
266 *
267 * @return APP_DRV_* in app_drv_error.h
268 ****************************************************************************************
269 */
270 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);
271
272 /**
273 ****************************************************************************************
274 * @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
275 *
276 * @param[in] id : just support APP_SPI_ID_MASTER
277 * @param[in] instruction : 1-byte instruction phase
278 * @param[in] address : 3-byte address phase
279 * @param[in] dummy_bytes : dummy bytes, 0 ~ 4
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_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);
287
288 /**
289 ****************************************************************************************
290 * @brief Receive in master or slave mode an amount of data in blocking mode.
291 *
292 * @param[in] id: which SPI module want to receive.
293 * @param[in] p_data: Pointer to data buffer
294 * @param[in] size: Amount of data to be sent
295 * @param[in] timeout: Timeout duration
296 *
297 * @return Result of operation.
298 ****************************************************************************************
299 */
300 uint16_t app_spi_receive_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout);
301
302 /**
303 ****************************************************************************************
304 * @brief Receive in master or slave mode an amount of data in non-blocking mode with Interrupt
305 *
306 * @param[in] id: which SPI module want to receive.
307 * @param[in] p_data: Pointer to data buffer
308 * @param[in] size: Amount of data to be sent
309 *
310 * @return Result of operation.
311 ****************************************************************************************
312 */
313 uint16_t app_spi_receive_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
314
315 /**
316 ****************************************************************************************
317 * @brief Transmits in master or slave mode an amount of data in blocking mode.
318 *
319 * @param[in] id: which SPI module want to transmit.
320 * @param[in] p_data: Pointer to data buffer
321 * @param[in] size: Amount of data to be sent
322 * @param[in] timeout: Timeout duration
323 *
324 * @return Result of operation.
325 ****************************************************************************************
326 */
327 uint16_t app_spi_transmit_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size, uint32_t timeout);
328
329 /**
330 ****************************************************************************************
331 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt
332 *
333 * @param[in] id: which SPI module want to transmit.
334 * @param[in] p_data: Pointer to data buffer
335 * @param[in] size: Amount of data to be sent
336 *
337 * @return Result of operation.
338 ****************************************************************************************
339 */
340 uint16_t app_spi_transmit_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
341
342 /**
343 ****************************************************************************************
344 * @brief Transmits and receive in master or slave mode an amount of data in blocking mode.
345 *
346 * @param[in] id: which SPI module want to transmit.
347 * @param[in] p_tx_data: Pointer to tx data buffer
348 * @param[in] p_rx_data: Pointer to rx data buffer
349 * @param[in] size: Amount of data to be sent and receive
350 * @param[in] timeout: Timeout duration
351 *
352 * @return Result of operation.
353 ****************************************************************************************
354 */
355 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);
356
357 /**
358 ****************************************************************************************
359 * @brief Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt
360 *
361 * @param[in] id: which SPI module want to transmit.
362 * @param[in] p_tx_data: Pointer to tx data buffer
363 * @param[in] p_rx_data: Pointer to rx data buffer
364 * @param[in] size: Amount of data to be sent and receive
365 *
366 * @return Result of operation.
367 ****************************************************************************************
368 */
369 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);
370
371 /**
372 ****************************************************************************************
373 * @brief Read an amount of data from EEPROM in blocking mode.
374 *
375 * @param[in] id: which SPI module want to transmit.
376 * @param[in] p_tx_data: Pointer to transmission data buffer
377 * @param[out] p_rx_data: Pointer to reception data buffer
378 * @param[in] tx_size: Amount of data to be sent in bytes
379 * @param[in] rx_size: Amount of data to be received in bytes
380 * @param[in] timeout: Timeout duration
381 *
382 * @return Result of operation.
383 ****************************************************************************************
384 */
385 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);
386
387 /**
388 ****************************************************************************************
389 * @brief Read an amount of data from EEPROM in non-blocking mode with Interrupt.
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 *
397 * @return Result of operation.
398 ****************************************************************************************
399 */
400 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);
401
402 /**
403 ****************************************************************************************
404 * @brief Return the SPI handle.
405 *
406 * @param[in] id: SPI Channel ID.
407 *
408 * @return Pointer to the specified ID's SPI handle.
409 ****************************************************************************************
410 */
411 spi_handle_t *app_spi_get_handle(app_spi_id_t id);
412
413 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR551X)
414 /**
415 ****************************************************************************************
416 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with DMA
417 *
418 * @param[in] id: which SPI module want to transmit.
419 * @param[in] p_cmd_data: Pointer to command data buffer
420 * @param[in] p_tx_data: Pointer to transmission data buffer
421 * @param[in] cmd_size: Amount of command data to be sent in bytes
422 * @param[in] tx_size: Amount of data to be sent in bytes
423 *
424 * @return Result of operation.
425 ****************************************************************************************
426 */
427 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);
428
429 /**
430 ****************************************************************************************
431 * @brief Read an amount of data from EEPROM in non-blocking mode with DMA.
432 *
433 * @param[in] id: which SPI module want to transmit.
434 * @param[in] p_cmd_data: Pointer to command data buffer
435 * @param[out] p_rx_data: Pointer to reception data buffer
436 * @param[in] cmd_size: Amount of command data to be sent in bytes
437 * @param[in] rx_size: Amount of data to be received in bytes
438 *
439 * @return Result of operation.
440 ****************************************************************************************
441 */
442 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);
443
444 /**
445 ****************************************************************************************
446 * @brief [High speed] Receive in master or slave mode an amount of data in blocking mode.
447 *
448 * @param[in] id: which SPI module want to receive.
449 * @param[in] p_data: Pointer to data buffer
450 * @param[in] size: Amount of data to be sent
451 *
452 * @return Result of operation.
453 ****************************************************************************************
454 */
455 uint16_t app_spi_receive_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
456
457 /**
458 ****************************************************************************************
459 * @brief [High speed] Transmit in master or slave mode an amount of data in blocking mode.
460 *
461 * @param[in] id: which SPI module want to receive.
462 * @param[in] p_data: Pointer to data buffer
463 * @param[in] size: Amount of data to be sent
464 *
465 * @return Result of operation.
466 ****************************************************************************************
467 */
468 uint16_t app_spi_transmit_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
469 #endif
470
471 /** @} */
472
473 #endif
474
475 #ifdef __cplusplus
476 }
477 #endif
478
479 #endif
480
481 /** @} */
482
483 /** @} */
484
485 /** @} */
486
app_spi_pin_cfg_t
SPI IO configuration Structures.
Definition: app_spi.h:124
app_spi_state_t
app_spi_state_t
App spi state types.
Definition: app_spi.h:165
_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:205
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.
spi_env_t::p_pin_cfg
app_spi_pin_cfg_t * p_pin_cfg
SPI IO configuration Structures.
Definition: app_spi.h:187
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_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:191
spi_env_t
SPI device structure definition.
Definition: app_spi.h:184
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_evt_handler_t
void(* app_spi_evt_handler_t)(app_spi_evt_t *p_evt)
SPI event callback definition.
Definition: app_spi.h:161
app_spi_params_t
SPI parameters structure definition.
Definition: app_spi.h:203
_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:181
spi_env_t::is_soft_cs
volatile bool is_soft_cs
soft cs.
Definition: app_spi.h:192
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:145
app_spi_dma_state_t
app_spi_dma_state_t
App spi dma state types.
Definition: app_spi.h:175
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:190
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:161
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 inistall.
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:204
spi_env_t::handle
spi_handle_t handle
SPI handle Structure.
Definition: app_spi.h:186
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.
spi_env_t::evt_handler
app_spi_evt_handler_t evt_handler
SPI event callback.
Definition: app_spi.h:185
APP_SPI_DMA_ACTIVITY
@ APP_SPI_DMA_ACTIVITY
Definition: app_spi.h:177
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_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:208
APP_SPI_INVALID
@ APP_SPI_INVALID
Definition: app_spi.h:166
APP_SPI_DMA_INVALID
@ APP_SPI_DMA_INVALID
Definition: app_spi.h:176
app_spi_evt_type_t
app_spi_evt_type_t
SPI event Enumerations definition.
Definition: app_spi.h:94
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:195
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:194
app_spi_evt_t::size
uint16_t size
SPI transmitted/received counter.
Definition: app_spi.h:155
APP_SPI_ACTIVITY
@ APP_SPI_ACTIVITY
Definition: app_spi.h:167
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:253
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:189
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_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:206
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:207
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 inistall.
Definition: app_spi.h:137
app_spi_params_t::spi_env
spi_env_t spi_env
SPI device structure definition.
Definition: app_spi.h:209
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