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