001
targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_ll_dac.c@0:13413ea9a877, 2022-06-12 (annotated)
- Committer:
- ganlikun
- Date:
- Sun Jun 12 14:02:44 2022 +0000
- Revision:
- 0:13413ea9a877
00
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ganlikun | 0:13413ea9a877 | 1 | /** |
ganlikun | 0:13413ea9a877 | 2 | ****************************************************************************** |
ganlikun | 0:13413ea9a877 | 3 | * @file stm32f4xx_ll_dac.c |
ganlikun | 0:13413ea9a877 | 4 | * @author MCD Application Team |
ganlikun | 0:13413ea9a877 | 5 | * @version V1.7.1 |
ganlikun | 0:13413ea9a877 | 6 | * @date 14-April-2017 |
ganlikun | 0:13413ea9a877 | 7 | * @brief DAC LL module driver |
ganlikun | 0:13413ea9a877 | 8 | ****************************************************************************** |
ganlikun | 0:13413ea9a877 | 9 | * @attention |
ganlikun | 0:13413ea9a877 | 10 | * |
ganlikun | 0:13413ea9a877 | 11 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
ganlikun | 0:13413ea9a877 | 12 | * |
ganlikun | 0:13413ea9a877 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
ganlikun | 0:13413ea9a877 | 14 | * are permitted provided that the following conditions are met: |
ganlikun | 0:13413ea9a877 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
ganlikun | 0:13413ea9a877 | 16 | * this list of conditions and the following disclaimer. |
ganlikun | 0:13413ea9a877 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
ganlikun | 0:13413ea9a877 | 18 | * this list of conditions and the following disclaimer in the documentation |
ganlikun | 0:13413ea9a877 | 19 | * and/or other materials provided with the distribution. |
ganlikun | 0:13413ea9a877 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
ganlikun | 0:13413ea9a877 | 21 | * may be used to endorse or promote products derived from this software |
ganlikun | 0:13413ea9a877 | 22 | * without specific prior written permission. |
ganlikun | 0:13413ea9a877 | 23 | * |
ganlikun | 0:13413ea9a877 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
ganlikun | 0:13413ea9a877 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
ganlikun | 0:13413ea9a877 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
ganlikun | 0:13413ea9a877 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
ganlikun | 0:13413ea9a877 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
ganlikun | 0:13413ea9a877 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
ganlikun | 0:13413ea9a877 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
ganlikun | 0:13413ea9a877 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
ganlikun | 0:13413ea9a877 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
ganlikun | 0:13413ea9a877 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
ganlikun | 0:13413ea9a877 | 34 | * |
ganlikun | 0:13413ea9a877 | 35 | ****************************************************************************** |
ganlikun | 0:13413ea9a877 | 36 | */ |
ganlikun | 0:13413ea9a877 | 37 | #if defined(USE_FULL_LL_DRIVER) |
ganlikun | 0:13413ea9a877 | 38 | |
ganlikun | 0:13413ea9a877 | 39 | /* Includes ------------------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 40 | #include "stm32f4xx_ll_dac.h" |
ganlikun | 0:13413ea9a877 | 41 | #include "stm32f4xx_ll_bus.h" |
ganlikun | 0:13413ea9a877 | 42 | |
ganlikun | 0:13413ea9a877 | 43 | #ifdef USE_FULL_ASSERT |
ganlikun | 0:13413ea9a877 | 44 | #include "stm32_assert.h" |
ganlikun | 0:13413ea9a877 | 45 | #else |
ganlikun | 0:13413ea9a877 | 46 | #define assert_param(expr) ((void)0U) |
ganlikun | 0:13413ea9a877 | 47 | #endif |
ganlikun | 0:13413ea9a877 | 48 | |
ganlikun | 0:13413ea9a877 | 49 | /** @addtogroup STM32F4xx_LL_Driver |
ganlikun | 0:13413ea9a877 | 50 | * @{ |
ganlikun | 0:13413ea9a877 | 51 | */ |
ganlikun | 0:13413ea9a877 | 52 | |
ganlikun | 0:13413ea9a877 | 53 | #if defined(DAC) |
ganlikun | 0:13413ea9a877 | 54 | |
ganlikun | 0:13413ea9a877 | 55 | /** @addtogroup DAC_LL DAC |
ganlikun | 0:13413ea9a877 | 56 | * @{ |
ganlikun | 0:13413ea9a877 | 57 | */ |
ganlikun | 0:13413ea9a877 | 58 | |
ganlikun | 0:13413ea9a877 | 59 | /* Private types -------------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 60 | /* Private variables ---------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 61 | /* Private constants ---------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 62 | /* Private macros ------------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 63 | |
ganlikun | 0:13413ea9a877 | 64 | /** @addtogroup DAC_LL_Private_Macros |
ganlikun | 0:13413ea9a877 | 65 | * @{ |
ganlikun | 0:13413ea9a877 | 66 | */ |
ganlikun | 0:13413ea9a877 | 67 | |
ganlikun | 0:13413ea9a877 | 68 | #if defined(DAC_CHANNEL2_SUPPORT) |
ganlikun | 0:13413ea9a877 | 69 | #define IS_LL_DAC_CHANNEL(__DACX__, __DAC_CHANNEL__) \ |
ganlikun | 0:13413ea9a877 | 70 | ( \ |
ganlikun | 0:13413ea9a877 | 71 | ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_1) \ |
ganlikun | 0:13413ea9a877 | 72 | || ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_2) \ |
ganlikun | 0:13413ea9a877 | 73 | ) |
ganlikun | 0:13413ea9a877 | 74 | #else |
ganlikun | 0:13413ea9a877 | 75 | #define IS_LL_DAC_CHANNEL(__DACX__, __DAC_CHANNEL__) \ |
ganlikun | 0:13413ea9a877 | 76 | ( \ |
ganlikun | 0:13413ea9a877 | 77 | ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_1) \ |
ganlikun | 0:13413ea9a877 | 78 | ) |
ganlikun | 0:13413ea9a877 | 79 | #endif /* DAC_CHANNEL2_SUPPORT */ |
ganlikun | 0:13413ea9a877 | 80 | |
ganlikun | 0:13413ea9a877 | 81 | #define IS_LL_DAC_TRIGGER_SOURCE(__TRIGGER_SOURCE__) \ |
ganlikun | 0:13413ea9a877 | 82 | ( ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_SOFTWARE) \ |
ganlikun | 0:13413ea9a877 | 83 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM2_TRGO) \ |
ganlikun | 0:13413ea9a877 | 84 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM4_TRGO) \ |
ganlikun | 0:13413ea9a877 | 85 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM5_TRGO) \ |
ganlikun | 0:13413ea9a877 | 86 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM6_TRGO) \ |
ganlikun | 0:13413ea9a877 | 87 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM7_TRGO) \ |
ganlikun | 0:13413ea9a877 | 88 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM8_TRGO) \ |
ganlikun | 0:13413ea9a877 | 89 | || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_EXTI_LINE9) \ |
ganlikun | 0:13413ea9a877 | 90 | ) |
ganlikun | 0:13413ea9a877 | 91 | |
ganlikun | 0:13413ea9a877 | 92 | #define IS_LL_DAC_WAVE_AUTO_GENER_MODE(__WAVE_AUTO_GENERATION_MODE__) \ |
ganlikun | 0:13413ea9a877 | 93 | ( ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NONE) \ |
ganlikun | 0:13413ea9a877 | 94 | || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NOISE) \ |
ganlikun | 0:13413ea9a877 | 95 | || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE) \ |
ganlikun | 0:13413ea9a877 | 96 | ) |
ganlikun | 0:13413ea9a877 | 97 | |
ganlikun | 0:13413ea9a877 | 98 | #define IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(__WAVE_AUTO_GENERATION_CONFIG__) \ |
ganlikun | 0:13413ea9a877 | 99 | ( ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BIT0) \ |
ganlikun | 0:13413ea9a877 | 100 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS1_0) \ |
ganlikun | 0:13413ea9a877 | 101 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS2_0) \ |
ganlikun | 0:13413ea9a877 | 102 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS3_0) \ |
ganlikun | 0:13413ea9a877 | 103 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS4_0) \ |
ganlikun | 0:13413ea9a877 | 104 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS5_0) \ |
ganlikun | 0:13413ea9a877 | 105 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS6_0) \ |
ganlikun | 0:13413ea9a877 | 106 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS7_0) \ |
ganlikun | 0:13413ea9a877 | 107 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS8_0) \ |
ganlikun | 0:13413ea9a877 | 108 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS9_0) \ |
ganlikun | 0:13413ea9a877 | 109 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS10_0) \ |
ganlikun | 0:13413ea9a877 | 110 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS11_0) \ |
ganlikun | 0:13413ea9a877 | 111 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1) \ |
ganlikun | 0:13413ea9a877 | 112 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_3) \ |
ganlikun | 0:13413ea9a877 | 113 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_7) \ |
ganlikun | 0:13413ea9a877 | 114 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_15) \ |
ganlikun | 0:13413ea9a877 | 115 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_31) \ |
ganlikun | 0:13413ea9a877 | 116 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_63) \ |
ganlikun | 0:13413ea9a877 | 117 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_127) \ |
ganlikun | 0:13413ea9a877 | 118 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_255) \ |
ganlikun | 0:13413ea9a877 | 119 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_511) \ |
ganlikun | 0:13413ea9a877 | 120 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1023) \ |
ganlikun | 0:13413ea9a877 | 121 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_2047) \ |
ganlikun | 0:13413ea9a877 | 122 | || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_4095) \ |
ganlikun | 0:13413ea9a877 | 123 | ) |
ganlikun | 0:13413ea9a877 | 124 | |
ganlikun | 0:13413ea9a877 | 125 | #define IS_LL_DAC_OUTPUT_BUFFER(__OUTPUT_BUFFER__) \ |
ganlikun | 0:13413ea9a877 | 126 | ( ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_ENABLE) \ |
ganlikun | 0:13413ea9a877 | 127 | || ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_DISABLE) \ |
ganlikun | 0:13413ea9a877 | 128 | ) |
ganlikun | 0:13413ea9a877 | 129 | |
ganlikun | 0:13413ea9a877 | 130 | /** |
ganlikun | 0:13413ea9a877 | 131 | * @} |
ganlikun | 0:13413ea9a877 | 132 | */ |
ganlikun | 0:13413ea9a877 | 133 | |
ganlikun | 0:13413ea9a877 | 134 | |
ganlikun | 0:13413ea9a877 | 135 | /* Private function prototypes -----------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 136 | |
ganlikun | 0:13413ea9a877 | 137 | /* Exported functions --------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 138 | /** @addtogroup DAC_LL_Exported_Functions |
ganlikun | 0:13413ea9a877 | 139 | * @{ |
ganlikun | 0:13413ea9a877 | 140 | */ |
ganlikun | 0:13413ea9a877 | 141 | |
ganlikun | 0:13413ea9a877 | 142 | /** @addtogroup DAC_LL_EF_Init |
ganlikun | 0:13413ea9a877 | 143 | * @{ |
ganlikun | 0:13413ea9a877 | 144 | */ |
ganlikun | 0:13413ea9a877 | 145 | |
ganlikun | 0:13413ea9a877 | 146 | /** |
ganlikun | 0:13413ea9a877 | 147 | * @brief De-initialize registers of the selected DAC instance |
ganlikun | 0:13413ea9a877 | 148 | * to their default reset values. |
ganlikun | 0:13413ea9a877 | 149 | * @param DACx DAC instance |
ganlikun | 0:13413ea9a877 | 150 | * @retval An ErrorStatus enumeration value: |
ganlikun | 0:13413ea9a877 | 151 | * - SUCCESS: DAC registers are de-initialized |
ganlikun | 0:13413ea9a877 | 152 | * - ERROR: not applicable |
ganlikun | 0:13413ea9a877 | 153 | */ |
ganlikun | 0:13413ea9a877 | 154 | ErrorStatus LL_DAC_DeInit(DAC_TypeDef *DACx) |
ganlikun | 0:13413ea9a877 | 155 | { |
ganlikun | 0:13413ea9a877 | 156 | /* Check the parameters */ |
ganlikun | 0:13413ea9a877 | 157 | assert_param(IS_DAC_ALL_INSTANCE(DACx)); |
ganlikun | 0:13413ea9a877 | 158 | |
ganlikun | 0:13413ea9a877 | 159 | /* Force reset of DAC1 clock */ |
ganlikun | 0:13413ea9a877 | 160 | LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_DAC1); |
ganlikun | 0:13413ea9a877 | 161 | |
ganlikun | 0:13413ea9a877 | 162 | /* Release reset of DAC1 clock */ |
ganlikun | 0:13413ea9a877 | 163 | LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_DAC1); |
ganlikun | 0:13413ea9a877 | 164 | return SUCCESS; |
ganlikun | 0:13413ea9a877 | 165 | } |
ganlikun | 0:13413ea9a877 | 166 | |
ganlikun | 0:13413ea9a877 | 167 | /** |
ganlikun | 0:13413ea9a877 | 168 | * @brief Initialize some features of DAC instance. |
ganlikun | 0:13413ea9a877 | 169 | * @note The setting of these parameters by function @ref LL_DAC_Init() |
ganlikun | 0:13413ea9a877 | 170 | * is conditioned to DAC state: |
ganlikun | 0:13413ea9a877 | 171 | * DAC instance must be disabled. |
ganlikun | 0:13413ea9a877 | 172 | * @param DACx DAC instance |
ganlikun | 0:13413ea9a877 | 173 | * @param DAC_Channel This parameter can be one of the following values: |
ganlikun | 0:13413ea9a877 | 174 | * @arg @ref LL_DAC_CHANNEL_1 |
ganlikun | 0:13413ea9a877 | 175 | * @arg @ref LL_DAC_CHANNEL_2 (1) |
ganlikun | 0:13413ea9a877 | 176 | * |
ganlikun | 0:13413ea9a877 | 177 | * (1) On this STM32 serie, parameter not available on all devices. |
ganlikun | 0:13413ea9a877 | 178 | * Refer to device datasheet for channels availability. |
ganlikun | 0:13413ea9a877 | 179 | * @param DAC_InitStruct Pointer to a @ref LL_DAC_InitTypeDef structure |
ganlikun | 0:13413ea9a877 | 180 | * @retval An ErrorStatus enumeration value: |
ganlikun | 0:13413ea9a877 | 181 | * - SUCCESS: DAC registers are initialized |
ganlikun | 0:13413ea9a877 | 182 | * - ERROR: DAC registers are not initialized |
ganlikun | 0:13413ea9a877 | 183 | */ |
ganlikun | 0:13413ea9a877 | 184 | ErrorStatus LL_DAC_Init(DAC_TypeDef *DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef *DAC_InitStruct) |
ganlikun | 0:13413ea9a877 | 185 | { |
ganlikun | 0:13413ea9a877 | 186 | ErrorStatus status = SUCCESS; |
ganlikun | 0:13413ea9a877 | 187 | |
ganlikun | 0:13413ea9a877 | 188 | /* Check the parameters */ |
ganlikun | 0:13413ea9a877 | 189 | assert_param(IS_DAC_ALL_INSTANCE(DACx)); |
ganlikun | 0:13413ea9a877 | 190 | assert_param(IS_LL_DAC_CHANNEL(DACx, DAC_Channel)); |
ganlikun | 0:13413ea9a877 | 191 | assert_param(IS_LL_DAC_TRIGGER_SOURCE(DAC_InitStruct->TriggerSource)); |
ganlikun | 0:13413ea9a877 | 192 | assert_param(IS_LL_DAC_OUTPUT_BUFFER(DAC_InitStruct->OutputBuffer)); |
ganlikun | 0:13413ea9a877 | 193 | assert_param(IS_LL_DAC_WAVE_AUTO_GENER_MODE(DAC_InitStruct->WaveAutoGeneration)); |
ganlikun | 0:13413ea9a877 | 194 | if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE) |
ganlikun | 0:13413ea9a877 | 195 | { |
ganlikun | 0:13413ea9a877 | 196 | assert_param(IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(DAC_InitStruct->WaveAutoGenerationConfig)); |
ganlikun | 0:13413ea9a877 | 197 | } |
ganlikun | 0:13413ea9a877 | 198 | |
ganlikun | 0:13413ea9a877 | 199 | /* Note: Hardware constraint (refer to description of this function) */ |
ganlikun | 0:13413ea9a877 | 200 | /* DAC instance must be disabled. */ |
ganlikun | 0:13413ea9a877 | 201 | if(LL_DAC_IsEnabled(DACx, DAC_Channel) == 0U) |
ganlikun | 0:13413ea9a877 | 202 | { |
ganlikun | 0:13413ea9a877 | 203 | /* Configuration of DAC channel: */ |
ganlikun | 0:13413ea9a877 | 204 | /* - TriggerSource */ |
ganlikun | 0:13413ea9a877 | 205 | /* - WaveAutoGeneration */ |
ganlikun | 0:13413ea9a877 | 206 | /* - OutputBuffer */ |
ganlikun | 0:13413ea9a877 | 207 | if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE) |
ganlikun | 0:13413ea9a877 | 208 | { |
ganlikun | 0:13413ea9a877 | 209 | MODIFY_REG(DACx->CR, |
ganlikun | 0:13413ea9a877 | 210 | ( DAC_CR_TSEL1 |
ganlikun | 0:13413ea9a877 | 211 | | DAC_CR_WAVE1 |
ganlikun | 0:13413ea9a877 | 212 | | DAC_CR_MAMP1 |
ganlikun | 0:13413ea9a877 | 213 | | DAC_CR_BOFF1 |
ganlikun | 0:13413ea9a877 | 214 | ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) |
ganlikun | 0:13413ea9a877 | 215 | , |
ganlikun | 0:13413ea9a877 | 216 | ( DAC_InitStruct->TriggerSource |
ganlikun | 0:13413ea9a877 | 217 | | DAC_InitStruct->WaveAutoGeneration |
ganlikun | 0:13413ea9a877 | 218 | | DAC_InitStruct->WaveAutoGenerationConfig |
ganlikun | 0:13413ea9a877 | 219 | | DAC_InitStruct->OutputBuffer |
ganlikun | 0:13413ea9a877 | 220 | ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) |
ganlikun | 0:13413ea9a877 | 221 | ); |
ganlikun | 0:13413ea9a877 | 222 | } |
ganlikun | 0:13413ea9a877 | 223 | else |
ganlikun | 0:13413ea9a877 | 224 | { |
ganlikun | 0:13413ea9a877 | 225 | MODIFY_REG(DACx->CR, |
ganlikun | 0:13413ea9a877 | 226 | ( DAC_CR_TSEL1 |
ganlikun | 0:13413ea9a877 | 227 | | DAC_CR_WAVE1 |
ganlikun | 0:13413ea9a877 | 228 | | DAC_CR_BOFF1 |
ganlikun | 0:13413ea9a877 | 229 | ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) |
ganlikun | 0:13413ea9a877 | 230 | , |
ganlikun | 0:13413ea9a877 | 231 | ( DAC_InitStruct->TriggerSource |
ganlikun | 0:13413ea9a877 | 232 | | LL_DAC_WAVE_AUTO_GENERATION_NONE |
ganlikun | 0:13413ea9a877 | 233 | | DAC_InitStruct->OutputBuffer |
ganlikun | 0:13413ea9a877 | 234 | ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK) |
ganlikun | 0:13413ea9a877 | 235 | ); |
ganlikun | 0:13413ea9a877 | 236 | } |
ganlikun | 0:13413ea9a877 | 237 | } |
ganlikun | 0:13413ea9a877 | 238 | else |
ganlikun | 0:13413ea9a877 | 239 | { |
ganlikun | 0:13413ea9a877 | 240 | /* Initialization error: DAC instance is not disabled. */ |
ganlikun | 0:13413ea9a877 | 241 | status = ERROR; |
ganlikun | 0:13413ea9a877 | 242 | } |
ganlikun | 0:13413ea9a877 | 243 | return status; |
ganlikun | 0:13413ea9a877 | 244 | } |
ganlikun | 0:13413ea9a877 | 245 | |
ganlikun | 0:13413ea9a877 | 246 | /** |
ganlikun | 0:13413ea9a877 | 247 | * @brief Set each @ref LL_DAC_InitTypeDef field to default value. |
ganlikun | 0:13413ea9a877 | 248 | * @param DAC_InitStruct pointer to a @ref LL_DAC_InitTypeDef structure |
ganlikun | 0:13413ea9a877 | 249 | * whose fields will be set to default values. |
ganlikun | 0:13413ea9a877 | 250 | * @retval None |
ganlikun | 0:13413ea9a877 | 251 | */ |
ganlikun | 0:13413ea9a877 | 252 | void LL_DAC_StructInit(LL_DAC_InitTypeDef *DAC_InitStruct) |
ganlikun | 0:13413ea9a877 | 253 | { |
ganlikun | 0:13413ea9a877 | 254 | /* Set DAC_InitStruct fields to default values */ |
ganlikun | 0:13413ea9a877 | 255 | DAC_InitStruct->TriggerSource = LL_DAC_TRIG_SOFTWARE; |
ganlikun | 0:13413ea9a877 | 256 | DAC_InitStruct->WaveAutoGeneration = LL_DAC_WAVE_AUTO_GENERATION_NONE; |
ganlikun | 0:13413ea9a877 | 257 | /* Note: Parameter discarded if wave auto generation is disabled, */ |
ganlikun | 0:13413ea9a877 | 258 | /* set anyway to its default value. */ |
ganlikun | 0:13413ea9a877 | 259 | DAC_InitStruct->WaveAutoGenerationConfig = LL_DAC_NOISE_LFSR_UNMASK_BIT0; |
ganlikun | 0:13413ea9a877 | 260 | DAC_InitStruct->OutputBuffer = LL_DAC_OUTPUT_BUFFER_ENABLE; |
ganlikun | 0:13413ea9a877 | 261 | } |
ganlikun | 0:13413ea9a877 | 262 | |
ganlikun | 0:13413ea9a877 | 263 | /** |
ganlikun | 0:13413ea9a877 | 264 | * @} |
ganlikun | 0:13413ea9a877 | 265 | */ |
ganlikun | 0:13413ea9a877 | 266 | |
ganlikun | 0:13413ea9a877 | 267 | /** |
ganlikun | 0:13413ea9a877 | 268 | * @} |
ganlikun | 0:13413ea9a877 | 269 | */ |
ganlikun | 0:13413ea9a877 | 270 | |
ganlikun | 0:13413ea9a877 | 271 | /** |
ganlikun | 0:13413ea9a877 | 272 | * @} |
ganlikun | 0:13413ea9a877 | 273 | */ |
ganlikun | 0:13413ea9a877 | 274 | |
ganlikun | 0:13413ea9a877 | 275 | #endif /* DAC */ |
ganlikun | 0:13413ea9a877 | 276 | |
ganlikun | 0:13413ea9a877 | 277 | /** |
ganlikun | 0:13413ea9a877 | 278 | * @} |
ganlikun | 0:13413ea9a877 | 279 | */ |
ganlikun | 0:13413ea9a877 | 280 | |
ganlikun | 0:13413ea9a877 | 281 | #endif /* USE_FULL_LL_DRIVER */ |
ganlikun | 0:13413ea9a877 | 282 | |
ganlikun | 0:13413ea9a877 | 283 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
ganlikun | 0:13413ea9a877 | 284 |