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