meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

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 96:487b796308b0 5 * @version V1.2.0
Kojto 96:487b796308b0 6 * @date 06-February-2015
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 96:487b796308b0 11 * <h2><center>&copy; COPYRIGHT(c) 2015 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 96:487b796308b0 46 #if !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
bogdanm 84:0b3ab51c8877 55 /** @addtogroup 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 96:487b796308b0 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 96:487b796308b0 139 #define DAC_TRIGGER_T6_TRGO ((uint32_t) DAC_CR_TEN1) /*!< TIM6 TRGO selected as external conversion trigger for DAC channel */
Kojto 96:487b796308b0 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 96:487b796308b0 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 96:487b796308b0 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 96:487b796308b0 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 96:487b796308b0 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 96:487b796308b0 147 #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 148 #endif
Kojto 96:487b796308b0 149
Kojto 96:487b796308b0 150 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 151 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
Kojto 96:487b796308b0 152 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
Kojto 96:487b796308b0 153 ((TRIGGER) == DAC_TRIGGER_T3_TRGO) || \
Kojto 96:487b796308b0 154 ((TRIGGER) == DAC_TRIGGER_T7_TRGO) || \
Kojto 96:487b796308b0 155 ((TRIGGER) == DAC_TRIGGER_T21_TRGO) || \
Kojto 96:487b796308b0 156 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
Kojto 96:487b796308b0 157 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
Kojto 96:487b796308b0 158 ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
Kojto 96:487b796308b0 159 #else /* STM32L072xx || STM32L073xx || STM32L082xx || STM32L083xx */
bogdanm 84:0b3ab51c8877 160 #define IS_DAC_TRIGGER(TRIGGER) (((TRIGGER) == DAC_TRIGGER_NONE) || \
bogdanm 84:0b3ab51c8877 161 ((TRIGGER) == DAC_TRIGGER_T6_TRGO) || \
bogdanm 84:0b3ab51c8877 162 ((TRIGGER) == DAC_TRIGGER_T21_TRGO) || \
bogdanm 84:0b3ab51c8877 163 ((TRIGGER) == DAC_TRIGGER_T2_TRGO) || \
bogdanm 84:0b3ab51c8877 164 ((TRIGGER) == DAC_TRIGGER_EXT_IT9) || \
bogdanm 84:0b3ab51c8877 165 ((TRIGGER) == DAC_TRIGGER_SOFTWARE))
Kojto 96:487b796308b0 166 #endif /* STM32L072xx || STM32L073xx || STM32L082xx || STM32L083xx */
bogdanm 84:0b3ab51c8877 167 /**
bogdanm 84:0b3ab51c8877 168 * @}
bogdanm 84:0b3ab51c8877 169 */
bogdanm 84:0b3ab51c8877 170
Kojto 96:487b796308b0 171 /** @defgroup DAC_output_buffer DAC output buffer
bogdanm 84:0b3ab51c8877 172 * @{
bogdanm 84:0b3ab51c8877 173 */
bogdanm 84:0b3ab51c8877 174 #define DAC_OUTPUTBUFFER_ENABLE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 175 #define DAC_OUTPUTBUFFER_DISABLE ((uint32_t)DAC_CR_BOFF1)
bogdanm 84:0b3ab51c8877 176
bogdanm 84:0b3ab51c8877 177 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OUTPUTBUFFER_ENABLE) || \
bogdanm 84:0b3ab51c8877 178 ((STATE) == DAC_OUTPUTBUFFER_DISABLE))
bogdanm 84:0b3ab51c8877 179 /**
bogdanm 84:0b3ab51c8877 180 * @}
bogdanm 84:0b3ab51c8877 181 */
bogdanm 84:0b3ab51c8877 182
Kojto 96:487b796308b0 183 /** @defgroup DAC_Channel_selection DAC Channel selection
bogdanm 84:0b3ab51c8877 184 * @{
bogdanm 84:0b3ab51c8877 185 */
bogdanm 84:0b3ab51c8877 186 #define DAC_CHANNEL_1 ((uint32_t)0x00000000)
Kojto 96:487b796308b0 187 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 188 #define DAC_CHANNEL_2 ((uint32_t)0x00000010)
Kojto 96:487b796308b0 189 #endif
bogdanm 84:0b3ab51c8877 190
Kojto 96:487b796308b0 191 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 192 #define IS_DAC_CHANNEL(CHANNEL) (((CHANNEL) == DAC_CHANNEL_1) || \
Kojto 96:487b796308b0 193 ((CHANNEL) == DAC_CHANNEL_2))
Kojto 96:487b796308b0 194 #else
bogdanm 84:0b3ab51c8877 195 #define IS_DAC_CHANNEL(CHANNEL) ((CHANNEL) == DAC_CHANNEL_1)
Kojto 96:487b796308b0 196 #endif
bogdanm 84:0b3ab51c8877 197 /**
bogdanm 84:0b3ab51c8877 198 * @}
bogdanm 84:0b3ab51c8877 199 */
bogdanm 84:0b3ab51c8877 200
Kojto 96:487b796308b0 201 /** @defgroup DAC_data_alignement DAC data alignement
bogdanm 84:0b3ab51c8877 202 * @{
bogdanm 84:0b3ab51c8877 203 */
bogdanm 84:0b3ab51c8877 204 #define DAC_ALIGN_12B_R ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 205 #define DAC_ALIGN_12B_L ((uint32_t)0x00000004)
bogdanm 84:0b3ab51c8877 206 #define DAC_ALIGN_8B_R ((uint32_t)0x00000008)
bogdanm 84:0b3ab51c8877 207
bogdanm 84:0b3ab51c8877 208 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_ALIGN_12B_R) || \
bogdanm 84:0b3ab51c8877 209 ((ALIGN) == DAC_ALIGN_12B_L) || \
bogdanm 84:0b3ab51c8877 210 ((ALIGN) == DAC_ALIGN_8B_R))
bogdanm 84:0b3ab51c8877 211 /**
bogdanm 84:0b3ab51c8877 212 * @}
bogdanm 84:0b3ab51c8877 213 */
bogdanm 84:0b3ab51c8877 214
Kojto 96:487b796308b0 215 /** @defgroup DAC_data DAC data
bogdanm 84:0b3ab51c8877 216 * @{
bogdanm 84:0b3ab51c8877 217 */
bogdanm 84:0b3ab51c8877 218 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
bogdanm 84:0b3ab51c8877 219 /**
bogdanm 84:0b3ab51c8877 220 * @}
bogdanm 84:0b3ab51c8877 221 */
bogdanm 84:0b3ab51c8877 222
Kojto 96:487b796308b0 223 /** @defgroup DAC_flags_definition DAC flags definition
bogdanm 84:0b3ab51c8877 224 * @{
bogdanm 84:0b3ab51c8877 225 */
bogdanm 84:0b3ab51c8877 226 #define DAC_FLAG_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1)
Kojto 96:487b796308b0 227 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 228 #define DAC_FLAG_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2)
Kojto 96:487b796308b0 229 #endif
bogdanm 84:0b3ab51c8877 230
Kojto 96:487b796308b0 231 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 232 #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR1) || \
Kojto 96:487b796308b0 233 ((FLAG) == DAC_FLAG_DMAUDR2))
Kojto 96:487b796308b0 234 #else
Kojto 96:487b796308b0 235 #define IS_DAC_FLAG(FLAG) ((FLAG) == DAC_FLAG_DMAUDR1)
Kojto 96:487b796308b0 236 #endif
bogdanm 84:0b3ab51c8877 237 /**
bogdanm 84:0b3ab51c8877 238 * @}
bogdanm 84:0b3ab51c8877 239 */
bogdanm 84:0b3ab51c8877 240
Kojto 96:487b796308b0 241 /** @defgroup DAC_IT_definition DAC IT definition
bogdanm 84:0b3ab51c8877 242 * @{
bogdanm 84:0b3ab51c8877 243 */
Kojto 96:487b796308b0 244 #define DAC_IT_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1)
Kojto 96:487b796308b0 245 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 246 #define DAC_IT_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2)
Kojto 96:487b796308b0 247 #endif
bogdanm 84:0b3ab51c8877 248
Kojto 96:487b796308b0 249 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
Kojto 96:487b796308b0 250 #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR1) || \
Kojto 96:487b796308b0 251 ((IT) == DAC_IT_DMAUDR2))
Kojto 96:487b796308b0 252 #else
bogdanm 84:0b3ab51c8877 253 #define IS_DAC_IT(IT) ((IT) == DAC_IT_DMAUDR1)
Kojto 96:487b796308b0 254 #endif
Kojto 96:487b796308b0 255
Kojto 96:487b796308b0 256 /**
Kojto 96:487b796308b0 257 * @}
Kojto 96:487b796308b0 258 */
bogdanm 84:0b3ab51c8877 259
bogdanm 84:0b3ab51c8877 260 /**
bogdanm 84:0b3ab51c8877 261 * @}
bogdanm 84:0b3ab51c8877 262 */
bogdanm 84:0b3ab51c8877 263
bogdanm 84:0b3ab51c8877 264 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 265
Kojto 96:487b796308b0 266 /** @defgroup DAC_Exported_Macros DAC Exported Macros
Kojto 96:487b796308b0 267 * @{
Kojto 96:487b796308b0 268 */
Kojto 96:487b796308b0 269
bogdanm 84:0b3ab51c8877 270 /** @brief Reset DAC handle state
Kojto 96:487b796308b0 271 * @param __HANDLE__: specifies the DAC handle.
bogdanm 84:0b3ab51c8877 272 * @retval None
bogdanm 84:0b3ab51c8877 273 */
bogdanm 84:0b3ab51c8877 274 #define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DAC_STATE_RESET)
bogdanm 84:0b3ab51c8877 275
Kojto 96:487b796308b0 276 /** @brief Enable the DAC channel
Kojto 96:487b796308b0 277 * @param __HANDLE__: specifies the DAC handle.
Kojto 96:487b796308b0 278 * @param __DAC_CHANNEL__: specifies the DAC channel
Kojto 96:487b796308b0 279 * @retval None
Kojto 96:487b796308b0 280 */
Kojto 96:487b796308b0 281 #define __HAL_DAC_ENABLE(__HANDLE__, __DAC_CHANNEL__) \
Kojto 96:487b796308b0 282 SET_BIT((__HANDLE__)->Instance->CR, (DAC_CR_EN1 << (__DAC_CHANNEL__)))
Kojto 96:487b796308b0 283
Kojto 96:487b796308b0 284 /** @brief Disable the DAC channel
Kojto 96:487b796308b0 285 * @param __HANDLE__: specifies the DAC handle
Kojto 96:487b796308b0 286 * @param __DAC_CHANNEL__: specifies the DAC channel.
Kojto 96:487b796308b0 287 * @retval None
Kojto 96:487b796308b0 288 */
Kojto 96:487b796308b0 289 #define __HAL_DAC_DISABLE(__HANDLE__, __DAC_CHANNEL__) \
Kojto 96:487b796308b0 290 CLEAR_BIT((__HANDLE__)->Instance->CR, (DAC_CR_EN1 << (__DAC_CHANNEL__)))
bogdanm 84:0b3ab51c8877 291
Kojto 96:487b796308b0 292 /** @brief Set DHR12R1 alignment
Kojto 96:487b796308b0 293 * @param __ALIGNEMENT__: specifies the DAC alignement
Kojto 96:487b796308b0 294 * @retval None
Kojto 96:487b796308b0 295 */
Kojto 96:487b796308b0 296 #define __DAC_DHR12R1_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000008) + (__ALIGNEMENT__))
Kojto 96:487b796308b0 297
Kojto 96:487b796308b0 298 /** @brief Set DHR12R2 alignment
Kojto 96:487b796308b0 299 * @param __ALIGNEMENT__: specifies the DAC alignement
Kojto 96:487b796308b0 300 * @retval None
Kojto 96:487b796308b0 301 */
Kojto 96:487b796308b0 302 #define __DAC_DHR12R2_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000014) + (__ALIGNEMENT__))
Kojto 96:487b796308b0 303
Kojto 96:487b796308b0 304 /** @brief Set DHR12RD alignment
Kojto 96:487b796308b0 305 * @param __ALIGNEMENT__: specifies the DAC alignement
Kojto 96:487b796308b0 306 * @retval None
Kojto 96:487b796308b0 307 */
Kojto 96:487b796308b0 308 #define __DAC_DHR12RD_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000020) + (__ALIGNEMENT__))
Kojto 96:487b796308b0 309
Kojto 96:487b796308b0 310 /** @brief Enable the DAC interrupt
Kojto 96:487b796308b0 311 * @param __HANDLE__: specifies the DAC handle
Kojto 96:487b796308b0 312 * @param __INTERRUPT__: specifies the DAC interrupt.
Kojto 96:487b796308b0 313 * @retval None
Kojto 96:487b796308b0 314 */
Kojto 96:487b796308b0 315 #define __HAL_DAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 316 SET_BIT((__HANDLE__)->Instance->CR, __INTERRUPT__)
bogdanm 84:0b3ab51c8877 317
bogdanm 84:0b3ab51c8877 318
Kojto 96:487b796308b0 319 /** @brief Disable the DAC interrupt
Kojto 96:487b796308b0 320 * @param __HANDLE__: specifies the DAC handle
Kojto 96:487b796308b0 321 * @param __INTERRUPT__: specifies the DAC interrupt.
Kojto 96:487b796308b0 322 * @retval None
Kojto 96:487b796308b0 323 */
Kojto 96:487b796308b0 324 #define __HAL_DAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 325 CLEAR_BIT((__HANDLE__)->Instance->CR, __INTERRUPT__)
bogdanm 84:0b3ab51c8877 326
bogdanm 84:0b3ab51c8877 327
Kojto 96:487b796308b0 328 /** @brief Get the selected DAC's flag status.
Kojto 96:487b796308b0 329 * @param __HANDLE__: specifies the DAC handle.
Kojto 96:487b796308b0 330 * @param __FLAG__: specifies the FLAG.
Kojto 96:487b796308b0 331 * @retval None
Kojto 96:487b796308b0 332 */
bogdanm 84:0b3ab51c8877 333 #define __HAL_DAC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
bogdanm 84:0b3ab51c8877 334
Kojto 96:487b796308b0 335 /** @brief Clear the DAC's flag.
Kojto 96:487b796308b0 336 * @param __HANDLE__: specifies the DAC handle.
Kojto 96:487b796308b0 337 * @param __FLAG__: specifies the FLAG.
Kojto 96:487b796308b0 338 * @retval None
Kojto 96:487b796308b0 339 */
bogdanm 92:4fc01daae5a5 340 #define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = (__FLAG__))
bogdanm 84:0b3ab51c8877 341
Kojto 96:487b796308b0 342 /**
Kojto 96:487b796308b0 343 * @}
Kojto 96:487b796308b0 344 */
Kojto 96:487b796308b0 345
Kojto 96:487b796308b0 346
bogdanm 84:0b3ab51c8877 347 /* Include DAC HAL Extension module */
bogdanm 84:0b3ab51c8877 348 #include "stm32l0xx_hal_dac_ex.h"
bogdanm 84:0b3ab51c8877 349
bogdanm 84:0b3ab51c8877 350 /* Exported functions --------------------------------------------------------*/
Kojto 96:487b796308b0 351
Kojto 96:487b796308b0 352 /** @addtogroup DAC_Exported_Functions
Kojto 96:487b796308b0 353 * @{
Kojto 96:487b796308b0 354 */
Kojto 96:487b796308b0 355
Kojto 96:487b796308b0 356 /** @addtogroup DAC_Exported_Functions_Group1
Kojto 96:487b796308b0 357 * @{
Kojto 96:487b796308b0 358 */
Kojto 96:487b796308b0 359 /* Initialization and de-initialization functions *****************************/
bogdanm 84:0b3ab51c8877 360 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 361 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 362 void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 363 void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 364
Kojto 96:487b796308b0 365 /**
Kojto 96:487b796308b0 366 * @}
Kojto 96:487b796308b0 367 */
Kojto 96:487b796308b0 368
Kojto 96:487b796308b0 369 /** @addtogroup DAC_Exported_Functions_Group2
Kojto 96:487b796308b0 370 * @{
Kojto 96:487b796308b0 371 */
Kojto 96:487b796308b0 372 /* IO operation functions *****************************************************/
Kojto 96:487b796308b0 373 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 96:487b796308b0 374 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 96:487b796308b0 375 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment);
Kojto 96:487b796308b0 376 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel);
Kojto 96:487b796308b0 377 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data);
Kojto 96:487b796308b0 378 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel);
bogdanm 84:0b3ab51c8877 379
Kojto 96:487b796308b0 380 /**
Kojto 96:487b796308b0 381 * @}
Kojto 96:487b796308b0 382 */
Kojto 96:487b796308b0 383
Kojto 96:487b796308b0 384 /** @addtogroup DAC_Exported_Functions_Group2
Kojto 96:487b796308b0 385 * @{
Kojto 96:487b796308b0 386 */
bogdanm 84:0b3ab51c8877 387 /* Peripheral Control functions ***********************************************/
Kojto 96:487b796308b0 388 HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel);
bogdanm 84:0b3ab51c8877 389
Kojto 96:487b796308b0 390 /**
Kojto 96:487b796308b0 391 * @}
Kojto 96:487b796308b0 392 */
Kojto 96:487b796308b0 393
Kojto 96:487b796308b0 394 /** @addtogroup DAC_Exported_Functions_Group2
Kojto 96:487b796308b0 395 * @{
Kojto 96:487b796308b0 396 */
Kojto 96:487b796308b0 397 /* Peripheral State functions ***************************************************/
bogdanm 84:0b3ab51c8877 398 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 399 void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 400 uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac);
bogdanm 84:0b3ab51c8877 401
bogdanm 84:0b3ab51c8877 402 void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 403 void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac);
bogdanm 84:0b3ab51c8877 404 void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac);
bogdanm 84:0b3ab51c8877 405 void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac);
bogdanm 84:0b3ab51c8877 406
Kojto 96:487b796308b0 407 /**
Kojto 96:487b796308b0 408 * @}
Kojto 96:487b796308b0 409 */
Kojto 96:487b796308b0 410
Kojto 96:487b796308b0 411 /**
Kojto 96:487b796308b0 412 * @}
Kojto 96:487b796308b0 413 */
Kojto 96:487b796308b0 414
bogdanm 84:0b3ab51c8877 415
bogdanm 84:0b3ab51c8877 416 /**
bogdanm 84:0b3ab51c8877 417 * @}
bogdanm 84:0b3ab51c8877 418 */
bogdanm 84:0b3ab51c8877 419
bogdanm 84:0b3ab51c8877 420 /**
bogdanm 84:0b3ab51c8877 421 * @}
bogdanm 84:0b3ab51c8877 422 */
Kojto 96:487b796308b0 423
Kojto 96:487b796308b0 424 #endif /* STM32L031xx && STM32L041xx && STM32L061xx && STM32L071xx && STM32L081xx*/
bogdanm 84:0b3ab51c8877 425
bogdanm 84:0b3ab51c8877 426 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 427 }
bogdanm 84:0b3ab51c8877 428 #endif
bogdanm 84:0b3ab51c8877 429
bogdanm 84:0b3ab51c8877 430 #endif /*__STM32L0xx_HAL_DAC_H */
bogdanm 84:0b3ab51c8877 431
bogdanm 84:0b3ab51c8877 432 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/