mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F072RB/stm32f0xx_hal_dac_ex.c@218:44081b78fdc2, 2014-05-30 (annotated)
- Committer:
- mbed_official
- Date:
- Fri May 30 15:30:09 2014 +0100
- Revision:
- 218:44081b78fdc2
- Parent:
- 205:c41fc65bcfb4
Synchronized with git revision d854859072d318241476ccc5f335965444d4c1d8
Full URL: https://github.com/mbedmicro/mbed/commit/d854859072d318241476ccc5f335965444d4c1d8/
[NUCLEO_F072RB] Update CubeF0 HAL driver
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 205:c41fc65bcfb4 | 1 | /** |
mbed_official | 205:c41fc65bcfb4 | 2 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 3 | * @file stm32f0xx_hal_dac_ex.c |
mbed_official | 205:c41fc65bcfb4 | 4 | * @author MCD Application Team |
mbed_official | 205:c41fc65bcfb4 | 5 | * @version V1.0.0 |
mbed_official | 218:44081b78fdc2 | 6 | * @date 28-May-2014 |
mbed_official | 205:c41fc65bcfb4 | 7 | * @brief DAC HAL module driver. |
mbed_official | 205:c41fc65bcfb4 | 8 | * This file provides firmware functions to manage the following |
mbed_official | 205:c41fc65bcfb4 | 9 | * functionalities of DAC extension peripheral: |
mbed_official | 205:c41fc65bcfb4 | 10 | * + Extended features functions |
mbed_official | 205:c41fc65bcfb4 | 11 | * |
mbed_official | 205:c41fc65bcfb4 | 12 | * |
mbed_official | 205:c41fc65bcfb4 | 13 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 14 | ============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 15 | ##### How to use this driver ##### |
mbed_official | 205:c41fc65bcfb4 | 16 | ============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 17 | [..] |
mbed_official | 205:c41fc65bcfb4 | 18 | (+) When Dual mode is enabled (i.e DAC Channel1 and Channel2 are used simultaneously) : |
mbed_official | 205:c41fc65bcfb4 | 19 | Use HAL_DACEx_DualGetValue() to get digital data to be converted and use |
mbed_official | 205:c41fc65bcfb4 | 20 | HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2. |
mbed_official | 205:c41fc65bcfb4 | 21 | (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal. |
mbed_official | 205:c41fc65bcfb4 | 22 | (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal. |
mbed_official | 205:c41fc65bcfb4 | 23 | |
mbed_official | 205:c41fc65bcfb4 | 24 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 25 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 26 | * @attention |
mbed_official | 205:c41fc65bcfb4 | 27 | * |
mbed_official | 205:c41fc65bcfb4 | 28 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 205:c41fc65bcfb4 | 29 | * |
mbed_official | 205:c41fc65bcfb4 | 30 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 205:c41fc65bcfb4 | 31 | * are permitted provided that the following conditions are met: |
mbed_official | 205:c41fc65bcfb4 | 32 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 33 | * this list of conditions and the following disclaimer. |
mbed_official | 205:c41fc65bcfb4 | 34 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 205:c41fc65bcfb4 | 35 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 205:c41fc65bcfb4 | 36 | * and/or other materials provided with the distribution. |
mbed_official | 205:c41fc65bcfb4 | 37 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 205:c41fc65bcfb4 | 38 | * may be used to endorse or promote products derived from this software |
mbed_official | 205:c41fc65bcfb4 | 39 | * without specific prior written permission. |
mbed_official | 205:c41fc65bcfb4 | 40 | * |
mbed_official | 205:c41fc65bcfb4 | 41 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 205:c41fc65bcfb4 | 42 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 205:c41fc65bcfb4 | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 205:c41fc65bcfb4 | 44 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 205:c41fc65bcfb4 | 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 205:c41fc65bcfb4 | 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 205:c41fc65bcfb4 | 47 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 205:c41fc65bcfb4 | 48 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 205:c41fc65bcfb4 | 49 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 205:c41fc65bcfb4 | 50 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 205:c41fc65bcfb4 | 51 | * |
mbed_official | 205:c41fc65bcfb4 | 52 | ****************************************************************************** |
mbed_official | 205:c41fc65bcfb4 | 53 | */ |
mbed_official | 205:c41fc65bcfb4 | 54 | |
mbed_official | 205:c41fc65bcfb4 | 55 | |
mbed_official | 205:c41fc65bcfb4 | 56 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 57 | #include "stm32f0xx_hal.h" |
mbed_official | 205:c41fc65bcfb4 | 58 | |
mbed_official | 205:c41fc65bcfb4 | 59 | /** @addtogroup STM32F0xx_HAL_Driver |
mbed_official | 205:c41fc65bcfb4 | 60 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 61 | */ |
mbed_official | 205:c41fc65bcfb4 | 62 | |
mbed_official | 205:c41fc65bcfb4 | 63 | /** @defgroup DACEx |
mbed_official | 205:c41fc65bcfb4 | 64 | * @brief DAC driver modules |
mbed_official | 205:c41fc65bcfb4 | 65 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 66 | */ |
mbed_official | 205:c41fc65bcfb4 | 67 | |
mbed_official | 205:c41fc65bcfb4 | 68 | #ifdef HAL_DAC_MODULE_ENABLED |
mbed_official | 205:c41fc65bcfb4 | 69 | |
mbed_official | 205:c41fc65bcfb4 | 70 | #if defined(STM32F051x8) || defined(STM32F058xx) || \ |
mbed_official | 205:c41fc65bcfb4 | 71 | defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 72 | |
mbed_official | 205:c41fc65bcfb4 | 73 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 74 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 75 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 76 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 77 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 78 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 205:c41fc65bcfb4 | 79 | |
mbed_official | 205:c41fc65bcfb4 | 80 | static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma); |
mbed_official | 205:c41fc65bcfb4 | 81 | static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma); |
mbed_official | 205:c41fc65bcfb4 | 82 | static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma); |
mbed_official | 205:c41fc65bcfb4 | 83 | |
mbed_official | 205:c41fc65bcfb4 | 84 | /** @defgroup DACEx_Private_Functions |
mbed_official | 205:c41fc65bcfb4 | 85 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 86 | */ |
mbed_official | 205:c41fc65bcfb4 | 87 | |
mbed_official | 205:c41fc65bcfb4 | 88 | /** @defgroup DACEx_Group1 Extended features functions |
mbed_official | 205:c41fc65bcfb4 | 89 | * @brief Extended features functions |
mbed_official | 205:c41fc65bcfb4 | 90 | * |
mbed_official | 205:c41fc65bcfb4 | 91 | @verbatim |
mbed_official | 205:c41fc65bcfb4 | 92 | ============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 93 | ##### Extended features functions ##### |
mbed_official | 205:c41fc65bcfb4 | 94 | ============================================================================== |
mbed_official | 205:c41fc65bcfb4 | 95 | [..] This section provides functions allowing to: |
mbed_official | 205:c41fc65bcfb4 | 96 | (+) Start conversion. |
mbed_official | 205:c41fc65bcfb4 | 97 | (+) Stop conversion. |
mbed_official | 205:c41fc65bcfb4 | 98 | (+) Start conversion and enable DMA transfer. |
mbed_official | 205:c41fc65bcfb4 | 99 | (+) Stop conversion and disable DMA transfer. |
mbed_official | 205:c41fc65bcfb4 | 100 | (+) Get result of conversion. |
mbed_official | 205:c41fc65bcfb4 | 101 | (+) Get result of dual mode conversion. |
mbed_official | 205:c41fc65bcfb4 | 102 | |
mbed_official | 205:c41fc65bcfb4 | 103 | @endverbatim |
mbed_official | 205:c41fc65bcfb4 | 104 | * @{ |
mbed_official | 205:c41fc65bcfb4 | 105 | */ |
mbed_official | 205:c41fc65bcfb4 | 106 | |
mbed_official | 205:c41fc65bcfb4 | 107 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 108 | /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 109 | |
mbed_official | 205:c41fc65bcfb4 | 110 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 111 | |
mbed_official | 205:c41fc65bcfb4 | 112 | /** |
mbed_official | 205:c41fc65bcfb4 | 113 | * @brief Configures the selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 114 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 115 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 116 | * @param sConfig: DAC configuration structure. |
mbed_official | 205:c41fc65bcfb4 | 117 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 118 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 119 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 120 | * @arg DAC_CHANNEL_2: DAC Channel2 selected |
mbed_official | 205:c41fc65bcfb4 | 121 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 122 | */ |
mbed_official | 205:c41fc65bcfb4 | 123 | HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel) |
mbed_official | 205:c41fc65bcfb4 | 124 | { |
mbed_official | 205:c41fc65bcfb4 | 125 | uint32_t tmpreg1 = 0, tmpreg2 = 0; |
mbed_official | 205:c41fc65bcfb4 | 126 | |
mbed_official | 205:c41fc65bcfb4 | 127 | /* Check the DAC parameters */ |
mbed_official | 205:c41fc65bcfb4 | 128 | assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); |
mbed_official | 205:c41fc65bcfb4 | 129 | assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer)); |
mbed_official | 205:c41fc65bcfb4 | 130 | assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); |
mbed_official | 205:c41fc65bcfb4 | 131 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 132 | |
mbed_official | 205:c41fc65bcfb4 | 133 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 134 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 135 | |
mbed_official | 205:c41fc65bcfb4 | 136 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 137 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 138 | |
mbed_official | 205:c41fc65bcfb4 | 139 | /* Get the DAC CR value */ |
mbed_official | 205:c41fc65bcfb4 | 140 | tmpreg1 = DAC->CR; |
mbed_official | 205:c41fc65bcfb4 | 141 | /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */ |
mbed_official | 205:c41fc65bcfb4 | 142 | tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel); |
mbed_official | 205:c41fc65bcfb4 | 143 | /* Configure for the selected DAC channel: buffer output, trigger */ |
mbed_official | 205:c41fc65bcfb4 | 144 | /* Set TSELx and TENx bits according to DAC_Trigger value */ |
mbed_official | 205:c41fc65bcfb4 | 145 | /* Set BOFFx bit according to DAC_OutputBuffer value */ |
mbed_official | 205:c41fc65bcfb4 | 146 | tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer); |
mbed_official | 205:c41fc65bcfb4 | 147 | /* Calculate CR register value depending on DAC_Channel */ |
mbed_official | 205:c41fc65bcfb4 | 148 | tmpreg1 |= tmpreg2 << Channel; |
mbed_official | 205:c41fc65bcfb4 | 149 | /* Write to DAC CR */ |
mbed_official | 205:c41fc65bcfb4 | 150 | DAC->CR = tmpreg1; |
mbed_official | 205:c41fc65bcfb4 | 151 | /* Disable wave generation */ |
mbed_official | 205:c41fc65bcfb4 | 152 | DAC->CR &= ~(DAC_CR_WAVE1 << Channel); |
mbed_official | 205:c41fc65bcfb4 | 153 | |
mbed_official | 205:c41fc65bcfb4 | 154 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 155 | hdac->State = HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 156 | |
mbed_official | 205:c41fc65bcfb4 | 157 | /* Process unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 158 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 159 | |
mbed_official | 205:c41fc65bcfb4 | 160 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 161 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 162 | } |
mbed_official | 205:c41fc65bcfb4 | 163 | |
mbed_official | 205:c41fc65bcfb4 | 164 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 165 | |
mbed_official | 205:c41fc65bcfb4 | 166 | #if defined (STM32F051x8) || defined (STM32F058xx) |
mbed_official | 205:c41fc65bcfb4 | 167 | |
mbed_official | 205:c41fc65bcfb4 | 168 | /** |
mbed_official | 205:c41fc65bcfb4 | 169 | * @brief Configures the selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 170 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 171 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 172 | * @param sConfig: DAC configuration structure. |
mbed_official | 205:c41fc65bcfb4 | 173 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 174 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 175 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 176 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 177 | */ |
mbed_official | 205:c41fc65bcfb4 | 178 | HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel) |
mbed_official | 205:c41fc65bcfb4 | 179 | { |
mbed_official | 205:c41fc65bcfb4 | 180 | uint32_t tmpreg1 = 0, tmpreg2 = 0; |
mbed_official | 205:c41fc65bcfb4 | 181 | |
mbed_official | 205:c41fc65bcfb4 | 182 | /* Check the DAC parameters */ |
mbed_official | 205:c41fc65bcfb4 | 183 | assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); |
mbed_official | 205:c41fc65bcfb4 | 184 | assert_param(IS_DAC_OUTPUT_BUFFER_STATE(sConfig->DAC_OutputBuffer)); |
mbed_official | 205:c41fc65bcfb4 | 185 | assert_param(IS_DAC_TRIGGER(sConfig->DAC_Trigger)); |
mbed_official | 205:c41fc65bcfb4 | 186 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 187 | |
mbed_official | 205:c41fc65bcfb4 | 188 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 189 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 190 | |
mbed_official | 205:c41fc65bcfb4 | 191 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 192 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 193 | |
mbed_official | 205:c41fc65bcfb4 | 194 | /* Get the DAC CR value */ |
mbed_official | 205:c41fc65bcfb4 | 195 | tmpreg1 = DAC->CR; |
mbed_official | 205:c41fc65bcfb4 | 196 | /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */ |
mbed_official | 205:c41fc65bcfb4 | 197 | // tmpreg1 &= ~(((uint32_t)(DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel); |
mbed_official | 205:c41fc65bcfb4 | 198 | tmpreg1 &= ~(((uint32_t)(DAC_CR_TSEL1 | DAC_CR_TEN1 | DAC_CR_BOFF1)) << Channel); |
mbed_official | 205:c41fc65bcfb4 | 199 | /* Configure for the selected DAC channel: buffer output, trigger */ |
mbed_official | 205:c41fc65bcfb4 | 200 | /* Set TSELx and TENx bits according to DAC_Trigger value */ |
mbed_official | 205:c41fc65bcfb4 | 201 | /* Set BOFFx bit according to DAC_OutputBuffer value */ |
mbed_official | 205:c41fc65bcfb4 | 202 | tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer); |
mbed_official | 205:c41fc65bcfb4 | 203 | /* Calculate CR register value depending on DAC_Channel */ |
mbed_official | 205:c41fc65bcfb4 | 204 | tmpreg1 |= tmpreg2 << Channel; |
mbed_official | 205:c41fc65bcfb4 | 205 | /* Write to DAC CR */ |
mbed_official | 205:c41fc65bcfb4 | 206 | DAC->CR = tmpreg1; |
mbed_official | 205:c41fc65bcfb4 | 207 | /* Disable wave generation */ |
mbed_official | 205:c41fc65bcfb4 | 208 | // DAC->CR &= ~(DAC_CR_WAVE1 << Channel); |
mbed_official | 205:c41fc65bcfb4 | 209 | |
mbed_official | 205:c41fc65bcfb4 | 210 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 211 | hdac->State = HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 212 | |
mbed_official | 205:c41fc65bcfb4 | 213 | /* Process unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 214 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 215 | |
mbed_official | 205:c41fc65bcfb4 | 216 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 217 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 218 | } |
mbed_official | 205:c41fc65bcfb4 | 219 | |
mbed_official | 205:c41fc65bcfb4 | 220 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 221 | |
mbed_official | 205:c41fc65bcfb4 | 222 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 223 | /* DAC 1 has 2 channels 1 & 2 */ |
mbed_official | 205:c41fc65bcfb4 | 224 | |
mbed_official | 205:c41fc65bcfb4 | 225 | /** |
mbed_official | 205:c41fc65bcfb4 | 226 | * @brief Returns the last data output value of the selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 227 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 228 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 229 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 230 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 231 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 232 | * @arg DAC_CHANNEL_2: DAC Channel2 selected |
mbed_official | 205:c41fc65bcfb4 | 233 | * @retval The selected DAC channel data output value. |
mbed_official | 205:c41fc65bcfb4 | 234 | */ |
mbed_official | 205:c41fc65bcfb4 | 235 | uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel) |
mbed_official | 205:c41fc65bcfb4 | 236 | { |
mbed_official | 205:c41fc65bcfb4 | 237 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 238 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 239 | |
mbed_official | 205:c41fc65bcfb4 | 240 | /* Returns the DAC channel data output register value */ |
mbed_official | 205:c41fc65bcfb4 | 241 | if(Channel == DAC_CHANNEL_1) |
mbed_official | 205:c41fc65bcfb4 | 242 | { |
mbed_official | 205:c41fc65bcfb4 | 243 | return hdac->Instance->DOR1; |
mbed_official | 205:c41fc65bcfb4 | 244 | } |
mbed_official | 205:c41fc65bcfb4 | 245 | else |
mbed_official | 205:c41fc65bcfb4 | 246 | { |
mbed_official | 205:c41fc65bcfb4 | 247 | return hdac->Instance->DOR2; |
mbed_official | 205:c41fc65bcfb4 | 248 | } |
mbed_official | 205:c41fc65bcfb4 | 249 | } |
mbed_official | 205:c41fc65bcfb4 | 250 | |
mbed_official | 205:c41fc65bcfb4 | 251 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 252 | |
mbed_official | 205:c41fc65bcfb4 | 253 | #if defined (STM32F051x8) || defined (STM32F058xx) |
mbed_official | 205:c41fc65bcfb4 | 254 | |
mbed_official | 205:c41fc65bcfb4 | 255 | /* DAC 1 has 1 channels */ |
mbed_official | 205:c41fc65bcfb4 | 256 | |
mbed_official | 205:c41fc65bcfb4 | 257 | /** |
mbed_official | 205:c41fc65bcfb4 | 258 | * @brief Returns the last data output value of the selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 259 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 260 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 261 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 262 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 263 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 264 | * @retval The selected DAC channel data output value. |
mbed_official | 205:c41fc65bcfb4 | 265 | */ |
mbed_official | 205:c41fc65bcfb4 | 266 | uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel) |
mbed_official | 205:c41fc65bcfb4 | 267 | { |
mbed_official | 205:c41fc65bcfb4 | 268 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 269 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 270 | |
mbed_official | 205:c41fc65bcfb4 | 271 | /* Returns the DAC channel data output register value */ |
mbed_official | 205:c41fc65bcfb4 | 272 | return hdac->Instance->DOR1; |
mbed_official | 205:c41fc65bcfb4 | 273 | } |
mbed_official | 205:c41fc65bcfb4 | 274 | |
mbed_official | 205:c41fc65bcfb4 | 275 | |
mbed_official | 205:c41fc65bcfb4 | 276 | |
mbed_official | 205:c41fc65bcfb4 | 277 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 278 | |
mbed_official | 205:c41fc65bcfb4 | 279 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 280 | |
mbed_official | 205:c41fc65bcfb4 | 281 | /** |
mbed_official | 205:c41fc65bcfb4 | 282 | * @brief Enables DAC and starts conversion of channel. |
mbed_official | 205:c41fc65bcfb4 | 283 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 284 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 285 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 286 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 287 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 288 | * @arg DAC_CHANNEL_2: DAC Channel2 selected |
mbed_official | 205:c41fc65bcfb4 | 289 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 290 | */ |
mbed_official | 205:c41fc65bcfb4 | 291 | HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel) |
mbed_official | 205:c41fc65bcfb4 | 292 | { |
mbed_official | 205:c41fc65bcfb4 | 293 | uint32_t tmp1 = 0, tmp2 = 0; |
mbed_official | 205:c41fc65bcfb4 | 294 | |
mbed_official | 205:c41fc65bcfb4 | 295 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 296 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 297 | |
mbed_official | 205:c41fc65bcfb4 | 298 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 299 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 300 | |
mbed_official | 205:c41fc65bcfb4 | 301 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 302 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 303 | |
mbed_official | 205:c41fc65bcfb4 | 304 | /* Enable the Peripharal */ |
mbed_official | 205:c41fc65bcfb4 | 305 | __HAL_DAC_ENABLE(hdac, Channel); |
mbed_official | 205:c41fc65bcfb4 | 306 | |
mbed_official | 205:c41fc65bcfb4 | 307 | if(Channel == DAC_CHANNEL_1) |
mbed_official | 205:c41fc65bcfb4 | 308 | { |
mbed_official | 205:c41fc65bcfb4 | 309 | tmp1 = hdac->Instance->CR & DAC_CR_TEN1; |
mbed_official | 205:c41fc65bcfb4 | 310 | tmp2 = hdac->Instance->CR & DAC_CR_TSEL1; |
mbed_official | 205:c41fc65bcfb4 | 311 | /* Check if software trigger enabled */ |
mbed_official | 205:c41fc65bcfb4 | 312 | if((tmp1 == DAC_CR_TEN1) && (tmp2 == DAC_CR_TSEL1)) |
mbed_official | 205:c41fc65bcfb4 | 313 | { |
mbed_official | 205:c41fc65bcfb4 | 314 | /* Enable the selected DAC software conversion */ |
mbed_official | 205:c41fc65bcfb4 | 315 | hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1; |
mbed_official | 205:c41fc65bcfb4 | 316 | } |
mbed_official | 205:c41fc65bcfb4 | 317 | } |
mbed_official | 205:c41fc65bcfb4 | 318 | else |
mbed_official | 205:c41fc65bcfb4 | 319 | { |
mbed_official | 205:c41fc65bcfb4 | 320 | tmp1 = hdac->Instance->CR & DAC_CR_TEN2; |
mbed_official | 205:c41fc65bcfb4 | 321 | tmp2 = hdac->Instance->CR & DAC_CR_TSEL2; |
mbed_official | 205:c41fc65bcfb4 | 322 | /* Check if software trigger enabled */ |
mbed_official | 205:c41fc65bcfb4 | 323 | if((tmp1 == DAC_CR_TEN2) && (tmp2 == DAC_CR_TSEL2)) |
mbed_official | 205:c41fc65bcfb4 | 324 | { |
mbed_official | 205:c41fc65bcfb4 | 325 | /* Enable the selected DAC software conversion*/ |
mbed_official | 205:c41fc65bcfb4 | 326 | hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG2; |
mbed_official | 205:c41fc65bcfb4 | 327 | } |
mbed_official | 205:c41fc65bcfb4 | 328 | } |
mbed_official | 205:c41fc65bcfb4 | 329 | |
mbed_official | 205:c41fc65bcfb4 | 330 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 331 | hdac->State = HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 332 | |
mbed_official | 205:c41fc65bcfb4 | 333 | /* Process unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 334 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 335 | |
mbed_official | 205:c41fc65bcfb4 | 336 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 337 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 338 | } |
mbed_official | 205:c41fc65bcfb4 | 339 | |
mbed_official | 205:c41fc65bcfb4 | 340 | /** |
mbed_official | 205:c41fc65bcfb4 | 341 | * @brief Enables DAC and starts conversion of channel. |
mbed_official | 205:c41fc65bcfb4 | 342 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 343 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 344 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 345 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 346 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 347 | * @arg DAC_CHANNEL_2: DAC Channel2 selected |
mbed_official | 205:c41fc65bcfb4 | 348 | * @param pData: The destination peripheral Buffer address. |
mbed_official | 205:c41fc65bcfb4 | 349 | * @param Length: The length of data to be transferred from memory to DAC peripheral |
mbed_official | 205:c41fc65bcfb4 | 350 | * @param Alignment: Specifies the data alignment for DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 351 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 352 | * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 353 | * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 354 | * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 355 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 356 | */ |
mbed_official | 205:c41fc65bcfb4 | 357 | HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment) |
mbed_official | 205:c41fc65bcfb4 | 358 | { |
mbed_official | 205:c41fc65bcfb4 | 359 | uint32_t tmpreg = 0; |
mbed_official | 205:c41fc65bcfb4 | 360 | |
mbed_official | 205:c41fc65bcfb4 | 361 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 362 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 363 | assert_param(IS_DAC_ALIGN(Alignment)); |
mbed_official | 205:c41fc65bcfb4 | 364 | |
mbed_official | 205:c41fc65bcfb4 | 365 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 366 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 367 | |
mbed_official | 205:c41fc65bcfb4 | 368 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 369 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 370 | |
mbed_official | 205:c41fc65bcfb4 | 371 | if(Channel == DAC_CHANNEL_1) |
mbed_official | 205:c41fc65bcfb4 | 372 | { |
mbed_official | 205:c41fc65bcfb4 | 373 | /* Set the DMA transfer complete callback for channel1 */ |
mbed_official | 205:c41fc65bcfb4 | 374 | hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1; |
mbed_official | 205:c41fc65bcfb4 | 375 | |
mbed_official | 205:c41fc65bcfb4 | 376 | /* Set the DMA half transfer complete callback for channel1 */ |
mbed_official | 205:c41fc65bcfb4 | 377 | hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1; |
mbed_official | 205:c41fc65bcfb4 | 378 | |
mbed_official | 205:c41fc65bcfb4 | 379 | /* Set the DMA error callback for channel1 */ |
mbed_official | 205:c41fc65bcfb4 | 380 | hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1; |
mbed_official | 205:c41fc65bcfb4 | 381 | |
mbed_official | 205:c41fc65bcfb4 | 382 | /* Enable the selected DAC channel1 DMA request */ |
mbed_official | 205:c41fc65bcfb4 | 383 | hdac->Instance->CR |= DAC_CR_DMAEN1; |
mbed_official | 205:c41fc65bcfb4 | 384 | |
mbed_official | 205:c41fc65bcfb4 | 385 | /* Case of use of channel 1 */ |
mbed_official | 205:c41fc65bcfb4 | 386 | switch(Alignment) |
mbed_official | 205:c41fc65bcfb4 | 387 | { |
mbed_official | 205:c41fc65bcfb4 | 388 | case DAC_ALIGN_12B_R: |
mbed_official | 205:c41fc65bcfb4 | 389 | /* Get DHR12R1 address */ |
mbed_official | 205:c41fc65bcfb4 | 390 | tmpreg = (uint32_t)&hdac->Instance->DHR12R1; |
mbed_official | 205:c41fc65bcfb4 | 391 | break; |
mbed_official | 205:c41fc65bcfb4 | 392 | case DAC_ALIGN_12B_L: |
mbed_official | 205:c41fc65bcfb4 | 393 | /* Get DHR12L1 address */ |
mbed_official | 205:c41fc65bcfb4 | 394 | tmpreg = (uint32_t)&hdac->Instance->DHR12L1; |
mbed_official | 205:c41fc65bcfb4 | 395 | break; |
mbed_official | 205:c41fc65bcfb4 | 396 | case DAC_ALIGN_8B_R: |
mbed_official | 205:c41fc65bcfb4 | 397 | /* Get DHR8R1 address */ |
mbed_official | 205:c41fc65bcfb4 | 398 | tmpreg = (uint32_t)&hdac->Instance->DHR8R1; |
mbed_official | 205:c41fc65bcfb4 | 399 | break; |
mbed_official | 205:c41fc65bcfb4 | 400 | default: |
mbed_official | 205:c41fc65bcfb4 | 401 | break; |
mbed_official | 205:c41fc65bcfb4 | 402 | } |
mbed_official | 205:c41fc65bcfb4 | 403 | } |
mbed_official | 205:c41fc65bcfb4 | 404 | else |
mbed_official | 205:c41fc65bcfb4 | 405 | { |
mbed_official | 205:c41fc65bcfb4 | 406 | /* Set the DMA transfer complete callback for channel2 */ |
mbed_official | 205:c41fc65bcfb4 | 407 | hdac->DMA_Handle2->XferCpltCallback = DAC_DMAConvCpltCh2; |
mbed_official | 205:c41fc65bcfb4 | 408 | |
mbed_official | 205:c41fc65bcfb4 | 409 | /* Set the DMA half transfer complete callback for channel2 */ |
mbed_official | 205:c41fc65bcfb4 | 410 | hdac->DMA_Handle2->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh2; |
mbed_official | 205:c41fc65bcfb4 | 411 | |
mbed_official | 205:c41fc65bcfb4 | 412 | /* Set the DMA error callback for channel2 */ |
mbed_official | 205:c41fc65bcfb4 | 413 | hdac->DMA_Handle2->XferErrorCallback = DAC_DMAErrorCh2; |
mbed_official | 205:c41fc65bcfb4 | 414 | |
mbed_official | 205:c41fc65bcfb4 | 415 | /* Enable the selected DAC channel2 DMA request */ |
mbed_official | 205:c41fc65bcfb4 | 416 | hdac->Instance->CR |= DAC_CR_DMAEN2; |
mbed_official | 205:c41fc65bcfb4 | 417 | |
mbed_official | 205:c41fc65bcfb4 | 418 | /* Case of use of channel 2 */ |
mbed_official | 205:c41fc65bcfb4 | 419 | switch(Alignment) |
mbed_official | 205:c41fc65bcfb4 | 420 | { |
mbed_official | 205:c41fc65bcfb4 | 421 | case DAC_ALIGN_12B_R: |
mbed_official | 205:c41fc65bcfb4 | 422 | /* Get DHR12R2 address */ |
mbed_official | 205:c41fc65bcfb4 | 423 | tmpreg = (uint32_t)&hdac->Instance->DHR12R2; |
mbed_official | 205:c41fc65bcfb4 | 424 | break; |
mbed_official | 205:c41fc65bcfb4 | 425 | case DAC_ALIGN_12B_L: |
mbed_official | 205:c41fc65bcfb4 | 426 | /* Get DHR12L2 address */ |
mbed_official | 205:c41fc65bcfb4 | 427 | tmpreg = (uint32_t)&hdac->Instance->DHR12L2; |
mbed_official | 205:c41fc65bcfb4 | 428 | break; |
mbed_official | 205:c41fc65bcfb4 | 429 | case DAC_ALIGN_8B_R: |
mbed_official | 205:c41fc65bcfb4 | 430 | /* Get DHR8R2 address */ |
mbed_official | 205:c41fc65bcfb4 | 431 | tmpreg = (uint32_t)&hdac->Instance->DHR8R2; |
mbed_official | 205:c41fc65bcfb4 | 432 | break; |
mbed_official | 205:c41fc65bcfb4 | 433 | default: |
mbed_official | 205:c41fc65bcfb4 | 434 | break; |
mbed_official | 205:c41fc65bcfb4 | 435 | } |
mbed_official | 205:c41fc65bcfb4 | 436 | } |
mbed_official | 205:c41fc65bcfb4 | 437 | |
mbed_official | 205:c41fc65bcfb4 | 438 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 439 | if(Channel == DAC_CHANNEL_1) |
mbed_official | 205:c41fc65bcfb4 | 440 | { |
mbed_official | 205:c41fc65bcfb4 | 441 | /* Enable the DAC DMA underrun interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 442 | __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1); |
mbed_official | 205:c41fc65bcfb4 | 443 | |
mbed_official | 205:c41fc65bcfb4 | 444 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 445 | HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length); |
mbed_official | 205:c41fc65bcfb4 | 446 | } |
mbed_official | 205:c41fc65bcfb4 | 447 | else |
mbed_official | 205:c41fc65bcfb4 | 448 | { |
mbed_official | 205:c41fc65bcfb4 | 449 | /* Enable the DAC DMA underrun interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 450 | __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR2); |
mbed_official | 205:c41fc65bcfb4 | 451 | |
mbed_official | 205:c41fc65bcfb4 | 452 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 453 | HAL_DMA_Start_IT(hdac->DMA_Handle2, (uint32_t)pData, tmpreg, Length); |
mbed_official | 205:c41fc65bcfb4 | 454 | } |
mbed_official | 205:c41fc65bcfb4 | 455 | |
mbed_official | 205:c41fc65bcfb4 | 456 | /* Enable the Peripharal */ |
mbed_official | 205:c41fc65bcfb4 | 457 | __HAL_DAC_ENABLE(hdac, Channel); |
mbed_official | 205:c41fc65bcfb4 | 458 | |
mbed_official | 205:c41fc65bcfb4 | 459 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 460 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 461 | |
mbed_official | 205:c41fc65bcfb4 | 462 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 463 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 464 | } |
mbed_official | 205:c41fc65bcfb4 | 465 | |
mbed_official | 205:c41fc65bcfb4 | 466 | |
mbed_official | 205:c41fc65bcfb4 | 467 | |
mbed_official | 205:c41fc65bcfb4 | 468 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 469 | |
mbed_official | 205:c41fc65bcfb4 | 470 | #if defined (STM32F051x8) || defined (STM32F058xx) |
mbed_official | 205:c41fc65bcfb4 | 471 | |
mbed_official | 205:c41fc65bcfb4 | 472 | HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel) |
mbed_official | 205:c41fc65bcfb4 | 473 | { |
mbed_official | 205:c41fc65bcfb4 | 474 | uint32_t tmp1 = 0, tmp2 = 0; |
mbed_official | 205:c41fc65bcfb4 | 475 | |
mbed_official | 205:c41fc65bcfb4 | 476 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 477 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 478 | |
mbed_official | 205:c41fc65bcfb4 | 479 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 480 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 481 | |
mbed_official | 205:c41fc65bcfb4 | 482 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 483 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 484 | |
mbed_official | 205:c41fc65bcfb4 | 485 | /* Enable the Peripharal */ |
mbed_official | 205:c41fc65bcfb4 | 486 | __HAL_DAC_ENABLE(hdac, Channel); |
mbed_official | 205:c41fc65bcfb4 | 487 | |
mbed_official | 205:c41fc65bcfb4 | 488 | if(Channel == DAC_CHANNEL_1) |
mbed_official | 205:c41fc65bcfb4 | 489 | { |
mbed_official | 205:c41fc65bcfb4 | 490 | tmp1 = hdac->Instance->CR & DAC_CR_TEN1; |
mbed_official | 205:c41fc65bcfb4 | 491 | tmp2 = hdac->Instance->CR & DAC_CR_TSEL1; |
mbed_official | 205:c41fc65bcfb4 | 492 | /* Check if software trigger enabled */ |
mbed_official | 205:c41fc65bcfb4 | 493 | if((tmp1 == DAC_CR_TEN1) && (tmp2 == DAC_CR_TSEL1)) |
mbed_official | 205:c41fc65bcfb4 | 494 | { |
mbed_official | 205:c41fc65bcfb4 | 495 | /* Enable the selected DAC software conversion */ |
mbed_official | 205:c41fc65bcfb4 | 496 | hdac->Instance->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1; |
mbed_official | 205:c41fc65bcfb4 | 497 | } |
mbed_official | 205:c41fc65bcfb4 | 498 | } |
mbed_official | 205:c41fc65bcfb4 | 499 | |
mbed_official | 205:c41fc65bcfb4 | 500 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 501 | hdac->State = HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 502 | |
mbed_official | 205:c41fc65bcfb4 | 503 | /* Process unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 504 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 505 | |
mbed_official | 205:c41fc65bcfb4 | 506 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 507 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 508 | } |
mbed_official | 205:c41fc65bcfb4 | 509 | |
mbed_official | 205:c41fc65bcfb4 | 510 | /** |
mbed_official | 205:c41fc65bcfb4 | 511 | * @brief Enables DAC and starts conversion of channel. |
mbed_official | 205:c41fc65bcfb4 | 512 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 513 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 514 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 515 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 516 | * @arg DAC_CHANNEL_1: DAC Channel1 selected |
mbed_official | 205:c41fc65bcfb4 | 517 | * @param pData: The destination peripheral Buffer address. |
mbed_official | 205:c41fc65bcfb4 | 518 | * @param Length: The length of data to be transferred from memory to DAC peripheral |
mbed_official | 205:c41fc65bcfb4 | 519 | * @param Alignment: Specifies the data alignment for DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 520 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 521 | * @arg DAC_ALIGN_8B_R: 8bit right data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 522 | * @arg DAC_ALIGN_12B_L: 12bit left data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 523 | * @arg DAC_ALIGN_12B_R: 12bit right data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 524 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 525 | */ |
mbed_official | 205:c41fc65bcfb4 | 526 | HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment) |
mbed_official | 205:c41fc65bcfb4 | 527 | { |
mbed_official | 205:c41fc65bcfb4 | 528 | uint32_t tmpreg = 0; |
mbed_official | 205:c41fc65bcfb4 | 529 | |
mbed_official | 205:c41fc65bcfb4 | 530 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 531 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 532 | assert_param(IS_DAC_ALIGN(Alignment)); |
mbed_official | 205:c41fc65bcfb4 | 533 | |
mbed_official | 205:c41fc65bcfb4 | 534 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 535 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 536 | |
mbed_official | 205:c41fc65bcfb4 | 537 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 538 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 539 | |
mbed_official | 205:c41fc65bcfb4 | 540 | /* Set the DMA transfer complete callback for channel1 */ |
mbed_official | 205:c41fc65bcfb4 | 541 | hdac->DMA_Handle1->XferCpltCallback = DAC_DMAConvCpltCh1; |
mbed_official | 205:c41fc65bcfb4 | 542 | |
mbed_official | 205:c41fc65bcfb4 | 543 | /* Set the DMA half transfer complete callback for channel1 */ |
mbed_official | 205:c41fc65bcfb4 | 544 | hdac->DMA_Handle1->XferHalfCpltCallback = DAC_DMAHalfConvCpltCh1; |
mbed_official | 205:c41fc65bcfb4 | 545 | |
mbed_official | 205:c41fc65bcfb4 | 546 | /* Set the DMA error callback for channel1 */ |
mbed_official | 205:c41fc65bcfb4 | 547 | hdac->DMA_Handle1->XferErrorCallback = DAC_DMAErrorCh1; |
mbed_official | 205:c41fc65bcfb4 | 548 | |
mbed_official | 205:c41fc65bcfb4 | 549 | /* Enable the selected DAC channel1 DMA request */ |
mbed_official | 205:c41fc65bcfb4 | 550 | hdac->Instance->CR |= DAC_CR_DMAEN1; |
mbed_official | 205:c41fc65bcfb4 | 551 | |
mbed_official | 205:c41fc65bcfb4 | 552 | /* Case of use of channel 1 */ |
mbed_official | 205:c41fc65bcfb4 | 553 | switch(Alignment) |
mbed_official | 205:c41fc65bcfb4 | 554 | { |
mbed_official | 205:c41fc65bcfb4 | 555 | case DAC_ALIGN_12B_R: |
mbed_official | 205:c41fc65bcfb4 | 556 | /* Get DHR12R1 address */ |
mbed_official | 205:c41fc65bcfb4 | 557 | tmpreg = (uint32_t)&hdac->Instance->DHR12R1; |
mbed_official | 205:c41fc65bcfb4 | 558 | break; |
mbed_official | 205:c41fc65bcfb4 | 559 | case DAC_ALIGN_12B_L: |
mbed_official | 205:c41fc65bcfb4 | 560 | /* Get DHR12L1 address */ |
mbed_official | 205:c41fc65bcfb4 | 561 | tmpreg = (uint32_t)&hdac->Instance->DHR12L1; |
mbed_official | 205:c41fc65bcfb4 | 562 | break; |
mbed_official | 205:c41fc65bcfb4 | 563 | case DAC_ALIGN_8B_R: |
mbed_official | 205:c41fc65bcfb4 | 564 | /* Get DHR8R1 address */ |
mbed_official | 205:c41fc65bcfb4 | 565 | tmpreg = (uint32_t)&hdac->Instance->DHR8R1; |
mbed_official | 205:c41fc65bcfb4 | 566 | break; |
mbed_official | 205:c41fc65bcfb4 | 567 | default: |
mbed_official | 205:c41fc65bcfb4 | 568 | break; |
mbed_official | 205:c41fc65bcfb4 | 569 | } |
mbed_official | 205:c41fc65bcfb4 | 570 | |
mbed_official | 205:c41fc65bcfb4 | 571 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 572 | /* Enable the DAC DMA underrun interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 573 | __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1); |
mbed_official | 205:c41fc65bcfb4 | 574 | |
mbed_official | 205:c41fc65bcfb4 | 575 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 576 | HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length); |
mbed_official | 205:c41fc65bcfb4 | 577 | |
mbed_official | 205:c41fc65bcfb4 | 578 | /* Enable the DAC DMA underrun interrupt */ |
mbed_official | 205:c41fc65bcfb4 | 579 | __HAL_DAC_ENABLE_IT(hdac, DAC_IT_DMAUDR1); |
mbed_official | 205:c41fc65bcfb4 | 580 | |
mbed_official | 205:c41fc65bcfb4 | 581 | /* Enable the DMA channel */ |
mbed_official | 205:c41fc65bcfb4 | 582 | HAL_DMA_Start_IT(hdac->DMA_Handle1, (uint32_t)pData, tmpreg, Length); |
mbed_official | 205:c41fc65bcfb4 | 583 | |
mbed_official | 205:c41fc65bcfb4 | 584 | /* Enable the Peripharal */ |
mbed_official | 205:c41fc65bcfb4 | 585 | __HAL_DAC_ENABLE(hdac, Channel); |
mbed_official | 205:c41fc65bcfb4 | 586 | |
mbed_official | 205:c41fc65bcfb4 | 587 | /* Process Unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 588 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 589 | |
mbed_official | 205:c41fc65bcfb4 | 590 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 591 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 592 | } |
mbed_official | 205:c41fc65bcfb4 | 593 | |
mbed_official | 205:c41fc65bcfb4 | 594 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 595 | |
mbed_official | 205:c41fc65bcfb4 | 596 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 597 | /* DAC channel 2 is available on top of DAC channel 1 */ |
mbed_official | 205:c41fc65bcfb4 | 598 | |
mbed_official | 205:c41fc65bcfb4 | 599 | /** |
mbed_official | 205:c41fc65bcfb4 | 600 | * @brief Handles DAC interrupt request |
mbed_official | 205:c41fc65bcfb4 | 601 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 602 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 603 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 604 | */ |
mbed_official | 205:c41fc65bcfb4 | 605 | void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac) |
mbed_official | 205:c41fc65bcfb4 | 606 | { |
mbed_official | 205:c41fc65bcfb4 | 607 | /* Check Overrun flag */ |
mbed_official | 205:c41fc65bcfb4 | 608 | if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1)) |
mbed_official | 205:c41fc65bcfb4 | 609 | { |
mbed_official | 205:c41fc65bcfb4 | 610 | /* Change DAC state to error state */ |
mbed_official | 205:c41fc65bcfb4 | 611 | hdac->State = HAL_DAC_STATE_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 612 | |
mbed_official | 205:c41fc65bcfb4 | 613 | /* Set DAC error code to chanel1 DMA underrun error */ |
mbed_official | 205:c41fc65bcfb4 | 614 | hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1; |
mbed_official | 205:c41fc65bcfb4 | 615 | |
mbed_official | 205:c41fc65bcfb4 | 616 | /* Clear the underrun flag */ |
mbed_official | 205:c41fc65bcfb4 | 617 | __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1); |
mbed_official | 205:c41fc65bcfb4 | 618 | |
mbed_official | 205:c41fc65bcfb4 | 619 | /* Disable the selected DAC channel1 DMA request */ |
mbed_official | 205:c41fc65bcfb4 | 620 | hdac->Instance->CR &= ~DAC_CR_DMAEN1; |
mbed_official | 205:c41fc65bcfb4 | 621 | |
mbed_official | 205:c41fc65bcfb4 | 622 | /* Error callback */ |
mbed_official | 205:c41fc65bcfb4 | 623 | HAL_DAC_DMAUnderrunCallbackCh1(hdac); |
mbed_official | 205:c41fc65bcfb4 | 624 | } |
mbed_official | 205:c41fc65bcfb4 | 625 | else |
mbed_official | 205:c41fc65bcfb4 | 626 | { |
mbed_official | 205:c41fc65bcfb4 | 627 | /* Change DAC state to error state */ |
mbed_official | 205:c41fc65bcfb4 | 628 | hdac->State = HAL_DAC_STATE_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 629 | |
mbed_official | 205:c41fc65bcfb4 | 630 | /* Set DAC error code to channel2 DMA underrun error */ |
mbed_official | 205:c41fc65bcfb4 | 631 | hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH2; |
mbed_official | 205:c41fc65bcfb4 | 632 | |
mbed_official | 205:c41fc65bcfb4 | 633 | /* Clear the underrun flag */ |
mbed_official | 205:c41fc65bcfb4 | 634 | __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR2); |
mbed_official | 205:c41fc65bcfb4 | 635 | |
mbed_official | 205:c41fc65bcfb4 | 636 | /* Disable the selected DAC channel1 DMA request */ |
mbed_official | 205:c41fc65bcfb4 | 637 | hdac->Instance->CR &= ~DAC_CR_DMAEN2; |
mbed_official | 205:c41fc65bcfb4 | 638 | |
mbed_official | 205:c41fc65bcfb4 | 639 | /* Error callback */ |
mbed_official | 205:c41fc65bcfb4 | 640 | HAL_DACEx_DMAUnderrunCallbackCh2(hdac); |
mbed_official | 205:c41fc65bcfb4 | 641 | } |
mbed_official | 205:c41fc65bcfb4 | 642 | } |
mbed_official | 205:c41fc65bcfb4 | 643 | |
mbed_official | 205:c41fc65bcfb4 | 644 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 645 | |
mbed_official | 205:c41fc65bcfb4 | 646 | #if defined (STM32F051x8) || defined (STM32F058xx) |
mbed_official | 205:c41fc65bcfb4 | 647 | /* DAC channel 2 is NOT available. Only DAC channel 1 is available */ |
mbed_official | 205:c41fc65bcfb4 | 648 | |
mbed_official | 205:c41fc65bcfb4 | 649 | /** |
mbed_official | 205:c41fc65bcfb4 | 650 | * @brief Handles DAC interrupt request |
mbed_official | 205:c41fc65bcfb4 | 651 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 652 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 653 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 654 | */ |
mbed_official | 205:c41fc65bcfb4 | 655 | void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac) |
mbed_official | 205:c41fc65bcfb4 | 656 | { |
mbed_official | 205:c41fc65bcfb4 | 657 | /* Check Overrun flag */ |
mbed_official | 205:c41fc65bcfb4 | 658 | if(__HAL_DAC_GET_FLAG(hdac, DAC_FLAG_DMAUDR1)) |
mbed_official | 205:c41fc65bcfb4 | 659 | { |
mbed_official | 205:c41fc65bcfb4 | 660 | /* Change DAC state to error state */ |
mbed_official | 205:c41fc65bcfb4 | 661 | hdac->State = HAL_DAC_STATE_ERROR; |
mbed_official | 205:c41fc65bcfb4 | 662 | |
mbed_official | 205:c41fc65bcfb4 | 663 | /* Set DAC error code to chanel1 DMA underrun error */ |
mbed_official | 205:c41fc65bcfb4 | 664 | hdac->ErrorCode |= HAL_DAC_ERROR_DMAUNDERRUNCH1; |
mbed_official | 205:c41fc65bcfb4 | 665 | |
mbed_official | 205:c41fc65bcfb4 | 666 | /* Clear the underrun flag */ |
mbed_official | 205:c41fc65bcfb4 | 667 | __HAL_DAC_CLEAR_FLAG(hdac,DAC_FLAG_DMAUDR1); |
mbed_official | 205:c41fc65bcfb4 | 668 | |
mbed_official | 205:c41fc65bcfb4 | 669 | /* Disable the selected DAC channel1 DMA request */ |
mbed_official | 205:c41fc65bcfb4 | 670 | hdac->Instance->CR &= ~DAC_CR_DMAEN1; |
mbed_official | 205:c41fc65bcfb4 | 671 | |
mbed_official | 205:c41fc65bcfb4 | 672 | /* Error callback */ |
mbed_official | 205:c41fc65bcfb4 | 673 | HAL_DAC_DMAUnderrunCallbackCh1(hdac); |
mbed_official | 205:c41fc65bcfb4 | 674 | } |
mbed_official | 205:c41fc65bcfb4 | 675 | } |
mbed_official | 205:c41fc65bcfb4 | 676 | |
mbed_official | 205:c41fc65bcfb4 | 677 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 678 | |
mbed_official | 205:c41fc65bcfb4 | 679 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 680 | |
mbed_official | 205:c41fc65bcfb4 | 681 | /** |
mbed_official | 205:c41fc65bcfb4 | 682 | * @brief Returns the last data output value of the selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 683 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 684 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 685 | * @retval The selected DAC channel data output value. |
mbed_official | 205:c41fc65bcfb4 | 686 | */ |
mbed_official | 205:c41fc65bcfb4 | 687 | uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac) |
mbed_official | 205:c41fc65bcfb4 | 688 | { |
mbed_official | 205:c41fc65bcfb4 | 689 | uint32_t tmp = 0; |
mbed_official | 205:c41fc65bcfb4 | 690 | |
mbed_official | 205:c41fc65bcfb4 | 691 | tmp |= hdac->Instance->DOR1; |
mbed_official | 205:c41fc65bcfb4 | 692 | |
mbed_official | 205:c41fc65bcfb4 | 693 | /* DAC channel 2 is present in DAC 1 */ |
mbed_official | 205:c41fc65bcfb4 | 694 | tmp |= hdac->Instance->DOR2 << 16; |
mbed_official | 205:c41fc65bcfb4 | 695 | |
mbed_official | 205:c41fc65bcfb4 | 696 | /* Returns the DAC channel data output register value */ |
mbed_official | 205:c41fc65bcfb4 | 697 | return tmp; |
mbed_official | 205:c41fc65bcfb4 | 698 | } |
mbed_official | 205:c41fc65bcfb4 | 699 | |
mbed_official | 205:c41fc65bcfb4 | 700 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 701 | |
mbed_official | 205:c41fc65bcfb4 | 702 | #if defined (STM32F051x8) || defined (STM32F058xx) |
mbed_official | 205:c41fc65bcfb4 | 703 | |
mbed_official | 205:c41fc65bcfb4 | 704 | /** |
mbed_official | 205:c41fc65bcfb4 | 705 | * @brief Returns the last data output value of the selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 706 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 707 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 708 | * @retval The selected DAC channel data output value. |
mbed_official | 205:c41fc65bcfb4 | 709 | */ |
mbed_official | 205:c41fc65bcfb4 | 710 | uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac) |
mbed_official | 205:c41fc65bcfb4 | 711 | { |
mbed_official | 205:c41fc65bcfb4 | 712 | uint32_t tmp = 0; |
mbed_official | 205:c41fc65bcfb4 | 713 | |
mbed_official | 205:c41fc65bcfb4 | 714 | tmp |= hdac->Instance->DOR1; |
mbed_official | 205:c41fc65bcfb4 | 715 | |
mbed_official | 205:c41fc65bcfb4 | 716 | /* Returns the DAC channel data output register value */ |
mbed_official | 205:c41fc65bcfb4 | 717 | return tmp; |
mbed_official | 205:c41fc65bcfb4 | 718 | } |
mbed_official | 205:c41fc65bcfb4 | 719 | |
mbed_official | 205:c41fc65bcfb4 | 720 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 721 | |
mbed_official | 205:c41fc65bcfb4 | 722 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 723 | |
mbed_official | 205:c41fc65bcfb4 | 724 | /** |
mbed_official | 205:c41fc65bcfb4 | 725 | * @brief Enables or disables the selected DAC channel wave generation. |
mbed_official | 205:c41fc65bcfb4 | 726 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 727 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 728 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 729 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 730 | * DAC_CHANNEL_1 / DAC_CHANNEL_2 |
mbed_official | 205:c41fc65bcfb4 | 731 | * @param Amplitude: Select max triangle amplitude. |
mbed_official | 205:c41fc65bcfb4 | 732 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 733 | * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1 |
mbed_official | 205:c41fc65bcfb4 | 734 | * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3 |
mbed_official | 205:c41fc65bcfb4 | 735 | * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7 |
mbed_official | 205:c41fc65bcfb4 | 736 | * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15 |
mbed_official | 205:c41fc65bcfb4 | 737 | * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31 |
mbed_official | 205:c41fc65bcfb4 | 738 | * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63 |
mbed_official | 205:c41fc65bcfb4 | 739 | * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127 |
mbed_official | 205:c41fc65bcfb4 | 740 | * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255 |
mbed_official | 205:c41fc65bcfb4 | 741 | * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511 |
mbed_official | 205:c41fc65bcfb4 | 742 | * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023 |
mbed_official | 205:c41fc65bcfb4 | 743 | * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047 |
mbed_official | 205:c41fc65bcfb4 | 744 | * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095 |
mbed_official | 205:c41fc65bcfb4 | 745 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 746 | */ |
mbed_official | 205:c41fc65bcfb4 | 747 | HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) |
mbed_official | 205:c41fc65bcfb4 | 748 | { |
mbed_official | 205:c41fc65bcfb4 | 749 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 750 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 751 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); |
mbed_official | 205:c41fc65bcfb4 | 752 | |
mbed_official | 205:c41fc65bcfb4 | 753 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 754 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 755 | |
mbed_official | 205:c41fc65bcfb4 | 756 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 757 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 758 | |
mbed_official | 205:c41fc65bcfb4 | 759 | /* Enable the selected wave generation for the selected DAC channel */ |
mbed_official | 205:c41fc65bcfb4 | 760 | hdac->Instance->CR |= (DAC_WAVE_TRIANGLE | Amplitude) << Channel; |
mbed_official | 205:c41fc65bcfb4 | 761 | |
mbed_official | 205:c41fc65bcfb4 | 762 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 763 | hdac->State = HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 764 | |
mbed_official | 205:c41fc65bcfb4 | 765 | /* Process unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 766 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 767 | |
mbed_official | 205:c41fc65bcfb4 | 768 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 769 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 770 | } |
mbed_official | 205:c41fc65bcfb4 | 771 | |
mbed_official | 205:c41fc65bcfb4 | 772 | /** |
mbed_official | 205:c41fc65bcfb4 | 773 | * @brief Enables or disables the selected DAC channel wave generation. |
mbed_official | 205:c41fc65bcfb4 | 774 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 775 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 776 | * @param Channel: The selected DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 777 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 778 | * DAC_CHANNEL_1 / DAC_CHANNEL_2 |
mbed_official | 205:c41fc65bcfb4 | 779 | * @param Amplitude: Unmask DAC channel LFSR for noise wave generation. |
mbed_official | 205:c41fc65bcfb4 | 780 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 781 | * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 782 | * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 783 | * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 784 | * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 785 | * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 786 | * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 787 | * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 788 | * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 789 | * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 790 | * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 791 | * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 792 | * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation |
mbed_official | 205:c41fc65bcfb4 | 793 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 794 | */ |
mbed_official | 205:c41fc65bcfb4 | 795 | HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) |
mbed_official | 205:c41fc65bcfb4 | 796 | { |
mbed_official | 205:c41fc65bcfb4 | 797 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 798 | assert_param(IS_DAC_CHANNEL(Channel)); |
mbed_official | 205:c41fc65bcfb4 | 799 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); |
mbed_official | 205:c41fc65bcfb4 | 800 | |
mbed_official | 205:c41fc65bcfb4 | 801 | /* Process locked */ |
mbed_official | 205:c41fc65bcfb4 | 802 | __HAL_LOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 803 | |
mbed_official | 205:c41fc65bcfb4 | 804 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 805 | hdac->State = HAL_DAC_STATE_BUSY; |
mbed_official | 205:c41fc65bcfb4 | 806 | |
mbed_official | 205:c41fc65bcfb4 | 807 | /* Enable the selected wave generation for the selected DAC channel */ |
mbed_official | 205:c41fc65bcfb4 | 808 | hdac->Instance->CR |= (DAC_WAVE_NOISE | Amplitude) << Channel; |
mbed_official | 205:c41fc65bcfb4 | 809 | |
mbed_official | 205:c41fc65bcfb4 | 810 | /* Change DAC state */ |
mbed_official | 205:c41fc65bcfb4 | 811 | hdac->State = HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 812 | |
mbed_official | 205:c41fc65bcfb4 | 813 | /* Process unlocked */ |
mbed_official | 205:c41fc65bcfb4 | 814 | __HAL_UNLOCK(hdac); |
mbed_official | 205:c41fc65bcfb4 | 815 | |
mbed_official | 205:c41fc65bcfb4 | 816 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 817 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 818 | } |
mbed_official | 205:c41fc65bcfb4 | 819 | |
mbed_official | 205:c41fc65bcfb4 | 820 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 821 | |
mbed_official | 205:c41fc65bcfb4 | 822 | #if defined(STM32F051x8) || defined(STM32F058xx) || \ |
mbed_official | 205:c41fc65bcfb4 | 823 | defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 824 | |
mbed_official | 205:c41fc65bcfb4 | 825 | /** |
mbed_official | 205:c41fc65bcfb4 | 826 | * @brief Set the specified data holding register value for dual DAC channel. |
mbed_official | 205:c41fc65bcfb4 | 827 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 828 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 829 | * @param Alignment: Specifies the data alignment for dual channel DAC. |
mbed_official | 205:c41fc65bcfb4 | 830 | * This parameter can be one of the following values: |
mbed_official | 205:c41fc65bcfb4 | 831 | * DAC_ALIGN_8B_R: 8bit right data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 832 | * DAC_ALIGN_12B_L: 12bit left data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 833 | * DAC_ALIGN_12B_R: 12bit right data alignment selected |
mbed_official | 205:c41fc65bcfb4 | 834 | * @param Data1: Data for DAC Channel2 to be loaded in the selected data holding register. |
mbed_official | 205:c41fc65bcfb4 | 835 | * @param Data2: Data for DAC Channel1 to be loaded in the selected data holding register. |
mbed_official | 205:c41fc65bcfb4 | 836 | * @note In dual mode, a unique register access is required to write in both |
mbed_official | 205:c41fc65bcfb4 | 837 | * DAC channels at the same time. |
mbed_official | 205:c41fc65bcfb4 | 838 | * @retval HAL status |
mbed_official | 205:c41fc65bcfb4 | 839 | */ |
mbed_official | 205:c41fc65bcfb4 | 840 | HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2) |
mbed_official | 205:c41fc65bcfb4 | 841 | { |
mbed_official | 205:c41fc65bcfb4 | 842 | uint32_t data = 0, tmp = 0; |
mbed_official | 205:c41fc65bcfb4 | 843 | |
mbed_official | 205:c41fc65bcfb4 | 844 | /* Check the parameters */ |
mbed_official | 205:c41fc65bcfb4 | 845 | assert_param(IS_DAC_ALIGN(Alignment)); |
mbed_official | 205:c41fc65bcfb4 | 846 | assert_param(IS_DAC_DATA(Data1)); |
mbed_official | 205:c41fc65bcfb4 | 847 | assert_param(IS_DAC_DATA(Data2)); |
mbed_official | 205:c41fc65bcfb4 | 848 | |
mbed_official | 205:c41fc65bcfb4 | 849 | /* Calculate and set dual DAC data holding register value */ |
mbed_official | 205:c41fc65bcfb4 | 850 | if (Alignment == DAC_ALIGN_8B_R) |
mbed_official | 205:c41fc65bcfb4 | 851 | { |
mbed_official | 205:c41fc65bcfb4 | 852 | data = ((uint32_t)Data2 << 8) | Data1; |
mbed_official | 205:c41fc65bcfb4 | 853 | } |
mbed_official | 205:c41fc65bcfb4 | 854 | else |
mbed_official | 205:c41fc65bcfb4 | 855 | { |
mbed_official | 205:c41fc65bcfb4 | 856 | data = ((uint32_t)Data2 << 16) | Data1; |
mbed_official | 205:c41fc65bcfb4 | 857 | } |
mbed_official | 205:c41fc65bcfb4 | 858 | |
mbed_official | 205:c41fc65bcfb4 | 859 | tmp = (uint32_t)hdac->Instance; |
mbed_official | 205:c41fc65bcfb4 | 860 | tmp += __HAL_DHR12RD_ALIGNEMENT(Alignment); |
mbed_official | 205:c41fc65bcfb4 | 861 | |
mbed_official | 205:c41fc65bcfb4 | 862 | /* Set the dual DAC selected data holding register */ |
mbed_official | 205:c41fc65bcfb4 | 863 | *(__IO uint32_t *)tmp = data; |
mbed_official | 205:c41fc65bcfb4 | 864 | |
mbed_official | 205:c41fc65bcfb4 | 865 | /* Return function status */ |
mbed_official | 205:c41fc65bcfb4 | 866 | return HAL_OK; |
mbed_official | 205:c41fc65bcfb4 | 867 | } |
mbed_official | 205:c41fc65bcfb4 | 868 | |
mbed_official | 205:c41fc65bcfb4 | 869 | /** |
mbed_official | 205:c41fc65bcfb4 | 870 | * @} |
mbed_official | 205:c41fc65bcfb4 | 871 | */ |
mbed_official | 205:c41fc65bcfb4 | 872 | |
mbed_official | 205:c41fc65bcfb4 | 873 | /** |
mbed_official | 205:c41fc65bcfb4 | 874 | * @brief DMA conversion complete callback. |
mbed_official | 205:c41fc65bcfb4 | 875 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 876 | * the configuration information for the specified DMA module. |
mbed_official | 205:c41fc65bcfb4 | 877 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 878 | */ |
mbed_official | 205:c41fc65bcfb4 | 879 | static void DAC_DMAConvCpltCh1(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 880 | { |
mbed_official | 205:c41fc65bcfb4 | 881 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 882 | |
mbed_official | 205:c41fc65bcfb4 | 883 | HAL_DAC_ConvCpltCallbackCh1(hdac); |
mbed_official | 205:c41fc65bcfb4 | 884 | |
mbed_official | 205:c41fc65bcfb4 | 885 | hdac->State= HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 886 | } |
mbed_official | 205:c41fc65bcfb4 | 887 | |
mbed_official | 205:c41fc65bcfb4 | 888 | /** |
mbed_official | 205:c41fc65bcfb4 | 889 | * @brief DMA half transfer complete callback. |
mbed_official | 205:c41fc65bcfb4 | 890 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 891 | * the configuration information for the specified DMA module. |
mbed_official | 205:c41fc65bcfb4 | 892 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 893 | */ |
mbed_official | 205:c41fc65bcfb4 | 894 | static void DAC_DMAHalfConvCpltCh1(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 895 | { |
mbed_official | 205:c41fc65bcfb4 | 896 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 897 | /* Conversion complete callback */ |
mbed_official | 205:c41fc65bcfb4 | 898 | HAL_DAC_ConvHalfCpltCallbackCh1(hdac); |
mbed_official | 205:c41fc65bcfb4 | 899 | } |
mbed_official | 205:c41fc65bcfb4 | 900 | |
mbed_official | 205:c41fc65bcfb4 | 901 | /** |
mbed_official | 205:c41fc65bcfb4 | 902 | * @brief DMA error callback |
mbed_official | 205:c41fc65bcfb4 | 903 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 904 | * the configuration information for the specified DMA module. |
mbed_official | 205:c41fc65bcfb4 | 905 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 906 | */ |
mbed_official | 205:c41fc65bcfb4 | 907 | static void DAC_DMAErrorCh1(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 908 | { |
mbed_official | 205:c41fc65bcfb4 | 909 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 910 | |
mbed_official | 205:c41fc65bcfb4 | 911 | /* Set DAC error code to DMA error */ |
mbed_official | 205:c41fc65bcfb4 | 912 | hdac->ErrorCode |= HAL_DAC_ERROR_DMA; |
mbed_official | 205:c41fc65bcfb4 | 913 | |
mbed_official | 205:c41fc65bcfb4 | 914 | HAL_DAC_ErrorCallbackCh1(hdac); |
mbed_official | 205:c41fc65bcfb4 | 915 | |
mbed_official | 205:c41fc65bcfb4 | 916 | hdac->State= HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 917 | } |
mbed_official | 205:c41fc65bcfb4 | 918 | |
mbed_official | 205:c41fc65bcfb4 | 919 | #endif /* STM32F051x8 STM32F058xx */ |
mbed_official | 205:c41fc65bcfb4 | 920 | /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 921 | |
mbed_official | 205:c41fc65bcfb4 | 922 | #if defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) |
mbed_official | 205:c41fc65bcfb4 | 923 | |
mbed_official | 205:c41fc65bcfb4 | 924 | /** |
mbed_official | 205:c41fc65bcfb4 | 925 | * @brief Conversion complete callback in non blocking mode for Channel2 |
mbed_official | 205:c41fc65bcfb4 | 926 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 927 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 928 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 929 | */ |
mbed_official | 205:c41fc65bcfb4 | 930 | __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac) |
mbed_official | 205:c41fc65bcfb4 | 931 | { |
mbed_official | 205:c41fc65bcfb4 | 932 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 933 | the HAL_DAC_ConvCpltCallback could be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 934 | */ |
mbed_official | 205:c41fc65bcfb4 | 935 | } |
mbed_official | 205:c41fc65bcfb4 | 936 | |
mbed_official | 205:c41fc65bcfb4 | 937 | /** |
mbed_official | 205:c41fc65bcfb4 | 938 | * @brief Conversion half DMA transfer callback in non blocking mode for Channel2 |
mbed_official | 205:c41fc65bcfb4 | 939 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 940 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 941 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 942 | */ |
mbed_official | 205:c41fc65bcfb4 | 943 | __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac) |
mbed_official | 205:c41fc65bcfb4 | 944 | { |
mbed_official | 205:c41fc65bcfb4 | 945 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 946 | the HAL_DAC_ConvHalfCpltCallbackCh2 could be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 947 | */ |
mbed_official | 205:c41fc65bcfb4 | 948 | } |
mbed_official | 205:c41fc65bcfb4 | 949 | |
mbed_official | 205:c41fc65bcfb4 | 950 | /** |
mbed_official | 205:c41fc65bcfb4 | 951 | * @brief Error DAC callback for Channel2. |
mbed_official | 205:c41fc65bcfb4 | 952 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 953 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 954 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 955 | */ |
mbed_official | 205:c41fc65bcfb4 | 956 | __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac) |
mbed_official | 205:c41fc65bcfb4 | 957 | { |
mbed_official | 205:c41fc65bcfb4 | 958 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 959 | the HAL_DAC_ErrorCallback could be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 960 | */ |
mbed_official | 205:c41fc65bcfb4 | 961 | } |
mbed_official | 205:c41fc65bcfb4 | 962 | |
mbed_official | 205:c41fc65bcfb4 | 963 | /** |
mbed_official | 205:c41fc65bcfb4 | 964 | * @brief DMA underrun DAC callback for channel2. |
mbed_official | 205:c41fc65bcfb4 | 965 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 966 | * the configuration information for the specified DAC. |
mbed_official | 205:c41fc65bcfb4 | 967 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 968 | */ |
mbed_official | 205:c41fc65bcfb4 | 969 | __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac) |
mbed_official | 205:c41fc65bcfb4 | 970 | { |
mbed_official | 205:c41fc65bcfb4 | 971 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 205:c41fc65bcfb4 | 972 | the HAL_DAC_DMAUnderrunCallbackCh2 could be implemented in the user file |
mbed_official | 205:c41fc65bcfb4 | 973 | */ |
mbed_official | 205:c41fc65bcfb4 | 974 | } |
mbed_official | 205:c41fc65bcfb4 | 975 | |
mbed_official | 205:c41fc65bcfb4 | 976 | /** |
mbed_official | 205:c41fc65bcfb4 | 977 | * @brief DMA conversion complete callback. |
mbed_official | 205:c41fc65bcfb4 | 978 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 979 | * the configuration information for the specified DMA module. |
mbed_official | 205:c41fc65bcfb4 | 980 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 981 | */ |
mbed_official | 205:c41fc65bcfb4 | 982 | void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 983 | { |
mbed_official | 205:c41fc65bcfb4 | 984 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 985 | |
mbed_official | 205:c41fc65bcfb4 | 986 | HAL_DACEx_ConvCpltCallbackCh2(hdac); |
mbed_official | 205:c41fc65bcfb4 | 987 | |
mbed_official | 205:c41fc65bcfb4 | 988 | hdac->State= HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 989 | } |
mbed_official | 205:c41fc65bcfb4 | 990 | |
mbed_official | 205:c41fc65bcfb4 | 991 | /** |
mbed_official | 205:c41fc65bcfb4 | 992 | * @brief DMA half transfer complete callback. |
mbed_official | 205:c41fc65bcfb4 | 993 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 994 | * the configuration information for the specified DMA module. |
mbed_official | 205:c41fc65bcfb4 | 995 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 996 | */ |
mbed_official | 205:c41fc65bcfb4 | 997 | void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 998 | { |
mbed_official | 205:c41fc65bcfb4 | 999 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 1000 | /* Conversion complete callback */ |
mbed_official | 205:c41fc65bcfb4 | 1001 | HAL_DACEx_ConvHalfCpltCallbackCh2(hdac); |
mbed_official | 205:c41fc65bcfb4 | 1002 | } |
mbed_official | 205:c41fc65bcfb4 | 1003 | |
mbed_official | 205:c41fc65bcfb4 | 1004 | /** |
mbed_official | 205:c41fc65bcfb4 | 1005 | * @brief DMA error callback |
mbed_official | 205:c41fc65bcfb4 | 1006 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 205:c41fc65bcfb4 | 1007 | * the configuration information for the specified DMA module. |
mbed_official | 205:c41fc65bcfb4 | 1008 | * @retval None |
mbed_official | 205:c41fc65bcfb4 | 1009 | */ |
mbed_official | 205:c41fc65bcfb4 | 1010 | void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma) |
mbed_official | 205:c41fc65bcfb4 | 1011 | { |
mbed_official | 205:c41fc65bcfb4 | 1012 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 205:c41fc65bcfb4 | 1013 | |
mbed_official | 205:c41fc65bcfb4 | 1014 | /* Set DAC error code to DMA error */ |
mbed_official | 205:c41fc65bcfb4 | 1015 | hdac->ErrorCode |= HAL_DAC_ERROR_DMA; |
mbed_official | 205:c41fc65bcfb4 | 1016 | |
mbed_official | 205:c41fc65bcfb4 | 1017 | HAL_DACEx_ErrorCallbackCh2(hdac); |
mbed_official | 205:c41fc65bcfb4 | 1018 | |
mbed_official | 205:c41fc65bcfb4 | 1019 | hdac->State= HAL_DAC_STATE_READY; |
mbed_official | 205:c41fc65bcfb4 | 1020 | } |
mbed_official | 205:c41fc65bcfb4 | 1021 | |
mbed_official | 205:c41fc65bcfb4 | 1022 | /** |
mbed_official | 205:c41fc65bcfb4 | 1023 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1024 | */ |
mbed_official | 205:c41fc65bcfb4 | 1025 | |
mbed_official | 205:c41fc65bcfb4 | 1026 | #endif /* STM32F071xB STM32F072xB STM32F078xx */ |
mbed_official | 205:c41fc65bcfb4 | 1027 | |
mbed_official | 205:c41fc65bcfb4 | 1028 | #endif /* HAL_DAC_MODULE_ENABLED */ |
mbed_official | 205:c41fc65bcfb4 | 1029 | |
mbed_official | 205:c41fc65bcfb4 | 1030 | /** |
mbed_official | 205:c41fc65bcfb4 | 1031 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1032 | */ |
mbed_official | 205:c41fc65bcfb4 | 1033 | |
mbed_official | 205:c41fc65bcfb4 | 1034 | /** |
mbed_official | 205:c41fc65bcfb4 | 1035 | * @} |
mbed_official | 205:c41fc65bcfb4 | 1036 | */ |
mbed_official | 205:c41fc65bcfb4 | 1037 | |
mbed_official | 205:c41fc65bcfb4 | 1038 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |