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