stm32l4xx_hal_dac_ex.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_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>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_DAC_EX_H
  37. #define __STM32L4xx_HAL_DAC_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx_hal_def.h"
  43. /** @addtogroup STM32L4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup DACEx
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /**
  51. * @brief HAL State structures definition
  52. */
  53. /* Exported constants --------------------------------------------------------*/
  54. /** @defgroup DACEx_Exported_Constants DACEx Exported Constants
  55. * @{
  56. */
  57. /** @defgroup DACEx_lfsrunmask_triangleamplitude DACEx lfsrunmask triangle amplitude
  58. * @{
  59. */
  60. #define DAC_LFSRUNMASK_BIT0 ((uint32_t)0x00000000) /*!< Unmask DAC channel LFSR bit0 for noise wave generation */
  61. #define DAC_LFSRUNMASK_BITS1_0 ((uint32_t)DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[1:0] for noise wave generation */
  62. #define DAC_LFSRUNMASK_BITS2_0 ((uint32_t)DAC_CR_MAMP1_1) /*!< Unmask DAC channel LFSR bit[2:0] for noise wave generation */
  63. #define DAC_LFSRUNMASK_BITS3_0 ((uint32_t)DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0)/*!< Unmask DAC channel LFSR bit[3:0] for noise wave generation */
  64. #define DAC_LFSRUNMASK_BITS4_0 ((uint32_t)DAC_CR_MAMP1_2) /*!< Unmask DAC channel LFSR bit[4:0] for noise wave generation */
  65. #define DAC_LFSRUNMASK_BITS5_0 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[5:0] for noise wave generation */
  66. #define DAC_LFSRUNMASK_BITS6_0 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1) /*!< Unmask DAC channel LFSR bit[6:0] for noise wave generation */
  67. #define DAC_LFSRUNMASK_BITS7_0 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[7:0] for noise wave generation */
  68. #define DAC_LFSRUNMASK_BITS8_0 ((uint32_t)DAC_CR_MAMP1_3) /*!< Unmask DAC channel LFSR bit[8:0] for noise wave generation */
  69. #define DAC_LFSRUNMASK_BITS9_0 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[9:0] for noise wave generation */
  70. #define DAC_LFSRUNMASK_BITS10_0 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1) /*!< Unmask DAC channel LFSR bit[10:0] for noise wave generation */
  71. #define DAC_LFSRUNMASK_BITS11_0 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Unmask DAC channel LFSR bit[11:0] for noise wave generation */
  72. #define DAC_TRIANGLEAMPLITUDE_1 ((uint32_t)0x00000000) /*!< Select max triangle amplitude of 1 */
  73. #define DAC_TRIANGLEAMPLITUDE_3 ((uint32_t)DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 3 */
  74. #define DAC_TRIANGLEAMPLITUDE_7 ((uint32_t)DAC_CR_MAMP1_1) /*!< Select max triangle amplitude of 7 */
  75. #define DAC_TRIANGLEAMPLITUDE_15 ((uint32_t)DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 15 */
  76. #define DAC_TRIANGLEAMPLITUDE_31 ((uint32_t)DAC_CR_MAMP1_2) /*!< Select max triangle amplitude of 31 */
  77. #define DAC_TRIANGLEAMPLITUDE_63 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 63 */
  78. #define DAC_TRIANGLEAMPLITUDE_127 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1) /*!< Select max triangle amplitude of 127 */
  79. #define DAC_TRIANGLEAMPLITUDE_255 ((uint32_t)DAC_CR_MAMP1_2 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 255 */
  80. #define DAC_TRIANGLEAMPLITUDE_511 ((uint32_t)DAC_CR_MAMP1_3) /*!< Select max triangle amplitude of 511 */
  81. #define DAC_TRIANGLEAMPLITUDE_1023 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 1023 */
  82. #define DAC_TRIANGLEAMPLITUDE_2047 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1) /*!< Select max triangle amplitude of 2047 */
  83. #define DAC_TRIANGLEAMPLITUDE_4095 ((uint32_t)DAC_CR_MAMP1_3 | DAC_CR_MAMP1_1 | DAC_CR_MAMP1_0) /*!< Select max triangle amplitude of 4095 */
  84. /**
  85. * @}
  86. */
  87. /**
  88. * @}
  89. */
  90. /* Exported macro ------------------------------------------------------------*/
  91. /* Private macro -------------------------------------------------------------*/
  92. /** @defgroup DACEx_Private_Macros DACEx Private Macros
  93. * @{
  94. */
  95. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
  96. #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
  97. ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
  98. ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
  99. ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \
  100. ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
  101. ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
  102. #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
  103. #if defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
  104. #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
  105. ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
  106. ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
  107. ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
  108. ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
  109. #endif /* STM32L451xx STM32L452xx STM32L462xx */
  110. #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx)
  111. #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
  112. ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
  113. ((TRIGGER) == DAC_TRIGGER_T4_TRGO) || \
  114. ((TRIGGER) == DAC_TRIGGER_T5_TRGO) || \
  115. ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
  116. ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \
  117. ((TRIGGER) == DAC_TRIGGER_T8_TRGO) || \
  118. ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
  119. ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
  120. #endif /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
  121. #if defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
  122. #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
  123. ((TRIGGER) == DAC_TRIGGER_T1_TRGO) || \
  124. ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
  125. ((TRIGGER) == DAC_TRIGGER_T4_TRGO) || \
  126. ((TRIGGER) == DAC_TRIGGER_T5_TRGO) || \
  127. ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
  128. ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \
  129. ((TRIGGER) == DAC_TRIGGER_T8_TRGO) || \
  130. ((TRIGGER) == DAC_TRIGGER_T15_TRGO) || \
  131. ((TRIGGER) == DAC_TRIGGER_LPTIM1_OUT) || \
  132. ((TRIGGER) == DAC_TRIGGER_LPTIM2_OUT) || \
  133. ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
  134. ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
  135. #define IS_DAC_HIGH_FREQUENCY_MODE(MODE) (((MODE) == DAC_HIGH_FREQUENCY_INTERFACE_MODE_DISABLE) || \
  136. ((MODE) == DAC_HIGH_FREQUENCY_INTERFACE_MODE_ABOVE_80MHZ) || \
  137. ((MODE) == DAC_HIGH_FREQUENCY_INTERFACE_MODE_AUTOMATIC))
  138. #endif /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
  139. #define IS_DAC_SAMPLETIME(TIME) ((TIME) <= 0x000003FF)
  140. #define IS_DAC_HOLDTIME(TIME) ((TIME) <= 0x000003FF)
  141. #define IS_DAC_SAMPLEANDHOLD(MODE) (((MODE) == DAC_SAMPLEANDHOLD_DISABLE) || \
  142. ((MODE) == DAC_SAMPLEANDHOLD_ENABLE))
  143. #define IS_DAC_TRIMMINGVALUE(TRIMMINGVALUE) ((TRIMMINGVALUE) <= 0x1F)
  144. #define IS_DAC_NEWTRIMMINGVALUE(TRIMMINGVALUE) ((TRIMMINGVALUE) <= 0x1F)
  145. #define IS_DAC_CHIP_CONNECTION(CONNECT) (((CONNECT) == DAC_CHIPCONNECT_DISABLE) || \
  146. ((CONNECT) == DAC_CHIPCONNECT_ENABLE))
  147. #define IS_DAC_TRIMMING(TRIMMING) (((TRIMMING) == DAC_TRIMMING_FACTORY) || \
  148. ((TRIMMING) == DAC_TRIMMING_USER))
  149. #define IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(VALUE) (((VALUE) == DAC_LFSRUNMASK_BIT0) || \
  150. ((VALUE) == DAC_LFSRUNMASK_BITS1_0) || \
  151. ((VALUE) == DAC_LFSRUNMASK_BITS2_0) || \
  152. ((VALUE) == DAC_LFSRUNMASK_BITS3_0) || \
  153. ((VALUE) == DAC_LFSRUNMASK_BITS4_0) || \
  154. ((VALUE) == DAC_LFSRUNMASK_BITS5_0) || \
  155. ((VALUE) == DAC_LFSRUNMASK_BITS6_0) || \
  156. ((VALUE) == DAC_LFSRUNMASK_BITS7_0) || \
  157. ((VALUE) == DAC_LFSRUNMASK_BITS8_0) || \
  158. ((VALUE) == DAC_LFSRUNMASK_BITS9_0) || \
  159. ((VALUE) == DAC_LFSRUNMASK_BITS10_0) || \
  160. ((VALUE) == DAC_LFSRUNMASK_BITS11_0) || \
  161. ((VALUE) == DAC_TRIANGLEAMPLITUDE_1) || \
  162. ((VALUE) == DAC_TRIANGLEAMPLITUDE_3) || \
  163. ((VALUE) == DAC_TRIANGLEAMPLITUDE_7) || \
  164. ((VALUE) == DAC_TRIANGLEAMPLITUDE_15) || \
  165. ((VALUE) == DAC_TRIANGLEAMPLITUDE_31) || \
  166. ((VALUE) == DAC_TRIANGLEAMPLITUDE_63) || \
  167. ((VALUE) == DAC_TRIANGLEAMPLITUDE_127) || \
  168. ((VALUE) == DAC_TRIANGLEAMPLITUDE_255) || \
  169. ((VALUE) == DAC_TRIANGLEAMPLITUDE_511) || \
  170. ((VALUE) == DAC_TRIANGLEAMPLITUDE_1023) || \
  171. ((VALUE) == DAC_TRIANGLEAMPLITUDE_2047) || \
  172. ((VALUE) == DAC_TRIANGLEAMPLITUDE_4095))
  173. /**
  174. * @}
  175. */
  176. /* Exported functions --------------------------------------------------------*/
  177. /* Extended features functions ***********************************************/
  178. /** @addtogroup DACEx_Exported_Functions
  179. * @{
  180. */
  181. /** @addtogroup DACEx_Exported_Functions_Group2
  182. * @{
  183. */
  184. /* IO operation functions *****************************************************/
  185. HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude);
  186. HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Amplitude);
  187. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
  188. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
  189. defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
  190. HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef* hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2);
  191. #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
  192. /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
  193. /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
  194. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
  195. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
  196. defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
  197. void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef* hdac);
  198. void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef* hdac);
  199. void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef* hdac);
  200. void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef* hdac);
  201. #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
  202. /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
  203. /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
  204. HAL_StatusTypeDef HAL_DACEx_SelfCalibrate (DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel);
  205. HAL_StatusTypeDef HAL_DACEx_SetUserTrimming (DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel, uint32_t NewTrimmingValue);
  206. /**
  207. * @}
  208. */
  209. /** @addtogroup DACEx_Exported_Functions_Group3
  210. * @{
  211. */
  212. /* Peripheral Control functions ***********************************************/
  213. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
  214. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
  215. defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
  216. uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef* hdac);
  217. #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
  218. /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
  219. /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
  220. uint32_t HAL_DACEx_GetTrimOffset (DAC_HandleTypeDef *hdac, uint32_t Channel);
  221. /**
  222. * @}
  223. */
  224. /**
  225. * @}
  226. */
  227. #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
  228. defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || defined (STM32L496xx) || defined (STM32L4A6xx) || \
  229. defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined(STM32L4S9xx)
  230. /** @addtogroup DACEx_Private_Functions
  231. * @{
  232. */
  233. /* DAC_DMAConvCpltCh2 / DAC_DMAErrorCh2 / DAC_DMAHalfConvCpltCh2 */
  234. /* are called by HAL_DAC_Start_DMA */
  235. void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma);
  236. void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma);
  237. void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma);
  238. /**
  239. * @}
  240. */
  241. #endif /* STM32L431xx STM32L432xx STM32L433xx STM32L442xx STM32L443xx */
  242. /* STM32L471xx STM32L475xx STM32L476xx STM32L485xx STM32L486xx STM32L496xx STM32L4A6xx */
  243. /* STM32L4R5xx STM32L4R7xx STM32L4R9xx STM32L4S5xx STM32L4S7xx STM32L4S9xx */
  244. /**
  245. * @}
  246. */
  247. /**
  248. * @}
  249. */
  250. #ifdef __cplusplus
  251. }
  252. #endif
  253. #endif /*__STM32L4xx_HAL_DAC_EX_H */
  254. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/