mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Wed Apr 27 12:10:56 2016 -0500
Revision:
119:aae6fcc7d9bb
Parent:
96:487b796308b0
Release 119 of the mbed library

Changes:
- new targets - EFM32PG_STK3401, NUCLEO_L031K6
- ST - hwflwctl support for NUCLEO_L476RG
- Update STM32CUBE_L0 from v1.2 to v1.5
- STM32F7 - bugfix - The weak function HAL_Delay is overwritten to use us ticker API.
- Maxim - Fixing the send break for the MAXWSNENV and MAX32600MBED

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 84:0b3ab51c8877 1 /**
bogdanm 84:0b3ab51c8877 2 ******************************************************************************
bogdanm 84:0b3ab51c8877 3 * @file stm32l0xx_hal_dac.h
bogdanm 84:0b3ab51c8877 4 * @author MCD Application Team
Kojto 119:aae6fcc7d9bb 5 * @version V1.5.0
Kojto 119:aae6fcc7d9bb 6 * @date 8-January-2016
bogdanm 84:0b3ab51c8877 7 * @brief Header file of DAC HAL module.
bogdanm 84:0b3ab51c8877 8 ******************************************************************************
bogdanm 84:0b3ab51c8877 9 * @attention
bogdanm 84:0b3ab51c8877 10 *
Kojto 119:aae6fcc7d9bb 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
bogdanm 84:0b3ab51c8877 12 *
bogdanm 84:0b3ab51c8877 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 84:0b3ab51c8877 14 * are permitted provided that the following conditions are met:
bogdanm 84:0b3ab51c8877 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 84:0b3ab51c8877 16 * this list of conditions and the following disclaimer.
bogdanm 84:0b3ab51c8877 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 84:0b3ab51c8877 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 84:0b3ab51c8877 19 * and/or other materials provided with the distribution.
bogdanm 84:0b3ab51c8877 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 84:0b3ab51c8877 21 * may be used to endorse or promote products derived from this software
bogdanm 84:0b3ab51c8877 22 * without specific prior written permission.
bogdanm 84:0b3ab51c8877 23 *
bogdanm 84:0b3ab51c8877 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 84:0b3ab51c8877 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 84:0b3ab51c8877 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 84:0b3ab51c8877 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 84:0b3ab51c8877 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 84:0b3ab51c8877 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 84:0b3ab51c8877 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 84:0b3ab51c8877 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 84:0b3ab51c8877 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 84:0b3ab51c8877 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 84:0b3ab51c8877 34 *
bogdanm 84:0b3ab51c8877 35 ******************************************************************************
bogdanm 84:0b3ab51c8877 36 */
bogdanm 84:0b3ab51c8877 37
bogdanm 84:0b3ab51c8877 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 84:0b3ab51c8877 39 #ifndef __STM32L0xx_HAL_DAC_H
bogdanm 84:0b3ab51c8877 40 #define __STM32L0xx_HAL_DAC_H
bogdanm 84:0b3ab51c8877 41
bogdanm 84:0b3ab51c8877 42 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 43 extern "C" {
bogdanm 84:0b3ab51c8877 44 #endif
bogdanm 84:0b3ab51c8877 45
Kojto 119:aae6fcc7d9bb 46 #if !defined (STM32L011xx) && !defined (STM32L021xx) && !defined (STM32L031xx) && !defined (STM32L041xx) && !defined (STM32L051xx) && !defined (STM32L061xx) && !defined (STM32L071xx) && !defined (STM32L081xx)
bogdanm 84:0b3ab51c8877 47
bogdanm 84:0b3ab51c8877 48 /* Includes ------------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 49 #include "stm32l0xx_hal_def.h"
bogdanm 84:0b3ab51c8877 50
bogdanm 84:0b3ab51c8877 51 /** @addtogroup STM32L0xx_HAL_Driver
bogdanm 84:0b3ab51c8877 52 * @{
bogdanm 84:0b3ab51c8877 53 */
bogdanm 84:0b3ab51c8877 54
Kojto 119:aae6fcc7d9bb 55 /** @defgroup DAC DAC
bogdanm 84:0b3ab51c8877 56 * @{
bogdanm 84:0b3ab51c8877 57 */
bogdanm 84:0b3ab51c8877 58
bogdanm 84:0b3ab51c8877 59 /* Exported types ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 60
Kojto 96:487b796308b0 61 /** @defgroup DAC_Exported_Types DAC Exported Types
Kojto 96:487b796308b0 62 * @{
Kojto 96:487b796308b0 63 */
Kojto 96:487b796308b0 64
bogdanm 84:0b3ab51c8877 65 /**
bogdanm 84:0b3ab51c8877 66 * @brief HAL State structures definition
bogdanm 84:0b3ab51c8877 67 */
bogdanm 84:0b3ab51c8877 68 typedef enum
bogdanm 84:0b3ab51c8877 69 {
bogdanm 84:0b3ab51c8877 70 HAL_DAC_STATE_RESET = 0x00, /*!< DAC not yet initialized or disabled */
bogdanm 84:0b3ab51c8877 71 HAL_DAC_STATE_READY = 0x01, /*!< DAC initialized and ready for use */
bogdanm 84:0b3ab51c8877 72 HAL_DAC_STATE_BUSY = 0x02, /*!< DAC internal processing is ongoing */
bogdanm 84:0b3ab51c8877 73 HAL_DAC_STATE_TIMEOUT = 0x03, /*!< DAC timeout state */
bogdanm 84:0b3ab51c8877 74 HAL_DAC_STATE_ERROR = 0x04 /*!< DAC error state */
bogdanm 84:0b3ab51c8877 75
bogdanm 84:0b3ab51c8877 76 }HAL_DAC_StateTypeDef;
bogdanm 84:0b3ab51c8877 77
bogdanm 84:0b3ab51c8877 78 /**
bogdanm 84:0b3ab51c8877 79 * @brief DAC handle Structure definition
bogdanm 84:0b3ab51c8877 80 */
bogdanm 84:0b3ab51c8877 81 typedef struct
bogdanm 84:0b3ab51c8877 82 {
bogdanm 84:0b3ab51c8877 83 DAC_TypeDef *Instance; /*!< Register base address */
bogdanm 84:0b3ab51c8877 84
bogdanm 84:0b3ab51c8877 85 __IO HAL_DAC_StateTypeDef State; /*!< DAC communication state */
bogdanm 84:0b3ab51c8877 86
bogdanm 84:0b3ab51c8877 87 HAL_LockTypeDef Lock; /*!< DAC locking object */
bogdanm 84:0b3ab51c8877 88
bogdanm 84:0b3ab51c8877 89 DMA_HandleTypeDef *DMA_Handle1; /*!< Pointer DMA handler for channel 1 */
bogdanm 84:0b3ab51c8877 90
Kojto 96:487b796308b0 91 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 92 DMA_HandleTypeDef *DMA_Handle2; /*!< Pointer DMA handler for channel 2 */
Kojto 96:487b796308b0 93 #endif
Kojto 96:487b796308b0 94
Kojto 96:487b796308b0 95 __IO uint32_t ErrorCode; /*!< DAC Error code */
bogdanm 84:0b3ab51c8877 96
bogdanm 84:0b3ab51c8877 97 }DAC_HandleTypeDef;
bogdanm 84:0b3ab51c8877 98
bogdanm 84:0b3ab51c8877 99 /**
bogdanm 84:0b3ab51c8877 100 * @brief DAC Configuration regular Channel structure definition
bogdanm 84:0b3ab51c8877 101 */
bogdanm 84:0b3ab51c8877 102 typedef struct
bogdanm 84:0b3ab51c8877 103 {
bogdanm 84:0b3ab51c8877 104 uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel.
bogdanm 84:0b3ab51c8877 105 This parameter can be a value of @ref DAC_trigger_selection */
bogdanm 84:0b3ab51c8877 106
bogdanm 84:0b3ab51c8877 107 uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled.
bogdanm 84:0b3ab51c8877 108 This parameter can be a value of @ref DAC_output_buffer */
bogdanm 84:0b3ab51c8877 109
bogdanm 84:0b3ab51c8877 110 }DAC_ChannelConfTypeDef;
bogdanm 84:0b3ab51c8877 111
Kojto 96:487b796308b0 112 /**
Kojto 96:487b796308b0 113 * @}
Kojto 96:487b796308b0 114 */
Kojto 96:487b796308b0 115
bogdanm 84:0b3ab51c8877 116 /* Exported constants --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 117
Kojto 96:487b796308b0 118 /** @defgroup DAC_Exported_Constants DAC Exported Constants
Kojto 96:487b796308b0 119 * @{
Kojto 96:487b796308b0 120 */
Kojto 96:487b796308b0 121
Kojto 96:487b796308b0 122 /** @defgroup DAC_Error_Code DAC Error Code
bogdanm 84:0b3ab51c8877 123 * @{
bogdanm 84:0b3ab51c8877 124 */
bogdanm 84:0b3ab51c8877 125 #define HAL_DAC_ERROR_NONE 0x00 /*!< No error */
Kojto 96:487b796308b0 126 #define HAL_DAC_ERROR_DMAUNDERRUNCH1 0x01 /*!< DAC channel1 DAM underrun error */
Kojto 96:487b796308b0 127 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 128 #define HAL_DAC_ERROR_DMAUNDERRUNCH2 0x02 /*!< DAC channel2 DAM underrun error */
Kojto 96:487b796308b0 129 #endif
bogdanm 84:0b3ab51c8877 130 #define HAL_DAC_ERROR_DMA 0x04 /*!< DMA error */
bogdanm 84:0b3ab51c8877 131 /**
bogdanm 84:0b3ab51c8877 132 * @}
bogdanm 84:0b3ab51c8877 133 */
bogdanm 84:0b3ab51c8877 134
Kojto 96:487b796308b0 135 /** @defgroup DAC_trigger_selection DAC trigger selection
bogdanm 84:0b3ab51c8877 136 * @{
bogdanm 84:0b3ab51c8877 137 */
Kojto 119:aae6fcc7d9bb 138 #define DAC_TRIGGER_NONE ((uint32_t)0x00000000) /*!< Conversion is automatic once the DAC1_DHRxxxx register has been loaded, and not by external trigger */
Kojto 119:aae6fcc7d9bb 139 #define DAC_TRIGGER_T6_TRGO ((uint32_t) DAC_CR_TEN1) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
Kojto 119:aae6fcc7d9bb 140 #define DAC_TRIGGER_T21_TRGO ((uint32_t)( DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM21 TRGO selected as external conversion trigger for DAC channel */
Kojto 119:aae6fcc7d9bb 141 #define DAC_TRIGGER_T2_TRGO ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TEN1)) /*!< TIM2 TRGO selected as external conversion trigger for DAC channel */
Kojto 119:aae6fcc7d9bb 142 #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 */
Kojto 119:aae6fcc7d9bb 143 #define DAC_TRIGGER_SOFTWARE ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_1 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< Conversion started by software trigger for DAC channel */
bogdanm 84:0b3ab51c8877 144
Kojto 96:487b796308b0 145 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 119:aae6fcc7d9bb 146 #define DAC_TRIGGER_T3_TRGO ((uint32_t)( DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM3 TRGO selected as external conversion trigger for DAC channel */
Kojto 119:aae6fcc7d9bb 147 #define DAC_TRIGGER_T3_CH3 ((uint32_t)( DAC_CR_TSEL1_1 | DAC_CR_TEN1)) /*!< TIM3 CH3 selected as external conversion trigger for DAC channel */
Kojto 119:aae6fcc7d9bb 148 #define DAC_TRIGGER_T7_TRGO ((uint32_t)(DAC_CR_TSEL1_2 | DAC_CR_TSEL1_0 | DAC_CR_TEN1)) /*!< TIM7 TRGO selected as external conversion trigger for DAC channel */
Kojto 96:487b796308b0 149 #endif
Kojto 96:487b796308b0 150
Kojto 96:487b796308b0 151 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 119:aae6fcc7d9bb 152 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
Kojto 119:aae6fcc7d9bb 153 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
Kojto 119:aae6fcc7d9bb 154 ((TRIGGER) == DAC_TRIGGER_T3_TRGO) || \
Kojto 119:aae6fcc7d9bb 155 ((TRIGGER) == DAC_TRIGGER_T3_CH3) || \
Kojto 119:aae6fcc7d9bb 156 ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \
Kojto 119:aae6fcc7d9bb 157 ((TRIGGER) == DAC_TRIGGER_T21_TRGO) || \
Kojto 119:aae6fcc7d9bb 158 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
Kojto 119:aae6fcc7d9bb 159 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
Kojto 96:487b796308b0 160 ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
Kojto 96:487b796308b0 161 #else /* STM32L072xx || STM32L073xx || STM32L082xx || STM32L083xx */
Kojto 119:aae6fcc7d9bb 162 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
Kojto 119:aae6fcc7d9bb 163 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
Kojto 119:aae6fcc7d9bb 164 ((TRIGGER) == DAC_TRIGGER_T21_TRGO) || \
Kojto 119:aae6fcc7d9bb 165 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
Kojto 119:aae6fcc7d9bb 166 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
bogdanm 84:0b3ab51c8877 167 ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
Kojto 96:487b796308b0 168 #endif /* STM32L072xx || STM32L073xx || STM32L082xx || STM32L083xx */
bogdanm 84:0b3ab51c8877 169 /**
bogdanm 84:0b3ab51c8877 170 * @}
bogdanm 84:0b3ab51c8877 171 */
bogdanm 84:0b3ab51c8877 172
Kojto 96:487b796308b0 173 /** @defgroup DAC_output_buffer DAC output buffer
bogdanm 84:0b3ab51c8877 174 * @{
bogdanm 84:0b3ab51c8877 175 */
bogdanm 84:0b3ab51c8877 176 #define DAC_OUTPUTBUFFER_ENABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 177 #define DAC_OUTPUTBUFFER_DISABLE ((uint32_t)DAC_CR_BOFF1)
bogdanm 84:0b3ab51c8877 178
bogdanm 84:0b3ab51c8877 179 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OUTPUTBUFFER_ENABLE) || \
bogdanm 84:0b3ab51c8877 180 ((STATE) == DAC_OUTPUTBUFFER_DISABLE))
bogdanm 84:0b3ab51c8877 181 /**
bogdanm 84:0b3ab51c8877 182 * @}
bogdanm 84:0b3ab51c8877 183 */
bogdanm 84:0b3ab51c8877 184
Kojto 96:487b796308b0 185 /** @defgroup DAC_Channel_selection DAC Channel selection
bogdanm 84:0b3ab51c8877 186 * @{
bogdanm 84:0b3ab51c8877 187 */
bogdanm 84:0b3ab51c8877 188 #define DAC_CHANNEL_1 ((uint32_t)0x00000000)
Kojto 96:487b796308b0 189 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 190 #define DAC_CHANNEL_2 ((uint32_t)0x00000010)
Kojto 96:487b796308b0 191 #endif
bogdanm 84:0b3ab51c8877 192
Kojto 96:487b796308b0 193 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 194 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CHANNEL_1) || \
Kojto 96:487b796308b0 195 ((CHANNEL) == DAC_CHANNEL_2))
Kojto 96:487b796308b0 196 #else
bogdanm 84:0b3ab51c8877 197 #define IS_DAC_CHANNEL(CHANNEL) ((CHANNEL) == DAC_CHANNEL_1)
Kojto 96:487b796308b0 198 #endif
bogdanm 84:0b3ab51c8877 199 /**
bogdanm 84:0b3ab51c8877 200 * @}
bogdanm 84:0b3ab51c8877 201 */
bogdanm 84:0b3ab51c8877 202
Kojto 96:487b796308b0 203 /** @defgroup DAC_data_alignement DAC data alignement
bogdanm 84:0b3ab51c8877 204 * @{
bogdanm 84:0b3ab51c8877 205 */
bogdanm 84:0b3ab51c8877 206 #define DAC_ALIGN_12B_R ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 207 #define DAC_ALIGN_12B_L ((uint32_t)0x00000004)
bogdanm 84:0b3ab51c8877 208 #define DAC_ALIGN_8B_R ((uint32_t)0x00000008)
bogdanm 84:0b3ab51c8877 209
bogdanm 84:0b3ab51c8877 210 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_ALIGN_12B_R) || \
bogdanm 84:0b3ab51c8877 211 ((ALIGN) == DAC_ALIGN_12B_L) || \
bogdanm 84:0b3ab51c8877 212 ((ALIGN) == DAC_ALIGN_8B_R))
bogdanm 84:0b3ab51c8877 213 /**
bogdanm 84:0b3ab51c8877 214 * @}
bogdanm 84:0b3ab51c8877 215 */
bogdanm 84:0b3ab51c8877 216
Kojto 96:487b796308b0 217 /** @defgroup DAC_data DAC data
bogdanm 84:0b3ab51c8877 218 * @{
bogdanm 84:0b3ab51c8877 219 */
bogdanm 84:0b3ab51c8877 220 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
bogdanm 84:0b3ab51c8877 221 /**
bogdanm 84:0b3ab51c8877 222 * @}
bogdanm 84:0b3ab51c8877 223 */
bogdanm 84:0b3ab51c8877 224
Kojto 96:487b796308b0 225 /** @defgroup DAC_flags_definition DAC flags definition
bogdanm 84:0b3ab51c8877 226 * @{
bogdanm 84:0b3ab51c8877 227 */
bogdanm 84:0b3ab51c8877 228 #define DAC_FLAG_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1)
Kojto 96:487b796308b0 229 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 230 #define DAC_FLAG_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2)
Kojto 96:487b796308b0 231 #endif
bogdanm 84:0b3ab51c8877 232
bogdanm 84:0b3ab51c8877 233 /**
bogdanm 84:0b3ab51c8877 234 * @}
bogdanm 84:0b3ab51c8877 235 */
bogdanm 84:0b3ab51c8877 236
Kojto 96:487b796308b0 237 /** @defgroup DAC_IT_definition DAC IT definition
bogdanm 84:0b3ab51c8877 238 * @{
bogdanm 84:0b3ab51c8877 239 */
Kojto 96:487b796308b0 240 #define DAC_IT_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1)
Kojto 96:487b796308b0 241 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 242 #define DAC_IT_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2)
Kojto 96:487b796308b0 243 #endif
bogdanm 84:0b3ab51c8877 244
Kojto 96:487b796308b0 245 /**
Kojto 96:487b796308b0 246 * @}
Kojto 96:487b796308b0 247 */
bogdanm 84:0b3ab51c8877 248
bogdanm 84:0b3ab51c8877 249 /**
bogdanm 84:0b3ab51c8877 250 * @}
bogdanm 84:0b3ab51c8877 251 */
bogdanm 84:0b3ab51c8877 252
bogdanm 84:0b3ab51c8877 253 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 254
Kojto 96:487b796308b0 255 /** @defgroup DAC_Exported_Macros DAC Exported Macros
Kojto 96:487b796308b0 256 * @{
Kojto 96:487b796308b0 257 */
Kojto 96:487b796308b0 258
bogdanm 84:0b3ab51c8877 259 /** @brief Reset DAC handle state
Kojto 96:487b796308b0 260 * @param __HANDLE__: specifies the DAC handle.
bogdanm 84:0b3ab51c8877 261 * @retval None
bogdanm 84:0b3ab51c8877 262 */
bogdanm 84:0b3ab51c8877 263 #define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DAC_STATE_RESET)
bogdanm 84:0b3ab51c8877 264
Kojto 96:487b796308b0 265 /** @brief Enable the DAC channel
Kojto 96:487b796308b0 266 * @param __HANDLE__: specifies the DAC handle.
Kojto 96:487b796308b0 267 * @param __DAC_CHANNEL__: specifies the DAC channel
Kojto 96:487b796308b0 268 * @retval None
Kojto 96:487b796308b0 269 */
Kojto 96:487b796308b0 270 #define __HAL_DAC_ENABLE(__HANDLE__, __DAC_CHANNEL__) \
Kojto 96:487b796308b0 271 SET_BIT((__HANDLE__)->Instance->CR, (DAC_CR_EN1 << (__DAC_CHANNEL__)))
Kojto 96:487b796308b0 272
Kojto 96:487b796308b0 273 /** @brief Disable the DAC channel
Kojto 96:487b796308b0 274 * @param __HANDLE__: specifies the DAC handle
Kojto 96:487b796308b0 275 * @param __DAC_CHANNEL__: specifies the DAC channel.
Kojto 96:487b796308b0 276 * @retval None
Kojto 96:487b796308b0 277 */
Kojto 96:487b796308b0 278 #define __HAL_DAC_DISABLE(__HANDLE__, __DAC_CHANNEL__) \
Kojto 96:487b796308b0 279 CLEAR_BIT((__HANDLE__)->Instance->CR, (DAC_CR_EN1 << (__DAC_CHANNEL__)))
bogdanm 84:0b3ab51c8877 280
Kojto 119:aae6fcc7d9bb 281
Kojto 96:487b796308b0 282 #define __HAL_DAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 283 SET_BIT((__HANDLE__)->Instance->CR, __INTERRUPT__)
bogdanm 84:0b3ab51c8877 284
bogdanm 84:0b3ab51c8877 285
Kojto 96:487b796308b0 286 /** @brief Disable the DAC interrupt
Kojto 96:487b796308b0 287 * @param __HANDLE__: specifies the DAC handle
Kojto 96:487b796308b0 288 * @param __INTERRUPT__: specifies the DAC interrupt.
Kojto 96:487b796308b0 289 * @retval None
Kojto 96:487b796308b0 290 */
Kojto 96:487b796308b0 291 #define __HAL_DAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 292 CLEAR_BIT((__HANDLE__)->Instance->CR, __INTERRUPT__)
bogdanm 84:0b3ab51c8877 293
Kojto 119:aae6fcc7d9bb 294 /** @brief Check whether the specified DAC interrupt source is enabled or not.
Kojto 119:aae6fcc7d9bb 295 * @param __HANDLE__: DAC handle
Kojto 119:aae6fcc7d9bb 296 * @param __INTERRUPT__: DAC interrupt source to check
Kojto 119:aae6fcc7d9bb 297 * This parameter can be any combination of the following values:
Kojto 119:aae6fcc7d9bb 298 * @arg DAC_IT_DMAUDR1: DAC channel 1 DMA underrun interrupt
Kojto 119:aae6fcc7d9bb 299 * @arg DAC_IT_DMAUDR2: DAC channel 2 DMA underrun interrupt (STM32L072xx STM32L073xx STM32L082xx STM32L083xx only)
Kojto 119:aae6fcc7d9bb 300 * @retval State of interruption (SET or RESET)
Kojto 119:aae6fcc7d9bb 301 */
Kojto 119:aae6fcc7d9bb 302 #define __HAL_DAC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
Kojto 119:aae6fcc7d9bb 303 (((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__))
bogdanm 84:0b3ab51c8877 304
Kojto 96:487b796308b0 305 /** @brief Get the selected DAC's flag status.
Kojto 96:487b796308b0 306 * @param __HANDLE__: specifies the DAC handle.
Kojto 96:487b796308b0 307 * @param __FLAG__: specifies the FLAG.
Kojto 96:487b796308b0 308 * @retval None
Kojto 96:487b796308b0 309 */
Kojto 119:aae6fcc7d9bb 310 #define __HAL_DAC_GET_FLAG(__HANDLE__, __FLAG__) \
Kojto 119:aae6fcc7d9bb 311 ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
bogdanm 84:0b3ab51c8877 312
Kojto 96:487b796308b0 313 /** @brief Clear the DAC's flag.
Kojto 96:487b796308b0 314 * @param __HANDLE__: specifies the DAC handle.
Kojto 96:487b796308b0 315 * @param __FLAG__: specifies the FLAG.
Kojto 96:487b796308b0 316 * @retval None
Kojto 96:487b796308b0 317 */
Kojto 119:aae6fcc7d9bb 318 #define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
Kojto 119:aae6fcc7d9bb 319 (((__HANDLE__)->Instance->SR) = (__FLAG__))
Kojto 119:aae6fcc7d9bb 320
Kojto 119:aae6fcc7d9bb 321 /**
Kojto 119:aae6fcc7d9bb 322 * @}
Kojto 119:aae6fcc7d9bb 323 */
Kojto 119:aae6fcc7d9bb 324
Kojto 119:aae6fcc7d9bb 325 /* Private macro ------------------------------------------------------------*/
Kojto 119:aae6fcc7d9bb 326
Kojto 119:aae6fcc7d9bb 327 /** @defgroup DAC_Private_Macros DAC Private Macros
Kojto 119:aae6fcc7d9bb 328 * @{
Kojto 119:aae6fcc7d9bb 329 */
Kojto 119:aae6fcc7d9bb 330
Kojto 119:aae6fcc7d9bb 331 /** @brief Set DHR12R1 alignment
Kojto 119:aae6fcc7d9bb 332 * @param __ALIGNEMENT__: specifies the DAC alignement
Kojto 119:aae6fcc7d9bb 333 * @retval None
Kojto 119:aae6fcc7d9bb 334 */
Kojto 119:aae6fcc7d9bb 335 #define DAC_DHR12R1_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000008) + (__ALIGNEMENT__))
bogdanm 84:0b3ab51c8877 336
Kojto 119:aae6fcc7d9bb 337 /** @brief Set DHR12R2 alignment
Kojto 119:aae6fcc7d9bb 338 * @param __ALIGNEMENT__: specifies the DAC alignement
Kojto 119:aae6fcc7d9bb 339 * @retval None
Kojto 119:aae6fcc7d9bb 340 */
Kojto 119:aae6fcc7d9bb 341 #define DAC_DHR12R2_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000014) + (__ALIGNEMENT__))
Kojto 119:aae6fcc7d9bb 342
Kojto 119:aae6fcc7d9bb 343 /** @brief Set DHR12RD alignment
Kojto 119:aae6fcc7d9bb 344 * @param __ALIGNEMENT__: specifies the DAC alignement
Kojto 119:aae6fcc7d9bb 345 * @retval None
Kojto 119:aae6fcc7d9bb 346 */
Kojto 119:aae6fcc7d9bb 347 #define DAC_DHR12RD_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000020) + (__ALIGNEMENT__))
Kojto 119:aae6fcc7d9bb 348
Kojto 119:aae6fcc7d9bb 349 /** @brief Enable the DAC interrupt
Kojto 119:aae6fcc7d9bb 350 * @param __HANDLE__: specifies the DAC handle
Kojto 119:aae6fcc7d9bb 351 * @param __INTERRUPT__: specifies the DAC interrupt.
Kojto 119:aae6fcc7d9bb 352 * @retval None
Kojto 119:aae6fcc7d9bb 353 */
Kojto 119:aae6fcc7d9bb 354
Kojto 96:487b796308b0 355 /**
Kojto 96:487b796308b0 356 * @}
Kojto 96:487b796308b0 357 */
Kojto 96:487b796308b0 358
Kojto 96:487b796308b0 359
bogdanm 84:0b3ab51c8877 360 /* Include DAC HAL Extension module */
bogdanm 84:0b3ab51c8877 361 #include "stm32l0xx_hal_dac_ex.h"
bogdanm 84:0b3ab51c8877 362
bogdanm 84:0b3ab51c8877 363 /* Exported functions --------------------------------------------------------*/
Kojto 96:487b796308b0 364
Kojto 119:aae6fcc7d9bb 365 /** @defgroup DAC_Exported_Functions DAC Exported Functions
Kojto 96:487b796308b0 366 * @{
Kojto 96:487b796308b0 367 */
Kojto 96:487b796308b0 368
Kojto 119:aae6fcc7d9bb 369 /** @defgroup DAC_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 96:487b796308b0 370 * @{
Kojto 96:487b796308b0 371 */
Kojto 96:487b796308b0 372 /* Initialization and de-initialization functions *****************************/
bogdanm 84:0b3ab51c8877 373 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 374 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 375 void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 376 void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 377
Kojto 96:487b796308b0 378 /**
Kojto 96:487b796308b0 379 * @}
Kojto 96:487b796308b0 380 */
Kojto 96:487b796308b0 381
Kojto 119:aae6fcc7d9bb 382 /** @defgroup DAC_Exported_Functions_Group2 IO operation functions
Kojto 96:487b796308b0 383 * @{
Kojto 96:487b796308b0 384 */
Kojto 96:487b796308b0 385 /* IO operation functions *****************************************************/
Kojto 96:487b796308b0 386 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 96:487b796308b0 387 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 96:487b796308b0 388 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment);
Kojto 96:487b796308b0 389 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 96:487b796308b0 390 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data);
Kojto 96:487b796308b0 391 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 119:aae6fcc7d9bb 392 void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac);
Kojto 119:aae6fcc7d9bb 393 void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac);
Kojto 119:aae6fcc7d9bb 394 void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac);
Kojto 119:aae6fcc7d9bb 395 void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac);
Kojto 119:aae6fcc7d9bb 396 void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac);
bogdanm 84:0b3ab51c8877 397
Kojto 96:487b796308b0 398 /**
Kojto 96:487b796308b0 399 * @}
Kojto 96:487b796308b0 400 */
Kojto 96:487b796308b0 401
Kojto 119:aae6fcc7d9bb 402 /** @defgroup DAC_Exported_Functions_Group3 Peripheral Control functions
Kojto 96:487b796308b0 403 * @{
Kojto 96:487b796308b0 404 */
bogdanm 84:0b3ab51c8877 405 /* Peripheral Control functions ***********************************************/
Kojto 96:487b796308b0 406 HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel);
bogdanm 84:0b3ab51c8877 407
Kojto 96:487b796308b0 408 /**
Kojto 96:487b796308b0 409 * @}
Kojto 96:487b796308b0 410 */
Kojto 96:487b796308b0 411
Kojto 119:aae6fcc7d9bb 412 /** @defgroup DAC_Exported_Functions_Group4 Peripheral State and Errors functions
Kojto 96:487b796308b0 413 * @{
Kojto 96:487b796308b0 414 */
Kojto 96:487b796308b0 415 /* Peripheral State functions ***************************************************/
bogdanm 84:0b3ab51c8877 416 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 417 uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac);
bogdanm 84:0b3ab51c8877 418
Kojto 96:487b796308b0 419 /**
Kojto 96:487b796308b0 420 * @}
Kojto 96:487b796308b0 421 */
Kojto 96:487b796308b0 422
Kojto 96:487b796308b0 423 /**
Kojto 96:487b796308b0 424 * @}
Kojto 96:487b796308b0 425 */
Kojto 96:487b796308b0 426
bogdanm 84:0b3ab51c8877 427 /**
bogdanm 84:0b3ab51c8877 428 * @}
bogdanm 84:0b3ab51c8877 429 */
bogdanm 84:0b3ab51c8877 430
bogdanm 84:0b3ab51c8877 431 /**
bogdanm 84:0b3ab51c8877 432 * @}
bogdanm 84:0b3ab51c8877 433 */
Kojto 96:487b796308b0 434
Kojto 119:aae6fcc7d9bb 435 #endif /* STM32L011xx && STM32L021xx && STM32L031xx && STM32L041xx && STM32L061xx && STM32L071xx && STM32L081xx*/
bogdanm 84:0b3ab51c8877 436
bogdanm 84:0b3ab51c8877 437 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 438 }
bogdanm 84:0b3ab51c8877 439 #endif
bogdanm 84:0b3ab51c8877 440
bogdanm 84:0b3ab51c8877 441 #endif /*__STM32L0xx_HAL_DAC_H */
bogdanm 84:0b3ab51c8877 442
bogdanm 84:0b3ab51c8877 443 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/