app_dma.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file app_dma.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of DMA 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_DMA DMA
47 * @brief DMA APP module driver.
48 * @{
49 */
50
51
52 #ifndef _APP_DMA_PUB_H_
53 #define _APP_DMA_PUB_H_
54
55 #include "grx_hal.h"
56 #include "app_drv_error.h"
57 #include "app_drv_config.h"
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 #ifdef HAL_DMA_MODULE_ENABLED
63
64
65 /** @addtogroup APP_DMA_ENUMERATIONS Enumerations
66 * @{
67 */
68
69 /**
70 * @brief DMA event Enumerations definition
71 */
72 typedef enum
73 {
74 APP_DMA_EVT_ERROR, /**< The event of error interrupt. */
75 APP_DMA_EVT_TFR, /**< The event of transfer complete interrupt. */
76 APP_DMA_EVT_BLK, /**< The event of block transfer complete interrupt. */
77 } app_dma_evt_type_t;
78
79 /**@brief App dma state types. */
80 typedef enum
81 {
82 APP_DMA_INVALID = 0,
83 APP_DMA_ACTIVITY,
84 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
85 APP_DMA_SLEEP,
86 #endif
87 } app_dma_state_t;
88
89 /** @} */
90
91 /** @addtogroup APP_DMA_TYPEDEFS Type definitions
92 * @{
93 */
94
95 /**
96 * @brief DMA id definition
97 */
98 typedef int16_t dma_id_t;
99
100 /**
101 * @brief DMA event callback definition
102 */
103 typedef void (*app_dma_evt_handler_t)(app_dma_evt_type_t type);
104
105 /** @} */
106
107 /** @addtogroup APP_DMA_STRUCTURES Structures
108 * @{
109 */
110
111 /**
112 * @brief DMA device structure definition
113 */
114 typedef struct
115 {
116 app_dma_state_t dma_state; /**< App dma state types. */
117 dma_handle_t handle; /**< DMA handle definition. */
118 app_dma_evt_handler_t evt_handler; /**< DMA event callback definition. */
119 } dma_env_t;
120
121 /**
122 * @brief DMA parameters structure definition
123 */
124 typedef struct
125 {
126 dma_regs_t *p_instance; /**< DMA inistall. */
127 dma_channel_t channel_number; /**< Specifies the channel of DMA. */
128 dma_init_t init; /**< DMA communication parameters. */
129 } app_dma_params_t;
130
131 /** @} */
132
133
134 /* Exported functions --------------------------------------------------------*/
135 /** @addtogroup APP_DMA_DRIVER_FUNCTIONS Functions
136 * @{
137 */
138 /**
139 ****************************************************************************************
140 * @brief Initialize the APP DMA DRIVER according to the specified parameters
141 * in the app_dma_params_t and app_dma_evt_handler_t.
142 *
143 * @param[in] p_params: Pointer to app_dma_params_t parameter which contains the
144 * configuration information for the specified DMA module.
145 * @param[in] evt_handler: DMA user callback function.
146 *
147 * @return DMA ID
148 ****************************************************************************************
149 */
150 dma_id_t app_dma_init(app_dma_params_t *p_params, app_dma_evt_handler_t evt_handler);
151
152 /**
153 ****************************************************************************************
154 * @brief De-initialize the APP ADC DRIVER peripheral.
155 *
156 * @param[in] id: Deinitialize DMA channel for a specific ID.
157 *
158 * @return Result of De-initialization.
159 ****************************************************************************************
160 */
161 uint16_t app_dma_deinit(dma_id_t id);
162
163 /**
164 ****************************************************************************************
165 * @brief Start the DMA Transfer.
166 *
167 * @param[in] id: DMA channel id.
168 * @param[in] src_address: The source memory Buffer address
169 * @param[in] dst_address: The destination memory Buffer address
170 * @param[in] data_length: The length of data to be transferred from source to destination, ranging between 0 and 4095.
171 ****************************************************************************************
172 */
173 uint16_t app_dma_start(dma_id_t id, uint32_t src_address, uint32_t dst_address, uint32_t data_length);
174
175 /**
176 ****************************************************************************************
177 * @brief Return the DMA handle.
178 *
179 * @param[in] id: DMA Channel ID.
180 *
181 * @return Pointer to the specified ID's DMA handle.
182 ****************************************************************************************
183 */
184 dma_handle_t *app_dma_get_handle(dma_id_t id);
185
186 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
187 /**
188 ****************************************************************************************
189 * @brief resume dma after wake up for other modules.
190 *
191 * @param[in] id: DMA Channel ID.
192 *
193 * @return void.
194 ****************************************************************************************
195 */
196 void dma_wake_up(dma_id_t id);
197 #endif
198
199 #ifdef APP_DMA_SG_LLP_ENABLE
200 /**
201 ****************************************************************************************
202 * @brief Start the DMA Transfer with sg & llp function.
203 *
204 * @param[in] id: DMA channel id.
205 * @param[in] src_address: The source address
206 * @param[in] dst_address: The destination address
207 * @param[in] data_length: The length of data to be transferred from source to destination, ranging between 0 and 4095.
208 * @param[in] sg_llp_config: The config of source and destination's sg and llp fuction.
209 ****************************************************************************************
210 */
211 uint16_t app_dma_start_sg_llp(dma_id_t id, uint32_t src_address, uint32_t dst_address, uint32_t data_length, dma_sg_llp_config_t *sg_llp_config);
212 #endif
213
214
215 /** @} */
216
217 #endif
218
219 #ifdef __cplusplus
220 }
221 #endif
222
223 #endif
224
225 /** @} */
226
227 /** @} */
228
229 /** @} */
230
app_dma_get_handle
dma_handle_t * app_dma_get_handle(dma_id_t id)
Return the DMA handle.
APP_DMA_INVALID
@ APP_DMA_INVALID
Definition: app_dma.h:82
dma_env_t
DMA device structure definition.
Definition: app_dma.h:115
dma_env_t::dma_state
app_dma_state_t dma_state
Definition: app_dma.h:116
_dma_init
DMA Configuration Structure definition.
Definition: hal_dma.h:158
app_dma_params_t
DMA parameters structure definition.
Definition: app_dma.h:125
app_dma_evt_handler_t
void(* app_dma_evt_handler_t)(app_dma_evt_type_t type)
DMA event callback definition.
Definition: app_dma.h:103
APP_DMA_EVT_TFR
@ APP_DMA_EVT_TFR
Definition: app_dma.h:75
APP_DMA_ACTIVITY
@ APP_DMA_ACTIVITY
Definition: app_dma.h:83
app_dma_params_t::channel_number
dma_channel_t channel_number
Definition: app_dma.h:127
app_dma_params_t::init
dma_init_t init
Definition: app_dma.h:128
grx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_dma_start
uint16_t app_dma_start(dma_id_t id, uint32_t src_address, uint32_t dst_address, uint32_t data_length)
Start the DMA Transfer.
APP_DMA_EVT_BLK
@ APP_DMA_EVT_BLK
Definition: app_dma.h:76
app_dma_state_t
app_dma_state_t
App dma state types.
Definition: app_dma.h:81
app_dma_evt_type_t
app_dma_evt_type_t
DMA event Enumerations definition.
Definition: app_dma.h:73
dma_env_t::evt_handler
app_dma_evt_handler_t evt_handler
Definition: app_dma.h:118
app_dma_params_t::p_instance
dma_regs_t * p_instance
Definition: app_dma.h:126
APP_DMA_EVT_ERROR
@ APP_DMA_EVT_ERROR
Definition: app_dma.h:74
app_dma_init
dma_id_t app_dma_init(app_dma_params_t *p_params, app_dma_evt_handler_t evt_handler)
Initialize the APP DMA DRIVER according to the specified parameters in the app_dma_params_t and app_d...
dma_env_t::handle
dma_handle_t handle
Definition: app_dma.h:117
app_dma_deinit
uint16_t app_dma_deinit(dma_id_t id)
De-initialize the APP ADC DRIVER peripheral.
app_drv_error.h
Header file of app driver error code.
app_drv_config.h
Header file of app driver config code.
_dma_handle
DMA handle Structure definition.
Definition: hal_dma.h:195
dma_id_t
int16_t dma_id_t
DMA id definition.
Definition: app_dma.h:98
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: hal_dma.h:95