Initial commit
mbed-dev-master/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_dac_ex.c@0:bb348c97df44, 2020-09-16 (annotated)
- Committer:
- lypinator
- Date:
- Wed Sep 16 01:11:49 2020 +0000
- Revision:
- 0:bb348c97df44
Added PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lypinator | 0:bb348c97df44 | 1 | /** |
lypinator | 0:bb348c97df44 | 2 | ****************************************************************************** |
lypinator | 0:bb348c97df44 | 3 | * @file stm32f4xx_hal_dac_ex.c |
lypinator | 0:bb348c97df44 | 4 | * @author MCD Application Team |
lypinator | 0:bb348c97df44 | 5 | * @brief DAC HAL module driver. |
lypinator | 0:bb348c97df44 | 6 | * This file provides firmware functions to manage the following |
lypinator | 0:bb348c97df44 | 7 | * functionalities of DAC extension peripheral: |
lypinator | 0:bb348c97df44 | 8 | * + Extended features functions |
lypinator | 0:bb348c97df44 | 9 | * |
lypinator | 0:bb348c97df44 | 10 | * |
lypinator | 0:bb348c97df44 | 11 | @verbatim |
lypinator | 0:bb348c97df44 | 12 | ============================================================================== |
lypinator | 0:bb348c97df44 | 13 | ##### How to use this driver ##### |
lypinator | 0:bb348c97df44 | 14 | ============================================================================== |
lypinator | 0:bb348c97df44 | 15 | [..] |
lypinator | 0:bb348c97df44 | 16 | (+) When Dual mode is enabled (i.e DAC Channel1 and Channel2 are used simultaneously) : |
lypinator | 0:bb348c97df44 | 17 | Use HAL_DACEx_DualGetValue() to get digital data to be converted and use |
lypinator | 0:bb348c97df44 | 18 | HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2. |
lypinator | 0:bb348c97df44 | 19 | (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal. |
lypinator | 0:bb348c97df44 | 20 | (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal. |
lypinator | 0:bb348c97df44 | 21 | |
lypinator | 0:bb348c97df44 | 22 | @endverbatim |
lypinator | 0:bb348c97df44 | 23 | ****************************************************************************** |
lypinator | 0:bb348c97df44 | 24 | * @attention |
lypinator | 0:bb348c97df44 | 25 | * |
lypinator | 0:bb348c97df44 | 26 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
lypinator | 0:bb348c97df44 | 27 | * |
lypinator | 0:bb348c97df44 | 28 | * Redistribution and use in source and binary forms, with or without modification, |
lypinator | 0:bb348c97df44 | 29 | * are permitted provided that the following conditions are met: |
lypinator | 0:bb348c97df44 | 30 | * 1. Redistributions of source code must retain the above copyright notice, |
lypinator | 0:bb348c97df44 | 31 | * this list of conditions and the following disclaimer. |
lypinator | 0:bb348c97df44 | 32 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
lypinator | 0:bb348c97df44 | 33 | * this list of conditions and the following disclaimer in the documentation |
lypinator | 0:bb348c97df44 | 34 | * and/or other materials provided with the distribution. |
lypinator | 0:bb348c97df44 | 35 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
lypinator | 0:bb348c97df44 | 36 | * may be used to endorse or promote products derived from this software |
lypinator | 0:bb348c97df44 | 37 | * without specific prior written permission. |
lypinator | 0:bb348c97df44 | 38 | * |
lypinator | 0:bb348c97df44 | 39 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
lypinator | 0:bb348c97df44 | 40 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
lypinator | 0:bb348c97df44 | 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
lypinator | 0:bb348c97df44 | 42 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
lypinator | 0:bb348c97df44 | 43 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
lypinator | 0:bb348c97df44 | 44 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
lypinator | 0:bb348c97df44 | 45 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
lypinator | 0:bb348c97df44 | 46 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
lypinator | 0:bb348c97df44 | 47 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
lypinator | 0:bb348c97df44 | 48 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
lypinator | 0:bb348c97df44 | 49 | * |
lypinator | 0:bb348c97df44 | 50 | ****************************************************************************** |
lypinator | 0:bb348c97df44 | 51 | */ |
lypinator | 0:bb348c97df44 | 52 | |
lypinator | 0:bb348c97df44 | 53 | |
lypinator | 0:bb348c97df44 | 54 | /* Includes ------------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 55 | #include "stm32f4xx_hal.h" |
lypinator | 0:bb348c97df44 | 56 | |
lypinator | 0:bb348c97df44 | 57 | /** @addtogroup STM32F4xx_HAL_Driver |
lypinator | 0:bb348c97df44 | 58 | * @{ |
lypinator | 0:bb348c97df44 | 59 | */ |
lypinator | 0:bb348c97df44 | 60 | |
lypinator | 0:bb348c97df44 | 61 | /** @defgroup DACEx DACEx |
lypinator | 0:bb348c97df44 | 62 | * @brief DAC driver modules |
lypinator | 0:bb348c97df44 | 63 | * @{ |
lypinator | 0:bb348c97df44 | 64 | */ |
lypinator | 0:bb348c97df44 | 65 | |
lypinator | 0:bb348c97df44 | 66 | #ifdef HAL_DAC_MODULE_ENABLED |
lypinator | 0:bb348c97df44 | 67 | |
lypinator | 0:bb348c97df44 | 68 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ |
lypinator | 0:bb348c97df44 | 69 | defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ |
lypinator | 0:bb348c97df44 | 70 | defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) ||\ |
lypinator | 0:bb348c97df44 | 71 | defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || defined(STM32F423xx) |
lypinator | 0:bb348c97df44 | 72 | /* Private typedef -----------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 73 | /* Private define ------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 74 | /* Private macro -------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 75 | /* Private variables ---------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 76 | /* Private function prototypes -----------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 77 | /* Private functions ---------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 78 | /* Exported functions --------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 79 | /** @defgroup DACEx_Exported_Functions DAC Exported Functions |
lypinator | 0:bb348c97df44 | 80 | * @{ |
lypinator | 0:bb348c97df44 | 81 | */ |
lypinator | 0:bb348c97df44 | 82 | |
lypinator | 0:bb348c97df44 | 83 | /** @defgroup DACEx_Exported_Functions_Group1 Extended features functions |
lypinator | 0:bb348c97df44 | 84 | * @brief Extended features functions |
lypinator | 0:bb348c97df44 | 85 | * |
lypinator | 0:bb348c97df44 | 86 | @verbatim |
lypinator | 0:bb348c97df44 | 87 | ============================================================================== |
lypinator | 0:bb348c97df44 | 88 | ##### Extended features functions ##### |
lypinator | 0:bb348c97df44 | 89 | ============================================================================== |
lypinator | 0:bb348c97df44 | 90 | [..] This section provides functions allowing to: |
lypinator | 0:bb348c97df44 | 91 | (+) Start conversion. |
lypinator | 0:bb348c97df44 | 92 | (+) Stop conversion. |
lypinator | 0:bb348c97df44 | 93 | (+) Start conversion and enable DMA transfer. |
lypinator | 0:bb348c97df44 | 94 | (+) Stop conversion and disable DMA transfer. |
lypinator | 0:bb348c97df44 | 95 | (+) Get result of conversion. |
lypinator | 0:bb348c97df44 | 96 | (+) Get result of dual mode conversion. |
lypinator | 0:bb348c97df44 | 97 | |
lypinator | 0:bb348c97df44 | 98 | @endverbatim |
lypinator | 0:bb348c97df44 | 99 | * @{ |
lypinator | 0:bb348c97df44 | 100 | */ |
lypinator | 0:bb348c97df44 | 101 | |
lypinator | 0:bb348c97df44 | 102 | /** |
lypinator | 0:bb348c97df44 | 103 | * @brief Returns the last data output value of the selected DAC channel. |
lypinator | 0:bb348c97df44 | 104 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 105 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 106 | * @retval The selected DAC channel data output value. |
lypinator | 0:bb348c97df44 | 107 | */ |
lypinator | 0:bb348c97df44 | 108 | uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac) |
lypinator | 0:bb348c97df44 | 109 | { |
lypinator | 0:bb348c97df44 | 110 | uint32_t tmp = 0U; |
lypinator | 0:bb348c97df44 | 111 | |
lypinator | 0:bb348c97df44 | 112 | tmp |= hdac->Instance->DOR1; |
lypinator | 0:bb348c97df44 | 113 | |
lypinator | 0:bb348c97df44 | 114 | tmp |= hdac->Instance->DOR2 << 16U; |
lypinator | 0:bb348c97df44 | 115 | |
lypinator | 0:bb348c97df44 | 116 | /* Returns the DAC channel data output register value */ |
lypinator | 0:bb348c97df44 | 117 | return tmp; |
lypinator | 0:bb348c97df44 | 118 | } |
lypinator | 0:bb348c97df44 | 119 | |
lypinator | 0:bb348c97df44 | 120 | /** |
lypinator | 0:bb348c97df44 | 121 | * @brief Enables or disables the selected DAC channel wave generation. |
lypinator | 0:bb348c97df44 | 122 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 123 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 124 | * @param Channel The selected DAC channel. |
lypinator | 0:bb348c97df44 | 125 | * This parameter can be one of the following values: |
lypinator | 0:bb348c97df44 | 126 | * DAC_CHANNEL_1 / DAC_CHANNEL_2 |
lypinator | 0:bb348c97df44 | 127 | * @param Amplitude Select max triangle amplitude. |
lypinator | 0:bb348c97df44 | 128 | * This parameter can be one of the following values: |
lypinator | 0:bb348c97df44 | 129 | * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1 |
lypinator | 0:bb348c97df44 | 130 | * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3 |
lypinator | 0:bb348c97df44 | 131 | * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7 |
lypinator | 0:bb348c97df44 | 132 | * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15 |
lypinator | 0:bb348c97df44 | 133 | * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31 |
lypinator | 0:bb348c97df44 | 134 | * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63 |
lypinator | 0:bb348c97df44 | 135 | * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127 |
lypinator | 0:bb348c97df44 | 136 | * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255 |
lypinator | 0:bb348c97df44 | 137 | * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511 |
lypinator | 0:bb348c97df44 | 138 | * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023 |
lypinator | 0:bb348c97df44 | 139 | * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047 |
lypinator | 0:bb348c97df44 | 140 | * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095 |
lypinator | 0:bb348c97df44 | 141 | * @retval HAL status |
lypinator | 0:bb348c97df44 | 142 | */ |
lypinator | 0:bb348c97df44 | 143 | HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) |
lypinator | 0:bb348c97df44 | 144 | { |
lypinator | 0:bb348c97df44 | 145 | /* Check the parameters */ |
lypinator | 0:bb348c97df44 | 146 | assert_param(IS_DAC_CHANNEL(Channel)); |
lypinator | 0:bb348c97df44 | 147 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); |
lypinator | 0:bb348c97df44 | 148 | |
lypinator | 0:bb348c97df44 | 149 | /* Process locked */ |
lypinator | 0:bb348c97df44 | 150 | __HAL_LOCK(hdac); |
lypinator | 0:bb348c97df44 | 151 | |
lypinator | 0:bb348c97df44 | 152 | /* Change DAC state */ |
lypinator | 0:bb348c97df44 | 153 | hdac->State = HAL_DAC_STATE_BUSY; |
lypinator | 0:bb348c97df44 | 154 | |
lypinator | 0:bb348c97df44 | 155 | /* Enable the selected wave generation for the selected DAC channel */ |
lypinator | 0:bb348c97df44 | 156 | MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel); |
lypinator | 0:bb348c97df44 | 157 | |
lypinator | 0:bb348c97df44 | 158 | /* Change DAC state */ |
lypinator | 0:bb348c97df44 | 159 | hdac->State = HAL_DAC_STATE_READY; |
lypinator | 0:bb348c97df44 | 160 | |
lypinator | 0:bb348c97df44 | 161 | /* Process unlocked */ |
lypinator | 0:bb348c97df44 | 162 | __HAL_UNLOCK(hdac); |
lypinator | 0:bb348c97df44 | 163 | |
lypinator | 0:bb348c97df44 | 164 | /* Return function status */ |
lypinator | 0:bb348c97df44 | 165 | return HAL_OK; |
lypinator | 0:bb348c97df44 | 166 | } |
lypinator | 0:bb348c97df44 | 167 | |
lypinator | 0:bb348c97df44 | 168 | /** |
lypinator | 0:bb348c97df44 | 169 | * @brief Enables or disables the selected DAC channel wave generation. |
lypinator | 0:bb348c97df44 | 170 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 171 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 172 | * @param Channel The selected DAC channel. |
lypinator | 0:bb348c97df44 | 173 | * This parameter can be one of the following values: |
lypinator | 0:bb348c97df44 | 174 | * DAC_CHANNEL_1 / DAC_CHANNEL_2 |
lypinator | 0:bb348c97df44 | 175 | * @param Amplitude Unmask DAC channel LFSR for noise wave generation. |
lypinator | 0:bb348c97df44 | 176 | * This parameter can be one of the following values: |
lypinator | 0:bb348c97df44 | 177 | * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation |
lypinator | 0:bb348c97df44 | 178 | * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 179 | * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 180 | * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 181 | * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 182 | * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 183 | * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 184 | * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 185 | * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 186 | * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 187 | * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 188 | * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation |
lypinator | 0:bb348c97df44 | 189 | * @retval HAL status |
lypinator | 0:bb348c97df44 | 190 | */ |
lypinator | 0:bb348c97df44 | 191 | HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) |
lypinator | 0:bb348c97df44 | 192 | { |
lypinator | 0:bb348c97df44 | 193 | /* Check the parameters */ |
lypinator | 0:bb348c97df44 | 194 | assert_param(IS_DAC_CHANNEL(Channel)); |
lypinator | 0:bb348c97df44 | 195 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); |
lypinator | 0:bb348c97df44 | 196 | |
lypinator | 0:bb348c97df44 | 197 | /* Process locked */ |
lypinator | 0:bb348c97df44 | 198 | __HAL_LOCK(hdac); |
lypinator | 0:bb348c97df44 | 199 | |
lypinator | 0:bb348c97df44 | 200 | /* Change DAC state */ |
lypinator | 0:bb348c97df44 | 201 | hdac->State = HAL_DAC_STATE_BUSY; |
lypinator | 0:bb348c97df44 | 202 | |
lypinator | 0:bb348c97df44 | 203 | /* Enable the selected wave generation for the selected DAC channel */ |
lypinator | 0:bb348c97df44 | 204 | MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel); |
lypinator | 0:bb348c97df44 | 205 | |
lypinator | 0:bb348c97df44 | 206 | /* Change DAC state */ |
lypinator | 0:bb348c97df44 | 207 | hdac->State = HAL_DAC_STATE_READY; |
lypinator | 0:bb348c97df44 | 208 | |
lypinator | 0:bb348c97df44 | 209 | /* Process unlocked */ |
lypinator | 0:bb348c97df44 | 210 | __HAL_UNLOCK(hdac); |
lypinator | 0:bb348c97df44 | 211 | |
lypinator | 0:bb348c97df44 | 212 | /* Return function status */ |
lypinator | 0:bb348c97df44 | 213 | return HAL_OK; |
lypinator | 0:bb348c97df44 | 214 | } |
lypinator | 0:bb348c97df44 | 215 | |
lypinator | 0:bb348c97df44 | 216 | /** |
lypinator | 0:bb348c97df44 | 217 | * @brief Set the specified data holding register value for dual DAC channel. |
lypinator | 0:bb348c97df44 | 218 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 219 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 220 | * @param Alignment Specifies the data alignment for dual channel DAC. |
lypinator | 0:bb348c97df44 | 221 | * This parameter can be one of the following values: |
lypinator | 0:bb348c97df44 | 222 | * DAC_ALIGN_8B_R: 8bit right data alignment selected |
lypinator | 0:bb348c97df44 | 223 | * DAC_ALIGN_12B_L: 12bit left data alignment selected |
lypinator | 0:bb348c97df44 | 224 | * DAC_ALIGN_12B_R: 12bit right data alignment selected |
lypinator | 0:bb348c97df44 | 225 | * @param Data1 Data for DAC Channel2 to be loaded in the selected data holding register. |
lypinator | 0:bb348c97df44 | 226 | * @param Data2 Data for DAC Channel1 to be loaded in the selected data holding register. |
lypinator | 0:bb348c97df44 | 227 | * @note In dual mode, a unique register access is required to write in both |
lypinator | 0:bb348c97df44 | 228 | * DAC channels at the same time. |
lypinator | 0:bb348c97df44 | 229 | * @retval HAL status |
lypinator | 0:bb348c97df44 | 230 | */ |
lypinator | 0:bb348c97df44 | 231 | HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2) |
lypinator | 0:bb348c97df44 | 232 | { |
lypinator | 0:bb348c97df44 | 233 | uint32_t data = 0U, tmp = 0U; |
lypinator | 0:bb348c97df44 | 234 | |
lypinator | 0:bb348c97df44 | 235 | /* Check the parameters */ |
lypinator | 0:bb348c97df44 | 236 | assert_param(IS_DAC_ALIGN(Alignment)); |
lypinator | 0:bb348c97df44 | 237 | assert_param(IS_DAC_DATA(Data1)); |
lypinator | 0:bb348c97df44 | 238 | assert_param(IS_DAC_DATA(Data2)); |
lypinator | 0:bb348c97df44 | 239 | |
lypinator | 0:bb348c97df44 | 240 | /* Calculate and set dual DAC data holding register value */ |
lypinator | 0:bb348c97df44 | 241 | if (Alignment == DAC_ALIGN_8B_R) |
lypinator | 0:bb348c97df44 | 242 | { |
lypinator | 0:bb348c97df44 | 243 | data = ((uint32_t)Data2 << 8U) | Data1; |
lypinator | 0:bb348c97df44 | 244 | } |
lypinator | 0:bb348c97df44 | 245 | else |
lypinator | 0:bb348c97df44 | 246 | { |
lypinator | 0:bb348c97df44 | 247 | data = ((uint32_t)Data2 << 16U) | Data1; |
lypinator | 0:bb348c97df44 | 248 | } |
lypinator | 0:bb348c97df44 | 249 | |
lypinator | 0:bb348c97df44 | 250 | tmp = (uint32_t)hdac->Instance; |
lypinator | 0:bb348c97df44 | 251 | tmp += DAC_DHR12RD_ALIGNMENT(Alignment); |
lypinator | 0:bb348c97df44 | 252 | |
lypinator | 0:bb348c97df44 | 253 | /* Set the dual DAC selected data holding register */ |
lypinator | 0:bb348c97df44 | 254 | *(__IO uint32_t *)tmp = data; |
lypinator | 0:bb348c97df44 | 255 | |
lypinator | 0:bb348c97df44 | 256 | /* Return function status */ |
lypinator | 0:bb348c97df44 | 257 | return HAL_OK; |
lypinator | 0:bb348c97df44 | 258 | } |
lypinator | 0:bb348c97df44 | 259 | |
lypinator | 0:bb348c97df44 | 260 | /** |
lypinator | 0:bb348c97df44 | 261 | * @} |
lypinator | 0:bb348c97df44 | 262 | */ |
lypinator | 0:bb348c97df44 | 263 | |
lypinator | 0:bb348c97df44 | 264 | /** |
lypinator | 0:bb348c97df44 | 265 | * @brief Conversion complete callback in non blocking mode for Channel2 |
lypinator | 0:bb348c97df44 | 266 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 267 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 268 | * @retval None |
lypinator | 0:bb348c97df44 | 269 | */ |
lypinator | 0:bb348c97df44 | 270 | __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac) |
lypinator | 0:bb348c97df44 | 271 | { |
lypinator | 0:bb348c97df44 | 272 | /* Prevent unused argument(s) compilation warning */ |
lypinator | 0:bb348c97df44 | 273 | UNUSED(hdac); |
lypinator | 0:bb348c97df44 | 274 | /* NOTE : This function Should not be modified, when the callback is needed, |
lypinator | 0:bb348c97df44 | 275 | the HAL_DAC_ConvCpltCallback could be implemented in the user file |
lypinator | 0:bb348c97df44 | 276 | */ |
lypinator | 0:bb348c97df44 | 277 | } |
lypinator | 0:bb348c97df44 | 278 | |
lypinator | 0:bb348c97df44 | 279 | /** |
lypinator | 0:bb348c97df44 | 280 | * @brief Conversion half DMA transfer callback in non blocking mode for Channel2 |
lypinator | 0:bb348c97df44 | 281 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 282 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 283 | * @retval None |
lypinator | 0:bb348c97df44 | 284 | */ |
lypinator | 0:bb348c97df44 | 285 | __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac) |
lypinator | 0:bb348c97df44 | 286 | { |
lypinator | 0:bb348c97df44 | 287 | /* Prevent unused argument(s) compilation warning */ |
lypinator | 0:bb348c97df44 | 288 | UNUSED(hdac); |
lypinator | 0:bb348c97df44 | 289 | /* NOTE : This function Should not be modified, when the callback is needed, |
lypinator | 0:bb348c97df44 | 290 | the HAL_DAC_ConvHalfCpltCallbackCh2 could be implemented in the user file |
lypinator | 0:bb348c97df44 | 291 | */ |
lypinator | 0:bb348c97df44 | 292 | } |
lypinator | 0:bb348c97df44 | 293 | |
lypinator | 0:bb348c97df44 | 294 | /** |
lypinator | 0:bb348c97df44 | 295 | * @brief Error DAC callback for Channel2. |
lypinator | 0:bb348c97df44 | 296 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 297 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 298 | * @retval None |
lypinator | 0:bb348c97df44 | 299 | */ |
lypinator | 0:bb348c97df44 | 300 | __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac) |
lypinator | 0:bb348c97df44 | 301 | { |
lypinator | 0:bb348c97df44 | 302 | /* Prevent unused argument(s) compilation warning */ |
lypinator | 0:bb348c97df44 | 303 | UNUSED(hdac); |
lypinator | 0:bb348c97df44 | 304 | /* NOTE : This function Should not be modified, when the callback is needed, |
lypinator | 0:bb348c97df44 | 305 | the HAL_DAC_ErrorCallback could be implemented in the user file |
lypinator | 0:bb348c97df44 | 306 | */ |
lypinator | 0:bb348c97df44 | 307 | } |
lypinator | 0:bb348c97df44 | 308 | |
lypinator | 0:bb348c97df44 | 309 | /** |
lypinator | 0:bb348c97df44 | 310 | * @brief DMA underrun DAC callback for channel2. |
lypinator | 0:bb348c97df44 | 311 | * @param hdac pointer to a DAC_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 312 | * the configuration information for the specified DAC. |
lypinator | 0:bb348c97df44 | 313 | * @retval None |
lypinator | 0:bb348c97df44 | 314 | */ |
lypinator | 0:bb348c97df44 | 315 | __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac) |
lypinator | 0:bb348c97df44 | 316 | { |
lypinator | 0:bb348c97df44 | 317 | /* Prevent unused argument(s) compilation warning */ |
lypinator | 0:bb348c97df44 | 318 | UNUSED(hdac); |
lypinator | 0:bb348c97df44 | 319 | /* NOTE : This function Should not be modified, when the callback is needed, |
lypinator | 0:bb348c97df44 | 320 | the HAL_DAC_DMAUnderrunCallbackCh2 could be implemented in the user file |
lypinator | 0:bb348c97df44 | 321 | */ |
lypinator | 0:bb348c97df44 | 322 | } |
lypinator | 0:bb348c97df44 | 323 | |
lypinator | 0:bb348c97df44 | 324 | /** |
lypinator | 0:bb348c97df44 | 325 | * @brief DMA conversion complete callback. |
lypinator | 0:bb348c97df44 | 326 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 327 | * the configuration information for the specified DMA module. |
lypinator | 0:bb348c97df44 | 328 | * @retval None |
lypinator | 0:bb348c97df44 | 329 | */ |
lypinator | 0:bb348c97df44 | 330 | void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma) |
lypinator | 0:bb348c97df44 | 331 | { |
lypinator | 0:bb348c97df44 | 332 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
lypinator | 0:bb348c97df44 | 333 | |
lypinator | 0:bb348c97df44 | 334 | HAL_DACEx_ConvCpltCallbackCh2(hdac); |
lypinator | 0:bb348c97df44 | 335 | |
lypinator | 0:bb348c97df44 | 336 | hdac->State= HAL_DAC_STATE_READY; |
lypinator | 0:bb348c97df44 | 337 | } |
lypinator | 0:bb348c97df44 | 338 | |
lypinator | 0:bb348c97df44 | 339 | /** |
lypinator | 0:bb348c97df44 | 340 | * @brief DMA half transfer complete callback. |
lypinator | 0:bb348c97df44 | 341 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 342 | * the configuration information for the specified DMA module. |
lypinator | 0:bb348c97df44 | 343 | * @retval None |
lypinator | 0:bb348c97df44 | 344 | */ |
lypinator | 0:bb348c97df44 | 345 | void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma) |
lypinator | 0:bb348c97df44 | 346 | { |
lypinator | 0:bb348c97df44 | 347 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
lypinator | 0:bb348c97df44 | 348 | /* Conversion complete callback */ |
lypinator | 0:bb348c97df44 | 349 | HAL_DACEx_ConvHalfCpltCallbackCh2(hdac); |
lypinator | 0:bb348c97df44 | 350 | } |
lypinator | 0:bb348c97df44 | 351 | |
lypinator | 0:bb348c97df44 | 352 | /** |
lypinator | 0:bb348c97df44 | 353 | * @brief DMA error callback |
lypinator | 0:bb348c97df44 | 354 | * @param hdma pointer to a DMA_HandleTypeDef structure that contains |
lypinator | 0:bb348c97df44 | 355 | * the configuration information for the specified DMA module. |
lypinator | 0:bb348c97df44 | 356 | * @retval None |
lypinator | 0:bb348c97df44 | 357 | */ |
lypinator | 0:bb348c97df44 | 358 | void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma) |
lypinator | 0:bb348c97df44 | 359 | { |
lypinator | 0:bb348c97df44 | 360 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
lypinator | 0:bb348c97df44 | 361 | |
lypinator | 0:bb348c97df44 | 362 | /* Set DAC error code to DMA error */ |
lypinator | 0:bb348c97df44 | 363 | hdac->ErrorCode |= HAL_DAC_ERROR_DMA; |
lypinator | 0:bb348c97df44 | 364 | |
lypinator | 0:bb348c97df44 | 365 | HAL_DACEx_ErrorCallbackCh2(hdac); |
lypinator | 0:bb348c97df44 | 366 | |
lypinator | 0:bb348c97df44 | 367 | hdac->State= HAL_DAC_STATE_READY; |
lypinator | 0:bb348c97df44 | 368 | } |
lypinator | 0:bb348c97df44 | 369 | |
lypinator | 0:bb348c97df44 | 370 | /** |
lypinator | 0:bb348c97df44 | 371 | * @} |
lypinator | 0:bb348c97df44 | 372 | */ |
lypinator | 0:bb348c97df44 | 373 | |
lypinator | 0:bb348c97df44 | 374 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx ||\ |
lypinator | 0:bb348c97df44 | 375 | STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||\ |
lypinator | 0:bb348c97df44 | 376 | STM32F410xx || STM32F446xx || STM32F469xx || STM32F479xx ||\ |
lypinator | 0:bb348c97df44 | 377 | STM32F413xx || STM32F423xx */ |
lypinator | 0:bb348c97df44 | 378 | |
lypinator | 0:bb348c97df44 | 379 | #endif /* HAL_DAC_MODULE_ENABLED */ |
lypinator | 0:bb348c97df44 | 380 | |
lypinator | 0:bb348c97df44 | 381 | /** |
lypinator | 0:bb348c97df44 | 382 | * @} |
lypinator | 0:bb348c97df44 | 383 | */ |
lypinator | 0:bb348c97df44 | 384 | |
lypinator | 0:bb348c97df44 | 385 | /** |
lypinator | 0:bb348c97df44 | 386 | * @} |
lypinator | 0:bb348c97df44 | 387 | */ |
lypinator | 0:bb348c97df44 | 388 | |
lypinator | 0:bb348c97df44 | 389 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |