mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F100RB/stm32f10x_dac.c@126:549ba18ddd81, 2014-03-19 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Mar 19 16:00:09 2014 +0000
- Revision:
- 126:549ba18ddd81
Synchronized with git revision cf8fd1cf86b0cd85131dd24a6ded21cc6fe04827
Full URL: https://github.com/mbedmicro/mbed/commit/cf8fd1cf86b0cd85131dd24a6ded21cc6fe04827/
Conflicts:
workspace_tools/targets.py
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 126:549ba18ddd81 | 1 | /** |
mbed_official | 126:549ba18ddd81 | 2 | ****************************************************************************** |
mbed_official | 126:549ba18ddd81 | 3 | * @file stm32f10x_dac.c |
mbed_official | 126:549ba18ddd81 | 4 | * @author MCD Application Team |
mbed_official | 126:549ba18ddd81 | 5 | * @version V3.6.1 |
mbed_official | 126:549ba18ddd81 | 6 | * @date 05-March-2012 |
mbed_official | 126:549ba18ddd81 | 7 | * @brief This file provides all the DAC firmware functions. |
mbed_official | 126:549ba18ddd81 | 8 | ******************************************************************************* |
mbed_official | 126:549ba18ddd81 | 9 | * Copyright (c) 2014, STMicroelectronics |
mbed_official | 126:549ba18ddd81 | 10 | * All rights reserved. |
mbed_official | 126:549ba18ddd81 | 11 | * |
mbed_official | 126:549ba18ddd81 | 12 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 126:549ba18ddd81 | 13 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 126:549ba18ddd81 | 14 | * |
mbed_official | 126:549ba18ddd81 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 126:549ba18ddd81 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 126:549ba18ddd81 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 126:549ba18ddd81 | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 126:549ba18ddd81 | 19 | * and/or other materials provided with the distribution. |
mbed_official | 126:549ba18ddd81 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 126:549ba18ddd81 | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 126:549ba18ddd81 | 22 | * without specific prior written permission. |
mbed_official | 126:549ba18ddd81 | 23 | * |
mbed_official | 126:549ba18ddd81 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 126:549ba18ddd81 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 126:549ba18ddd81 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 126:549ba18ddd81 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 126:549ba18ddd81 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 126:549ba18ddd81 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 126:549ba18ddd81 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 126:549ba18ddd81 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 126:549ba18ddd81 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 126:549ba18ddd81 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 126:549ba18ddd81 | 34 | ******************************************************************************* |
mbed_official | 126:549ba18ddd81 | 35 | */ |
mbed_official | 126:549ba18ddd81 | 36 | |
mbed_official | 126:549ba18ddd81 | 37 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 126:549ba18ddd81 | 38 | #include "stm32f10x_dac.h" |
mbed_official | 126:549ba18ddd81 | 39 | #include "stm32f10x_rcc.h" |
mbed_official | 126:549ba18ddd81 | 40 | |
mbed_official | 126:549ba18ddd81 | 41 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 126:549ba18ddd81 | 42 | * @{ |
mbed_official | 126:549ba18ddd81 | 43 | */ |
mbed_official | 126:549ba18ddd81 | 44 | |
mbed_official | 126:549ba18ddd81 | 45 | /** @defgroup DAC |
mbed_official | 126:549ba18ddd81 | 46 | * @brief DAC driver modules |
mbed_official | 126:549ba18ddd81 | 47 | * @{ |
mbed_official | 126:549ba18ddd81 | 48 | */ |
mbed_official | 126:549ba18ddd81 | 49 | |
mbed_official | 126:549ba18ddd81 | 50 | /** @defgroup DAC_Private_TypesDefinitions |
mbed_official | 126:549ba18ddd81 | 51 | * @{ |
mbed_official | 126:549ba18ddd81 | 52 | */ |
mbed_official | 126:549ba18ddd81 | 53 | |
mbed_official | 126:549ba18ddd81 | 54 | /** |
mbed_official | 126:549ba18ddd81 | 55 | * @} |
mbed_official | 126:549ba18ddd81 | 56 | */ |
mbed_official | 126:549ba18ddd81 | 57 | |
mbed_official | 126:549ba18ddd81 | 58 | /** @defgroup DAC_Private_Defines |
mbed_official | 126:549ba18ddd81 | 59 | * @{ |
mbed_official | 126:549ba18ddd81 | 60 | */ |
mbed_official | 126:549ba18ddd81 | 61 | |
mbed_official | 126:549ba18ddd81 | 62 | /* CR register Mask */ |
mbed_official | 126:549ba18ddd81 | 63 | #define CR_CLEAR_MASK ((uint32_t)0x00000FFE) |
mbed_official | 126:549ba18ddd81 | 64 | |
mbed_official | 126:549ba18ddd81 | 65 | /* DAC Dual Channels SWTRIG masks */ |
mbed_official | 126:549ba18ddd81 | 66 | #define DUAL_SWTRIG_SET ((uint32_t)0x00000003) |
mbed_official | 126:549ba18ddd81 | 67 | #define DUAL_SWTRIG_RESET ((uint32_t)0xFFFFFFFC) |
mbed_official | 126:549ba18ddd81 | 68 | |
mbed_official | 126:549ba18ddd81 | 69 | /* DHR registers offsets */ |
mbed_official | 126:549ba18ddd81 | 70 | #define DHR12R1_OFFSET ((uint32_t)0x00000008) |
mbed_official | 126:549ba18ddd81 | 71 | #define DHR12R2_OFFSET ((uint32_t)0x00000014) |
mbed_official | 126:549ba18ddd81 | 72 | #define DHR12RD_OFFSET ((uint32_t)0x00000020) |
mbed_official | 126:549ba18ddd81 | 73 | |
mbed_official | 126:549ba18ddd81 | 74 | /* DOR register offset */ |
mbed_official | 126:549ba18ddd81 | 75 | #define DOR_OFFSET ((uint32_t)0x0000002C) |
mbed_official | 126:549ba18ddd81 | 76 | /** |
mbed_official | 126:549ba18ddd81 | 77 | * @} |
mbed_official | 126:549ba18ddd81 | 78 | */ |
mbed_official | 126:549ba18ddd81 | 79 | |
mbed_official | 126:549ba18ddd81 | 80 | /** @defgroup DAC_Private_Macros |
mbed_official | 126:549ba18ddd81 | 81 | * @{ |
mbed_official | 126:549ba18ddd81 | 82 | */ |
mbed_official | 126:549ba18ddd81 | 83 | |
mbed_official | 126:549ba18ddd81 | 84 | /** |
mbed_official | 126:549ba18ddd81 | 85 | * @} |
mbed_official | 126:549ba18ddd81 | 86 | */ |
mbed_official | 126:549ba18ddd81 | 87 | |
mbed_official | 126:549ba18ddd81 | 88 | /** @defgroup DAC_Private_Variables |
mbed_official | 126:549ba18ddd81 | 89 | * @{ |
mbed_official | 126:549ba18ddd81 | 90 | */ |
mbed_official | 126:549ba18ddd81 | 91 | |
mbed_official | 126:549ba18ddd81 | 92 | /** |
mbed_official | 126:549ba18ddd81 | 93 | * @} |
mbed_official | 126:549ba18ddd81 | 94 | */ |
mbed_official | 126:549ba18ddd81 | 95 | |
mbed_official | 126:549ba18ddd81 | 96 | /** @defgroup DAC_Private_FunctionPrototypes |
mbed_official | 126:549ba18ddd81 | 97 | * @{ |
mbed_official | 126:549ba18ddd81 | 98 | */ |
mbed_official | 126:549ba18ddd81 | 99 | |
mbed_official | 126:549ba18ddd81 | 100 | /** |
mbed_official | 126:549ba18ddd81 | 101 | * @} |
mbed_official | 126:549ba18ddd81 | 102 | */ |
mbed_official | 126:549ba18ddd81 | 103 | |
mbed_official | 126:549ba18ddd81 | 104 | /** @defgroup DAC_Private_Functions |
mbed_official | 126:549ba18ddd81 | 105 | * @{ |
mbed_official | 126:549ba18ddd81 | 106 | */ |
mbed_official | 126:549ba18ddd81 | 107 | |
mbed_official | 126:549ba18ddd81 | 108 | /** |
mbed_official | 126:549ba18ddd81 | 109 | * @brief Deinitializes the DAC peripheral registers to their default reset values. |
mbed_official | 126:549ba18ddd81 | 110 | * @param None |
mbed_official | 126:549ba18ddd81 | 111 | * @retval None |
mbed_official | 126:549ba18ddd81 | 112 | */ |
mbed_official | 126:549ba18ddd81 | 113 | void DAC_DeInit(void) |
mbed_official | 126:549ba18ddd81 | 114 | { |
mbed_official | 126:549ba18ddd81 | 115 | /* Enable DAC reset state */ |
mbed_official | 126:549ba18ddd81 | 116 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, ENABLE); |
mbed_official | 126:549ba18ddd81 | 117 | /* Release DAC from reset state */ |
mbed_official | 126:549ba18ddd81 | 118 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_DAC, DISABLE); |
mbed_official | 126:549ba18ddd81 | 119 | } |
mbed_official | 126:549ba18ddd81 | 120 | |
mbed_official | 126:549ba18ddd81 | 121 | /** |
mbed_official | 126:549ba18ddd81 | 122 | * @brief Initializes the DAC peripheral according to the specified |
mbed_official | 126:549ba18ddd81 | 123 | * parameters in the DAC_InitStruct. |
mbed_official | 126:549ba18ddd81 | 124 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 125 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 126 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 127 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 128 | * @param DAC_InitStruct: pointer to a DAC_InitTypeDef structure that |
mbed_official | 126:549ba18ddd81 | 129 | * contains the configuration information for the specified DAC channel. |
mbed_official | 126:549ba18ddd81 | 130 | * @retval None |
mbed_official | 126:549ba18ddd81 | 131 | */ |
mbed_official | 126:549ba18ddd81 | 132 | void DAC_Init(uint32_t DAC_Channel, DAC_InitTypeDef* DAC_InitStruct) |
mbed_official | 126:549ba18ddd81 | 133 | { |
mbed_official | 126:549ba18ddd81 | 134 | uint32_t tmpreg1 = 0, tmpreg2 = 0; |
mbed_official | 126:549ba18ddd81 | 135 | /* Check the DAC parameters */ |
mbed_official | 126:549ba18ddd81 | 136 | assert_param(IS_DAC_TRIGGER(DAC_InitStruct->DAC_Trigger)); |
mbed_official | 126:549ba18ddd81 | 137 | assert_param(IS_DAC_GENERATE_WAVE(DAC_InitStruct->DAC_WaveGeneration)); |
mbed_official | 126:549ba18ddd81 | 138 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude)); |
mbed_official | 126:549ba18ddd81 | 139 | assert_param(IS_DAC_OUTPUT_BUFFER_STATE(DAC_InitStruct->DAC_OutputBuffer)); |
mbed_official | 126:549ba18ddd81 | 140 | /*---------------------------- DAC CR Configuration --------------------------*/ |
mbed_official | 126:549ba18ddd81 | 141 | /* Get the DAC CR value */ |
mbed_official | 126:549ba18ddd81 | 142 | tmpreg1 = DAC->CR; |
mbed_official | 126:549ba18ddd81 | 143 | /* Clear BOFFx, TENx, TSELx, WAVEx and MAMPx bits */ |
mbed_official | 126:549ba18ddd81 | 144 | tmpreg1 &= ~(CR_CLEAR_MASK << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 145 | /* Configure for the selected DAC channel: buffer output, trigger, wave generation, |
mbed_official | 126:549ba18ddd81 | 146 | mask/amplitude for wave generation */ |
mbed_official | 126:549ba18ddd81 | 147 | /* Set TSELx and TENx bits according to DAC_Trigger value */ |
mbed_official | 126:549ba18ddd81 | 148 | /* Set WAVEx bits according to DAC_WaveGeneration value */ |
mbed_official | 126:549ba18ddd81 | 149 | /* Set MAMPx bits according to DAC_LFSRUnmask_TriangleAmplitude value */ |
mbed_official | 126:549ba18ddd81 | 150 | /* Set BOFFx bit according to DAC_OutputBuffer value */ |
mbed_official | 126:549ba18ddd81 | 151 | tmpreg2 = (DAC_InitStruct->DAC_Trigger | DAC_InitStruct->DAC_WaveGeneration | |
mbed_official | 126:549ba18ddd81 | 152 | DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude | DAC_InitStruct->DAC_OutputBuffer); |
mbed_official | 126:549ba18ddd81 | 153 | /* Calculate CR register value depending on DAC_Channel */ |
mbed_official | 126:549ba18ddd81 | 154 | tmpreg1 |= tmpreg2 << DAC_Channel; |
mbed_official | 126:549ba18ddd81 | 155 | /* Write to DAC CR */ |
mbed_official | 126:549ba18ddd81 | 156 | DAC->CR = tmpreg1; |
mbed_official | 126:549ba18ddd81 | 157 | } |
mbed_official | 126:549ba18ddd81 | 158 | |
mbed_official | 126:549ba18ddd81 | 159 | /** |
mbed_official | 126:549ba18ddd81 | 160 | * @brief Fills each DAC_InitStruct member with its default value. |
mbed_official | 126:549ba18ddd81 | 161 | * @param DAC_InitStruct : pointer to a DAC_InitTypeDef structure which will |
mbed_official | 126:549ba18ddd81 | 162 | * be initialized. |
mbed_official | 126:549ba18ddd81 | 163 | * @retval None |
mbed_official | 126:549ba18ddd81 | 164 | */ |
mbed_official | 126:549ba18ddd81 | 165 | void DAC_StructInit(DAC_InitTypeDef* DAC_InitStruct) |
mbed_official | 126:549ba18ddd81 | 166 | { |
mbed_official | 126:549ba18ddd81 | 167 | /*--------------- Reset DAC init structure parameters values -----------------*/ |
mbed_official | 126:549ba18ddd81 | 168 | /* Initialize the DAC_Trigger member */ |
mbed_official | 126:549ba18ddd81 | 169 | DAC_InitStruct->DAC_Trigger = DAC_Trigger_None; |
mbed_official | 126:549ba18ddd81 | 170 | /* Initialize the DAC_WaveGeneration member */ |
mbed_official | 126:549ba18ddd81 | 171 | DAC_InitStruct->DAC_WaveGeneration = DAC_WaveGeneration_None; |
mbed_official | 126:549ba18ddd81 | 172 | /* Initialize the DAC_LFSRUnmask_TriangleAmplitude member */ |
mbed_official | 126:549ba18ddd81 | 173 | DAC_InitStruct->DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0; |
mbed_official | 126:549ba18ddd81 | 174 | /* Initialize the DAC_OutputBuffer member */ |
mbed_official | 126:549ba18ddd81 | 175 | DAC_InitStruct->DAC_OutputBuffer = DAC_OutputBuffer_Enable; |
mbed_official | 126:549ba18ddd81 | 176 | } |
mbed_official | 126:549ba18ddd81 | 177 | |
mbed_official | 126:549ba18ddd81 | 178 | /** |
mbed_official | 126:549ba18ddd81 | 179 | * @brief Enables or disables the specified DAC channel. |
mbed_official | 126:549ba18ddd81 | 180 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 181 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 182 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 183 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 184 | * @param NewState: new state of the DAC channel. |
mbed_official | 126:549ba18ddd81 | 185 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 186 | * @retval None |
mbed_official | 126:549ba18ddd81 | 187 | */ |
mbed_official | 126:549ba18ddd81 | 188 | void DAC_Cmd(uint32_t DAC_Channel, FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 189 | { |
mbed_official | 126:549ba18ddd81 | 190 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 191 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 192 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 193 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 194 | { |
mbed_official | 126:549ba18ddd81 | 195 | /* Enable the selected DAC channel */ |
mbed_official | 126:549ba18ddd81 | 196 | DAC->CR |= (DAC_CR_EN1 << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 197 | } |
mbed_official | 126:549ba18ddd81 | 198 | else |
mbed_official | 126:549ba18ddd81 | 199 | { |
mbed_official | 126:549ba18ddd81 | 200 | /* Disable the selected DAC channel */ |
mbed_official | 126:549ba18ddd81 | 201 | DAC->CR &= ~(DAC_CR_EN1 << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 202 | } |
mbed_official | 126:549ba18ddd81 | 203 | } |
mbed_official | 126:549ba18ddd81 | 204 | #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) |
mbed_official | 126:549ba18ddd81 | 205 | /** |
mbed_official | 126:549ba18ddd81 | 206 | * @brief Enables or disables the specified DAC interrupts. |
mbed_official | 126:549ba18ddd81 | 207 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 208 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 209 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 210 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 211 | * @param DAC_IT: specifies the DAC interrupt sources to be enabled or disabled. |
mbed_official | 126:549ba18ddd81 | 212 | * This parameter can be the following values: |
mbed_official | 126:549ba18ddd81 | 213 | * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
mbed_official | 126:549ba18ddd81 | 214 | * @param NewState: new state of the specified DAC interrupts. |
mbed_official | 126:549ba18ddd81 | 215 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 216 | * @retval None |
mbed_official | 126:549ba18ddd81 | 217 | */ |
mbed_official | 126:549ba18ddd81 | 218 | void DAC_ITConfig(uint32_t DAC_Channel, uint32_t DAC_IT, FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 219 | { |
mbed_official | 126:549ba18ddd81 | 220 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 221 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 222 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 223 | assert_param(IS_DAC_IT(DAC_IT)); |
mbed_official | 126:549ba18ddd81 | 224 | |
mbed_official | 126:549ba18ddd81 | 225 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 226 | { |
mbed_official | 126:549ba18ddd81 | 227 | /* Enable the selected DAC interrupts */ |
mbed_official | 126:549ba18ddd81 | 228 | DAC->CR |= (DAC_IT << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 229 | } |
mbed_official | 126:549ba18ddd81 | 230 | else |
mbed_official | 126:549ba18ddd81 | 231 | { |
mbed_official | 126:549ba18ddd81 | 232 | /* Disable the selected DAC interrupts */ |
mbed_official | 126:549ba18ddd81 | 233 | DAC->CR &= (~(uint32_t)(DAC_IT << DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 234 | } |
mbed_official | 126:549ba18ddd81 | 235 | } |
mbed_official | 126:549ba18ddd81 | 236 | #endif |
mbed_official | 126:549ba18ddd81 | 237 | |
mbed_official | 126:549ba18ddd81 | 238 | /** |
mbed_official | 126:549ba18ddd81 | 239 | * @brief Enables or disables the specified DAC channel DMA request. |
mbed_official | 126:549ba18ddd81 | 240 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 241 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 242 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 243 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 244 | * @param NewState: new state of the selected DAC channel DMA request. |
mbed_official | 126:549ba18ddd81 | 245 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 246 | * @retval None |
mbed_official | 126:549ba18ddd81 | 247 | */ |
mbed_official | 126:549ba18ddd81 | 248 | void DAC_DMACmd(uint32_t DAC_Channel, FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 249 | { |
mbed_official | 126:549ba18ddd81 | 250 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 251 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 252 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 253 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 254 | { |
mbed_official | 126:549ba18ddd81 | 255 | /* Enable the selected DAC channel DMA request */ |
mbed_official | 126:549ba18ddd81 | 256 | DAC->CR |= (DAC_CR_DMAEN1 << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 257 | } |
mbed_official | 126:549ba18ddd81 | 258 | else |
mbed_official | 126:549ba18ddd81 | 259 | { |
mbed_official | 126:549ba18ddd81 | 260 | /* Disable the selected DAC channel DMA request */ |
mbed_official | 126:549ba18ddd81 | 261 | DAC->CR &= ~(DAC_CR_DMAEN1 << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 262 | } |
mbed_official | 126:549ba18ddd81 | 263 | } |
mbed_official | 126:549ba18ddd81 | 264 | |
mbed_official | 126:549ba18ddd81 | 265 | /** |
mbed_official | 126:549ba18ddd81 | 266 | * @brief Enables or disables the selected DAC channel software trigger. |
mbed_official | 126:549ba18ddd81 | 267 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 268 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 269 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 270 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 271 | * @param NewState: new state of the selected DAC channel software trigger. |
mbed_official | 126:549ba18ddd81 | 272 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 273 | * @retval None |
mbed_official | 126:549ba18ddd81 | 274 | */ |
mbed_official | 126:549ba18ddd81 | 275 | void DAC_SoftwareTriggerCmd(uint32_t DAC_Channel, FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 276 | { |
mbed_official | 126:549ba18ddd81 | 277 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 278 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 279 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 280 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 281 | { |
mbed_official | 126:549ba18ddd81 | 282 | /* Enable software trigger for the selected DAC channel */ |
mbed_official | 126:549ba18ddd81 | 283 | DAC->SWTRIGR |= (uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4); |
mbed_official | 126:549ba18ddd81 | 284 | } |
mbed_official | 126:549ba18ddd81 | 285 | else |
mbed_official | 126:549ba18ddd81 | 286 | { |
mbed_official | 126:549ba18ddd81 | 287 | /* Disable software trigger for the selected DAC channel */ |
mbed_official | 126:549ba18ddd81 | 288 | DAC->SWTRIGR &= ~((uint32_t)DAC_SWTRIGR_SWTRIG1 << (DAC_Channel >> 4)); |
mbed_official | 126:549ba18ddd81 | 289 | } |
mbed_official | 126:549ba18ddd81 | 290 | } |
mbed_official | 126:549ba18ddd81 | 291 | |
mbed_official | 126:549ba18ddd81 | 292 | /** |
mbed_official | 126:549ba18ddd81 | 293 | * @brief Enables or disables simultaneously the two DAC channels software |
mbed_official | 126:549ba18ddd81 | 294 | * triggers. |
mbed_official | 126:549ba18ddd81 | 295 | * @param NewState: new state of the DAC channels software triggers. |
mbed_official | 126:549ba18ddd81 | 296 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 297 | * @retval None |
mbed_official | 126:549ba18ddd81 | 298 | */ |
mbed_official | 126:549ba18ddd81 | 299 | void DAC_DualSoftwareTriggerCmd(FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 300 | { |
mbed_official | 126:549ba18ddd81 | 301 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 302 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 303 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 304 | { |
mbed_official | 126:549ba18ddd81 | 305 | /* Enable software trigger for both DAC channels */ |
mbed_official | 126:549ba18ddd81 | 306 | DAC->SWTRIGR |= DUAL_SWTRIG_SET ; |
mbed_official | 126:549ba18ddd81 | 307 | } |
mbed_official | 126:549ba18ddd81 | 308 | else |
mbed_official | 126:549ba18ddd81 | 309 | { |
mbed_official | 126:549ba18ddd81 | 310 | /* Disable software trigger for both DAC channels */ |
mbed_official | 126:549ba18ddd81 | 311 | DAC->SWTRIGR &= DUAL_SWTRIG_RESET; |
mbed_official | 126:549ba18ddd81 | 312 | } |
mbed_official | 126:549ba18ddd81 | 313 | } |
mbed_official | 126:549ba18ddd81 | 314 | |
mbed_official | 126:549ba18ddd81 | 315 | /** |
mbed_official | 126:549ba18ddd81 | 316 | * @brief Enables or disables the selected DAC channel wave generation. |
mbed_official | 126:549ba18ddd81 | 317 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 318 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 319 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 320 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 321 | * @param DAC_Wave: Specifies the wave type to enable or disable. |
mbed_official | 126:549ba18ddd81 | 322 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 323 | * @arg DAC_Wave_Noise: noise wave generation |
mbed_official | 126:549ba18ddd81 | 324 | * @arg DAC_Wave_Triangle: triangle wave generation |
mbed_official | 126:549ba18ddd81 | 325 | * @param NewState: new state of the selected DAC channel wave generation. |
mbed_official | 126:549ba18ddd81 | 326 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 126:549ba18ddd81 | 327 | * @retval None |
mbed_official | 126:549ba18ddd81 | 328 | */ |
mbed_official | 126:549ba18ddd81 | 329 | void DAC_WaveGenerationCmd(uint32_t DAC_Channel, uint32_t DAC_Wave, FunctionalState NewState) |
mbed_official | 126:549ba18ddd81 | 330 | { |
mbed_official | 126:549ba18ddd81 | 331 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 332 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 333 | assert_param(IS_DAC_WAVE(DAC_Wave)); |
mbed_official | 126:549ba18ddd81 | 334 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 126:549ba18ddd81 | 335 | if (NewState != DISABLE) |
mbed_official | 126:549ba18ddd81 | 336 | { |
mbed_official | 126:549ba18ddd81 | 337 | /* Enable the selected wave generation for the selected DAC channel */ |
mbed_official | 126:549ba18ddd81 | 338 | DAC->CR |= DAC_Wave << DAC_Channel; |
mbed_official | 126:549ba18ddd81 | 339 | } |
mbed_official | 126:549ba18ddd81 | 340 | else |
mbed_official | 126:549ba18ddd81 | 341 | { |
mbed_official | 126:549ba18ddd81 | 342 | /* Disable the selected wave generation for the selected DAC channel */ |
mbed_official | 126:549ba18ddd81 | 343 | DAC->CR &= ~(DAC_Wave << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 344 | } |
mbed_official | 126:549ba18ddd81 | 345 | } |
mbed_official | 126:549ba18ddd81 | 346 | |
mbed_official | 126:549ba18ddd81 | 347 | /** |
mbed_official | 126:549ba18ddd81 | 348 | * @brief Set the specified data holding register value for DAC channel1. |
mbed_official | 126:549ba18ddd81 | 349 | * @param DAC_Align: Specifies the data alignment for DAC channel1. |
mbed_official | 126:549ba18ddd81 | 350 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 351 | * @arg DAC_Align_8b_R: 8bit right data alignment selected |
mbed_official | 126:549ba18ddd81 | 352 | * @arg DAC_Align_12b_L: 12bit left data alignment selected |
mbed_official | 126:549ba18ddd81 | 353 | * @arg DAC_Align_12b_R: 12bit right data alignment selected |
mbed_official | 126:549ba18ddd81 | 354 | * @param Data : Data to be loaded in the selected data holding register. |
mbed_official | 126:549ba18ddd81 | 355 | * @retval None |
mbed_official | 126:549ba18ddd81 | 356 | */ |
mbed_official | 126:549ba18ddd81 | 357 | void DAC_SetChannel1Data(uint32_t DAC_Align, uint16_t Data) |
mbed_official | 126:549ba18ddd81 | 358 | { |
mbed_official | 126:549ba18ddd81 | 359 | __IO uint32_t tmp = 0; |
mbed_official | 126:549ba18ddd81 | 360 | |
mbed_official | 126:549ba18ddd81 | 361 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 362 | assert_param(IS_DAC_ALIGN(DAC_Align)); |
mbed_official | 126:549ba18ddd81 | 363 | assert_param(IS_DAC_DATA(Data)); |
mbed_official | 126:549ba18ddd81 | 364 | |
mbed_official | 126:549ba18ddd81 | 365 | tmp = (uint32_t)DAC_BASE; |
mbed_official | 126:549ba18ddd81 | 366 | tmp += DHR12R1_OFFSET + DAC_Align; |
mbed_official | 126:549ba18ddd81 | 367 | |
mbed_official | 126:549ba18ddd81 | 368 | /* Set the DAC channel1 selected data holding register */ |
mbed_official | 126:549ba18ddd81 | 369 | *(__IO uint32_t *) tmp = Data; |
mbed_official | 126:549ba18ddd81 | 370 | } |
mbed_official | 126:549ba18ddd81 | 371 | |
mbed_official | 126:549ba18ddd81 | 372 | /** |
mbed_official | 126:549ba18ddd81 | 373 | * @brief Set the specified data holding register value for DAC channel2. |
mbed_official | 126:549ba18ddd81 | 374 | * @param DAC_Align: Specifies the data alignment for DAC channel2. |
mbed_official | 126:549ba18ddd81 | 375 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 376 | * @arg DAC_Align_8b_R: 8bit right data alignment selected |
mbed_official | 126:549ba18ddd81 | 377 | * @arg DAC_Align_12b_L: 12bit left data alignment selected |
mbed_official | 126:549ba18ddd81 | 378 | * @arg DAC_Align_12b_R: 12bit right data alignment selected |
mbed_official | 126:549ba18ddd81 | 379 | * @param Data : Data to be loaded in the selected data holding register. |
mbed_official | 126:549ba18ddd81 | 380 | * @retval None |
mbed_official | 126:549ba18ddd81 | 381 | */ |
mbed_official | 126:549ba18ddd81 | 382 | void DAC_SetChannel2Data(uint32_t DAC_Align, uint16_t Data) |
mbed_official | 126:549ba18ddd81 | 383 | { |
mbed_official | 126:549ba18ddd81 | 384 | __IO uint32_t tmp = 0; |
mbed_official | 126:549ba18ddd81 | 385 | |
mbed_official | 126:549ba18ddd81 | 386 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 387 | assert_param(IS_DAC_ALIGN(DAC_Align)); |
mbed_official | 126:549ba18ddd81 | 388 | assert_param(IS_DAC_DATA(Data)); |
mbed_official | 126:549ba18ddd81 | 389 | |
mbed_official | 126:549ba18ddd81 | 390 | tmp = (uint32_t)DAC_BASE; |
mbed_official | 126:549ba18ddd81 | 391 | tmp += DHR12R2_OFFSET + DAC_Align; |
mbed_official | 126:549ba18ddd81 | 392 | |
mbed_official | 126:549ba18ddd81 | 393 | /* Set the DAC channel2 selected data holding register */ |
mbed_official | 126:549ba18ddd81 | 394 | *(__IO uint32_t *)tmp = Data; |
mbed_official | 126:549ba18ddd81 | 395 | } |
mbed_official | 126:549ba18ddd81 | 396 | |
mbed_official | 126:549ba18ddd81 | 397 | /** |
mbed_official | 126:549ba18ddd81 | 398 | * @brief Set the specified data holding register value for dual channel |
mbed_official | 126:549ba18ddd81 | 399 | * DAC. |
mbed_official | 126:549ba18ddd81 | 400 | * @param DAC_Align: Specifies the data alignment for dual channel DAC. |
mbed_official | 126:549ba18ddd81 | 401 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 402 | * @arg DAC_Align_8b_R: 8bit right data alignment selected |
mbed_official | 126:549ba18ddd81 | 403 | * @arg DAC_Align_12b_L: 12bit left data alignment selected |
mbed_official | 126:549ba18ddd81 | 404 | * @arg DAC_Align_12b_R: 12bit right data alignment selected |
mbed_official | 126:549ba18ddd81 | 405 | * @param Data2: Data for DAC Channel2 to be loaded in the selected data |
mbed_official | 126:549ba18ddd81 | 406 | * holding register. |
mbed_official | 126:549ba18ddd81 | 407 | * @param Data1: Data for DAC Channel1 to be loaded in the selected data |
mbed_official | 126:549ba18ddd81 | 408 | * holding register. |
mbed_official | 126:549ba18ddd81 | 409 | * @retval None |
mbed_official | 126:549ba18ddd81 | 410 | */ |
mbed_official | 126:549ba18ddd81 | 411 | void DAC_SetDualChannelData(uint32_t DAC_Align, uint16_t Data2, uint16_t Data1) |
mbed_official | 126:549ba18ddd81 | 412 | { |
mbed_official | 126:549ba18ddd81 | 413 | uint32_t data = 0, tmp = 0; |
mbed_official | 126:549ba18ddd81 | 414 | |
mbed_official | 126:549ba18ddd81 | 415 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 416 | assert_param(IS_DAC_ALIGN(DAC_Align)); |
mbed_official | 126:549ba18ddd81 | 417 | assert_param(IS_DAC_DATA(Data1)); |
mbed_official | 126:549ba18ddd81 | 418 | assert_param(IS_DAC_DATA(Data2)); |
mbed_official | 126:549ba18ddd81 | 419 | |
mbed_official | 126:549ba18ddd81 | 420 | /* Calculate and set dual DAC data holding register value */ |
mbed_official | 126:549ba18ddd81 | 421 | if (DAC_Align == DAC_Align_8b_R) |
mbed_official | 126:549ba18ddd81 | 422 | { |
mbed_official | 126:549ba18ddd81 | 423 | data = ((uint32_t)Data2 << 8) | Data1; |
mbed_official | 126:549ba18ddd81 | 424 | } |
mbed_official | 126:549ba18ddd81 | 425 | else |
mbed_official | 126:549ba18ddd81 | 426 | { |
mbed_official | 126:549ba18ddd81 | 427 | data = ((uint32_t)Data2 << 16) | Data1; |
mbed_official | 126:549ba18ddd81 | 428 | } |
mbed_official | 126:549ba18ddd81 | 429 | |
mbed_official | 126:549ba18ddd81 | 430 | tmp = (uint32_t)DAC_BASE; |
mbed_official | 126:549ba18ddd81 | 431 | tmp += DHR12RD_OFFSET + DAC_Align; |
mbed_official | 126:549ba18ddd81 | 432 | |
mbed_official | 126:549ba18ddd81 | 433 | /* Set the dual DAC selected data holding register */ |
mbed_official | 126:549ba18ddd81 | 434 | *(__IO uint32_t *)tmp = data; |
mbed_official | 126:549ba18ddd81 | 435 | } |
mbed_official | 126:549ba18ddd81 | 436 | |
mbed_official | 126:549ba18ddd81 | 437 | /** |
mbed_official | 126:549ba18ddd81 | 438 | * @brief Returns the last data output value of the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 439 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 440 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 441 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 442 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 443 | * @retval The selected DAC channel data output value. |
mbed_official | 126:549ba18ddd81 | 444 | */ |
mbed_official | 126:549ba18ddd81 | 445 | uint16_t DAC_GetDataOutputValue(uint32_t DAC_Channel) |
mbed_official | 126:549ba18ddd81 | 446 | { |
mbed_official | 126:549ba18ddd81 | 447 | __IO uint32_t tmp = 0; |
mbed_official | 126:549ba18ddd81 | 448 | |
mbed_official | 126:549ba18ddd81 | 449 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 450 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 451 | |
mbed_official | 126:549ba18ddd81 | 452 | tmp = (uint32_t) DAC_BASE ; |
mbed_official | 126:549ba18ddd81 | 453 | tmp += DOR_OFFSET + ((uint32_t)DAC_Channel >> 2); |
mbed_official | 126:549ba18ddd81 | 454 | |
mbed_official | 126:549ba18ddd81 | 455 | /* Returns the DAC channel data output register value */ |
mbed_official | 126:549ba18ddd81 | 456 | return (uint16_t) (*(__IO uint32_t*) tmp); |
mbed_official | 126:549ba18ddd81 | 457 | } |
mbed_official | 126:549ba18ddd81 | 458 | |
mbed_official | 126:549ba18ddd81 | 459 | #if defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || defined (STM32F10X_HD_VL) |
mbed_official | 126:549ba18ddd81 | 460 | /** |
mbed_official | 126:549ba18ddd81 | 461 | * @brief Checks whether the specified DAC flag is set or not. |
mbed_official | 126:549ba18ddd81 | 462 | * @param DAC_Channel: thee selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 463 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 464 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 465 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 466 | * @param DAC_FLAG: specifies the flag to check. |
mbed_official | 126:549ba18ddd81 | 467 | * This parameter can be only of the following value: |
mbed_official | 126:549ba18ddd81 | 468 | * @arg DAC_FLAG_DMAUDR: DMA underrun flag |
mbed_official | 126:549ba18ddd81 | 469 | * @retval The new state of DAC_FLAG (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 470 | */ |
mbed_official | 126:549ba18ddd81 | 471 | FlagStatus DAC_GetFlagStatus(uint32_t DAC_Channel, uint32_t DAC_FLAG) |
mbed_official | 126:549ba18ddd81 | 472 | { |
mbed_official | 126:549ba18ddd81 | 473 | FlagStatus bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 474 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 475 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 476 | assert_param(IS_DAC_FLAG(DAC_FLAG)); |
mbed_official | 126:549ba18ddd81 | 477 | |
mbed_official | 126:549ba18ddd81 | 478 | /* Check the status of the specified DAC flag */ |
mbed_official | 126:549ba18ddd81 | 479 | if ((DAC->SR & (DAC_FLAG << DAC_Channel)) != (uint8_t)RESET) |
mbed_official | 126:549ba18ddd81 | 480 | { |
mbed_official | 126:549ba18ddd81 | 481 | /* DAC_FLAG is set */ |
mbed_official | 126:549ba18ddd81 | 482 | bitstatus = SET; |
mbed_official | 126:549ba18ddd81 | 483 | } |
mbed_official | 126:549ba18ddd81 | 484 | else |
mbed_official | 126:549ba18ddd81 | 485 | { |
mbed_official | 126:549ba18ddd81 | 486 | /* DAC_FLAG is reset */ |
mbed_official | 126:549ba18ddd81 | 487 | bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 488 | } |
mbed_official | 126:549ba18ddd81 | 489 | /* Return the DAC_FLAG status */ |
mbed_official | 126:549ba18ddd81 | 490 | return bitstatus; |
mbed_official | 126:549ba18ddd81 | 491 | } |
mbed_official | 126:549ba18ddd81 | 492 | |
mbed_official | 126:549ba18ddd81 | 493 | /** |
mbed_official | 126:549ba18ddd81 | 494 | * @brief Clears the DAC channelx's pending flags. |
mbed_official | 126:549ba18ddd81 | 495 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 496 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 497 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 498 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 499 | * @param DAC_FLAG: specifies the flag to clear. |
mbed_official | 126:549ba18ddd81 | 500 | * This parameter can be of the following value: |
mbed_official | 126:549ba18ddd81 | 501 | * @arg DAC_FLAG_DMAUDR: DMA underrun flag |
mbed_official | 126:549ba18ddd81 | 502 | * @retval None |
mbed_official | 126:549ba18ddd81 | 503 | */ |
mbed_official | 126:549ba18ddd81 | 504 | void DAC_ClearFlag(uint32_t DAC_Channel, uint32_t DAC_FLAG) |
mbed_official | 126:549ba18ddd81 | 505 | { |
mbed_official | 126:549ba18ddd81 | 506 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 507 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 508 | assert_param(IS_DAC_FLAG(DAC_FLAG)); |
mbed_official | 126:549ba18ddd81 | 509 | |
mbed_official | 126:549ba18ddd81 | 510 | /* Clear the selected DAC flags */ |
mbed_official | 126:549ba18ddd81 | 511 | DAC->SR = (DAC_FLAG << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 512 | } |
mbed_official | 126:549ba18ddd81 | 513 | |
mbed_official | 126:549ba18ddd81 | 514 | /** |
mbed_official | 126:549ba18ddd81 | 515 | * @brief Checks whether the specified DAC interrupt has occurred or not. |
mbed_official | 126:549ba18ddd81 | 516 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 517 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 518 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 519 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 520 | * @param DAC_IT: specifies the DAC interrupt source to check. |
mbed_official | 126:549ba18ddd81 | 521 | * This parameter can be the following values: |
mbed_official | 126:549ba18ddd81 | 522 | * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
mbed_official | 126:549ba18ddd81 | 523 | * @retval The new state of DAC_IT (SET or RESET). |
mbed_official | 126:549ba18ddd81 | 524 | */ |
mbed_official | 126:549ba18ddd81 | 525 | ITStatus DAC_GetITStatus(uint32_t DAC_Channel, uint32_t DAC_IT) |
mbed_official | 126:549ba18ddd81 | 526 | { |
mbed_official | 126:549ba18ddd81 | 527 | ITStatus bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 528 | uint32_t enablestatus = 0; |
mbed_official | 126:549ba18ddd81 | 529 | |
mbed_official | 126:549ba18ddd81 | 530 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 531 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 532 | assert_param(IS_DAC_IT(DAC_IT)); |
mbed_official | 126:549ba18ddd81 | 533 | |
mbed_official | 126:549ba18ddd81 | 534 | /* Get the DAC_IT enable bit status */ |
mbed_official | 126:549ba18ddd81 | 535 | enablestatus = (DAC->CR & (DAC_IT << DAC_Channel)) ; |
mbed_official | 126:549ba18ddd81 | 536 | |
mbed_official | 126:549ba18ddd81 | 537 | /* Check the status of the specified DAC interrupt */ |
mbed_official | 126:549ba18ddd81 | 538 | if (((DAC->SR & (DAC_IT << DAC_Channel)) != (uint32_t)RESET) && enablestatus) |
mbed_official | 126:549ba18ddd81 | 539 | { |
mbed_official | 126:549ba18ddd81 | 540 | /* DAC_IT is set */ |
mbed_official | 126:549ba18ddd81 | 541 | bitstatus = SET; |
mbed_official | 126:549ba18ddd81 | 542 | } |
mbed_official | 126:549ba18ddd81 | 543 | else |
mbed_official | 126:549ba18ddd81 | 544 | { |
mbed_official | 126:549ba18ddd81 | 545 | /* DAC_IT is reset */ |
mbed_official | 126:549ba18ddd81 | 546 | bitstatus = RESET; |
mbed_official | 126:549ba18ddd81 | 547 | } |
mbed_official | 126:549ba18ddd81 | 548 | /* Return the DAC_IT status */ |
mbed_official | 126:549ba18ddd81 | 549 | return bitstatus; |
mbed_official | 126:549ba18ddd81 | 550 | } |
mbed_official | 126:549ba18ddd81 | 551 | |
mbed_official | 126:549ba18ddd81 | 552 | /** |
mbed_official | 126:549ba18ddd81 | 553 | * @brief Clears the DAC channelx's interrupt pending bits. |
mbed_official | 126:549ba18ddd81 | 554 | * @param DAC_Channel: the selected DAC channel. |
mbed_official | 126:549ba18ddd81 | 555 | * This parameter can be one of the following values: |
mbed_official | 126:549ba18ddd81 | 556 | * @arg DAC_Channel_1: DAC Channel1 selected |
mbed_official | 126:549ba18ddd81 | 557 | * @arg DAC_Channel_2: DAC Channel2 selected |
mbed_official | 126:549ba18ddd81 | 558 | * @param DAC_IT: specifies the DAC interrupt pending bit to clear. |
mbed_official | 126:549ba18ddd81 | 559 | * This parameter can be the following values: |
mbed_official | 126:549ba18ddd81 | 560 | * @arg DAC_IT_DMAUDR: DMA underrun interrupt mask |
mbed_official | 126:549ba18ddd81 | 561 | * @retval None |
mbed_official | 126:549ba18ddd81 | 562 | */ |
mbed_official | 126:549ba18ddd81 | 563 | void DAC_ClearITPendingBit(uint32_t DAC_Channel, uint32_t DAC_IT) |
mbed_official | 126:549ba18ddd81 | 564 | { |
mbed_official | 126:549ba18ddd81 | 565 | /* Check the parameters */ |
mbed_official | 126:549ba18ddd81 | 566 | assert_param(IS_DAC_CHANNEL(DAC_Channel)); |
mbed_official | 126:549ba18ddd81 | 567 | assert_param(IS_DAC_IT(DAC_IT)); |
mbed_official | 126:549ba18ddd81 | 568 | |
mbed_official | 126:549ba18ddd81 | 569 | /* Clear the selected DAC interrupt pending bits */ |
mbed_official | 126:549ba18ddd81 | 570 | DAC->SR = (DAC_IT << DAC_Channel); |
mbed_official | 126:549ba18ddd81 | 571 | } |
mbed_official | 126:549ba18ddd81 | 572 | #endif |
mbed_official | 126:549ba18ddd81 | 573 | |
mbed_official | 126:549ba18ddd81 | 574 | /** |
mbed_official | 126:549ba18ddd81 | 575 | * @} |
mbed_official | 126:549ba18ddd81 | 576 | */ |
mbed_official | 126:549ba18ddd81 | 577 | |
mbed_official | 126:549ba18ddd81 | 578 | /** |
mbed_official | 126:549ba18ddd81 | 579 | * @} |
mbed_official | 126:549ba18ddd81 | 580 | */ |
mbed_official | 126:549ba18ddd81 | 581 | |
mbed_official | 126:549ba18ddd81 | 582 | /** |
mbed_official | 126:549ba18ddd81 | 583 | * @} |
mbed_official | 126:549ba18ddd81 | 584 | */ |
mbed_official | 126:549ba18ddd81 | 585 | |
mbed_official | 126:549ba18ddd81 | 586 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |