Mouse code for the MacroRat
mbed-dev/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_dac_ex.c@18:6a4db94011d3, 2017-05-14 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sun May 14 23:18:57 2017 +0000
- Revision:
- 18:6a4db94011d3
Publishing again
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /** |
sahilmgandhi | 18:6a4db94011d3 | 2 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @file stm32f2xx_hal_dac_ex.c |
sahilmgandhi | 18:6a4db94011d3 | 4 | * @author MCD Application Team |
sahilmgandhi | 18:6a4db94011d3 | 5 | * @version V1.1.3 |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @date 29-June-2016 |
sahilmgandhi | 18:6a4db94011d3 | 7 | * @brief DAC HAL module driver. |
sahilmgandhi | 18:6a4db94011d3 | 8 | * This file provides firmware functions to manage the following |
sahilmgandhi | 18:6a4db94011d3 | 9 | * functionalities of DAC extension peripheral: |
sahilmgandhi | 18:6a4db94011d3 | 10 | * + Extended features functions |
sahilmgandhi | 18:6a4db94011d3 | 11 | * |
sahilmgandhi | 18:6a4db94011d3 | 12 | * |
sahilmgandhi | 18:6a4db94011d3 | 13 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 14 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 15 | ##### How to use this driver ##### |
sahilmgandhi | 18:6a4db94011d3 | 16 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 17 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 18 | (+) When Dual mode is enabled (i.e DAC Channel1 and Channel2 are used simultaneously) : |
sahilmgandhi | 18:6a4db94011d3 | 19 | Use HAL_DACEx_DualGetValue() to get digital data to be converted and use |
sahilmgandhi | 18:6a4db94011d3 | 20 | HAL_DACEx_DualSetValue() to set digital value to converted simultaneously in Channel 1 and Channel 2. |
sahilmgandhi | 18:6a4db94011d3 | 21 | (+) Use HAL_DACEx_TriangleWaveGenerate() to generate Triangle signal. |
sahilmgandhi | 18:6a4db94011d3 | 22 | (+) Use HAL_DACEx_NoiseWaveGenerate() to generate Noise signal. |
sahilmgandhi | 18:6a4db94011d3 | 23 | |
sahilmgandhi | 18:6a4db94011d3 | 24 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 25 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 26 | * @attention |
sahilmgandhi | 18:6a4db94011d3 | 27 | * |
sahilmgandhi | 18:6a4db94011d3 | 28 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
sahilmgandhi | 18:6a4db94011d3 | 29 | * |
sahilmgandhi | 18:6a4db94011d3 | 30 | * Redistribution and use in source and binary forms, with or without modification, |
sahilmgandhi | 18:6a4db94011d3 | 31 | * are permitted provided that the following conditions are met: |
sahilmgandhi | 18:6a4db94011d3 | 32 | * 1. Redistributions of source code must retain the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 33 | * this list of conditions and the following disclaimer. |
sahilmgandhi | 18:6a4db94011d3 | 34 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 35 | * this list of conditions and the following disclaimer in the documentation |
sahilmgandhi | 18:6a4db94011d3 | 36 | * and/or other materials provided with the distribution. |
sahilmgandhi | 18:6a4db94011d3 | 37 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
sahilmgandhi | 18:6a4db94011d3 | 38 | * may be used to endorse or promote products derived from this software |
sahilmgandhi | 18:6a4db94011d3 | 39 | * without specific prior written permission. |
sahilmgandhi | 18:6a4db94011d3 | 40 | * |
sahilmgandhi | 18:6a4db94011d3 | 41 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
sahilmgandhi | 18:6a4db94011d3 | 42 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
sahilmgandhi | 18:6a4db94011d3 | 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
sahilmgandhi | 18:6a4db94011d3 | 44 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
sahilmgandhi | 18:6a4db94011d3 | 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
sahilmgandhi | 18:6a4db94011d3 | 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
sahilmgandhi | 18:6a4db94011d3 | 47 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
sahilmgandhi | 18:6a4db94011d3 | 48 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
sahilmgandhi | 18:6a4db94011d3 | 49 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
sahilmgandhi | 18:6a4db94011d3 | 50 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
sahilmgandhi | 18:6a4db94011d3 | 51 | * |
sahilmgandhi | 18:6a4db94011d3 | 52 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 53 | */ |
sahilmgandhi | 18:6a4db94011d3 | 54 | |
sahilmgandhi | 18:6a4db94011d3 | 55 | |
sahilmgandhi | 18:6a4db94011d3 | 56 | /* Includes ------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 57 | #include "stm32f2xx_hal.h" |
sahilmgandhi | 18:6a4db94011d3 | 58 | |
sahilmgandhi | 18:6a4db94011d3 | 59 | /** @addtogroup STM32F2xx_HAL_Driver |
sahilmgandhi | 18:6a4db94011d3 | 60 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 61 | */ |
sahilmgandhi | 18:6a4db94011d3 | 62 | |
sahilmgandhi | 18:6a4db94011d3 | 63 | /** @defgroup DACEx DACEx |
sahilmgandhi | 18:6a4db94011d3 | 64 | * @brief DAC driver modules |
sahilmgandhi | 18:6a4db94011d3 | 65 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 66 | */ |
sahilmgandhi | 18:6a4db94011d3 | 67 | |
sahilmgandhi | 18:6a4db94011d3 | 68 | #ifdef HAL_DAC_MODULE_ENABLED |
sahilmgandhi | 18:6a4db94011d3 | 69 | |
sahilmgandhi | 18:6a4db94011d3 | 70 | /* Private typedef -----------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 71 | /* Private define ------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 72 | /* Private macro -------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 73 | /* Private variables ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 74 | /* Private function prototypes -----------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 75 | /* Private functions ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 76 | /* Exported functions --------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 77 | /** @defgroup DACEx_Exported_Functions DAC Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 78 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 79 | */ |
sahilmgandhi | 18:6a4db94011d3 | 80 | |
sahilmgandhi | 18:6a4db94011d3 | 81 | /** @defgroup DACEx_Exported_Functions_Group1 Extended features functions |
sahilmgandhi | 18:6a4db94011d3 | 82 | * @brief Extended features functions |
sahilmgandhi | 18:6a4db94011d3 | 83 | * |
sahilmgandhi | 18:6a4db94011d3 | 84 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 85 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 86 | ##### Extended features functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 87 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 88 | [..] This section provides functions allowing to: |
sahilmgandhi | 18:6a4db94011d3 | 89 | (+) Start conversion. |
sahilmgandhi | 18:6a4db94011d3 | 90 | (+) Stop conversion. |
sahilmgandhi | 18:6a4db94011d3 | 91 | (+) Start conversion and enable DMA transfer. |
sahilmgandhi | 18:6a4db94011d3 | 92 | (+) Stop conversion and disable DMA transfer. |
sahilmgandhi | 18:6a4db94011d3 | 93 | (+) Get result of conversion. |
sahilmgandhi | 18:6a4db94011d3 | 94 | (+) Get result of dual mode conversion. |
sahilmgandhi | 18:6a4db94011d3 | 95 | |
sahilmgandhi | 18:6a4db94011d3 | 96 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 97 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 98 | */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | /** |
sahilmgandhi | 18:6a4db94011d3 | 101 | * @brief Returns the last data output value of the selected DAC channel. |
sahilmgandhi | 18:6a4db94011d3 | 102 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 103 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 104 | * @retval The selected DAC channel data output value. |
sahilmgandhi | 18:6a4db94011d3 | 105 | */ |
sahilmgandhi | 18:6a4db94011d3 | 106 | uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac) |
sahilmgandhi | 18:6a4db94011d3 | 107 | { |
sahilmgandhi | 18:6a4db94011d3 | 108 | uint32_t tmp = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 109 | |
sahilmgandhi | 18:6a4db94011d3 | 110 | tmp |= hdac->Instance->DOR1; |
sahilmgandhi | 18:6a4db94011d3 | 111 | |
sahilmgandhi | 18:6a4db94011d3 | 112 | tmp |= hdac->Instance->DOR2 << 16U; |
sahilmgandhi | 18:6a4db94011d3 | 113 | |
sahilmgandhi | 18:6a4db94011d3 | 114 | /* Returns the DAC channel data output register value */ |
sahilmgandhi | 18:6a4db94011d3 | 115 | return tmp; |
sahilmgandhi | 18:6a4db94011d3 | 116 | } |
sahilmgandhi | 18:6a4db94011d3 | 117 | |
sahilmgandhi | 18:6a4db94011d3 | 118 | /** |
sahilmgandhi | 18:6a4db94011d3 | 119 | * @brief Enables or disables the selected DAC channel wave generation. |
sahilmgandhi | 18:6a4db94011d3 | 120 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 121 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 122 | * @param Channel: The selected DAC channel. |
sahilmgandhi | 18:6a4db94011d3 | 123 | * This parameter can be one of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 124 | * DAC_CHANNEL_1 / DAC_CHANNEL_2 |
sahilmgandhi | 18:6a4db94011d3 | 125 | * @param Amplitude: Select max triangle amplitude. |
sahilmgandhi | 18:6a4db94011d3 | 126 | * This parameter can be one of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 127 | * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1 |
sahilmgandhi | 18:6a4db94011d3 | 128 | * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3 |
sahilmgandhi | 18:6a4db94011d3 | 129 | * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7 |
sahilmgandhi | 18:6a4db94011d3 | 130 | * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15 |
sahilmgandhi | 18:6a4db94011d3 | 131 | * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31 |
sahilmgandhi | 18:6a4db94011d3 | 132 | * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63 |
sahilmgandhi | 18:6a4db94011d3 | 133 | * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127 |
sahilmgandhi | 18:6a4db94011d3 | 134 | * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255 |
sahilmgandhi | 18:6a4db94011d3 | 135 | * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511 |
sahilmgandhi | 18:6a4db94011d3 | 136 | * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023 |
sahilmgandhi | 18:6a4db94011d3 | 137 | * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047 |
sahilmgandhi | 18:6a4db94011d3 | 138 | * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095 |
sahilmgandhi | 18:6a4db94011d3 | 139 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 140 | */ |
sahilmgandhi | 18:6a4db94011d3 | 141 | HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) |
sahilmgandhi | 18:6a4db94011d3 | 142 | { |
sahilmgandhi | 18:6a4db94011d3 | 143 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 144 | assert_param(IS_DAC_CHANNEL(Channel)); |
sahilmgandhi | 18:6a4db94011d3 | 145 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); |
sahilmgandhi | 18:6a4db94011d3 | 146 | |
sahilmgandhi | 18:6a4db94011d3 | 147 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 148 | __HAL_LOCK(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 149 | |
sahilmgandhi | 18:6a4db94011d3 | 150 | /* Change DAC state */ |
sahilmgandhi | 18:6a4db94011d3 | 151 | hdac->State = HAL_DAC_STATE_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 152 | |
sahilmgandhi | 18:6a4db94011d3 | 153 | /* Enable the selected wave generation for the selected DAC channel */ |
sahilmgandhi | 18:6a4db94011d3 | 154 | MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_1 | Amplitude) << Channel); |
sahilmgandhi | 18:6a4db94011d3 | 155 | |
sahilmgandhi | 18:6a4db94011d3 | 156 | /* Change DAC state */ |
sahilmgandhi | 18:6a4db94011d3 | 157 | hdac->State = HAL_DAC_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 158 | |
sahilmgandhi | 18:6a4db94011d3 | 159 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 160 | __HAL_UNLOCK(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 161 | |
sahilmgandhi | 18:6a4db94011d3 | 162 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 163 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 164 | } |
sahilmgandhi | 18:6a4db94011d3 | 165 | |
sahilmgandhi | 18:6a4db94011d3 | 166 | /** |
sahilmgandhi | 18:6a4db94011d3 | 167 | * @brief Enables or disables the selected DAC channel wave generation. |
sahilmgandhi | 18:6a4db94011d3 | 168 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 169 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 170 | * @param Channel: The selected DAC channel. |
sahilmgandhi | 18:6a4db94011d3 | 171 | * This parameter can be one of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 172 | * DAC_CHANNEL_1 / DAC_CHANNEL_2 |
sahilmgandhi | 18:6a4db94011d3 | 173 | * @param Amplitude: Unmask DAC channel LFSR for noise wave generation. |
sahilmgandhi | 18:6a4db94011d3 | 174 | * This parameter can be one of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 175 | * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 176 | * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 177 | * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 178 | * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 179 | * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 180 | * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 181 | * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 182 | * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 183 | * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 184 | * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 185 | * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 186 | * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation |
sahilmgandhi | 18:6a4db94011d3 | 187 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 188 | */ |
sahilmgandhi | 18:6a4db94011d3 | 189 | HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude) |
sahilmgandhi | 18:6a4db94011d3 | 190 | { |
sahilmgandhi | 18:6a4db94011d3 | 191 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 192 | assert_param(IS_DAC_CHANNEL(Channel)); |
sahilmgandhi | 18:6a4db94011d3 | 193 | assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude)); |
sahilmgandhi | 18:6a4db94011d3 | 194 | |
sahilmgandhi | 18:6a4db94011d3 | 195 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 196 | __HAL_LOCK(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 197 | |
sahilmgandhi | 18:6a4db94011d3 | 198 | /* Change DAC state */ |
sahilmgandhi | 18:6a4db94011d3 | 199 | hdac->State = HAL_DAC_STATE_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 200 | |
sahilmgandhi | 18:6a4db94011d3 | 201 | /* Enable the selected wave generation for the selected DAC channel */ |
sahilmgandhi | 18:6a4db94011d3 | 202 | MODIFY_REG(hdac->Instance->CR, (DAC_CR_WAVE1 | DAC_CR_MAMP1) << Channel, (DAC_CR_WAVE1_0 | Amplitude) << Channel); |
sahilmgandhi | 18:6a4db94011d3 | 203 | |
sahilmgandhi | 18:6a4db94011d3 | 204 | /* Change DAC state */ |
sahilmgandhi | 18:6a4db94011d3 | 205 | hdac->State = HAL_DAC_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 206 | |
sahilmgandhi | 18:6a4db94011d3 | 207 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 208 | __HAL_UNLOCK(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 209 | |
sahilmgandhi | 18:6a4db94011d3 | 210 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 211 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 212 | } |
sahilmgandhi | 18:6a4db94011d3 | 213 | |
sahilmgandhi | 18:6a4db94011d3 | 214 | /** |
sahilmgandhi | 18:6a4db94011d3 | 215 | * @brief Set the specified data holding register value for dual DAC channel. |
sahilmgandhi | 18:6a4db94011d3 | 216 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 217 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 218 | * @param Alignment: Specifies the data alignment for dual channel DAC. |
sahilmgandhi | 18:6a4db94011d3 | 219 | * This parameter can be one of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 220 | * DAC_ALIGN_8B_R: 8bit right data alignment selected |
sahilmgandhi | 18:6a4db94011d3 | 221 | * DAC_ALIGN_12B_L: 12bit left data alignment selected |
sahilmgandhi | 18:6a4db94011d3 | 222 | * DAC_ALIGN_12B_R: 12bit right data alignment selected |
sahilmgandhi | 18:6a4db94011d3 | 223 | * @param Data1: Data for DAC Channel2 to be loaded in the selected data holding register. |
sahilmgandhi | 18:6a4db94011d3 | 224 | * @param Data2: Data for DAC Channel1 to be loaded in the selected data holding register. |
sahilmgandhi | 18:6a4db94011d3 | 225 | * @note In dual mode, a unique register access is required to write in both |
sahilmgandhi | 18:6a4db94011d3 | 226 | * DAC channels at the same time. |
sahilmgandhi | 18:6a4db94011d3 | 227 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 228 | */ |
sahilmgandhi | 18:6a4db94011d3 | 229 | HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2) |
sahilmgandhi | 18:6a4db94011d3 | 230 | { |
sahilmgandhi | 18:6a4db94011d3 | 231 | uint32_t data = 0U, tmp = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 232 | |
sahilmgandhi | 18:6a4db94011d3 | 233 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 234 | assert_param(IS_DAC_ALIGN(Alignment)); |
sahilmgandhi | 18:6a4db94011d3 | 235 | assert_param(IS_DAC_DATA(Data1)); |
sahilmgandhi | 18:6a4db94011d3 | 236 | assert_param(IS_DAC_DATA(Data2)); |
sahilmgandhi | 18:6a4db94011d3 | 237 | |
sahilmgandhi | 18:6a4db94011d3 | 238 | /* Calculate and set dual DAC data holding register value */ |
sahilmgandhi | 18:6a4db94011d3 | 239 | if (Alignment == DAC_ALIGN_8B_R) |
sahilmgandhi | 18:6a4db94011d3 | 240 | { |
sahilmgandhi | 18:6a4db94011d3 | 241 | data = ((uint32_t)Data2 << 8U) | Data1; |
sahilmgandhi | 18:6a4db94011d3 | 242 | } |
sahilmgandhi | 18:6a4db94011d3 | 243 | else |
sahilmgandhi | 18:6a4db94011d3 | 244 | { |
sahilmgandhi | 18:6a4db94011d3 | 245 | data = ((uint32_t)Data2 << 16U) | Data1; |
sahilmgandhi | 18:6a4db94011d3 | 246 | } |
sahilmgandhi | 18:6a4db94011d3 | 247 | |
sahilmgandhi | 18:6a4db94011d3 | 248 | tmp = (uint32_t)hdac->Instance; |
sahilmgandhi | 18:6a4db94011d3 | 249 | tmp += DAC_DHR12RD_ALIGNMENT(Alignment); |
sahilmgandhi | 18:6a4db94011d3 | 250 | |
sahilmgandhi | 18:6a4db94011d3 | 251 | /* Set the dual DAC selected data holding register */ |
sahilmgandhi | 18:6a4db94011d3 | 252 | *(__IO uint32_t *)tmp = data; |
sahilmgandhi | 18:6a4db94011d3 | 253 | |
sahilmgandhi | 18:6a4db94011d3 | 254 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 255 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 256 | } |
sahilmgandhi | 18:6a4db94011d3 | 257 | |
sahilmgandhi | 18:6a4db94011d3 | 258 | /** |
sahilmgandhi | 18:6a4db94011d3 | 259 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 260 | */ |
sahilmgandhi | 18:6a4db94011d3 | 261 | |
sahilmgandhi | 18:6a4db94011d3 | 262 | /** |
sahilmgandhi | 18:6a4db94011d3 | 263 | * @brief Conversion complete callback in non blocking mode for Channel2 |
sahilmgandhi | 18:6a4db94011d3 | 264 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 265 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 266 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 267 | */ |
sahilmgandhi | 18:6a4db94011d3 | 268 | __weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac) |
sahilmgandhi | 18:6a4db94011d3 | 269 | { |
sahilmgandhi | 18:6a4db94011d3 | 270 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 271 | UNUSED(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 272 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 273 | the HAL_DAC_ConvCpltCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 274 | */ |
sahilmgandhi | 18:6a4db94011d3 | 275 | } |
sahilmgandhi | 18:6a4db94011d3 | 276 | |
sahilmgandhi | 18:6a4db94011d3 | 277 | /** |
sahilmgandhi | 18:6a4db94011d3 | 278 | * @brief Conversion half DMA transfer callback in non blocking mode for Channel2 |
sahilmgandhi | 18:6a4db94011d3 | 279 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 280 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 281 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 282 | */ |
sahilmgandhi | 18:6a4db94011d3 | 283 | __weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac) |
sahilmgandhi | 18:6a4db94011d3 | 284 | { |
sahilmgandhi | 18:6a4db94011d3 | 285 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 286 | UNUSED(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 287 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 288 | the HAL_DAC_ConvHalfCpltCallbackCh2 could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 289 | */ |
sahilmgandhi | 18:6a4db94011d3 | 290 | } |
sahilmgandhi | 18:6a4db94011d3 | 291 | |
sahilmgandhi | 18:6a4db94011d3 | 292 | /** |
sahilmgandhi | 18:6a4db94011d3 | 293 | * @brief Error DAC callback for Channel2. |
sahilmgandhi | 18:6a4db94011d3 | 294 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 295 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 296 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 297 | */ |
sahilmgandhi | 18:6a4db94011d3 | 298 | __weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac) |
sahilmgandhi | 18:6a4db94011d3 | 299 | { |
sahilmgandhi | 18:6a4db94011d3 | 300 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 301 | UNUSED(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 302 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 303 | the HAL_DAC_ErrorCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 304 | */ |
sahilmgandhi | 18:6a4db94011d3 | 305 | } |
sahilmgandhi | 18:6a4db94011d3 | 306 | |
sahilmgandhi | 18:6a4db94011d3 | 307 | /** |
sahilmgandhi | 18:6a4db94011d3 | 308 | * @brief DMA underrun DAC callback for channel2. |
sahilmgandhi | 18:6a4db94011d3 | 309 | * @param hdac: pointer to a DAC_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 310 | * the configuration information for the specified DAC. |
sahilmgandhi | 18:6a4db94011d3 | 311 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 312 | */ |
sahilmgandhi | 18:6a4db94011d3 | 313 | __weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac) |
sahilmgandhi | 18:6a4db94011d3 | 314 | { |
sahilmgandhi | 18:6a4db94011d3 | 315 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 316 | UNUSED(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 317 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 318 | the HAL_DAC_DMAUnderrunCallbackCh2 could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 319 | */ |
sahilmgandhi | 18:6a4db94011d3 | 320 | } |
sahilmgandhi | 18:6a4db94011d3 | 321 | |
sahilmgandhi | 18:6a4db94011d3 | 322 | /** |
sahilmgandhi | 18:6a4db94011d3 | 323 | * @brief DMA conversion complete callback. |
sahilmgandhi | 18:6a4db94011d3 | 324 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 325 | * the configuration information for the specified DMA module. |
sahilmgandhi | 18:6a4db94011d3 | 326 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 327 | */ |
sahilmgandhi | 18:6a4db94011d3 | 328 | void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma) |
sahilmgandhi | 18:6a4db94011d3 | 329 | { |
sahilmgandhi | 18:6a4db94011d3 | 330 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
sahilmgandhi | 18:6a4db94011d3 | 331 | |
sahilmgandhi | 18:6a4db94011d3 | 332 | HAL_DACEx_ConvCpltCallbackCh2(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 333 | |
sahilmgandhi | 18:6a4db94011d3 | 334 | hdac->State= HAL_DAC_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 335 | } |
sahilmgandhi | 18:6a4db94011d3 | 336 | |
sahilmgandhi | 18:6a4db94011d3 | 337 | /** |
sahilmgandhi | 18:6a4db94011d3 | 338 | * @brief DMA half transfer complete callback. |
sahilmgandhi | 18:6a4db94011d3 | 339 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 340 | * the configuration information for the specified DMA module. |
sahilmgandhi | 18:6a4db94011d3 | 341 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 342 | */ |
sahilmgandhi | 18:6a4db94011d3 | 343 | void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma) |
sahilmgandhi | 18:6a4db94011d3 | 344 | { |
sahilmgandhi | 18:6a4db94011d3 | 345 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
sahilmgandhi | 18:6a4db94011d3 | 346 | /* Conversion complete callback */ |
sahilmgandhi | 18:6a4db94011d3 | 347 | HAL_DACEx_ConvHalfCpltCallbackCh2(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 348 | } |
sahilmgandhi | 18:6a4db94011d3 | 349 | |
sahilmgandhi | 18:6a4db94011d3 | 350 | /** |
sahilmgandhi | 18:6a4db94011d3 | 351 | * @brief DMA error callback |
sahilmgandhi | 18:6a4db94011d3 | 352 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 353 | * the configuration information for the specified DMA module. |
sahilmgandhi | 18:6a4db94011d3 | 354 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 355 | */ |
sahilmgandhi | 18:6a4db94011d3 | 356 | void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma) |
sahilmgandhi | 18:6a4db94011d3 | 357 | { |
sahilmgandhi | 18:6a4db94011d3 | 358 | DAC_HandleTypeDef* hdac = ( DAC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
sahilmgandhi | 18:6a4db94011d3 | 359 | |
sahilmgandhi | 18:6a4db94011d3 | 360 | /* Set DAC error code to DMA error */ |
sahilmgandhi | 18:6a4db94011d3 | 361 | hdac->ErrorCode |= HAL_DAC_ERROR_DMA; |
sahilmgandhi | 18:6a4db94011d3 | 362 | |
sahilmgandhi | 18:6a4db94011d3 | 363 | HAL_DACEx_ErrorCallbackCh2(hdac); |
sahilmgandhi | 18:6a4db94011d3 | 364 | |
sahilmgandhi | 18:6a4db94011d3 | 365 | hdac->State= HAL_DAC_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 366 | } |
sahilmgandhi | 18:6a4db94011d3 | 367 | |
sahilmgandhi | 18:6a4db94011d3 | 368 | /** |
sahilmgandhi | 18:6a4db94011d3 | 369 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 370 | */ |
sahilmgandhi | 18:6a4db94011d3 | 371 | |
sahilmgandhi | 18:6a4db94011d3 | 372 | #endif /* HAL_DAC_MODULE_ENABLED */ |
sahilmgandhi | 18:6a4db94011d3 | 373 | |
sahilmgandhi | 18:6a4db94011d3 | 374 | /** |
sahilmgandhi | 18:6a4db94011d3 | 375 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 376 | */ |
sahilmgandhi | 18:6a4db94011d3 | 377 | |
sahilmgandhi | 18:6a4db94011d3 | 378 | /** |
sahilmgandhi | 18:6a4db94011d3 | 379 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 380 | */ |
sahilmgandhi | 18:6a4db94011d3 | 381 | |
sahilmgandhi | 18:6a4db94011d3 | 382 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |