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