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