1 /** 2 ****************************************************************************** 3 * @file stm32f1xx_hal_dac_ex.h 4 * @author MCD Application Team 5 * @brief Header file of DAC HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© Copyright (c) 2016 STMicroelectronics. 10 * All rights reserved.</center></h2> 11 * 12 * This software component is licensed by ST under BSD 3-Clause license, 13 * the "License"; You may not use this file except in compliance with the 14 * License. You may obtain a copy of the License at: 15 * opensource.org/licenses/BSD-3-Clause 16 * 17 ****************************************************************************** 18 */ 19 20 /* Define to prevent recursive inclusion -------------------------------------*/ 21 #ifndef STM32F1xx_HAL_DAC_EX_H 22 #define STM32F1xx_HAL_DAC_EX_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /** @addtogroup STM32F1xx_HAL_Driver 29 * @{ 30 */ 31 32 /* Includes ------------------------------------------------------------------*/ 33 #include "stm32f1xx_hal_def.h" 34 35 #if defined(DAC) 36 37 /** @addtogroup DACEx 38 * @{ 39 */ 40 41 /* Exported types ------------------------------------------------------------*/ 42 43 /** 44 * @brief HAL State structures definition 45 */ 46 47 /* Exported constants --------------------------------------------------------*/ 48 49 /** @defgroup DACEx_Exported_Constants DACEx Exported Constants 50 * @{ 51 */ 52 53 /** @defgroup DACEx_lfsrunmask_triangleamplitude DACEx lfsrunmask triangle amplitude 54 * @{ 55 */ 56 #define DAC_LFSRUNMASK_BIT0 0x00000000UL /*!< Unmask DAC channel LFSR bit0 for noise wave generation */ 57 #define DAC_LFSRUNMASK_BITS1_0 ( DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */ 58 #define DAC_LFSRUNMASK_BITS2_0 ( DAC_CR_MAMP1_1 ) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */ 59 #define DAC_LFSRUNMASK_BITS3_0 ( DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */ 60 #define DAC_LFSRUNMASK_BITS4_0 ( DAC_CR_MAMP1_2 ) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */ 61 #define DAC_LFSRUNMASK_BITS5_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */ 62 #define DAC_LFSRUNMASK_BITS6_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 ) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */ 63 #define DAC_LFSRUNMASK_BITS7_0 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */ 64 #define DAC_LFSRUNMASK_BITS8_0 (DAC_CR_MAMP1_3 ) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */ 65 #define DAC_LFSRUNMASK_BITS9_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */ 66 #define DAC_LFSRUNMASK_BITS10_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 ) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */ 67 #define DAC_LFSRUNMASK_BITS11_0 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */ 68 #define DAC_TRIANGLEAMPLITUDE_1 0x00000000UL /*!< Select max triangle amplitude of 1 */ 69 #define DAC_TRIANGLEAMPLITUDE_3 ( DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 3 */ 70 #define DAC_TRIANGLEAMPLITUDE_7 ( DAC_CR_MAMP1_1 ) /*!< Select max triangle amplitude of 7 */ 71 #define DAC_TRIANGLEAMPLITUDE_15 ( DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 15 */ 72 #define DAC_TRIANGLEAMPLITUDE_31 ( DAC_CR_MAMP1_2 ) /*!< Select max triangle amplitude of 31 */ 73 #define DAC_TRIANGLEAMPLITUDE_63 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 63 */ 74 #define DAC_TRIANGLEAMPLITUDE_127 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 ) /*!< Select max triangle amplitude of 127 */ 75 #define DAC_TRIANGLEAMPLITUDE_255 ( DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 255 */ 76 #define DAC_TRIANGLEAMPLITUDE_511 (DAC_CR_MAMP1_3 ) /*!< Select max triangle amplitude of 511 */ 77 #define DAC_TRIANGLEAMPLITUDE_1023 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 1023 */ 78 #define DAC_TRIANGLEAMPLITUDE_2047 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 ) /*!< Select max triangle amplitude of 2047 */ 79 #define DAC_TRIANGLEAMPLITUDE_4095 (DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 4095 */ 80 81 /** 82 * @} 83 */ 84 85 /** @defgroup DACEx_trigger_selection DAC trigger selection 86 * @{ 87 */ 88 #define DAC_TRIGGER_NONE 0x00000000U /*!< Conversion is automatic once the DAC1_DHRxxxx register 89 has been loaded, and not by external trigger */ 90 #define DAC_TRIGGER_T6_TRGO ((uint32_t) DAC_CR_TEN1) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */ 91 #define DAC_TRIGGER_T7_TRGO ((uint32_t)( DAC_CR_TSEL1_1 | DAC_CR_TEN1)) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */ 92 #define DAC_TRIGGER_T2_TRGO ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TEN1)) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */ 93 #define DAC_TRIGGER_T4_TRGO ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM4 TRGO selected as external conversion trigger for DAC channel */ 94 #define DAC_TRIGGER_EXT_IT9 ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TEN1)) /*!< EXTI Line9 event selected as external conversion trigger for DAC channel */ 95 #define DAC_TRIGGER_SOFTWARE ((uint32_t)(DAC_CR_TSEL1 | DAC_CR_TEN1)) /*!< Conversion started by software trigger for DAC channel */ 96 97 #if defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) 98 /* For STM32F10x high-density and XL-density devices: TIM8 */ 99 #define DAC_TRIGGER_T8_TRGO ((uint32_t) DAC_CR_TSEL1_0 | DAC_CR_TEN1) /*!< TIM8 TRGO selected as external conversion trigger for DAC channel */ 100 #endif /* STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ 101 102 #if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F105xC) || defined (STM32F107xC) 103 /* For STM32F10x connectivity line devices and STM32F100x devices: TIM3 */ 104 #define DAC_TRIGGER_T3_TRGO ((uint32_t) DAC_CR_TSEL1_0 | DAC_CR_TEN1) /*!< TIM3 TRGO selected as external conversion trigger for DAC channel */ 105 #endif /* STM32F100xB || STM32F100xE || STM32F105xC || STM32F107xC */ 106 107 /* Availability of trigger from TIM5 and TIM15: */ 108 /* - For STM32F10x value line devices STM32F100xB: */ 109 /* trigger from TIM15 is available, TIM5 not available. */ 110 /* - For STM32F10x value line devices STM32F100xE: */ 111 /* trigger from TIM15 and TIM5 are both available, */ 112 /* selection depends on remap (with TIM5 as default configuration). */ 113 /* - Other STM32F1 devices: */ 114 /* trigger from TIM5 is available, TIM15 not available. */ 115 #if defined (STM32F100xB) 116 #define DAC_TRIGGER_T15_TRGO ((uint32_t)( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM15 TRGO selected as external conversion trigger for DAC channel */ 117 #else 118 119 #define DAC_TRIGGER_T5_TRGO ((uint32_t)( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM5 TRGO selected as external conversion trigger for DAC channel */ 120 121 #if defined (STM32F100xE) 122 /*!< DAC trigger availability depending on STM32F1 devices: 123 For STM32F100x high-density value line devices, the TIM15 TRGO event can be selected 124 as replacement of TIM5 TRGO if the MISC_REMAP bit in the AFIO_MAPR2 register is set. 125 Refer to macro "__HAL_AFIO_REMAP_MISC_ENABLE()/__HAL_AFIO_REMAP_MISC_DISABLE()". 126 Otherwise, TIM5 TRGO is used and TIM15 TRGO is not used (default case). 127 For more details please refer to the AFIO section. */ 128 #define DAC_TRIGGER_T15_TRGO DAC_TRIGGER_T5_TRGO 129 #endif /* STM32F100xE */ 130 131 #endif /* STM32F100xB */ 132 /** 133 * @} 134 */ 135 136 /** 137 * @} 138 */ 139 140 /* Exported macro ------------------------------------------------------------*/ 141 142 143 /* Private macro -------------------------------------------------------------*/ 144 145 /** @defgroup DACEx_Private_Macros DACEx Private Macros 146 * @{ 147 */ 148 #if defined (STM32F101xE) || defined (STM32F101xG) || defined (STM32F103xE) || defined (STM32F103xG) 149 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \ 150 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \ 151 ((TRIGGER) == DAC_TRIGGER_T8_TRGO) || \ 152 ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \ 153 ((TRIGGER) == DAC_TRIGGER_T5_TRGO) || \ 154 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \ 155 ((TRIGGER) == DAC_TRIGGER_T4_TRGO) || \ 156 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \ 157 ((TRIGGER) == DAC_TRIGGER_SOFTWARE)) 158 #endif /* STM32F101xE || STM32F101xG || STM32F103xE || STM32F103xG */ 159 #if defined (STM32F100xE) || defined (STM32F105xC) || defined (STM32F107xC) 160 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \ 161 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \ 162 ((TRIGGER) == DAC_TRIGGER_T3_TRGO) || \ 163 ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \ 164 ((TRIGGER) == DAC_TRIGGER_T5_TRGO) || \ 165 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \ 166 ((TRIGGER) == DAC_TRIGGER_T4_TRGO) || \ 167 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \ 168 ((TRIGGER) == DAC_TRIGGER_SOFTWARE)) 169 #endif /* STM32F100xE || STM32F105xC || STM32F107xC */ 170 #if defined (STM32F100xB) 171 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \ 172 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \ 173 ((TRIGGER) == DAC_TRIGGER_T3_TRGO) || \ 174 ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \ 175 ((TRIGGER) == DAC_TRIGGER_T15_TRGO) || \ 176 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \ 177 ((TRIGGER) == DAC_TRIGGER_T4_TRGO) || \ 178 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \ 179 ((TRIGGER) == DAC_TRIGGER_SOFTWARE)) 180 #endif /* STM32F100xB */ 181 182 #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUNMASK_BIT0) || \ 183 ((VALUE) == DAC_LFSRUNMASK_BITS1_0) || \ 184 ((VALUE) == DAC_LFSRUNMASK_BITS2_0) || \ 185 ((VALUE) == DAC_LFSRUNMASK_BITS3_0) || \ 186 ((VALUE) == DAC_LFSRUNMASK_BITS4_0) || \ 187 ((VALUE) == DAC_LFSRUNMASK_BITS5_0) || \ 188 ((VALUE) == DAC_LFSRUNMASK_BITS6_0) || \ 189 ((VALUE) == DAC_LFSRUNMASK_BITS7_0) || \ 190 ((VALUE) == DAC_LFSRUNMASK_BITS8_0) || \ 191 ((VALUE) == DAC_LFSRUNMASK_BITS9_0) || \ 192 ((VALUE) == DAC_LFSRUNMASK_BITS10_0) || \ 193 ((VALUE) == DAC_LFSRUNMASK_BITS11_0) || \ 194 ((VALUE) == DAC_TRIANGLEAMPLITUDE_1) || \ 195 ((VALUE) == DAC_TRIANGLEAMPLITUDE_3) || \ 196 ((VALUE) == DAC_TRIANGLEAMPLITUDE_7) || \ 197 ((VALUE) == DAC_TRIANGLEAMPLITUDE_15) || \ 198 ((VALUE) == DAC_TRIANGLEAMPLITUDE_31) || \ 199 ((VALUE) == DAC_TRIANGLEAMPLITUDE_63) || \ 200 ((VALUE) == DAC_TRIANGLEAMPLITUDE_127) || \ 201 ((VALUE) == DAC_TRIANGLEAMPLITUDE_255) || \ 202 ((VALUE) == DAC_TRIANGLEAMPLITUDE_511) || \ 203 ((VALUE) == DAC_TRIANGLEAMPLITUDE_1023) || \ 204 ((VALUE) == DAC_TRIANGLEAMPLITUDE_2047) || \ 205 ((VALUE) == DAC_TRIANGLEAMPLITUDE_4095)) 206 /** 207 * @} 208 */ 209 210 /* Exported functions --------------------------------------------------------*/ 211 /* Extended features functions ***********************************************/ 212 213 /** @addtogroup DACEx_Exported_Functions 214 * @{ 215 */ 216 217 /** @addtogroup DACEx_Exported_Functions_Group2 218 * @{ 219 */ 220 /* IO operation functions *****************************************************/ 221 222 HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude); 223 HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude); 224 225 HAL_StatusTypeDef HAL_DACEx_DualStart(DAC_HandleTypeDef *hdac); 226 HAL_StatusTypeDef HAL_DACEx_DualStop(DAC_HandleTypeDef *hdac); 227 HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef *hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2); 228 uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef *hdac); 229 230 void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac); 231 void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac); 232 void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac); 233 void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac); 234 235 236 /** 237 * @} 238 */ 239 240 /** 241 * @} 242 */ 243 244 /** 245 * @} 246 */ 247 248 /** @addtogroup DACEx_Private_Functions 249 * @{ 250 */ 251 252 /* DAC_DMAConvCpltCh2 / DAC_DMAErrorCh2 / DAC_DMAHalfConvCpltCh2 */ 253 /* are called by HAL_DAC_Start_DMA */ 254 void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma); 255 void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma); 256 void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma); 257 258 /** 259 * @} 260 */ 261 262 /** 263 * @} 264 */ 265 266 #endif /* DAC */ 267 268 /** 269 * @} 270 */ 271 272 #ifdef __cplusplus 273 } 274 #endif 275 276 #endif /* STM32F1xx_HAL_DAC_EX_H */ 277 278 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 279