my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Wed Jun 11 15:14:05 2014 +0100
Revision:
85:024bf7f99721
Child:
92:4fc01daae5a5
Release 85 of the mbed library

Main changes:

- K64F Ethernet fixes
- Updated tests
- Fixes for various mbed targets
- Code cleanup: fixed warnings, more consistent code style
- GCC support for K64F

There is a known issue with the I2C interface on some ST targets. If you
find the I2C interface problematic on your ST board, please log a bug
against this on mbed.org.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 85:024bf7f99721 1 /**
bogdanm 85:024bf7f99721 2 ******************************************************************************
bogdanm 85:024bf7f99721 3 * @file stm32f0xx_hal_dac.h
bogdanm 85:024bf7f99721 4 * @author MCD Application Team
bogdanm 85:024bf7f99721 5 * @version V1.0.0
bogdanm 85:024bf7f99721 6 * @date 28-May-2014
bogdanm 85:024bf7f99721 7 * @brief Header file of DAC HAL module.
bogdanm 85:024bf7f99721 8 ******************************************************************************
bogdanm 85:024bf7f99721 9 * @attention
bogdanm 85:024bf7f99721 10 *
bogdanm 85:024bf7f99721 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 85:024bf7f99721 12 *
bogdanm 85:024bf7f99721 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 85:024bf7f99721 14 * are permitted provided that the following conditions are met:
bogdanm 85:024bf7f99721 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 85:024bf7f99721 16 * this list of conditions and the following disclaimer.
bogdanm 85:024bf7f99721 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 85:024bf7f99721 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 85:024bf7f99721 19 * and/or other materials provided with the distribution.
bogdanm 85:024bf7f99721 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 85:024bf7f99721 21 * may be used to endorse or promote products derived from this software
bogdanm 85:024bf7f99721 22 * without specific prior written permission.
bogdanm 85:024bf7f99721 23 *
bogdanm 85:024bf7f99721 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 85:024bf7f99721 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 85:024bf7f99721 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 85:024bf7f99721 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 85:024bf7f99721 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 85:024bf7f99721 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 85:024bf7f99721 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 85:024bf7f99721 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 85:024bf7f99721 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 85:024bf7f99721 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 85:024bf7f99721 34 *
bogdanm 85:024bf7f99721 35 ******************************************************************************
bogdanm 85:024bf7f99721 36 */
bogdanm 85:024bf7f99721 37
bogdanm 85:024bf7f99721 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 85:024bf7f99721 39 #ifndef __STM32F0xx_HAL_DAC_H
bogdanm 85:024bf7f99721 40 #define __STM32F0xx_HAL_DAC_H
bogdanm 85:024bf7f99721 41
bogdanm 85:024bf7f99721 42 #ifdef __cplusplus
bogdanm 85:024bf7f99721 43 extern "C" {
bogdanm 85:024bf7f99721 44 #endif
bogdanm 85:024bf7f99721 45
bogdanm 85:024bf7f99721 46 #if defined(STM32F051x8) || defined(STM32F058xx) || \
bogdanm 85:024bf7f99721 47 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
bogdanm 85:024bf7f99721 48
bogdanm 85:024bf7f99721 49 /* Includes ------------------------------------------------------------------*/
bogdanm 85:024bf7f99721 50 #include "stm32f0xx_hal_def.h"
bogdanm 85:024bf7f99721 51
bogdanm 85:024bf7f99721 52 /** @addtogroup STM32F0xx_HAL_Driver
bogdanm 85:024bf7f99721 53 * @{
bogdanm 85:024bf7f99721 54 */
bogdanm 85:024bf7f99721 55
bogdanm 85:024bf7f99721 56 /** @addtogroup DAC
bogdanm 85:024bf7f99721 57 * @{
bogdanm 85:024bf7f99721 58 */
bogdanm 85:024bf7f99721 59
bogdanm 85:024bf7f99721 60 /* Exported types ------------------------------------------------------------*/
bogdanm 85:024bf7f99721 61
bogdanm 85:024bf7f99721 62 /**
bogdanm 85:024bf7f99721 63 * @brief HAL State structures definition
bogdanm 85:024bf7f99721 64 */
bogdanm 85:024bf7f99721 65 typedef enum
bogdanm 85:024bf7f99721 66 {
bogdanm 85:024bf7f99721 67 HAL_DAC_STATE_RESET = 0x00, /*!< DAC not yet initialized or disabled */
bogdanm 85:024bf7f99721 68 HAL_DAC_STATE_READY = 0x01, /*!< DAC initialized and ready for use */
bogdanm 85:024bf7f99721 69 HAL_DAC_STATE_BUSY = 0x02, /*!< DAC internal processing is ongoing */
bogdanm 85:024bf7f99721 70 HAL_DAC_STATE_TIMEOUT = 0x03, /*!< DAC timeout state */
bogdanm 85:024bf7f99721 71 HAL_DAC_STATE_ERROR = 0x04 /*!< DAC error state */
bogdanm 85:024bf7f99721 72
bogdanm 85:024bf7f99721 73 }HAL_DAC_StateTypeDef;
bogdanm 85:024bf7f99721 74
bogdanm 85:024bf7f99721 75 /**
bogdanm 85:024bf7f99721 76 * @brief DAC handle Structure definition
bogdanm 85:024bf7f99721 77 */
bogdanm 85:024bf7f99721 78 typedef struct
bogdanm 85:024bf7f99721 79 {
bogdanm 85:024bf7f99721 80 DAC_TypeDef *Instance; /*!< Register base address */
bogdanm 85:024bf7f99721 81
bogdanm 85:024bf7f99721 82 __IO HAL_DAC_StateTypeDef State; /*!< DAC communication state */
bogdanm 85:024bf7f99721 83
bogdanm 85:024bf7f99721 84 HAL_LockTypeDef Lock; /*!< DAC locking object */
bogdanm 85:024bf7f99721 85
bogdanm 85:024bf7f99721 86 DMA_HandleTypeDef *DMA_Handle1; /*!< Pointer DMA handler for channel 1 */
bogdanm 85:024bf7f99721 87
bogdanm 85:024bf7f99721 88 DMA_HandleTypeDef *DMA_Handle2; /*!< Pointer DMA handler for channel 2 */
bogdanm 85:024bf7f99721 89
bogdanm 85:024bf7f99721 90 __IO uint32_t ErrorCode; /*!< DAC Error code */
bogdanm 85:024bf7f99721 91
bogdanm 85:024bf7f99721 92 }DAC_HandleTypeDef;
bogdanm 85:024bf7f99721 93
bogdanm 85:024bf7f99721 94 /**
bogdanm 85:024bf7f99721 95 * @brief DAC Configuration regular Channel structure definition
bogdanm 85:024bf7f99721 96 */
bogdanm 85:024bf7f99721 97 typedef struct
bogdanm 85:024bf7f99721 98 {
bogdanm 85:024bf7f99721 99 uint32_t DAC_Trigger; /*!< Specifies the external trigger for the selected DAC channel.
bogdanm 85:024bf7f99721 100 This parameter can be a value of @ref DAC_trigger_selection */
bogdanm 85:024bf7f99721 101
bogdanm 85:024bf7f99721 102 uint32_t DAC_OutputBuffer; /*!< Specifies whether the DAC channel output buffer is enabled or disabled.
bogdanm 85:024bf7f99721 103 This parameter can be a value of @ref DAC_output_buffer */
bogdanm 85:024bf7f99721 104
bogdanm 85:024bf7f99721 105 }DAC_ChannelConfTypeDef;
bogdanm 85:024bf7f99721 106
bogdanm 85:024bf7f99721 107 /* Exported constants --------------------------------------------------------*/
bogdanm 85:024bf7f99721 108
bogdanm 85:024bf7f99721 109 /** @defgroup DAC_Error_Code
bogdanm 85:024bf7f99721 110 * @{
bogdanm 85:024bf7f99721 111 */
bogdanm 85:024bf7f99721 112 #define HAL_DAC_ERROR_NONE 0x00 /*!< No error */
bogdanm 85:024bf7f99721 113 #define HAL_DAC_ERROR_DMAUNDERRUNCH1 0x01 /*!< DAC channel1 DAM underrun error */
bogdanm 85:024bf7f99721 114 #define HAL_DAC_ERROR_DMAUNDERRUNCH2 0x02 /*!< DAC channel2 DAM underrun error */
bogdanm 85:024bf7f99721 115 #define HAL_DAC_ERROR_DMA 0x04 /*!< DMA error */
bogdanm 85:024bf7f99721 116 /**
bogdanm 85:024bf7f99721 117 * @}
bogdanm 85:024bf7f99721 118 */
bogdanm 85:024bf7f99721 119
bogdanm 85:024bf7f99721 120 /** @defgroup DAC_output_buffer
bogdanm 85:024bf7f99721 121 * @{
bogdanm 85:024bf7f99721 122 */
bogdanm 85:024bf7f99721 123 #define DAC_OUTPUTBUFFER_ENABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 124 #define DAC_OUTPUTBUFFER_DISABLE ((uint32_t)DAC_CR_BOFF1)
bogdanm 85:024bf7f99721 125
bogdanm 85:024bf7f99721 126 #define IS_DAC_OUTPUT_BUFFER_STATE(STATE) (((STATE) == DAC_OUTPUTBUFFER_ENABLE) || \
bogdanm 85:024bf7f99721 127 ((STATE) == DAC_OUTPUTBUFFER_DISABLE))
bogdanm 85:024bf7f99721 128 /**
bogdanm 85:024bf7f99721 129 * @}
bogdanm 85:024bf7f99721 130 */
bogdanm 85:024bf7f99721 131
bogdanm 85:024bf7f99721 132 /** @defgroup DAC_data_alignement
bogdanm 85:024bf7f99721 133 * @{
bogdanm 85:024bf7f99721 134 */
bogdanm 85:024bf7f99721 135 #define DAC_ALIGN_12B_R ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 136 #define DAC_ALIGN_12B_L ((uint32_t)0x00000004)
bogdanm 85:024bf7f99721 137 #define DAC_ALIGN_8B_R ((uint32_t)0x00000008)
bogdanm 85:024bf7f99721 138
bogdanm 85:024bf7f99721 139 #define IS_DAC_ALIGN(ALIGN) (((ALIGN) == DAC_ALIGN_12B_R) || \
bogdanm 85:024bf7f99721 140 ((ALIGN) == DAC_ALIGN_12B_L) || \
bogdanm 85:024bf7f99721 141 ((ALIGN) == DAC_ALIGN_8B_R))
bogdanm 85:024bf7f99721 142 /**
bogdanm 85:024bf7f99721 143 * @}
bogdanm 85:024bf7f99721 144 */
bogdanm 85:024bf7f99721 145
bogdanm 85:024bf7f99721 146 /** @defgroup DAC_data
bogdanm 85:024bf7f99721 147 * @{
bogdanm 85:024bf7f99721 148 */
bogdanm 85:024bf7f99721 149 #define IS_DAC_DATA(DATA) ((DATA) <= 0xFFF0)
bogdanm 85:024bf7f99721 150 /**
bogdanm 85:024bf7f99721 151 * @}
bogdanm 85:024bf7f99721 152 */
bogdanm 85:024bf7f99721 153
bogdanm 85:024bf7f99721 154 /** @defgroup DAC_flags_definition
bogdanm 85:024bf7f99721 155 * @{
bogdanm 85:024bf7f99721 156 */
bogdanm 85:024bf7f99721 157 #define DAC_FLAG_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1)
bogdanm 85:024bf7f99721 158 #define DAC_FLAG_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2)
bogdanm 85:024bf7f99721 159
bogdanm 85:024bf7f99721 160 #define IS_DAC_FLAG(FLAG) (((FLAG) == DAC_FLAG_DMAUDR1) || \
bogdanm 85:024bf7f99721 161 ((FLAG) == DAC_FLAG_DMAUDR2))
bogdanm 85:024bf7f99721 162 /**
bogdanm 85:024bf7f99721 163 * @}
bogdanm 85:024bf7f99721 164 */
bogdanm 85:024bf7f99721 165
bogdanm 85:024bf7f99721 166 /** @defgroup DAC_IT_definition
bogdanm 85:024bf7f99721 167 * @{
bogdanm 85:024bf7f99721 168 */
bogdanm 85:024bf7f99721 169 #define DAC_IT_DMAUDR1 ((uint32_t)DAC_SR_DMAUDR1)
bogdanm 85:024bf7f99721 170 #define DAC_IT_DMAUDR2 ((uint32_t)DAC_SR_DMAUDR2)
bogdanm 85:024bf7f99721 171
bogdanm 85:024bf7f99721 172 #define IS_DAC_IT(IT) (((IT) == DAC_IT_DMAUDR1) || \
bogdanm 85:024bf7f99721 173 ((IT) == DAC_IT_DMAUDR2))
bogdanm 85:024bf7f99721 174
bogdanm 85:024bf7f99721 175 /**
bogdanm 85:024bf7f99721 176 * @}
bogdanm 85:024bf7f99721 177 */
bogdanm 85:024bf7f99721 178
bogdanm 85:024bf7f99721 179 /* Exported macros -----------------------------------------------------------*/
bogdanm 85:024bf7f99721 180
bogdanm 85:024bf7f99721 181 /** @brief Reset DAC handle state
bogdanm 85:024bf7f99721 182 * @param __HANDLE__: DAC handle.
bogdanm 85:024bf7f99721 183 * @retval None
bogdanm 85:024bf7f99721 184 */
bogdanm 85:024bf7f99721 185 #define __HAL_DAC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DAC_STATE_RESET)
bogdanm 85:024bf7f99721 186
bogdanm 85:024bf7f99721 187 /* Enable the DAC peripheral */
bogdanm 85:024bf7f99721 188 #define __HAL_DAC_ENABLE(__HANDLE__, __DAC_Channel__) \
bogdanm 85:024bf7f99721 189 ((__HANDLE__)->Instance->CR |= (DAC_CR_EN1 << (__DAC_Channel__)))
bogdanm 85:024bf7f99721 190
bogdanm 85:024bf7f99721 191 /* Disable the DAC peripheral */
bogdanm 85:024bf7f99721 192 #define __HAL_DAC_DISABLE(__HANDLE__, __DAC_Channel__) \
bogdanm 85:024bf7f99721 193 ((__HANDLE__)->Instance->CR &= ~(DAC_CR_EN1 << (__DAC_Channel__)))
bogdanm 85:024bf7f99721 194
bogdanm 85:024bf7f99721 195 /* Set DHR12R1 alignment */
bogdanm 85:024bf7f99721 196 #define __HAL_DHR12R1_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000008) + (__ALIGNEMENT__))
bogdanm 85:024bf7f99721 197
bogdanm 85:024bf7f99721 198 /* Set DHR12R2 alignment */
bogdanm 85:024bf7f99721 199 #define __HAL_DHR12R2_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000014) + (__ALIGNEMENT__))
bogdanm 85:024bf7f99721 200
bogdanm 85:024bf7f99721 201 /* Set DHR12RD alignment */
bogdanm 85:024bf7f99721 202 #define __HAL_DHR12RD_ALIGNEMENT(__ALIGNEMENT__) (((uint32_t)0x00000020) + (__ALIGNEMENT__))
bogdanm 85:024bf7f99721 203
bogdanm 85:024bf7f99721 204 /* Enable the DAC interrupt */
bogdanm 85:024bf7f99721 205 #define __HAL_DAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) |= (__INTERRUPT__))
bogdanm 85:024bf7f99721 206
bogdanm 85:024bf7f99721 207 /* Disable the DAC interrupt */
bogdanm 85:024bf7f99721 208 #define __HAL_DAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR) &= ~(__INTERRUPT__))
bogdanm 85:024bf7f99721 209
bogdanm 85:024bf7f99721 210 /* Get the selected DAC's flag status */
bogdanm 85:024bf7f99721 211 #define __HAL_DAC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
bogdanm 85:024bf7f99721 212
bogdanm 85:024bf7f99721 213 /* Clear the DAC's flag */
bogdanm 85:024bf7f99721 214 #define __HAL_DAC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) |= (__FLAG__))
bogdanm 85:024bf7f99721 215
bogdanm 85:024bf7f99721 216 /* Include DAC HAL Extension module */
bogdanm 85:024bf7f99721 217 #include "stm32f0xx_hal_dac_ex.h"
bogdanm 85:024bf7f99721 218
bogdanm 85:024bf7f99721 219 /* Exported functions --------------------------------------------------------*/
bogdanm 85:024bf7f99721 220 /* Initialization and de-initialization functions *****************************/
bogdanm 85:024bf7f99721 221 HAL_StatusTypeDef HAL_DAC_Init(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 222 HAL_StatusTypeDef HAL_DAC_DeInit(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 223 void HAL_DAC_MspInit(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 224 void HAL_DAC_MspDeInit(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 225
bogdanm 85:024bf7f99721 226 /* IO operation functions *****************************************************/
bogdanm 85:024bf7f99721 227 HAL_StatusTypeDef HAL_DAC_Start(DAC_HandleTypeDef* hdac, uint32_t Channel);
bogdanm 85:024bf7f99721 228 HAL_StatusTypeDef HAL_DAC_Stop(DAC_HandleTypeDef* hdac, uint32_t Channel);
bogdanm 85:024bf7f99721 229 HAL_StatusTypeDef HAL_DAC_Start_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t* pData, uint32_t Length, uint32_t Alignment);
bogdanm 85:024bf7f99721 230 HAL_StatusTypeDef HAL_DAC_Stop_DMA(DAC_HandleTypeDef* hdac, uint32_t Channel);
bogdanm 85:024bf7f99721 231
bogdanm 85:024bf7f99721 232 /* Peripheral Control functions ***********************************************/
bogdanm 85:024bf7f99721 233 HAL_StatusTypeDef HAL_DAC_ConfigChannel(DAC_HandleTypeDef* hdac, DAC_ChannelConfTypeDef* sConfig, uint32_t Channel);
bogdanm 85:024bf7f99721 234 HAL_StatusTypeDef HAL_DAC_SetValue(DAC_HandleTypeDef* hdac, uint32_t Channel, uint32_t Alignment, uint32_t Data);
bogdanm 85:024bf7f99721 235 uint32_t HAL_DAC_GetValue(DAC_HandleTypeDef* hdac, uint32_t Channel);
bogdanm 85:024bf7f99721 236
bogdanm 85:024bf7f99721 237 /* Peripheral State and Error functions ***************************************/
bogdanm 85:024bf7f99721 238 HAL_DAC_StateTypeDef HAL_DAC_GetState(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 239 void HAL_DAC_IRQHandler(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 240 uint32_t HAL_DAC_GetError(DAC_HandleTypeDef *hdac);
bogdanm 85:024bf7f99721 241
bogdanm 85:024bf7f99721 242 void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 243 void HAL_DAC_ConvHalfCpltCallbackCh1(DAC_HandleTypeDef* hdac);
bogdanm 85:024bf7f99721 244 void HAL_DAC_ErrorCallbackCh1(DAC_HandleTypeDef *hdac);
bogdanm 85:024bf7f99721 245 void HAL_DAC_DMAUnderrunCallbackCh1(DAC_HandleTypeDef *hdac);
bogdanm 85:024bf7f99721 246
bogdanm 85:024bf7f99721 247 #endif /* */
bogdanm 85:024bf7f99721 248
bogdanm 85:024bf7f99721 249 /**
bogdanm 85:024bf7f99721 250 * @}
bogdanm 85:024bf7f99721 251 */
bogdanm 85:024bf7f99721 252
bogdanm 85:024bf7f99721 253 /**
bogdanm 85:024bf7f99721 254 * @}
bogdanm 85:024bf7f99721 255 */
bogdanm 85:024bf7f99721 256
bogdanm 85:024bf7f99721 257 #ifdef __cplusplus
bogdanm 85:024bf7f99721 258 }
bogdanm 85:024bf7f99721 259 #endif /* STM32F051x8 || STM32F058xx || */
bogdanm 85:024bf7f99721 260 /* STM32F071xB || STM32F072xB || STM32F078xx */
bogdanm 85:024bf7f99721 261
bogdanm 85:024bf7f99721 262
bogdanm 85:024bf7f99721 263 #endif /*__STM32F0xx_HAL_DAC_H */
bogdanm 85:024bf7f99721 264
bogdanm 85:024bf7f99721 265 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/