app_spi_dma.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file app_spi_dma.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_DMA_H_
53 #define _APP_SPI_DMA_H_
54
55 #include "app_io.h"
56 #include "app_dma.h"
57 #include "app_spi.h"
58 #include "app_drv_error.h"
59 #include "app_drv_config.h"
60 #include <stdbool.h>
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65 #ifdef HAL_SPI_MODULE_ENABLED
66
67 /* Exported functions --------------------------------------------------------*/
68 /** @addtogroup APP_SPI_DRIVER_FUNCTIONS Functions
69 * @{
70 */
71 /**
72 ****************************************************************************************
73 * @brief Initialize the APP SPI DRIVER according to the specified parameters
74 * in the app_spi_params_t and app_spi_evt_handler_t.
75 * @note If interrupt mode is set, you can use blocking mode. Conversely, if blocking mode
76 * is set, you can't use interrupt mode.
77 *
78 * @param[in] p_params: Pointer to app_spi_params_t parameter which contains the
79 * configuration information for the specified SPI module.
80 *
81 *
82 * @return Result of initialization.
83 ****************************************************************************************
84 */
85 uint16_t app_spi_dma_init(app_spi_params_t *p_params);
86
87 /**
88 ****************************************************************************************
89 * @brief De-initialize the APP SPI DRIVER peripheral.
90 *
91 * @param[in] id: De-initialize for a specific ID.
92 *
93 * @return Result of De-initialization.
94 ****************************************************************************************
95 */
96 uint16_t app_spi_dma_deinit(app_spi_id_t id);
97 /**
98 ****************************************************************************************
99 * @brief SPI master transmit with 1-byte inst and 3-byte addr, can use to write flash/display/eeprom, etc
100 * @note DO NOT Support interrupt mode
101 * @param[in] id : just support APP_SPI_ID_MASTER
102 * @param[in] instruction : 1-byte instruction phase
103 * @param[in] address : 3-byte address phase
104 * @param[in] p_data : pointer to transmit buffer
105 * @param[in] data_length : length of buffer, unit in byte
106 *
107 * @return APP_DRV_* in app_drv_error.h
108 ****************************************************************************************
109 */
110 uint16_t app_spim_dma_transmit_with_ia(app_spi_id_t id, uint8_t instruction, uint32_t address, uint8_t * p_data, uint16_t data_length);
111
112 /**
113 ****************************************************************************************
114 * @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
115 *
116 * @param[in] id : just support APP_SPI_ID_MASTER
117 * @param[in] instruction : 1-byte instruction phase
118 * @param[in] address : 3-byte address phase
119 * @param[in] dummy_bytes : dummy bytes, 0 ~ 4
120 * @param[in] p_data : pointer to transmit buffer
121 * @param[in] data_length : length of buffer, unit in byte
122 *
123 * @return APP_DRV_* in app_drv_error.h
124 ****************************************************************************************
125 */
126 uint16_t app_spim_dma_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);
127
128 /**
129 ****************************************************************************************
130 * @brief Receive in master or slave mode an amount of data in non-blocking mode with Interrupt
131 *
132 * @param[in] id: which SPI module want to receive.
133 * @param[in] p_data: Pointer to data buffer
134 * @param[in] size: Amount of data to be sent
135 *
136 * @return Result of operation.
137 ****************************************************************************************
138 */
139 uint16_t app_spi_dma_receive_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
140
141 /**
142 ****************************************************************************************
143 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt
144 *
145 * @param[in] id: which SPI module want to transmit.
146 * @param[in] p_data: Pointer to data buffer
147 * @param[in] size: Amount of data to be sent
148 *
149 * @return Result of operation.
150 ****************************************************************************************
151 */
152 uint16_t app_spi_dma_transmit_async(app_spi_id_t id, uint8_t *p_data, uint16_t size);
153
154 /**
155 ****************************************************************************************
156 * @brief Transmits and receive in master or slave mode an amount of data in non-blocking mode with Interrupt
157 *
158 * @param[in] id: which SPI module want to transmit.
159 * @param[in] p_tx_data: Pointer to tx data buffer
160 * @param[in] p_rx_data: Pointer to rx data buffer
161 * @param[in] size: Amount of data to be sent and receive
162 *
163 * @return Result of operation.
164 ****************************************************************************************
165 */
166 uint16_t app_spi_dma_transmit_receive_async(app_spi_id_t id, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t size);
167
168 /**
169 ****************************************************************************************
170 * @brief Read an amount of data from EEPROM in non-blocking mode with Interrupt.
171 *
172 * @param[in] id: which SPI module want to transmit.
173 * @param[in] p_tx_data: Pointer to transmission data buffer
174 * @param[out] p_rx_data: Pointer to reception data buffer
175 * @param[in] tx_size: Amount of data to be sent in bytes
176 * @param[in] rx_size: Amount of data to be received in bytes
177 *
178 * @return Result of operation.
179 ****************************************************************************************
180 */
181 uint16_t app_spi_dma_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);
182
183 #if (APP_DRIVER_CHIP_TYPE == APP_DRIVER_GR551X)
184 /**
185 ****************************************************************************************
186 * @brief Transmits in master or slave mode an amount of data in non-blocking mode with DMA
187 *
188 * @param[in] id: which SPI module want to transmit.
189 * @param[in] p_cmd_data: Pointer to command data buffer
190 * @param[in] p_tx_data: Pointer to transmission data buffer
191 * @param[in] cmd_size: Amount of command data to be sent in bytes
192 * @param[in] tx_size: Amount of data to be sent in bytes
193 *
194 * @return Result of operation.
195 ****************************************************************************************
196 */
197 uint16_t app_spi_dma_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);
198
199 /**
200 ****************************************************************************************
201 * @brief Read an amount of data from EEPROM in non-blocking mode with DMA.
202 *
203 * @param[in] id: which SPI module want to transmit.
204 * @param[in] p_cmd_data: Pointer to command data buffer
205 * @param[out] p_rx_data: Pointer to reception data buffer
206 * @param[in] cmd_size: Amount of command data to be sent in bytes
207 * @param[in] rx_size: Amount of data to be received in bytes
208 *
209 * @return Result of operation.
210 ****************************************************************************************
211 */
212 uint16_t app_spi_dma_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);
213
214 /**
215 ****************************************************************************************
216 * @brief [High speed] Receive in master or slave mode an amount of data in blocking mode.
217 *
218 * @param[in] id: which SPI module want to receive.
219 * @param[in] p_data: Pointer to data buffer
220 * @param[in] size: Amount of data to be sent
221 *
222 * @return Result of operation.
223 ****************************************************************************************
224 */
225 uint16_t app_spi_dma_receive_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
226
227 /**
228 ****************************************************************************************
229 * @brief [High speed] Transmit in master or slave mode an amount of data in blocking mode.
230 *
231 * @param[in] id: which SPI module want to receive.
232 * @param[in] p_data: Pointer to data buffer
233 * @param[in] size: Amount of data to be sent
234 *
235 * @return Result of operation.
236 ****************************************************************************************
237 */
238 uint16_t app_spi_dma_transmit_high_speed_sync(app_spi_id_t id, uint8_t *p_data, uint16_t size);
239 #endif
240
241 /** @} */
242
243 #endif
244
245 #ifdef __cplusplus
246 }
247 #endif
248
249 #endif
250
251 /** @} */
252
253 /** @} */
254
255 /** @} */
256
app_spi_dma_transmit_high_speed_sync
uint16_t app_spi_dma_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_params_t
SPI parameters structure definition.
Definition: app_spi.h:203
app_spi_dma_read_memory_async
uint16_t app_spi_dma_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_dma_init
uint16_t app_spi_dma_init(app_spi_params_t *p_params)
Initialize the APP SPI DRIVER according to the specified parameters in the app_spi_params_t and app_s...
app_spi_dma_transmit_receive_async
uint16_t app_spi_dma_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_io.h
Header file containing functions prototypes of GPIO app library.
app_spi_dma_receive_high_speed_sync
uint16_t app_spi_dma_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_dma_transmit_async
uint16_t app_spi_dma_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.
app_spi_id_t
app_spi_id_t
SPI module Enumerations definition.
Definition: app_spi.h:83
app_spi_dma_write_memory_async
uint16_t app_spi_dma_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_read_eeprom_async
uint16_t app_spi_dma_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_dma_deinit
uint16_t app_spi_dma_deinit(app_spi_id_t id)
De-initialize the APP SPI DRIVER peripheral.
app_dma.h
Header file containing functions prototypes of DMA app library.
app_spi_dma_receive_async
uint16_t app_spi_dma_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_spim_dma_receive_with_ia
uint16_t app_spim_dma_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.h
Header file containing functions prototypes of SPI app library.
app_spim_dma_transmit_with_ia
uint16_t app_spim_dma_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,...
app_drv_error.h
Header file of app driver error code.
app_drv_config.h
Header file of app driver config code.