mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
109:9296ab0bfc11
Child:
123:b0220dba8be7
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 109:9296ab0bfc11 1 /**
Kojto 109:9296ab0bfc11 2 ******************************************************************************
Kojto 109:9296ab0bfc11 3 * @file stm32f3xx_hal_adc.h
Kojto 109:9296ab0bfc11 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.2.1
Kojto 122:f9eeca106725 6 * @date 29-April-2015
Kojto 109:9296ab0bfc11 7 * @brief Header file containing functions prototypes of ADC HAL library.
Kojto 109:9296ab0bfc11 8 ******************************************************************************
Kojto 109:9296ab0bfc11 9 * @attention
Kojto 109:9296ab0bfc11 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 109:9296ab0bfc11 12 *
Kojto 109:9296ab0bfc11 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 109:9296ab0bfc11 14 * are permitted provided that the following conditions are met:
Kojto 109:9296ab0bfc11 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 109:9296ab0bfc11 16 * this list of conditions and the following disclaimer.
Kojto 109:9296ab0bfc11 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 109:9296ab0bfc11 18 * this list of conditions and the following disclaimer in the documentation
Kojto 109:9296ab0bfc11 19 * and/or other materials provided with the distribution.
Kojto 109:9296ab0bfc11 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 109:9296ab0bfc11 21 * may be used to endorse or promote products derived from this software
Kojto 109:9296ab0bfc11 22 * without specific prior written permission.
Kojto 109:9296ab0bfc11 23 *
Kojto 109:9296ab0bfc11 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 109:9296ab0bfc11 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 109:9296ab0bfc11 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 109:9296ab0bfc11 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 109:9296ab0bfc11 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 109:9296ab0bfc11 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 109:9296ab0bfc11 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 109:9296ab0bfc11 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 109:9296ab0bfc11 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 109:9296ab0bfc11 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 109:9296ab0bfc11 34 *
Kojto 109:9296ab0bfc11 35 ******************************************************************************
Kojto 109:9296ab0bfc11 36 */
Kojto 109:9296ab0bfc11 37
Kojto 109:9296ab0bfc11 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 109:9296ab0bfc11 39 #ifndef __STM32F3xx_ADC_H
Kojto 109:9296ab0bfc11 40 #define __STM32F3xx_ADC_H
Kojto 109:9296ab0bfc11 41
Kojto 109:9296ab0bfc11 42 #ifdef __cplusplus
Kojto 109:9296ab0bfc11 43 extern "C" {
Kojto 109:9296ab0bfc11 44 #endif
Kojto 109:9296ab0bfc11 45
Kojto 109:9296ab0bfc11 46 /* Includes ------------------------------------------------------------------*/
Kojto 109:9296ab0bfc11 47 #include "stm32f3xx_hal_def.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /* Include ADC HAL Extended module */
Kojto 122:f9eeca106725 50 /* (include on top of file since ADC structures are defined in extended file) */
Kojto 109:9296ab0bfc11 51 #include "stm32f3xx_hal_adc_ex.h"
Kojto 109:9296ab0bfc11 52
Kojto 109:9296ab0bfc11 53 /** @addtogroup STM32F3xx_HAL_Driver
Kojto 109:9296ab0bfc11 54 * @{
Kojto 109:9296ab0bfc11 55 */
Kojto 109:9296ab0bfc11 56
Kojto 109:9296ab0bfc11 57 /** @addtogroup ADC
Kojto 109:9296ab0bfc11 58 * @{
Kojto 109:9296ab0bfc11 59 */
Kojto 109:9296ab0bfc11 60
Kojto 109:9296ab0bfc11 61 /* Exported types ------------------------------------------------------------*/
Kojto 109:9296ab0bfc11 62 /** @defgroup ADC_Exported_Types ADC Exported Types
Kojto 109:9296ab0bfc11 63 * @{
Kojto 122:f9eeca106725 64 */
Kojto 109:9296ab0bfc11 65 /**
Kojto 122:f9eeca106725 66 * @brief HAL ADC state machine: ADC states definition (bitfields)
Kojto 122:f9eeca106725 67 * @note ADC state machine is managed by bitfields, state must be compared
Kojto 122:f9eeca106725 68 * with bit by bit.
Kojto 122:f9eeca106725 69 * For example:
Kojto 122:f9eeca106725 70 * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) "
Kojto 122:f9eeca106725 71 * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) "
Kojto 122:f9eeca106725 72 */
Kojto 122:f9eeca106725 73 /* States of ADC global scope */
Kojto 122:f9eeca106725 74 #define HAL_ADC_STATE_RESET ((uint32_t)0x00000000) /*!< ADC not yet initialized or disabled */
Kojto 122:f9eeca106725 75 #define HAL_ADC_STATE_READY ((uint32_t)0x00000001) /*!< ADC peripheral ready for use */
Kojto 122:f9eeca106725 76 #define HAL_ADC_STATE_BUSY_INTERNAL ((uint32_t)0x00000002) /*!< ADC is busy to internal process (initialization, calibration) */
Kojto 122:f9eeca106725 77 #define HAL_ADC_STATE_TIMEOUT ((uint32_t)0x00000004) /*!< TimeOut occurrence */
Kojto 122:f9eeca106725 78
Kojto 122:f9eeca106725 79 /* States of ADC errors */
Kojto 122:f9eeca106725 80 #define HAL_ADC_STATE_ERROR_INTERNAL ((uint32_t)0x00000010) /*!< Internal error occurrence */
Kojto 122:f9eeca106725 81 #define HAL_ADC_STATE_ERROR_CONFIG ((uint32_t)0x00000020) /*!< Configuration error occurrence */
Kojto 122:f9eeca106725 82 #define HAL_ADC_STATE_ERROR_DMA ((uint32_t)0x00000040) /*!< DMA error occurrence */
Kojto 122:f9eeca106725 83
Kojto 122:f9eeca106725 84 /* States of ADC group regular */
Kojto 122:f9eeca106725 85 #define HAL_ADC_STATE_REG_BUSY ((uint32_t)0x00000100) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
Kojto 122:f9eeca106725 86 external trigger, low power auto power-on, multimode ADC master control) */
Kojto 122:f9eeca106725 87 #define HAL_ADC_STATE_REG_EOC ((uint32_t)0x00000200) /*!< Conversion data available on group regular */
Kojto 122:f9eeca106725 88 #define HAL_ADC_STATE_REG_OVR ((uint32_t)0x00000400) /*!< Not available on STM32F1 device: Overrun occurrence */
Kojto 122:f9eeca106725 89 #define HAL_ADC_STATE_REG_EOSMP ((uint32_t)0x00000800) /*!< Not available on STM32F1 device: End Of Sampling flag raised */
Kojto 122:f9eeca106725 90
Kojto 122:f9eeca106725 91 /* States of ADC group injected */
Kojto 122:f9eeca106725 92 #define HAL_ADC_STATE_INJ_BUSY ((uint32_t)0x00001000) /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
Kojto 122:f9eeca106725 93 external trigger, low power auto power-on, multimode ADC master control) */
Kojto 122:f9eeca106725 94 #define HAL_ADC_STATE_INJ_EOC ((uint32_t)0x00002000) /*!< Conversion data available on group injected */
Kojto 122:f9eeca106725 95 #define HAL_ADC_STATE_INJ_JQOVF ((uint32_t)0x00004000) /*!< Not available on STM32F1 device: Injected queue overflow occurrence */
Kojto 122:f9eeca106725 96
Kojto 122:f9eeca106725 97 /* States of ADC analog watchdogs */
Kojto 122:f9eeca106725 98 #define HAL_ADC_STATE_AWD1 ((uint32_t)0x00010000) /*!< Out-of-window occurrence of analog watchdog 1 */
Kojto 122:f9eeca106725 99 #define HAL_ADC_STATE_AWD2 ((uint32_t)0x00020000) /*!< Not available on STM32F1 device: Out-of-window occurrence of analog watchdog 2 */
Kojto 122:f9eeca106725 100 #define HAL_ADC_STATE_AWD3 ((uint32_t)0x00040000) /*!< Not available on STM32F1 device: Out-of-window occurrence of analog watchdog 3 */
Kojto 122:f9eeca106725 101
Kojto 122:f9eeca106725 102 /* States of ADC multi-mode */
Kojto 122:f9eeca106725 103 #define HAL_ADC_STATE_MULTIMODE_SLAVE ((uint32_t)0x00100000) /*!< ADC in multimode slave state, controlled by another ADC master ( */
Kojto 122:f9eeca106725 104
Kojto 109:9296ab0bfc11 105
Kojto 109:9296ab0bfc11 106 /**
Kojto 109:9296ab0bfc11 107 * @brief ADC handle Structure definition
Kojto 122:f9eeca106725 108 */
Kojto 109:9296ab0bfc11 109 typedef struct __ADC_HandleTypeDef
Kojto 109:9296ab0bfc11 110 {
Kojto 109:9296ab0bfc11 111 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 109:9296ab0bfc11 112
Kojto 109:9296ab0bfc11 113 ADC_InitTypeDef Init; /*!< ADC required parameters */
Kojto 109:9296ab0bfc11 114
Kojto 109:9296ab0bfc11 115 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 109:9296ab0bfc11 116
Kojto 109:9296ab0bfc11 117 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 109:9296ab0bfc11 118
Kojto 122:f9eeca106725 119 __IO uint32_t State; /*!< ADC communication state (bitmap of ADC states) */
Kojto 109:9296ab0bfc11 120
Kojto 109:9296ab0bfc11 121 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 122:f9eeca106725 122
Kojto 122:f9eeca106725 123 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 122:f9eeca106725 124 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
Kojto 122:f9eeca106725 125 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
Kojto 122:f9eeca106725 126 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 127 ADC_InjectionConfigTypeDef InjectionConfig ; /*!< ADC injected channel configuration build-up structure */
Kojto 122:f9eeca106725 128 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 122:f9eeca106725 129 /* STM32F302xC || STM32F303xC || STM32F358xx || */
Kojto 122:f9eeca106725 130 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
Kojto 122:f9eeca106725 131 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
Kojto 122:f9eeca106725 132
Kojto 109:9296ab0bfc11 133 }ADC_HandleTypeDef;
Kojto 109:9296ab0bfc11 134 /**
Kojto 109:9296ab0bfc11 135 * @}
Kojto 109:9296ab0bfc11 136 */
Kojto 109:9296ab0bfc11 137
Kojto 109:9296ab0bfc11 138 /* Exported constants --------------------------------------------------------*/
Kojto 109:9296ab0bfc11 139 /* Exported macros -----------------------------------------------------------*/
Kojto 109:9296ab0bfc11 140
Kojto 109:9296ab0bfc11 141 /** @defgroup ADC_Exported_Macro ADC Exported Macros
Kojto 109:9296ab0bfc11 142 * @{
Kojto 109:9296ab0bfc11 143 */
Kojto 109:9296ab0bfc11 144 /** @brief Reset ADC handle state
Kojto 109:9296ab0bfc11 145 * @param __HANDLE__: ADC handle
Kojto 109:9296ab0bfc11 146 * @retval None
Kojto 109:9296ab0bfc11 147 */
Kojto 109:9296ab0bfc11 148 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 109:9296ab0bfc11 149
Kojto 109:9296ab0bfc11 150 /**
Kojto 109:9296ab0bfc11 151 * @}
Kojto 109:9296ab0bfc11 152 */
Kojto 109:9296ab0bfc11 153
Kojto 109:9296ab0bfc11 154
Kojto 109:9296ab0bfc11 155
Kojto 109:9296ab0bfc11 156 /* Exported functions --------------------------------------------------------*/
Kojto 109:9296ab0bfc11 157 /** @addtogroup ADC_Exported_Functions ADC Exported Functions
Kojto 109:9296ab0bfc11 158 * @{
Kojto 109:9296ab0bfc11 159 */
Kojto 109:9296ab0bfc11 160
Kojto 109:9296ab0bfc11 161 /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 109:9296ab0bfc11 162 * @{
Kojto 109:9296ab0bfc11 163 */
Kojto 109:9296ab0bfc11 164 /* Initialization and de-initialization functions **********************************/
Kojto 109:9296ab0bfc11 165 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 166 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 109:9296ab0bfc11 167 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 168 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 169 /**
Kojto 109:9296ab0bfc11 170 * @}
Kojto 109:9296ab0bfc11 171 */
Kojto 109:9296ab0bfc11 172
Kojto 109:9296ab0bfc11 173 /** @addtogroup ADC_Exported_Functions_Group2 Input and Output operation functions
Kojto 109:9296ab0bfc11 174 * @{
Kojto 109:9296ab0bfc11 175 */
Kojto 109:9296ab0bfc11 176 /* Blocking mode: Polling */
Kojto 109:9296ab0bfc11 177 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 178 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 179 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 109:9296ab0bfc11 180 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 109:9296ab0bfc11 181
Kojto 109:9296ab0bfc11 182 /* Non-blocking mode: Interruption */
Kojto 109:9296ab0bfc11 183 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 184 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 185
Kojto 109:9296ab0bfc11 186 /* Non-blocking mode: DMA */
Kojto 109:9296ab0bfc11 187 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 109:9296ab0bfc11 188 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 189
Kojto 109:9296ab0bfc11 190 /* ADC retrieve conversion value intended to be used with polling or interruption */
Kojto 109:9296ab0bfc11 191 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 192
Kojto 109:9296ab0bfc11 193 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
Kojto 109:9296ab0bfc11 194 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 195 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 196 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 197 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 198 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 109:9296ab0bfc11 199 /**
Kojto 109:9296ab0bfc11 200 * @}
Kojto 109:9296ab0bfc11 201 */
Kojto 109:9296ab0bfc11 202
Kojto 109:9296ab0bfc11 203 /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
Kojto 109:9296ab0bfc11 204 * @{
Kojto 109:9296ab0bfc11 205 */
Kojto 109:9296ab0bfc11 206 /* Peripheral Control functions ***********************************************/
Kojto 109:9296ab0bfc11 207 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 109:9296ab0bfc11 208 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 109:9296ab0bfc11 209 /**
Kojto 109:9296ab0bfc11 210 * @}
Kojto 109:9296ab0bfc11 211 */
Kojto 109:9296ab0bfc11 212
Kojto 109:9296ab0bfc11 213 /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
Kojto 109:9296ab0bfc11 214 * @brief ADC Peripheral State functions
Kojto 109:9296ab0bfc11 215 * @{
Kojto 109:9296ab0bfc11 216 */
Kojto 109:9296ab0bfc11 217 /* Peripheral State functions *************************************************/
Kojto 122:f9eeca106725 218 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 109:9296ab0bfc11 219 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 109:9296ab0bfc11 220 /**
Kojto 109:9296ab0bfc11 221 * @}
Kojto 109:9296ab0bfc11 222 */
Kojto 109:9296ab0bfc11 223
Kojto 109:9296ab0bfc11 224 /**
Kojto 109:9296ab0bfc11 225 * @}
Kojto 109:9296ab0bfc11 226 */
Kojto 109:9296ab0bfc11 227
Kojto 109:9296ab0bfc11 228 /**
Kojto 109:9296ab0bfc11 229 * @}
Kojto 109:9296ab0bfc11 230 */
Kojto 109:9296ab0bfc11 231
Kojto 109:9296ab0bfc11 232 /**
Kojto 109:9296ab0bfc11 233 * @}
Kojto 109:9296ab0bfc11 234 */
Kojto 109:9296ab0bfc11 235
Kojto 109:9296ab0bfc11 236 #ifdef __cplusplus
Kojto 109:9296ab0bfc11 237 }
Kojto 109:9296ab0bfc11 238 #endif
Kojto 109:9296ab0bfc11 239
Kojto 109:9296ab0bfc11 240 #endif /*__STM32F3xx_ADC_H */
Kojto 109:9296ab0bfc11 241
Kojto 109:9296ab0bfc11 242
Kojto 109:9296ab0bfc11 243 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/