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_H_
53 #define _APP_DMA_H_
54
55 #include "gr55xx_hal.h"
56 #include "app_drv_error.h"
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62 #ifdef HAL_DMA_MODULE_ENABLED
63
64 /** @addtogroup APP_DMA_TYPEDEFS Typedefs
65 * @{
66 */
67 /**
68 * @brief DMA id definition
69 */
70 typedef int16_t dma_id_t;
71 /** @} */
72
73 /** @addtogroup APP_DMA_ENUMERATIONS Enumerations
74 * @{
75 */
76 /**
77 * @brief DMA event Enumerations definition
78 */
79 typedef enum
80 {
81 APP_DMA_EVT_ERROR, /**< The event of error interrupt. */
82 APP_DMA_EVT_TFR, /**< The event of transfer complete interrupt. */
83 } app_dma_evt_type_t;
84 /** @} */
85
86 /** @addtogroup APP_DMA_STRUCTURES Structures
87 * @{
88 */
89 /**
90 * @brief DMA parameters structure definition
91 */
92 typedef struct
93 {
94 dma_channel_t channel_number; /**< Specifies the channel of DMA. */
95 dma_init_t init; /**< DMA communication parameters. */
96 } app_dma_params_t;
97 /** @} */
98
99 /** @addtogroup APP_DMA_TYPEDEFS Typedefs
100 * @{
101 */
102 /**
103 * @brief DMA event callback definition
104 */
105 typedef void (*app_dma_evt_handler_t)(app_dma_evt_type_t type);
106
107 /** @} */
108
109
110 /* Exported functions --------------------------------------------------------*/
111 /** @addtogroup APP_DMA_DRIVER_FUNCTIONS Functions
112 * @{
113 */
114 /**
115 ****************************************************************************************
116 * @brief Initialize the APP DMA DRIVER according to the specified parameters
117 * in the app_dma_params_t and app_dma_evt_handler_t.
118 *
119 * @param[in] p_params: Pointer to app_dma_params_t parameter which contains the
120 * configuration information for the specified DMA module.
121 * @param[in] evt_handler: DMA user callback function.
122 *
123 * @return DMA ID
124 ****************************************************************************************
125 */
126 dma_id_t app_dma_init(app_dma_params_t *p_params, app_dma_evt_handler_t evt_handler);
127
128 /**
129 ****************************************************************************************
130 * @brief De-initialize the APP ADC DRIVER peripheral.
131 *
132 * @param[in] ins_id: Deinitialize DMA channel for a specific ID.
133 *
134 * @return Result of De-initialization.
135 ****************************************************************************************
136 */
137 uint16_t app_dma_deinit(dma_id_t ins_id);
138
139 /**
140 ****************************************************************************************
141 * @brief Start the DMA Transfer.
142 *
143 * @param[in] id: DMA channel id.
144 * @param[in] src_address: The source memory Buffer address
145 * @param[in] dst_address: The destination memory Buffer address
146 * @param[in] data_length: The length of data to be transferred from source to destination, ranging between 0 and 4095.
147 ****************************************************************************************
148 */
149 uint16_t app_dma_start(dma_id_t id, uint32_t src_address, uint32_t dst_address, uint32_t data_length);
150
151 /**
152 ****************************************************************************************
153 * @brief Return the DMA handle.
154 *
155 * @param[in] id: DMA Channel ID.
156 *
157 * @return Pointer to the specified ID's DMA handle.
158 ****************************************************************************************
159 */
160 dma_handle_t *app_dma_get_handle(dma_id_t id);
161
162 #ifdef APP_DRIVER_WAKEUP_CALL_FUN
163 /**
164 ****************************************************************************************
165 * @brief resume dma after wake up for other modules.
166 *
167 * @param[in] id: DMA Channel ID.
168 *
169 * @return void.
170 ****************************************************************************************
171 */
172 void dma_wake_up(dma_id_t id);
173 #endif
174
175
176 /** @} */
177
178 #endif
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif
185
186 /** @} */
187 /** @} */
188 /** @} */
app_dma_get_handle
dma_handle_t * app_dma_get_handle(dma_id_t id)
Return the DMA handle.
_dma_init
DMA Configuration Structure definition.
Definition: gr55xx_hal_dma.h:137
app_dma_params_t
DMA parameters structure definition.
Definition: app_dma.h:93
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:105
APP_DMA_EVT_TFR
@ APP_DMA_EVT_TFR
The event of transfer complete interrupt.
Definition: app_dma.h:82
app_dma_params_t::channel_number
dma_channel_t channel_number
Specifies the channel of DMA.
Definition: app_dma.h:94
app_dma_params_t::init
dma_init_t init
DMA communication parameters.
Definition: app_dma.h:95
app_dma_deinit
uint16_t app_dma_deinit(dma_id_t ins_id)
De-initialize the APP ADC DRIVER peripheral.
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_type_t
app_dma_evt_type_t
DMA event Enumerations definition.
Definition: app_dma.h:80
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
APP_DMA_EVT_ERROR
@ APP_DMA_EVT_ERROR
The event of error interrupt.
Definition: app_dma.h:81
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...
app_drv_error.h
Header file of app driver error code.
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:179
dma_id_t
int16_t dma_id_t
DMA id definition.
Definition: app_dma.h:70
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93