Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed Sep 16 15:32:31 2015 +0100
Revision:
107:4f6c30876dfa
Release 107  of the mbed library

Changes:
- new platforms - DISCO_F746NG, DISCO_L476VG, NUCLEO_L476RG
- KL43Z - bugfix RTC init function
- K20 - SPI mode fix

Who changed what in which revision?

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