1 /** 2 ****************************************************************************** 3 * @file tae32f53xx_ll_dac.h 4 * @author MCD Application Team 5 * @brief Header file for DAC Module 6 * 7 ****************************************************************************** 8 * @attention 9 * 10 * <h2><center>© Copyright (c) 2020 Tai-Action. 11 * All rights reserved.</center></h2> 12 * 13 * This software is licensed by Tai-Action under BSD 3-Clause license, 14 * the "License"; You may not use this file except in compliance with the 15 * License. You may obtain a copy of the License at: 16 * opensource.org/licenses/BSD-3-Clause 17 * 18 ****************************************************************************** 19 */ 20 21 /* Define to prevent recursive inclusion -------------------------------------*/ 22 #ifndef _TAE32F53XX_LL_DAC_H_ 23 #define _TAE32F53XX_LL_DAC_H_ 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif /* __cplusplus */ 28 29 /* Includes ------------------------------------------------------------------*/ 30 #include "tae32f53xx_ll_def.h" 31 32 33 /** @addtogroup TAE32F53xx_LL_Driver 34 * @{ 35 */ 36 37 /** @addtogroup DAC_LL 38 * @{ 39 */ 40 41 42 /* Exported constants --------------------------------------------------------*/ 43 /** @defgroup DAC_LL_Exported_Constants DAC LL Exported Constants 44 * @brief DAC LL Exported Constants 45 * @{ 46 */ 47 48 /** @defgroup DAC_Channel_selection DAC Channel selection 49 * @brief DAC Channel selection 50 * @{ 51 */ 52 #define DAC_CHANNEL_0 (0x00000001U) /*!< DAC Channel 0 */ 53 #define DAC_CHANNEL_1 (0x00000002U) /*!< DAC Channel 1 */ 54 #define DAC_CHANNEL_2 (0x00000004U) /*!< DAC Channel 2 */ 55 #define DAC_CHANNEL_3 (0x00000008U) /*!< DAC Channel 3 */ 56 #define DAC_CHANNEL_ALL (DAC_CHANNEL_0 | DAC_CHANNEL_1 | DAC_CHANNEL_2 | DAC_CHANNEL_3 ) 57 /** 58 * @} 59 */ 60 61 /** @defgroup DAC_Interrupt_definition DAC Interrupt definition 62 * @brief DAC Interrupt definition 63 * @{ 64 */ 65 #define DAC_IT_DIE DAC_CR_DIE /*!< DAC_CHx DONE interrupt */ 66 #define DAC_IT_DBIE DAC_CR_DBIE /*!< DAC_CHx DONEB interrupt */ 67 /** 68 * @} 69 */ 70 71 /** @defgroup DAC_Flag_definition DAC Flag Definition 72 * @{ 73 */ 74 #define DAC_FLAG_D0IF DAC_ISR_D0IF /*!< DAC Channel0 DONE pending flag */ 75 #define DAC_FLAG_D1IF DAC_ISR_D1IF /*!< DAC Channel1 DONE pending flag */ 76 #define DAC_FLAG_D2IF DAC_ISR_D2IF /*!< DAC Channel2 DONE pending flag */ 77 #define DAC_FLAG_D3IF DAC_ISR_D3IF /*!< DAC Channel0 DONE pending flag */ 78 #define DAC_FLAG_DB0IF DAC_ISR_DB0IF /*!< DAC Channel0 DONEB pending flag */ 79 #define DAC_FLAG_DB1IF DAC_ISR_DB1IF /*!< DAC Channel1 DONEB pending flag */ 80 #define DAC_FLAG_DB2IF DAC_ISR_DB2IF /*!< DAC Channel2 DONEB pending flag */ 81 #define DAC_FLAG_DB3IF DAC_ISR_DB3IF /*!< DAC Channel3 DONEB pending flag */ 82 #define DAC_FLAG_ALLIF (DAC_FLAG_D0IF | DAC_FLAG_D1IF | \ 83 DAC_FLAG_D2IF | DAC_FLAG_D3IF | \ 84 DAC_FLAG_DB0IF | DAC_FLAG_DB1IF | \ 85 DAC_FLAG_DB2IF | DAC_FLAG_DB3IF ) 86 /** 87 * @} 88 */ 89 90 /** 91 * @} 92 */ 93 94 95 /* Exported macro ------------------------------------------------------------*/ 96 /** @defgroup DAC_LL_Exported_Macros DAC LL Exported Macros 97 * @brief DAC LL Exported Macros 98 * @{ 99 */ 100 101 /** 102 * @brief Enable DAC Channel 103 * @param __INSTANCE__ DAC peripheral 104 * @param __CHN_NB__ Specifies DAC Channel 105 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 106 * @return None 107 */ 108 #define __LL_DAC_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_PEN) 109 110 /** 111 * @brief Disable DAC Channel 112 * @param __INSTANCE__ DAC peripheral 113 * @param __CHN_NB__ Specifies DAC Channel 114 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 115 * @return None 116 */ 117 #define __LL_DAC_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_PEN) 118 119 120 /** 121 * @brief Enable DAC Channel Output to IO feature 122 * @param __INSTANCE__ DAC peripheral 123 * @param __CHN_NB__ Specifies DAC Channel 124 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 125 * @return None 126 */ 127 #define __LL_DAC_OUTPUT_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_OEN) 128 129 /** 130 * @brief Disable DAC Channel Output to IO feature 131 * @param __INSTANCE__ DAC peripheral 132 * @param __CHN_NB__ Specifies DAC Channel 133 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 134 * @return None 135 */ 136 #define __LL_DAC_OUTPUT_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_OEN) 137 138 /** 139 * @brief Enable the specified DAC Channel Interrupts 140 * @param __INSTANCE__ DAC peripheral 141 * @param __CHN_NB__ Specifies DAC Channel 142 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 143 * @param __INTERRUPT__ specifies the DAC Channel interrupt source to enable. 144 * This parameter can be any combination of @ref DAC_Interrupt_definition: 145 * @arg DAC_IT_DIE : DAC_CHx DONE interrupt 146 * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt 147 * @return None 148 */ 149 #define __LL_DAC_IT_ENABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], __INTERRUPT__) 150 151 /** 152 * @brief Disable the specified DAC Channel Interrupts 153 * @param __INSTANCE__ DAC peripheral 154 * @param __CHN_NB__ Specifies DAC Channel 155 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 156 * @param __INTERRUPT__ specifies the DAC Channel interrupt source to disable. 157 * This parameter can be any combination of @ref DAC_Interrupt_definition: 158 * @arg DAC_IT_DIE : DAC_CHx DONE interrupt 159 * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt 160 * @return None 161 */ 162 #define __LL_DAC_IT_DISABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], __INTERRUPT__) 163 164 /** 165 * @brief Check whether the specified DAC Channel interrupt source is set or not. 166 * @param __INSTANCE__ DAC peripheral 167 * @param __CHN_NB__ Specifies DAC Channel 168 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 169 * @param __INTERRUPT__ specifies the DAC Channel interrupt source to check. 170 * This parameter can be ONE of @ref DAC_Interrupt_definition: 171 * @arg DAC_IT_DIE : DAC_CHx DONE interrupt 172 * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt 173 * @return None 174 */ 175 #define __LL_DAC_IT_CHECK_SOURCE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) \ 176 ((READ_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) 177 178 /** 179 * @brief Check whether the specified pending flag is SET or not. 180 * @param __INSTANCE__ DAC peripheral. 181 * @param __FLAG__ specifies the DAC pending flag to check. 182 * This parameter can be ONE of the following values where x can be a value of 183 * 0, 1 ... (DAC_CHN_NB - 1): 184 * @arg DAC_FLAG_DxIF : DAC_CHx DONE interrupt pending flag 185 * @arg DAC_FLAG_DBxIF : DAC_CHx DONEB interrupt pending flag 186 * @return The new state of __FLAG__ (SET or RESET). 187 */ 188 #define __LL_DAC_PENDING_FLAG_GET(__INSTANCE__, __FLAG__) \ 189 ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) 190 191 /** 192 * @brief Clear the specified pending flags 193 * @param __INSTANCE__ DAC peripheral. 194 * @param __FLAG__ specifies the DAC pending flag to clear. 195 * This parameter can be any combination of the following values where x can be a value of 196 * 0, 1 ... (DAC_CHN_NB - 1): 197 * @arg DAC_FLAG_DxIF : DAC_CHx DONE interrupt pending flag 198 * @arg DAC_FLAG_DBxIF : DAC_CHx DONEB interrupt pending flag 199 * @arg DAC_FLAG_ALLIF : DAC All interrupt pending flags 200 * @return None 201 */ 202 #define __LL_DAC_PENDING_FLAG_CLEAR(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__)) 203 204 205 /** 206 * @brief Set the data for DAC channel conversion on runtime 207 * @param __INSTANCE__ DAC peripheral. 208 * @param __CHN_NB__ Specifies DAC Channel 209 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 210 * @param __DATA__ Data to be loaded 211 * @return None 212 */ 213 #define __LL_DAC_SET_VALUE(__INSTANCE__, __CHN_NB__, __DATA__) WRITE_REG((__INSTANCE__)->WDR[__CHN_NB__], __DATA__) 214 215 216 /** 217 * @brief Get the DAC channel conversion value on runtime 218 * @param __INSTANCE__ DAC peripheral. 219 * @param __CHN_NB__ Specifies DAC Channel 220 * This parameter can be a value of 0 to (DAC_CHN_NB - 1) 221 * @return Conversion value 222 */ 223 #define __LL_DAC_GET_VALUE(__INSTANCE__, __CHN_NB__) READ_REG((__INSTANCE__)->RDR[__CHN_NB__]) 224 225 /** 226 * @} 227 */ 228 229 230 /* Exported types ------------------------------------------------------------*/ 231 /** @defgroup DAC_LL_Exported_Types DAC LL Exported Types 232 * @brief DAC LL Exported Types 233 * @{ 234 */ 235 236 /** 237 * @brief DAC Channel Output 238 */ 239 typedef enum { 240 DAC_CHANNEL_OUTPUT_DISABLE = 0x00000000U, /*!< DAC Channel Disable */ 241 DAC_CHANNEL_OUTPUT_ENABLE = DAC_CR_OEN, /*!< DAC Channel Enable */ 242 } DAC_OutputEnETypedef; 243 244 /** 245 * @brief DAC Channel Interrupt Done 246 */ 247 typedef enum { 248 DAC_CHANNEL_DONE_IT_DISABLE = 0x00000000U, /*!< DAC Channel Done Interrupt Disable */ 249 DAC_CHANNEL_DONE_IT_ENABLE = DAC_CR_DIE, /*!< DAC Channel Done Interrupt Enable */ 250 } DAC_DoneITEnETypedef; 251 252 /** 253 * @brief DAC Channel Interrupt DoneB 254 */ 255 typedef enum { 256 DAC_CHANNEL_DONEB_IT_DISABLE = 0x00000000U, /*!< DAC Channel DoneB Interrupt Disable */ 257 DAC_CHANNEL_DONEB_IT_ENABLE = DAC_CR_DBIE, /*!< DAC Channel DoneB Interrupt Enable */ 258 } DAC_DoneBITEnETypedef; 259 260 /** 261 * @brief DAC Sawtooth Polarity 262 */ 263 typedef enum { 264 DAC_SAWTOOTH_POLARITY_DEC = 0x00000000U, /*!< Sawtooth wave generation, polarity is decrement */ 265 DAC_SAWTOOTH_POLARITY_INC = DAC_CR_STDIR, /*!< Sawtooth wave generation, polarity is increment */ 266 } DAC_SawthoothPolETypedef; 267 268 /** 269 * @brief DAC Triangle Initial Direction 270 */ 271 typedef enum { 272 DAC_TRIANGLE_INITIALDIRECTION_DEC = 0x00000000U, /*!< Triangle wave generation, initial direction is decrement */ 273 DAC_TRIANGLE_INITIALDIRECTION_INC = DAC_CR_TGDIR, /*!< Triangle wave generation, initial direction is increment */ 274 } DAC_TriangleInitDirETypedef; 275 276 /** 277 * @brief DAC Triangle Amplitude 278 */ 279 typedef enum { 280 DAC_TRIANGLE_AMPLITUDE_1 = 0x00000000U, /*!< Amplitude of 1 */ 281 DAC_TRIANGLE_AMPLITUDE_3 = DAC_CR_TGAMP_0, /*!< Amplitude of 3 */ 282 DAC_TRIANGLE_AMPLITUDE_7 = DAC_CR_TGAMP_1, /*!< Amplitude of 7 */ 283 DAC_TRIANGLE_AMPLITUDE_15 = DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 15 */ 284 DAC_TRIANGLE_AMPLITUDE_31 = DAC_CR_TGAMP_2, /*!< Amplitude of 31 */ 285 DAC_TRIANGLE_AMPLITUDE_63 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_0, /*!< Amplitude of 63 */ 286 DAC_TRIANGLE_AMPLITUDE_127 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_1, /*!< Amplitude of 127 */ 287 DAC_TRIANGLE_AMPLITUDE_255 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 255 */ 288 DAC_TRIANGLE_AMPLITUDE_511 = DAC_CR_TGAMP_3, /*!< Amplitude of 511 */ 289 DAC_TRIANGLE_AMPLITUDE_1023 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_0, /*!< Amplitude of 1023 */ 290 DAC_TRIANGLE_AMPLITUDE_2047 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_1, /*!< Amplitude of 2047 */ 291 DAC_TRIANGLE_AMPLITUDE_4095 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 4095 */ 292 } DAC_TrangleAmplETypedef; 293 294 /** 295 * @brief DAC Trigger Selection 296 */ 297 typedef enum { 298 DAC_TRIGGER_SOFTWARE = 0x0U, /*!< Software trigger by setting bit[s] in DAC_SWTR register */ 299 DAC_TRIGGER_TMR0_TRGO = 0x1U, /*!< TRGO signal exported from TMR0 (source from Update Event) */ 300 DAC_TRIGGER_TMR1_TRGO = 0x2U, /*!< TRGO signal exported from TMR1 (source from Update Event) */ 301 DAC_TRIGGER_TMR2_TRGO = 0x3U, /*!< TRGO signal exported from TMR2 (source from Update Event) */ 302 DAC_TRIGGER_TMR3_TRGO = 0x3U, /*!< TRGO signal exported from TMR3 (source from Update Event) */ 303 DAC_TRIGGER_TMR4_TRGO = 0x4U, /*!< TRGO signal exported from TMR4 (source from Update Event) */ 304 DAC_TRIGGER_TMR5_TRGO = 0x5U, /*!< TRGO signal exported from TMR5 (source from Update Event) */ 305 DAC_TRIGGER_TMR6_TRGO = 0x6U, /*!< TRGO signal exported from TMR6 (source from Update Event) */ 306 DAC_TRIGGER_TMR7_TRGO = 0x7U, /*!< TRGO signal exported from TMR7 (source from Update Event) */ 307 DAC_TRIGGER_HRPWM_DAC_RESET_TRG0 = 0x8U, /*!< DAC Reset Trigger event from HRPWM Slave timer0 */ 308 DAC_TRIGGER_HRPWM_DAC_RESET_TRG1 = 0x9U, /*!< DAC Reset Trigger event from HRPWM Slave timer1 */ 309 DAC_TRIGGER_HRPWM_DAC_RESET_TRG2 = 0xAU, /*!< DAC Reset Trigger event from HRPWM Slave timer2 */ 310 DAC_TRIGGER_HRPWM_DAC_RESET_TRG3 = 0xBU, /*!< DAC Reset Trigger event from HRPWM Slave timer3 */ 311 DAC_TRIGGER_HRPWM_DAC_RESET_TRG4 = 0xCU, /*!< DAC Reset Trigger event from HRPWM Slave timer4 */ 312 DAC_TRIGGER_HRPWM_DAC_RESET_TRG5 = 0xDU, /*!< DAC Reset Trigger event from HRPWM Slave timer5 */ 313 DAC_TRIGGER_HRPWM_DAC_STEP_TRG0 = 0x8U, /*!< DAC Step Trigger event from HRPWM Slave timer0 */ 314 DAC_TRIGGER_HRPWM_DAC_STEP_TRG1 = 0x9U, /*!< DAC Step Trigger event from HRPWM Slave timer1 */ 315 DAC_TRIGGER_HRPWM_DAC_STEP_TRG2 = 0xAU, /*!< DAC Step Trigger event from HRPWM Slave timer2 */ 316 DAC_TRIGGER_HRPWM_DAC_STEP_TRG3 = 0xBU, /*!< DAC Step Trigger event from HRPWM Slave timer3 */ 317 DAC_TRIGGER_HRPWM_DAC_STEP_TRG4 = 0xCU, /*!< DAC Step Trigger event from HRPWM Slave timer4 */ 318 DAC_TRIGGER_HRPWM_DAC_STEP_TRG5 = 0xDU, /*!< DAC Step Trigger event from HRPWM Slave timer5 */ 319 DAC_TRIGGER_HRPWM_ADC_TRG0 = 0xEU, /*!< DAC0 Step Trigger event from HRPWM Common ADDA Trigger 0 */ 320 DAC_TRIGGER_HRPWM_ADC_TRG1 = 0xEU, /*!< DAC1 Step Trigger event from HRPWM Common ADDA Trigger 1 */ 321 DAC_TRIGGER_HRPWM_ADC_TRG2 = 0xEU, /*!< DAC2 Step Trigger event from HRPWM Common ADDA Trigger 2 */ 322 DAC_TRIGGER_HRPWM_ADC_TRG3 = 0xEU, /*!< DAC3 Step Trigger event from HRPWM Common ADDA Trigger 3 */ 323 DAC_TRIGGER_HRPWM_ADC_TRG4 = 0xEU, /*!< DAC0 Reset Trigger event from HRPWM Common ADDA Trigger 4 */ 324 DAC_TRIGGER_HRPWM_ADC_TRG5 = 0xEU, /*!< DAC1 Reset Trigger event from HRPWM Common ADDA Trigger 5 */ 325 DAC_TRIGGER_HRPWM_ADC_TRG6 = 0xEU, /*!< DAC2 Reset Trigger event from HRPWM Common ADDA Trigger 6 */ 326 DAC_TRIGGER_HRPWM_ADC_TRG7 = 0xEU, /*!< DAC3 Reset Trigger event from HRPWM Common ADDA Trigger 7 */ 327 DAC_TRIGGER_EXTERNAL_INPUT_IO1 = 0xFU, /*!< DAC External Trigger from IO1, please see SPEC from more details */ 328 DAC_TRIGGER_EXTERNAL_INPUT_IO2 = 0xFU, /*!< DAC External Trigger from IO2, please see SPEC from more details */ 329 } DAC_TriggerSrcETypedef; 330 331 332 /** 333 * @brief DAC Channel Configuration structure definition 334 */ 335 typedef struct __DAC_ChannelConfTypeDef { 336 DAC_OutputEnETypedef Output; /*!< Specifies the DAC conversion output to IO or not. */ 337 338 uint32_t DoneIntPending; /*!< Specifies the interrupt for DONE pending flag enable or disable 339 This parameter can be a value of @ref DAC_Channel_Interrupt_Done 340 Note: Sawtooth Reset or Tranigle Step convert done will trigger the DONE flag */ 341 342 uint32_t DoneBIntPending; /*!< Specifies the interrupt for DONEB pending flag enable or disable 343 This parameter can be a value of @ref DAC_Channel_Interrupt_DoneB 344 Note: Sawtooth Step convert done will trigger the DONEB flag */ 345 } DAC_ChannelConfTypeDef; 346 347 /** 348 * @brief DAC Sawtooth Wave Configuration structure definition 349 */ 350 typedef struct __DAC_SawtoothConfTypeDef { 351 uint16_t ResetData; /*!< Specifies the Sawtooth wave Reset value. 352 This parameter can be a number in range from 0 to DAC full range 4095(0xFFF) */ 353 354 uint16_t StepData; /*!< Specifies the Sawtooth wave step value. 355 12.4 bit format, unsigned: 12 bits exponent / 4 bits mantissa 356 Step value step is 1/16 = 0.0625 357 Step value range is 0.0000 to 4095.9375 (0xFFF.F) */ 358 359 DAC_TriggerSrcETypedef ResetTrigger; /*!< Specifies the external trigger source for the Sawtooth wave reset trigger 360 Please see the SPEC Document for more details about the trigger selections */ 361 DAC_TriggerSrcETypedef StepTrigger; /*!< Specifies the external trigger source for the Sawtooth wave step trigger 362 Please see the SPEC Document for more details about the trigger selections */ 363 DAC_SawthoothPolETypedef Polarity; /*!< Specifies the Sawtooth wave step polarity.*/ 364 } DAC_SawtoothConfTypeDef; 365 366 /** 367 * @brief DAC Triangle Wave Configuration structure definition 368 */ 369 typedef struct __DAC_TriangleConfTypeDef { 370 DAC_TriangleInitDirETypedef InitialDirection; /*!< Specifies the Triangle wave initial step direction. */ 371 DAC_TrangleAmplETypedef Amplitude; /*!< Specifies max triangle amplitude. */ 372 DAC_TriggerSrcETypedef StepTrigger; /*!< Specifies the external trigger source for the Triangle wave step trigger 373 Please see the SPEC Document for more details about the trigger selections */ 374 } DAC_TriangleConfTypeDef; 375 376 /** 377 * @} 378 */ 379 380 381 /* Exported functions --------------------------------------------------------*/ 382 /** @addtogroup DAC_LL_Exported_Functions 383 * @{ 384 */ 385 386 /** @addtogroup DAC_LL_Exported_Functions_Group1 387 * @{ 388 */ 389 LL_StatusETypeDef LL_DAC_Init(DAC_TypeDef *Instance); 390 LL_StatusETypeDef LL_DAC_DeInit(DAC_TypeDef *Instance); 391 void LL_DAC_MspInit(DAC_TypeDef *Instance); 392 void LL_DAC_MspDeInit(DAC_TypeDef *Instance); 393 /** 394 * @} 395 */ 396 397 398 /** @addtogroup DAC_LL_Exported_Functions_Group2 399 * @{ 400 */ 401 LL_StatusETypeDef LL_DAC_ChannelConfig(DAC_TypeDef *Instance, uint32_t Channel, DAC_ChannelConfTypeDef *sConfig); 402 LL_StatusETypeDef LL_DAC_SawtoothWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_SawtoothConfTypeDef *sConfig); 403 LL_StatusETypeDef LL_DAC_TriangleWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_TriangleConfTypeDef *sConfig); 404 /** 405 * @} 406 */ 407 408 409 /** @addtogroup DAC_LL_Exported_Functions_Group3 410 * @{ 411 */ 412 LL_StatusETypeDef LL_DAC_Start(DAC_TypeDef *Instance, uint32_t Channel); 413 LL_StatusETypeDef LL_DAC_Stop(DAC_TypeDef *Instance, uint32_t Channel); 414 LL_StatusETypeDef LL_DAC_SetValue(DAC_TypeDef *Instance, uint32_t Channel, uint16_t Data); 415 uint16_t LL_DAC_GetValue(DAC_TypeDef *Instance, uint32_t Channel); 416 LL_StatusETypeDef LL_DAC_SawtoothWaveDataStep(DAC_TypeDef *Instance, uint32_t Channel); 417 LL_StatusETypeDef LL_DAC_SawtoothWaveDataReset(DAC_TypeDef *Instance, uint32_t Channel); 418 LL_StatusETypeDef LL_DAC_TriangleWaveStep(DAC_TypeDef *Instance, uint32_t Channel); 419 /** 420 * @} 421 */ 422 423 424 /** @addtogroup DAC_LL_Exported_Functions_Interrupt 425 * @{ 426 */ 427 void LL_DAC_IRQHandler(DAC_TypeDef *Instance); 428 void LL_DAC_ConvDoneCallback(DAC_TypeDef *Instance, uint32_t Channel); 429 void LL_DAC_ConvDoneBCallback(DAC_TypeDef *Instance, uint32_t Channel); 430 /** 431 * @} 432 */ 433 434 /** 435 * @} 436 */ 437 438 439 /* Private constants ---------------------------------------------------------*/ 440 /* Private macros ------------------------------------------------------------*/ 441 /** @defgroup DAC_LL_Private_Macros DAC LL Private Macros 442 * @brief DAC LL Private Macros 443 * @{ 444 */ 445 446 /** 447 * @brief Judge is DAC channel number or not 448 * @param CHN_NB channel number to judge 449 * @retval 0 isn't DAC channel number 450 * @retval 1 is DAC channel number 451 */ 452 #define IS_DAC_NUMBER(CHN_NB) ((CHN_NB) < DAC_CHN_NB) 453 454 /** 455 * @brief Judge is DAC channel or not 456 * @param CHN channel to judge 457 * @retval 0 isn't DAC channel 458 * @retval 1 is DAC channel 459 */ 460 #define IS_DAC_CHANNEL(CHN) (((CHN) == DAC_CHANNEL_0) || \ 461 ((CHN) == DAC_CHANNEL_1) || \ 462 ((CHN) == DAC_CHANNEL_2) || \ 463 ((CHN) == DAC_CHANNEL_3)) 464 465 /** 466 * @brief Judge is DAC channels mask or not 467 * @param CHN channels mask to judge 468 * @retval 0 isn't DAC channels mask 469 * @retval 1 is DAC channels mask 470 */ 471 #define IS_DAC_CHANNELS_MASK(CHN) ((((CHN) & DAC_CHANNEL_ALL) != 0x00UL) && \ 472 (((CHN) & ~(DAC_CHANNEL_ALL)) == 0x00UL)) 473 474 /** 475 * @brief Judge is DAC channel output select or not 476 * @param OUTPUT output select 477 * @retval 0 isn't DAC channel output select 478 * @retval 1 is DAC channel output select 479 */ 480 #define IS_DAC_CHANNEL_OUTPUT_SEL(OUTPUT) (((OUTPUT) == DAC_CHANNEL_OUTPUT_DISABLE) || \ 481 ((OUTPUT) == DAC_CHANNEL_OUTPUT_ENABLE)) 482 483 /** 484 * @brief Judge is DAC channel done interrupt pending config or not 485 * @param PENDING pending config to judge 486 * @retval 0 isn't DAC channel done interrupt pending config 487 * @retval 1 is DAC channel done interrupt pending config 488 */ 489 #define IS_DAC_CHANNEL_DONE_IT_PENDING_CFG(PENDING) (((PENDING) == DAC_CHANNEL_DONE_IT_DISABLE) || \ 490 ((PENDING) == DAC_CHANNEL_DONE_IT_ENABLE)) 491 492 /** 493 * @brief Judge is DAC channel doneB interrupt pending config or not 494 * @param PENDING pending config to judge 495 * @retval 0 isn't DAC channel doneB interrupt pending config 496 * @retval 1 is DAC channel doneB interrupt pending config 497 */ 498 #define IS_DAC_CHANNEL_DONEB_IT_PENDING_CFG(PENDING) (((PENDING) == DAC_CHANNEL_DONEB_IT_DISABLE) || \ 499 ((PENDING) == DAC_CHANNEL_DONEB_IT_ENABLE)) 500 501 /** 502 * @brief Judge is DAC sawtooth reset data or not 503 * @param DATA data to judge 504 * @retval 0 isn't DAC sawtooth reset data 505 * @retval 1 is DAC sawtooth reset data 506 */ 507 #define IS_DAC_SAWTOOTH_RESET_DATA(DATA) ((DATA) <= 0xFFFUL) 508 509 /** 510 * @brief Judge is DAC sawtooth step data or not 511 * @param DATA data to judge 512 * @retval 0 isn't DAC sawtooth step data 513 * @retval 1 is DAC sawtooth step data 514 */ 515 #define IS_DAC_SAWTOOTH_STEP_DATA(DATA) ((DATA) <= 0xFFFFUL) 516 517 /** 518 * @brief Judge is DAC sawtooth reset trigger or not 519 * @param TRIGGER trigger to judge 520 * @retval 0 isn't DAC sawtooth reset trigger 521 * @retval 1 is DAC sawtooth reset trigger 522 */ 523 #define IS_DAC_SAWTOOTH_RESET_TRIGGER(TRIGGER) ((TRIGGER) < 16U) 524 525 /** 526 * @brief Judge is DAC sawtooth step trigger or not 527 * @param TRIGGER trigger to judge 528 * @retval 0 isn't DAC sawtooth step trigger 529 * @retval 1 is DAC sawtooth step trigger 530 */ 531 #define IS_DAC_SAWTOOTH_STEP_TRIGGER(TRIGGER) ((TRIGGER) < 16U) 532 533 /** 534 * @brief Judge is DAC sawtooth polarity or not 535 * @param POLARITY polarity to judge 536 * @retval 0 isn't DAC sawtooth polarity 537 * @retval 1 is DAC sawtooth polarity 538 */ 539 #define IS_DAC_SAWTOOTH_POLARITY(POLARITY) (((POLARITY) == DAC_SAWTOOTH_POLARITY_DEC) || \ 540 ((POLARITY) == DAC_SAWTOOTH_POLARITY_INC)) 541 542 /** 543 * @brief Judge is DAC triangle initial direction or not 544 * @param DIR direction to judge 545 * @retval 0 isn't DAC triangle initial direction 546 * @retval 1 is DAC triangle initial direction 547 */ 548 #define IS_DAC_TRIANGLE_INITIALDIRECTION(DIR) (((DIR) == DAC_TRIANGLE_INITIALDIRECTION_DEC) || \ 549 ((DIR) == DAC_TRIANGLE_INITIALDIRECTION_INC)) 550 551 /** 552 * @brief Judge is DAC triangle amplitude or not 553 * @param AMP amplitude to judge 554 * @retval 0 isn't DAC triangle amplitude 555 * @retval 1 is DAC triangle amplitude 556 */ 557 #define IS_DAC_TRIANGLE_AMPLITUDE(AMP) (((AMP) == DAC_TRIANGLE_AMPLITUDE_1) || \ 558 ((AMP) == DAC_TRIANGLE_AMPLITUDE_3) || \ 559 ((AMP) == DAC_TRIANGLE_AMPLITUDE_7) || \ 560 ((AMP) == DAC_TRIANGLE_AMPLITUDE_15) || \ 561 ((AMP) == DAC_TRIANGLE_AMPLITUDE_31) || \ 562 ((AMP) == DAC_TRIANGLE_AMPLITUDE_63) || \ 563 ((AMP) == DAC_TRIANGLE_AMPLITUDE_127) || \ 564 ((AMP) == DAC_TRIANGLE_AMPLITUDE_255) || \ 565 ((AMP) == DAC_TRIANGLE_AMPLITUDE_511) || \ 566 ((AMP) == DAC_TRIANGLE_AMPLITUDE_1023) || \ 567 ((AMP) == DAC_TRIANGLE_AMPLITUDE_2047) || \ 568 ((AMP) == DAC_TRIANGLE_AMPLITUDE_4095)) 569 570 /** 571 * @brief Judge is DAC triangle step trigger or not 572 * @param TRIGGER trigger to judge 573 * @retval 0 isn't DAC triangle step trigger 574 * @retval 1 is DAC triangle step trigger 575 */ 576 #define IS_DAC_TRIANGLE_STEP_TRIGGER(TRIGGER) ((TRIGGER) < 16U) 577 578 /** 579 * @} 580 */ 581 582 583 /* Private types -------------------------------------------------------------*/ 584 /* Private variables ---------------------------------------------------------*/ 585 /* Private functions ---------------------------------------------------------*/ 586 587 588 /** 589 * @} 590 */ 591 592 /** 593 * @} 594 */ 595 596 597 #ifdef __cplusplus 598 } 599 #endif /* __cplusplus */ 600 601 602 #endif /* _TAE32F53XX_LL_DAC_H_ */ 603 604 605 /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ 606 607