The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
92:4fc01daae5a5
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
bogdanm 86:04dd9b1680ae 1 /**
bogdanm 86:04dd9b1680ae 2 ******************************************************************************
bogdanm 86:04dd9b1680ae 3 * @file stm32f3xx_hal_sdadc.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.2.1
Kojto 122:f9eeca106725 6 * @date 29-April-2015
bogdanm 86:04dd9b1680ae 7 * @brief This file contains all the functions prototypes for the SDADC
bogdanm 86:04dd9b1680ae 8 * firmware library.
bogdanm 86:04dd9b1680ae 9 ******************************************************************************
bogdanm 86:04dd9b1680ae 10 * @attention
bogdanm 86:04dd9b1680ae 11 *
Kojto 122:f9eeca106725 12 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
bogdanm 86:04dd9b1680ae 13 *
bogdanm 86:04dd9b1680ae 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 86:04dd9b1680ae 15 * are permitted provided that the following conditions are met:
bogdanm 86:04dd9b1680ae 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 86:04dd9b1680ae 17 * this list of conditions and the following disclaimer.
bogdanm 86:04dd9b1680ae 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 86:04dd9b1680ae 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 86:04dd9b1680ae 20 * and/or other materials provided with the distribution.
bogdanm 86:04dd9b1680ae 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 86:04dd9b1680ae 22 * may be used to endorse or promote products derived from this software
bogdanm 86:04dd9b1680ae 23 * without specific prior written permission.
bogdanm 86:04dd9b1680ae 24 *
bogdanm 86:04dd9b1680ae 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 86:04dd9b1680ae 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 86:04dd9b1680ae 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 86:04dd9b1680ae 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 86:04dd9b1680ae 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 86:04dd9b1680ae 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 86:04dd9b1680ae 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 86:04dd9b1680ae 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 86:04dd9b1680ae 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 86:04dd9b1680ae 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 86:04dd9b1680ae 35 *
bogdanm 86:04dd9b1680ae 36 ******************************************************************************
bogdanm 86:04dd9b1680ae 37 */
bogdanm 86:04dd9b1680ae 38
bogdanm 86:04dd9b1680ae 39 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 86:04dd9b1680ae 40 #ifndef __STM32F3xx_SDADC_H
bogdanm 86:04dd9b1680ae 41 #define __STM32F3xx_SDADC_H
bogdanm 86:04dd9b1680ae 42
bogdanm 86:04dd9b1680ae 43 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 44 extern "C" {
bogdanm 86:04dd9b1680ae 45 #endif
bogdanm 86:04dd9b1680ae 46
bogdanm 86:04dd9b1680ae 47 #if defined(STM32F373xC) || defined(STM32F378xx)
bogdanm 86:04dd9b1680ae 48
bogdanm 86:04dd9b1680ae 49 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 50 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 51
bogdanm 86:04dd9b1680ae 52 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 53 * @{
bogdanm 86:04dd9b1680ae 54 */
bogdanm 86:04dd9b1680ae 55
bogdanm 86:04dd9b1680ae 56 /** @addtogroup SDADC
bogdanm 86:04dd9b1680ae 57 * @{
bogdanm 86:04dd9b1680ae 58 */
bogdanm 86:04dd9b1680ae 59
bogdanm 86:04dd9b1680ae 60 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 61 /** @defgroup SDADC_Exported_Types SDADC Exported Types
bogdanm 92:4fc01daae5a5 62 * @{
bogdanm 92:4fc01daae5a5 63 */
bogdanm 92:4fc01daae5a5 64
bogdanm 86:04dd9b1680ae 65
bogdanm 86:04dd9b1680ae 66 /**
bogdanm 86:04dd9b1680ae 67 * @brief HAL SDADC States definition
bogdanm 86:04dd9b1680ae 68 */
bogdanm 86:04dd9b1680ae 69 typedef enum
bogdanm 86:04dd9b1680ae 70 {
bogdanm 86:04dd9b1680ae 71 HAL_SDADC_STATE_RESET = 0x00, /*!< SDADC not initialized */
bogdanm 86:04dd9b1680ae 72 HAL_SDADC_STATE_READY = 0x01, /*!< SDADC initialized and ready for use */
bogdanm 86:04dd9b1680ae 73 HAL_SDADC_STATE_CALIB = 0x02, /*!< SDADC calibration in progress */
bogdanm 86:04dd9b1680ae 74 HAL_SDADC_STATE_REG = 0x03, /*!< SDADC regular conversion in progress */
bogdanm 86:04dd9b1680ae 75 HAL_SDADC_STATE_INJ = 0x04, /*!< SDADC injected conversion in progress */
bogdanm 86:04dd9b1680ae 76 HAL_SDADC_STATE_REG_INJ = 0x05, /*!< SDADC regular and injected conversions in progress */
bogdanm 86:04dd9b1680ae 77 HAL_SDADC_STATE_ERROR = 0xFF, /*!< SDADC state error */
bogdanm 86:04dd9b1680ae 78 }HAL_SDADC_StateTypeDef;
bogdanm 86:04dd9b1680ae 79
bogdanm 86:04dd9b1680ae 80 /**
bogdanm 86:04dd9b1680ae 81 * @brief SDADC Init Structure definition
bogdanm 86:04dd9b1680ae 82 */
bogdanm 86:04dd9b1680ae 83 typedef struct
bogdanm 86:04dd9b1680ae 84 {
bogdanm 86:04dd9b1680ae 85 uint32_t IdleLowPowerMode; /*!< Specifies if SDADC can enter in power down or standby when idle.
bogdanm 86:04dd9b1680ae 86 This parameter can be a value of @ref SDADC_Idle_Low_Power_Mode */
bogdanm 86:04dd9b1680ae 87 uint32_t FastConversionMode; /*!< Specifies if Fast conversion mode is enabled or not.
bogdanm 86:04dd9b1680ae 88 This parameter can be a value of @ref SDADC_Fast_Conv_Mode */
bogdanm 86:04dd9b1680ae 89 uint32_t SlowClockMode; /*!< Specifies if slow clock mode is enabled or not.
bogdanm 86:04dd9b1680ae 90 This parameter can be a value of @ref SDADC_Slow_Clock_Mode */
bogdanm 86:04dd9b1680ae 91 uint32_t ReferenceVoltage; /*!< Specifies the reference voltage.
Kojto 122:f9eeca106725 92 Note: This parameter is common to all SDADC instances.
bogdanm 86:04dd9b1680ae 93 This parameter can be a value of @ref SDADC_Reference_Voltage */
bogdanm 86:04dd9b1680ae 94 }SDADC_InitTypeDef;
bogdanm 86:04dd9b1680ae 95
bogdanm 86:04dd9b1680ae 96 /**
bogdanm 86:04dd9b1680ae 97 * @brief SDADC handle Structure definition
bogdanm 86:04dd9b1680ae 98 */
bogdanm 86:04dd9b1680ae 99 typedef struct
bogdanm 86:04dd9b1680ae 100 {
bogdanm 86:04dd9b1680ae 101 SDADC_TypeDef *Instance; /*!< SDADC registers base address */
bogdanm 86:04dd9b1680ae 102 SDADC_InitTypeDef Init; /*!< SDADC init parameters */
bogdanm 86:04dd9b1680ae 103 DMA_HandleTypeDef *hdma; /*!< SDADC DMA Handle parameters */
bogdanm 86:04dd9b1680ae 104 uint32_t RegularContMode; /*!< Regular conversion continuous mode */
bogdanm 86:04dd9b1680ae 105 uint32_t InjectedContMode; /*!< Injected conversion continuous mode */
bogdanm 86:04dd9b1680ae 106 uint32_t InjectedChannelsNbr; /*!< Number of channels in injected sequence */
bogdanm 86:04dd9b1680ae 107 uint32_t InjConvRemaining; /*!< Injected conversion remaining */
bogdanm 86:04dd9b1680ae 108 uint32_t RegularTrigger; /*!< Current trigger used for regular conversion */
bogdanm 86:04dd9b1680ae 109 uint32_t InjectedTrigger; /*!< Current trigger used for injected conversion */
bogdanm 86:04dd9b1680ae 110 uint32_t ExtTriggerEdge; /*!< Rising, falling or both edges selected */
bogdanm 86:04dd9b1680ae 111 uint32_t RegularMultimode; /*!< current type of regular multimode */
bogdanm 86:04dd9b1680ae 112 uint32_t InjectedMultimode; /*!< Current type of injected multimode */
bogdanm 86:04dd9b1680ae 113 HAL_SDADC_StateTypeDef State; /*!< SDADC state */
bogdanm 86:04dd9b1680ae 114 uint32_t ErrorCode; /*!< SDADC Error code */
bogdanm 86:04dd9b1680ae 115 }SDADC_HandleTypeDef;
bogdanm 86:04dd9b1680ae 116
bogdanm 86:04dd9b1680ae 117 /**
bogdanm 86:04dd9b1680ae 118 * @brief SDADC Configuration Register Parameter Structure
bogdanm 86:04dd9b1680ae 119 */
bogdanm 86:04dd9b1680ae 120 typedef struct
bogdanm 86:04dd9b1680ae 121 {
bogdanm 86:04dd9b1680ae 122 uint32_t InputMode; /*!< Specifies the input mode (single ended, differential...)
bogdanm 86:04dd9b1680ae 123 This parameter can be any value of @ref SDADC_InputMode */
bogdanm 86:04dd9b1680ae 124 uint32_t Gain; /*!< Specifies the gain setting.
bogdanm 86:04dd9b1680ae 125 This parameter can be any value of @ref SDADC_Gain */
bogdanm 86:04dd9b1680ae 126 uint32_t CommonMode; /*!< Specifies the common mode setting (VSSA, VDDA, VDDA/2).
bogdanm 86:04dd9b1680ae 127 This parameter can be any value of @ref SDADC_CommonMode */
bogdanm 86:04dd9b1680ae 128 uint32_t Offset; /*!< Specifies the 12-bit offset value.
bogdanm 86:04dd9b1680ae 129 This parameter can be any value lower or equal to 0x00000FFF */
bogdanm 86:04dd9b1680ae 130 }SDADC_ConfParamTypeDef;
bogdanm 86:04dd9b1680ae 131
bogdanm 92:4fc01daae5a5 132 /**
bogdanm 92:4fc01daae5a5 133 * @}
bogdanm 92:4fc01daae5a5 134 */
bogdanm 92:4fc01daae5a5 135
bogdanm 92:4fc01daae5a5 136 /* Exported constants --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 137
bogdanm 92:4fc01daae5a5 138 /** @defgroup SDADC_Exported_Constants SDADC Exported Constants
bogdanm 92:4fc01daae5a5 139 * @{
bogdanm 92:4fc01daae5a5 140 */
bogdanm 92:4fc01daae5a5 141
bogdanm 92:4fc01daae5a5 142 /** @defgroup SDADC_Idle_Low_Power_Mode SDADC Idle Low Power Mode
bogdanm 86:04dd9b1680ae 143 * @{
bogdanm 86:04dd9b1680ae 144 */
bogdanm 86:04dd9b1680ae 145 #define SDADC_LOWPOWER_NONE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 146 #define SDADC_LOWPOWER_POWERDOWN SDADC_CR1_PDI
bogdanm 86:04dd9b1680ae 147 #define SDADC_LOWPOWER_STANDBY SDADC_CR1_SBI
bogdanm 86:04dd9b1680ae 148 /**
bogdanm 86:04dd9b1680ae 149 * @}
bogdanm 86:04dd9b1680ae 150 */
bogdanm 86:04dd9b1680ae 151
bogdanm 92:4fc01daae5a5 152 /** @defgroup SDADC_Fast_Conv_Mode SDADC Fast Conversion Mode
bogdanm 86:04dd9b1680ae 153 * @{
bogdanm 86:04dd9b1680ae 154 */
bogdanm 86:04dd9b1680ae 155 #define SDADC_FAST_CONV_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 156 #define SDADC_FAST_CONV_ENABLE SDADC_CR2_FAST
bogdanm 86:04dd9b1680ae 157 /**
bogdanm 86:04dd9b1680ae 158 * @}
bogdanm 86:04dd9b1680ae 159 */
bogdanm 86:04dd9b1680ae 160
bogdanm 92:4fc01daae5a5 161 /** @defgroup SDADC_Slow_Clock_Mode SDADC Slow Clock Mode
bogdanm 86:04dd9b1680ae 162 * @{
bogdanm 86:04dd9b1680ae 163 */
bogdanm 86:04dd9b1680ae 164 #define SDADC_SLOW_CLOCK_DISABLE ((uint32_t)0x00000000)
bogdanm 86:04dd9b1680ae 165 #define SDADC_SLOW_CLOCK_ENABLE SDADC_CR1_SLOWCK
bogdanm 86:04dd9b1680ae 166 /**
bogdanm 86:04dd9b1680ae 167 * @}
bogdanm 86:04dd9b1680ae 168 */
bogdanm 86:04dd9b1680ae 169
bogdanm 92:4fc01daae5a5 170 /** @defgroup SDADC_Reference_Voltage SDADC Reference Voltage
bogdanm 86:04dd9b1680ae 171 * @{
bogdanm 86:04dd9b1680ae 172 */
bogdanm 86:04dd9b1680ae 173 #define SDADC_VREF_EXT ((uint32_t)0x00000000) /*!< The reference voltage is forced externally using VREF pin */
bogdanm 86:04dd9b1680ae 174 #define SDADC_VREF_VREFINT1 SDADC_CR1_REFV_0 /*!< The reference voltage is forced internally to 1.22V VREFINT */
bogdanm 86:04dd9b1680ae 175 #define SDADC_VREF_VREFINT2 SDADC_CR1_REFV_1 /*!< The reference voltage is forced internally to 1.8V VREFINT */
bogdanm 86:04dd9b1680ae 176 #define SDADC_VREF_VDDA SDADC_CR1_REFV /*!< The reference voltage is forced internally to VDDA */
bogdanm 86:04dd9b1680ae 177 /**
bogdanm 86:04dd9b1680ae 178 * @}
bogdanm 86:04dd9b1680ae 179 */
bogdanm 86:04dd9b1680ae 180
bogdanm 92:4fc01daae5a5 181 /** @defgroup SDADC_ConfIndex SDADC Configuration Index
bogdanm 86:04dd9b1680ae 182 * @{
bogdanm 86:04dd9b1680ae 183 */
bogdanm 86:04dd9b1680ae 184
bogdanm 86:04dd9b1680ae 185 #define SDADC_CONF_INDEX_0 ((uint32_t)0x00000000) /*!< Configuration 0 Register selected */
bogdanm 86:04dd9b1680ae 186 #define SDADC_CONF_INDEX_1 ((uint32_t)0x00000001) /*!< Configuration 1 Register selected */
bogdanm 86:04dd9b1680ae 187 #define SDADC_CONF_INDEX_2 ((uint32_t)0x00000002) /*!< Configuration 2 Register selected */
bogdanm 86:04dd9b1680ae 188 /**
bogdanm 86:04dd9b1680ae 189 * @}
bogdanm 86:04dd9b1680ae 190 */
bogdanm 86:04dd9b1680ae 191
bogdanm 92:4fc01daae5a5 192 /** @defgroup SDADC_InputMode SDADC Input Mode
bogdanm 86:04dd9b1680ae 193 * @{
bogdanm 86:04dd9b1680ae 194 */
bogdanm 86:04dd9b1680ae 195 #define SDADC_INPUT_MODE_DIFF ((uint32_t)0x00000000) /*!< Conversions are executed in differential mode */
bogdanm 86:04dd9b1680ae 196 #define SDADC_INPUT_MODE_SE_OFFSET SDADC_CONF0R_SE0_0 /*!< Conversions are executed in single ended offset mode */
bogdanm 86:04dd9b1680ae 197 #define SDADC_INPUT_MODE_SE_ZERO_REFERENCE SDADC_CONF0R_SE0 /*!< Conversions are executed in single ended zero-volt reference mode */
bogdanm 86:04dd9b1680ae 198 /**
bogdanm 86:04dd9b1680ae 199 * @}
bogdanm 86:04dd9b1680ae 200 */
bogdanm 86:04dd9b1680ae 201
bogdanm 92:4fc01daae5a5 202 /** @defgroup SDADC_Gain SDADC Gain
bogdanm 86:04dd9b1680ae 203 * @{
bogdanm 86:04dd9b1680ae 204 */
bogdanm 86:04dd9b1680ae 205 #define SDADC_GAIN_1 ((uint32_t)0x00000000) /*!< Gain equal to 1 */
bogdanm 86:04dd9b1680ae 206 #define SDADC_GAIN_2 SDADC_CONF0R_GAIN0_0 /*!< Gain equal to 2 */
bogdanm 86:04dd9b1680ae 207 #define SDADC_GAIN_4 SDADC_CONF0R_GAIN0_1 /*!< Gain equal to 4 */
bogdanm 86:04dd9b1680ae 208 #define SDADC_GAIN_8 ((uint32_t)0x00300000) /*!< Gain equal to 8 */
bogdanm 86:04dd9b1680ae 209 #define SDADC_GAIN_16 SDADC_CONF0R_GAIN0_2 /*!< Gain equal to 16 */
bogdanm 86:04dd9b1680ae 210 #define SDADC_GAIN_32 ((uint32_t)0x00500000) /*!< Gain equal to 32 */
bogdanm 86:04dd9b1680ae 211 #define SDADC_GAIN_1_2 SDADC_CONF0R_GAIN0 /*!< Gain equal to 1/2 */
bogdanm 86:04dd9b1680ae 212 /**
bogdanm 86:04dd9b1680ae 213 * @}
bogdanm 86:04dd9b1680ae 214 */
bogdanm 86:04dd9b1680ae 215
bogdanm 92:4fc01daae5a5 216 /** @defgroup SDADC_CommonMode SDADC Common Mode
bogdanm 86:04dd9b1680ae 217 * @{
bogdanm 86:04dd9b1680ae 218 */
bogdanm 86:04dd9b1680ae 219 #define SDADC_COMMON_MODE_VSSA ((uint32_t)0x00000000) /*!< Select SDADC VSSA as common mode */
bogdanm 86:04dd9b1680ae 220 #define SDADC_COMMON_MODE_VDDA_2 SDADC_CONF0R_COMMON0_0 /*!< Select SDADC VDDA/2 as common mode */
bogdanm 86:04dd9b1680ae 221 #define SDADC_COMMON_MODE_VDDA SDADC_CONF0R_COMMON0_1 /*!< Select SDADC VDDA as common mode */
bogdanm 86:04dd9b1680ae 222 /**
bogdanm 86:04dd9b1680ae 223 * @}
bogdanm 86:04dd9b1680ae 224 */
bogdanm 86:04dd9b1680ae 225
Kojto 122:f9eeca106725 226
bogdanm 86:04dd9b1680ae 227
bogdanm 92:4fc01daae5a5 228 /** @defgroup SDADC_Channel_Selection SDADC Channel Selection
bogdanm 86:04dd9b1680ae 229 * @{
bogdanm 86:04dd9b1680ae 230 */
bogdanm 86:04dd9b1680ae 231
bogdanm 86:04dd9b1680ae 232 /* SDADC Channels ------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 233 /* The SDADC channels are defined as follows:
bogdanm 86:04dd9b1680ae 234 - in 16-bit LSB the channel mask is set
bogdanm 86:04dd9b1680ae 235 - in 16-bit MSB the channel number is set
bogdanm 86:04dd9b1680ae 236 e.g. for channel 5 definition:
bogdanm 86:04dd9b1680ae 237 - the channel mask is 0x00000020 (bit 5 is set)
bogdanm 86:04dd9b1680ae 238 - the channel number 5 is 0x00050000
bogdanm 86:04dd9b1680ae 239 --> Consequently, channel 5 definition is 0x00000020 | 0x00050000 = 0x00050020 */
bogdanm 86:04dd9b1680ae 240 #define SDADC_CHANNEL_0 ((uint32_t)0x00000001)
bogdanm 86:04dd9b1680ae 241 #define SDADC_CHANNEL_1 ((uint32_t)0x00010002)
bogdanm 86:04dd9b1680ae 242 #define SDADC_CHANNEL_2 ((uint32_t)0x00020004)
bogdanm 86:04dd9b1680ae 243 #define SDADC_CHANNEL_3 ((uint32_t)0x00030008)
bogdanm 86:04dd9b1680ae 244 #define SDADC_CHANNEL_4 ((uint32_t)0x00040010)
bogdanm 86:04dd9b1680ae 245 #define SDADC_CHANNEL_5 ((uint32_t)0x00050020)
bogdanm 86:04dd9b1680ae 246 #define SDADC_CHANNEL_6 ((uint32_t)0x00060040)
bogdanm 86:04dd9b1680ae 247 #define SDADC_CHANNEL_7 ((uint32_t)0x00070080)
bogdanm 86:04dd9b1680ae 248 #define SDADC_CHANNEL_8 ((uint32_t)0x00080100)
bogdanm 86:04dd9b1680ae 249 /**
bogdanm 86:04dd9b1680ae 250 * @}
bogdanm 86:04dd9b1680ae 251 */
bogdanm 86:04dd9b1680ae 252
bogdanm 92:4fc01daae5a5 253 /** @defgroup SDADC_CalibrationSequence SDADC Calibration Sequence
bogdanm 86:04dd9b1680ae 254 * @{
bogdanm 86:04dd9b1680ae 255 */
bogdanm 86:04dd9b1680ae 256 #define SDADC_CALIBRATION_SEQ_1 ((uint32_t)0x00000000) /*!< One calibration sequence to calculate offset of conf0 (OFFSET0[11:0]) */
bogdanm 86:04dd9b1680ae 257 #define SDADC_CALIBRATION_SEQ_2 SDADC_CR2_CALIBCNT_0 /*!< Two calibration sequences to calculate offset of conf0 and conf1 (OFFSET0[11:0] and OFFSET1[11:0]) */
bogdanm 86:04dd9b1680ae 258 #define SDADC_CALIBRATION_SEQ_3 SDADC_CR2_CALIBCNT_1 /*!< Three calibration sequences to calculate offset of conf0, conf1 and conf2 (OFFSET0[11:0], OFFSET1[11:0], and OFFSET2[11:0]) */
bogdanm 86:04dd9b1680ae 259 /**
bogdanm 86:04dd9b1680ae 260 * @}
bogdanm 86:04dd9b1680ae 261 */
bogdanm 86:04dd9b1680ae 262
bogdanm 92:4fc01daae5a5 263 /** @defgroup SDADC_ContinuousMode SDADC Continuous Mode
bogdanm 86:04dd9b1680ae 264 * @{
bogdanm 86:04dd9b1680ae 265 */
bogdanm 86:04dd9b1680ae 266 #define SDADC_CONTINUOUS_CONV_OFF ((uint32_t)0x00000000) /*!< Conversion are not continuous */
bogdanm 86:04dd9b1680ae 267 #define SDADC_CONTINUOUS_CONV_ON ((uint32_t)0x00000001) /*!< Conversion are continuous */
bogdanm 86:04dd9b1680ae 268 /**
bogdanm 86:04dd9b1680ae 269 * @}
bogdanm 86:04dd9b1680ae 270 */
bogdanm 86:04dd9b1680ae 271
bogdanm 92:4fc01daae5a5 272 /** @defgroup SDADC_Trigger SDADC Trigger
bogdanm 86:04dd9b1680ae 273 * @{
bogdanm 86:04dd9b1680ae 274 */
bogdanm 86:04dd9b1680ae 275 #define SDADC_SOFTWARE_TRIGGER ((uint32_t)0x00000000) /*!< Software trigger */
bogdanm 86:04dd9b1680ae 276 #define SDADC_SYNCHRONOUS_TRIGGER ((uint32_t)0x00000001) /*!< Synchronous with SDADC1 (only for SDADC2 and SDADC3) */
bogdanm 86:04dd9b1680ae 277 #define SDADC_EXTERNAL_TRIGGER ((uint32_t)0x00000002) /*!< External trigger */
bogdanm 86:04dd9b1680ae 278 /**
bogdanm 86:04dd9b1680ae 279 * @}
bogdanm 86:04dd9b1680ae 280 */
bogdanm 86:04dd9b1680ae 281
bogdanm 92:4fc01daae5a5 282 /** @defgroup SDADC_InjectedExtTrigger SDADC Injected External Trigger
bogdanm 86:04dd9b1680ae 283 * @{
bogdanm 86:04dd9b1680ae 284 */
bogdanm 86:04dd9b1680ae 285 #define SDADC_EXT_TRIG_TIM13_CC1 ((uint32_t)0x00000000) /*!< Trigger source for SDADC1 */
bogdanm 86:04dd9b1680ae 286 #define SDADC_EXT_TRIG_TIM14_CC1 ((uint32_t)0x00000100) /*!< Trigger source for SDADC1 */
bogdanm 86:04dd9b1680ae 287 #define SDADC_EXT_TRIG_TIM16_CC1 ((uint32_t)0x00000000) /*!< Trigger source for SDADC3 */
bogdanm 86:04dd9b1680ae 288 #define SDADC_EXT_TRIG_TIM17_CC1 ((uint32_t)0x00000000) /*!< Trigger source for SDADC2 */
bogdanm 86:04dd9b1680ae 289 #define SDADC_EXT_TRIG_TIM12_CC1 ((uint32_t)0x00000100) /*!< Trigger source for SDADC2 */
bogdanm 86:04dd9b1680ae 290 #define SDADC_EXT_TRIG_TIM12_CC2 ((uint32_t)0x00000100) /*!< Trigger source for SDADC3 */
bogdanm 86:04dd9b1680ae 291 #define SDADC_EXT_TRIG_TIM15_CC2 ((uint32_t)0x00000200) /*!< Trigger source for SDADC1 */
bogdanm 86:04dd9b1680ae 292 #define SDADC_EXT_TRIG_TIM2_CC3 ((uint32_t)0x00000200) /*!< Trigger source for SDADC2 */
bogdanm 86:04dd9b1680ae 293 #define SDADC_EXT_TRIG_TIM2_CC4 ((uint32_t)0x00000200) /*!< Trigger source for SDADC3 */
bogdanm 86:04dd9b1680ae 294 #define SDADC_EXT_TRIG_TIM3_CC1 ((uint32_t)0x00000300) /*!< Trigger source for SDADC1 */
bogdanm 86:04dd9b1680ae 295 #define SDADC_EXT_TRIG_TIM3_CC2 ((uint32_t)0x00000300) /*!< Trigger source for SDADC2 */
bogdanm 86:04dd9b1680ae 296 #define SDADC_EXT_TRIG_TIM3_CC3 ((uint32_t)0x00000300) /*!< Trigger source for SDADC3 */
bogdanm 86:04dd9b1680ae 297 #define SDADC_EXT_TRIG_TIM4_CC1 ((uint32_t)0x00000400) /*!< Trigger source for SDADC1 */
bogdanm 86:04dd9b1680ae 298 #define SDADC_EXT_TRIG_TIM4_CC2 ((uint32_t)0x00000400) /*!< Trigger source for SDADC2 */
bogdanm 86:04dd9b1680ae 299 #define SDADC_EXT_TRIG_TIM4_CC3 ((uint32_t)0x00000400) /*!< Trigger source for SDADC3 */
bogdanm 86:04dd9b1680ae 300 #define SDADC_EXT_TRIG_TIM19_CC2 ((uint32_t)0x00000500) /*!< Trigger source for SDADC1 */
bogdanm 86:04dd9b1680ae 301 #define SDADC_EXT_TRIG_TIM19_CC3 ((uint32_t)0x00000500) /*!< Trigger source for SDADC2 */
bogdanm 86:04dd9b1680ae 302 #define SDADC_EXT_TRIG_TIM19_CC4 ((uint32_t)0x00000500) /*!< Trigger source for SDADC3 */
bogdanm 86:04dd9b1680ae 303 #define SDADC_EXT_TRIG_EXTI11 ((uint32_t)0x00000700) /*!< Trigger source for SDADC1, SDADC2 and SDADC3 */
bogdanm 86:04dd9b1680ae 304 #define SDADC_EXT_TRIG_EXTI15 ((uint32_t)0x00000600) /*!< Trigger source for SDADC1, SDADC2 and SDADC3 */
Kojto 122:f9eeca106725 305 /**
Kojto 122:f9eeca106725 306 * @}
Kojto 122:f9eeca106725 307 */
Kojto 122:f9eeca106725 308
Kojto 122:f9eeca106725 309 /** @defgroup SDADC_ExtTriggerEdge SDADC External Trigger Edge
Kojto 122:f9eeca106725 310 * @{
Kojto 122:f9eeca106725 311 */
Kojto 122:f9eeca106725 312 #define SDADC_EXT_TRIG_RISING_EDGE SDADC_CR2_JEXTEN_0 /*!< External rising edge */
Kojto 122:f9eeca106725 313 #define SDADC_EXT_TRIG_FALLING_EDGE SDADC_CR2_JEXTEN_1 /*!< External falling edge */
Kojto 122:f9eeca106725 314 #define SDADC_EXT_TRIG_BOTH_EDGES SDADC_CR2_JEXTEN /*!< External rising and falling edges */
Kojto 122:f9eeca106725 315 /**
Kojto 122:f9eeca106725 316 * @}
Kojto 122:f9eeca106725 317 */
Kojto 122:f9eeca106725 318
Kojto 122:f9eeca106725 319 /** @defgroup SDADC_InjectedDelay SDADC Injected Conversion Delay
Kojto 122:f9eeca106725 320 * @{
Kojto 122:f9eeca106725 321 */
Kojto 122:f9eeca106725 322 #define SDADC_INJECTED_DELAY_NONE ((uint32_t)0x00000000) /*!< No delay on injected conversion */
Kojto 122:f9eeca106725 323 #define SDADC_INJECTED_DELAY SDADC_CR2_JDS /*!< Delay on injected conversion */
Kojto 122:f9eeca106725 324 /**
Kojto 122:f9eeca106725 325 * @}
Kojto 122:f9eeca106725 326 */
Kojto 122:f9eeca106725 327
Kojto 122:f9eeca106725 328 /** @defgroup SDADC_MultimodeType SDADC Multimode Type
Kojto 122:f9eeca106725 329 * @{
Kojto 122:f9eeca106725 330 */
Kojto 122:f9eeca106725 331 #define SDADC_MULTIMODE_SDADC1_SDADC2 ((uint32_t)0x00000000) /*!< Get conversion values for SDADC1 and SDADC2 */
Kojto 122:f9eeca106725 332 #define SDADC_MULTIMODE_SDADC1_SDADC3 ((uint32_t)0x00000001) /*!< Get conversion values for SDADC1 and SDADC3 */
Kojto 122:f9eeca106725 333 /**
Kojto 122:f9eeca106725 334 * @}
Kojto 122:f9eeca106725 335 */
Kojto 122:f9eeca106725 336
Kojto 122:f9eeca106725 337 /** @defgroup SDADC_ErrorCode SDADC Error Code
Kojto 122:f9eeca106725 338 * @{
Kojto 122:f9eeca106725 339 */
Kojto 122:f9eeca106725 340 #define SDADC_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 122:f9eeca106725 341 #define SDADC_ERROR_REGULAR_OVERRUN ((uint32_t)0x00000001) /*!< Overrun occurs during regular conversion */
Kojto 122:f9eeca106725 342 #define SDADC_ERROR_INJECTED_OVERRUN ((uint32_t)0x00000002) /*!< Overrun occurs during injected conversion */
Kojto 122:f9eeca106725 343 #define SDADC_ERROR_DMA ((uint32_t)0x00000003) /*!< DMA error occurs */
Kojto 122:f9eeca106725 344 /**
Kojto 122:f9eeca106725 345 * @}
Kojto 122:f9eeca106725 346 */
Kojto 122:f9eeca106725 347
Kojto 122:f9eeca106725 348 /** @defgroup SDADC_interrupts_definition SDADC interrupts definition
Kojto 122:f9eeca106725 349 * @{
Kojto 122:f9eeca106725 350 */
Kojto 122:f9eeca106725 351 #define SDADC_IT_EOCAL SDADC_CR1_EOCALIE /*!< End of calibration interrupt enable */
Kojto 122:f9eeca106725 352 #define SDADC_IT_JEOC SDADC_CR1_JEOCIE /*!< Injected end of conversion interrupt enable */
Kojto 122:f9eeca106725 353 #define SDADC_IT_JOVR SDADC_CR1_JOVRIE /*!< Injected data overrun interrupt enable */
Kojto 122:f9eeca106725 354 #define SDADC_IT_REOC SDADC_CR1_REOCIE /*!< Regular end of conversion interrupt enable */
Kojto 122:f9eeca106725 355 #define SDADC_IT_ROVR SDADC_CR1_ROVRIE /*!< Regular data overrun interrupt enable */
Kojto 122:f9eeca106725 356 /**
Kojto 122:f9eeca106725 357 * @}
Kojto 122:f9eeca106725 358 */
Kojto 122:f9eeca106725 359
Kojto 122:f9eeca106725 360 /** @defgroup SDADC_flags_definition SDADC flags definition
Kojto 122:f9eeca106725 361 * @{
Kojto 122:f9eeca106725 362 */
Kojto 122:f9eeca106725 363 #define SDADC_FLAG_EOCAL SDADC_ISR_EOCALF /*!< End of calibration flag */
Kojto 122:f9eeca106725 364 #define SDADC_FLAG_JEOC SDADC_ISR_JEOCF /*!< End of injected conversion flag */
Kojto 122:f9eeca106725 365 #define SDADC_FLAG_JOVR SDADC_ISR_JOVRF /*!< Injected conversion overrun flag */
Kojto 122:f9eeca106725 366 #define SDADC_FLAG_REOC SDADC_ISR_REOCF /*!< End of regular conversion flag */
Kojto 122:f9eeca106725 367 #define SDADC_FLAG_ROVR SDADC_ISR_ROVRF /*!< Regular conversion overrun flag */
Kojto 122:f9eeca106725 368 /**
Kojto 122:f9eeca106725 369 * @}
Kojto 122:f9eeca106725 370 */
Kojto 122:f9eeca106725 371
Kojto 122:f9eeca106725 372 /**
Kojto 122:f9eeca106725 373 * @}
Kojto 122:f9eeca106725 374 */
Kojto 122:f9eeca106725 375
Kojto 122:f9eeca106725 376 /* Exported macros -----------------------------------------------------------*/
Kojto 122:f9eeca106725 377 /** @defgroup SDADC_Exported_Macros SDADC Exported Macros
Kojto 122:f9eeca106725 378 * @{
Kojto 122:f9eeca106725 379 */
Kojto 122:f9eeca106725 380
Kojto 122:f9eeca106725 381 /* Macro for internal HAL driver usage, and possibly can be used into code of */
Kojto 122:f9eeca106725 382 /* final user. */
Kojto 122:f9eeca106725 383
Kojto 122:f9eeca106725 384 /** @brief Enable the ADC end of conversion interrupt.
Kojto 122:f9eeca106725 385 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 386 * @param __INTERRUPT__: ADC Interrupt
Kojto 122:f9eeca106725 387 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 388 * @arg SDADC_IT_EOCAL: End of calibration interrupt enable
Kojto 122:f9eeca106725 389 * @arg SDADC_IT_JEOC: Injected end of conversion interrupt enable
Kojto 122:f9eeca106725 390 * @arg SDADC_IT_JOVR: Injected data overrun interrupt enable
Kojto 122:f9eeca106725 391 * @arg SDADC_IT_REOC: Regular end of conversion interrupt enable
Kojto 122:f9eeca106725 392 * @arg SDADC_IT_ROVR: Regular data overrun interrupt enable
Kojto 122:f9eeca106725 393 * @retval None
Kojto 122:f9eeca106725 394 */
Kojto 122:f9eeca106725 395 #define __HAL_SDADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 122:f9eeca106725 396 (SET_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
Kojto 122:f9eeca106725 397
Kojto 122:f9eeca106725 398 /** @brief Disable the ADC end of conversion interrupt.
Kojto 122:f9eeca106725 399 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 400 * @param __INTERRUPT__: ADC Interrupt
Kojto 122:f9eeca106725 401 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 402 * @arg SDADC_IT_EOCAL: End of calibration interrupt enable
Kojto 122:f9eeca106725 403 * @arg SDADC_IT_JEOC: Injected end of conversion interrupt enable
Kojto 122:f9eeca106725 404 * @arg SDADC_IT_JOVR: Injected data overrun interrupt enable
Kojto 122:f9eeca106725 405 * @arg SDADC_IT_REOC: Regular end of conversion interrupt enable
Kojto 122:f9eeca106725 406 * @arg SDADC_IT_ROVR: Regular data overrun interrupt enable
Kojto 122:f9eeca106725 407 * @retval None
Kojto 122:f9eeca106725 408 */
Kojto 122:f9eeca106725 409 #define __HAL_SDADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 122:f9eeca106725 410 (CLEAR_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
Kojto 122:f9eeca106725 411
Kojto 122:f9eeca106725 412 /** @brief Checks if the specified ADC interrupt source is enabled or disabled.
Kojto 122:f9eeca106725 413 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 414 * @param __INTERRUPT__: ADC interrupt source to check
Kojto 122:f9eeca106725 415 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 416 * @arg SDADC_IT_EOCAL: End of calibration interrupt enable
Kojto 122:f9eeca106725 417 * @arg SDADC_IT_JEOC: Injected end of conversion interrupt enable
Kojto 122:f9eeca106725 418 * @arg SDADC_IT_JOVR: Injected data overrun interrupt enable
Kojto 122:f9eeca106725 419 * @arg SDADC_IT_REOC: Regular end of conversion interrupt enable
Kojto 122:f9eeca106725 420 * @arg SDADC_IT_ROVR: Regular data overrun interrupt enable
Kojto 122:f9eeca106725 421 * @retval State of interruption (SET or RESET)
Kojto 122:f9eeca106725 422 */
Kojto 122:f9eeca106725 423 #define __HAL_SDADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
Kojto 122:f9eeca106725 424 (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 122:f9eeca106725 425
Kojto 122:f9eeca106725 426 /** @brief Get the selected ADC's flag status.
Kojto 122:f9eeca106725 427 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 428 * @param __FLAG__: ADC flag
Kojto 122:f9eeca106725 429 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 430 * @arg SDADC_FLAG_EOCAL: End of calibration flag
Kojto 122:f9eeca106725 431 * @arg SDADC_FLAG_JEOC: End of injected conversion flag
Kojto 122:f9eeca106725 432 * @arg SDADC_FLAG_JOVR: Injected conversion overrun flag
Kojto 122:f9eeca106725 433 * @arg SDADC_FLAG_REOC: End of regular conversion flag
Kojto 122:f9eeca106725 434 * @arg SDADC_FLAG_ROVR: Regular conversion overrun flag
Kojto 122:f9eeca106725 435 * @retval None
Kojto 122:f9eeca106725 436 */
Kojto 122:f9eeca106725 437 #define __HAL_SDADC_GET_FLAG(__HANDLE__, __FLAG__) \
Kojto 122:f9eeca106725 438 ((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__))
Kojto 122:f9eeca106725 439
Kojto 122:f9eeca106725 440 /** @brief Clear the ADC's pending flags
Kojto 122:f9eeca106725 441 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 442 * @param __FLAG__: ADC flag
Kojto 122:f9eeca106725 443 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 444 * @arg SDADC_FLAG_EOCAL: End of calibration flag
Kojto 122:f9eeca106725 445 * @arg SDADC_FLAG_JEOC: End of injected conversion flag
Kojto 122:f9eeca106725 446 * @arg SDADC_FLAG_JOVR: Injected conversion overrun flag
Kojto 122:f9eeca106725 447 * @arg SDADC_FLAG_REOC: End of regular conversion flag
Kojto 122:f9eeca106725 448 * @arg SDADC_FLAG_ROVR: Regular conversion overrun flag
Kojto 122:f9eeca106725 449 * @retval None
Kojto 122:f9eeca106725 450 */
Kojto 122:f9eeca106725 451 #define __HAL_SDADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
Kojto 122:f9eeca106725 452 (CLEAR_BIT((__HANDLE__)->Instance->ISR, (__FLAG__)))
Kojto 122:f9eeca106725 453
Kojto 122:f9eeca106725 454 /** @brief Reset SDADC handle state
Kojto 122:f9eeca106725 455 * @param __HANDLE__: SDADC handle.
Kojto 122:f9eeca106725 456 * @retval None
Kojto 122:f9eeca106725 457 */
Kojto 122:f9eeca106725 458 #define __HAL_SDADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SDADC_STATE_RESET)
Kojto 122:f9eeca106725 459
Kojto 122:f9eeca106725 460 /**
Kojto 122:f9eeca106725 461 * @}
Kojto 122:f9eeca106725 462 */
Kojto 122:f9eeca106725 463
Kojto 122:f9eeca106725 464 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 465 /** @defgroup SDADC_Private_Macros SDADC Private Macros
Kojto 122:f9eeca106725 466 * @{
Kojto 122:f9eeca106725 467 */
Kojto 122:f9eeca106725 468
Kojto 122:f9eeca106725 469 #define IS_SDADC_LOWPOWER_MODE(LOWPOWER) (((LOWPOWER) == SDADC_LOWPOWER_NONE) || \
Kojto 122:f9eeca106725 470 ((LOWPOWER) == SDADC_LOWPOWER_POWERDOWN) || \
Kojto 122:f9eeca106725 471 ((LOWPOWER) == SDADC_LOWPOWER_STANDBY))
Kojto 122:f9eeca106725 472
Kojto 122:f9eeca106725 473 #define IS_SDADC_FAST_CONV_MODE(FAST) (((FAST) == SDADC_FAST_CONV_DISABLE) || \
Kojto 122:f9eeca106725 474 ((FAST) == SDADC_FAST_CONV_ENABLE))
Kojto 122:f9eeca106725 475
Kojto 122:f9eeca106725 476 #define IS_SDADC_SLOW_CLOCK_MODE(MODE) (((MODE) == SDADC_SLOW_CLOCK_DISABLE) || \
Kojto 122:f9eeca106725 477 ((MODE) == SDADC_SLOW_CLOCK_ENABLE))
Kojto 122:f9eeca106725 478
Kojto 122:f9eeca106725 479 #define IS_SDADC_VREF(VREF) (((VREF) == SDADC_VREF_EXT) || \
Kojto 122:f9eeca106725 480 ((VREF) == SDADC_VREF_VREFINT1) || \
Kojto 122:f9eeca106725 481 ((VREF) == SDADC_VREF_VREFINT2) || \
Kojto 122:f9eeca106725 482 ((VREF) == SDADC_VREF_VDDA))
Kojto 122:f9eeca106725 483
Kojto 122:f9eeca106725 484 #define IS_SDADC_CONF_INDEX(CONF) (((CONF) == SDADC_CONF_INDEX_0) || \
Kojto 122:f9eeca106725 485 ((CONF) == SDADC_CONF_INDEX_1) || \
Kojto 122:f9eeca106725 486 ((CONF) == SDADC_CONF_INDEX_2))
Kojto 122:f9eeca106725 487
Kojto 122:f9eeca106725 488 #define IS_SDADC_INPUT_MODE(MODE) (((MODE) == SDADC_INPUT_MODE_DIFF) || \
Kojto 122:f9eeca106725 489 ((MODE) == SDADC_INPUT_MODE_SE_OFFSET) || \
Kojto 122:f9eeca106725 490 ((MODE) == SDADC_INPUT_MODE_SE_ZERO_REFERENCE))
Kojto 122:f9eeca106725 491
Kojto 122:f9eeca106725 492 #define IS_SDADC_GAIN(GAIN) (((GAIN) == SDADC_GAIN_1) || \
Kojto 122:f9eeca106725 493 ((GAIN) == SDADC_GAIN_2) || \
Kojto 122:f9eeca106725 494 ((GAIN) == SDADC_GAIN_4) || \
Kojto 122:f9eeca106725 495 ((GAIN) == SDADC_GAIN_8) || \
Kojto 122:f9eeca106725 496 ((GAIN) == SDADC_GAIN_16) || \
Kojto 122:f9eeca106725 497 ((GAIN) == SDADC_GAIN_32) || \
Kojto 122:f9eeca106725 498 ((GAIN) == SDADC_GAIN_1_2))
Kojto 122:f9eeca106725 499
Kojto 122:f9eeca106725 500 #define IS_SDADC_COMMON_MODE(MODE) (((MODE) == SDADC_COMMON_MODE_VSSA) || \
Kojto 122:f9eeca106725 501 ((MODE) == SDADC_COMMON_MODE_VDDA_2) || \
Kojto 122:f9eeca106725 502 ((MODE) == SDADC_COMMON_MODE_VDDA))
Kojto 122:f9eeca106725 503
Kojto 122:f9eeca106725 504 #define IS_SDADC_OFFSET_VALUE(VALUE) ((VALUE) <= 0x00000FFF)
Kojto 122:f9eeca106725 505
Kojto 122:f9eeca106725 506 /* Just one channel of the 9 channels can be selected for regular conversion */
Kojto 122:f9eeca106725 507 #define IS_SDADC_REGULAR_CHANNEL(CHANNEL) (((CHANNEL) == SDADC_CHANNEL_0) || \
Kojto 122:f9eeca106725 508 ((CHANNEL) == SDADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 509 ((CHANNEL) == SDADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 510 ((CHANNEL) == SDADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 511 ((CHANNEL) == SDADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 512 ((CHANNEL) == SDADC_CHANNEL_5) || \
Kojto 122:f9eeca106725 513 ((CHANNEL) == SDADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 514 ((CHANNEL) == SDADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 515 ((CHANNEL) == SDADC_CHANNEL_8))
Kojto 122:f9eeca106725 516
Kojto 122:f9eeca106725 517 /* Any or all of the 9 channels can be selected for injected conversion */
Kojto 122:f9eeca106725 518 #define IS_SDADC_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) != 0) && ((CHANNEL) <= 0x000F01FF))
Kojto 122:f9eeca106725 519
Kojto 122:f9eeca106725 520
Kojto 122:f9eeca106725 521 #define IS_SDADC_CALIB_SEQUENCE(SEQUENCE) (((SEQUENCE) == SDADC_CALIBRATION_SEQ_1) || \
Kojto 122:f9eeca106725 522 ((SEQUENCE) == SDADC_CALIBRATION_SEQ_2) || \
Kojto 122:f9eeca106725 523 ((SEQUENCE) == SDADC_CALIBRATION_SEQ_3))
Kojto 122:f9eeca106725 524
Kojto 122:f9eeca106725 525 #define IS_SDADC_CONTINUOUS_MODE(MODE) (((MODE) == SDADC_CONTINUOUS_CONV_OFF) || \
Kojto 122:f9eeca106725 526 ((MODE) == SDADC_CONTINUOUS_CONV_ON))
Kojto 122:f9eeca106725 527
Kojto 122:f9eeca106725 528
Kojto 122:f9eeca106725 529 #define IS_SDADC_REGULAR_TRIGGER(TRIGGER) (((TRIGGER) == SDADC_SOFTWARE_TRIGGER) || \
Kojto 122:f9eeca106725 530 ((TRIGGER) == SDADC_SYNCHRONOUS_TRIGGER))
Kojto 122:f9eeca106725 531
Kojto 122:f9eeca106725 532 #define IS_SDADC_INJECTED_TRIGGER(TRIGGER) (((TRIGGER) == SDADC_SOFTWARE_TRIGGER) || \
Kojto 122:f9eeca106725 533 ((TRIGGER) == SDADC_SYNCHRONOUS_TRIGGER) || \
Kojto 122:f9eeca106725 534 ((TRIGGER) == SDADC_EXTERNAL_TRIGGER))
Kojto 122:f9eeca106725 535
bogdanm 86:04dd9b1680ae 536
bogdanm 86:04dd9b1680ae 537 #define IS_SDADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == SDADC_EXT_TRIG_TIM13_CC1) || \
bogdanm 86:04dd9b1680ae 538 ((INJTRIG) == SDADC_EXT_TRIG_TIM14_CC1) || \
bogdanm 86:04dd9b1680ae 539 ((INJTRIG) == SDADC_EXT_TRIG_TIM16_CC1) || \
bogdanm 86:04dd9b1680ae 540 ((INJTRIG) == SDADC_EXT_TRIG_TIM17_CC1) || \
bogdanm 86:04dd9b1680ae 541 ((INJTRIG) == SDADC_EXT_TRIG_TIM12_CC1) || \
bogdanm 86:04dd9b1680ae 542 ((INJTRIG) == SDADC_EXT_TRIG_TIM12_CC2) || \
bogdanm 86:04dd9b1680ae 543 ((INJTRIG) == SDADC_EXT_TRIG_TIM15_CC2) || \
bogdanm 86:04dd9b1680ae 544 ((INJTRIG) == SDADC_EXT_TRIG_TIM2_CC3) || \
bogdanm 86:04dd9b1680ae 545 ((INJTRIG) == SDADC_EXT_TRIG_TIM2_CC4) || \
bogdanm 86:04dd9b1680ae 546 ((INJTRIG) == SDADC_EXT_TRIG_TIM3_CC1) || \
bogdanm 86:04dd9b1680ae 547 ((INJTRIG) == SDADC_EXT_TRIG_TIM3_CC2) || \
bogdanm 86:04dd9b1680ae 548 ((INJTRIG) == SDADC_EXT_TRIG_TIM3_CC3) || \
bogdanm 86:04dd9b1680ae 549 ((INJTRIG) == SDADC_EXT_TRIG_TIM4_CC1) || \
bogdanm 86:04dd9b1680ae 550 ((INJTRIG) == SDADC_EXT_TRIG_TIM4_CC2) || \
bogdanm 86:04dd9b1680ae 551 ((INJTRIG) == SDADC_EXT_TRIG_TIM4_CC3) || \
bogdanm 86:04dd9b1680ae 552 ((INJTRIG) == SDADC_EXT_TRIG_TIM19_CC2) || \
bogdanm 86:04dd9b1680ae 553 ((INJTRIG) == SDADC_EXT_TRIG_TIM19_CC3) || \
bogdanm 86:04dd9b1680ae 554 ((INJTRIG) == SDADC_EXT_TRIG_TIM19_CC4) || \
bogdanm 86:04dd9b1680ae 555 ((INJTRIG) == SDADC_EXT_TRIG_EXTI11) || \
bogdanm 86:04dd9b1680ae 556 ((INJTRIG) == SDADC_EXT_TRIG_EXTI15))
bogdanm 86:04dd9b1680ae 557
bogdanm 86:04dd9b1680ae 558 #define IS_SDADC_EXT_TRIG_EDGE(TRIGGER) (((TRIGGER) == SDADC_EXT_TRIG_RISING_EDGE) || \
bogdanm 86:04dd9b1680ae 559 ((TRIGGER) == SDADC_EXT_TRIG_FALLING_EDGE) || \
bogdanm 86:04dd9b1680ae 560 ((TRIGGER) == SDADC_EXT_TRIG_BOTH_EDGES))
bogdanm 86:04dd9b1680ae 561
bogdanm 86:04dd9b1680ae 562
bogdanm 86:04dd9b1680ae 563 #define IS_SDADC_INJECTED_DELAY(DELAY) (((DELAY) == SDADC_INJECTED_DELAY_NONE) || \
bogdanm 86:04dd9b1680ae 564 ((DELAY) == SDADC_INJECTED_DELAY))
bogdanm 86:04dd9b1680ae 565
bogdanm 86:04dd9b1680ae 566 #define IS_SDADC_MULTIMODE_TYPE(TYPE) (((TYPE) == SDADC_MULTIMODE_SDADC1_SDADC2) || \
bogdanm 86:04dd9b1680ae 567 ((TYPE) == SDADC_MULTIMODE_SDADC1_SDADC3))
bogdanm 86:04dd9b1680ae 568 /**
bogdanm 86:04dd9b1680ae 569 * @}
bogdanm 86:04dd9b1680ae 570 */
bogdanm 86:04dd9b1680ae 571
bogdanm 86:04dd9b1680ae 572 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 573 /** @addtogroup SDADC_Exported_Functions SDADC Exported Functions
bogdanm 92:4fc01daae5a5 574 * @{
bogdanm 92:4fc01daae5a5 575 */
bogdanm 92:4fc01daae5a5 576
bogdanm 92:4fc01daae5a5 577 /** @addtogroup SDADC_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 92:4fc01daae5a5 578 * @{
bogdanm 92:4fc01daae5a5 579 */
bogdanm 86:04dd9b1680ae 580
bogdanm 86:04dd9b1680ae 581 /* Initialization and de-initialization functions *****************************/
bogdanm 86:04dd9b1680ae 582 HAL_StatusTypeDef HAL_SDADC_Init(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 583 HAL_StatusTypeDef HAL_SDADC_DeInit(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 584 void HAL_SDADC_MspInit(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 585 void HAL_SDADC_MspDeInit(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 586
bogdanm 92:4fc01daae5a5 587 /**
bogdanm 92:4fc01daae5a5 588 * @}
bogdanm 92:4fc01daae5a5 589 */
bogdanm 92:4fc01daae5a5 590
bogdanm 92:4fc01daae5a5 591 /** @addtogroup SDADC_Exported_Functions_Group2 peripheral control functions
bogdanm 92:4fc01daae5a5 592 * @{
bogdanm 92:4fc01daae5a5 593 */
bogdanm 92:4fc01daae5a5 594
bogdanm 86:04dd9b1680ae 595 /* Peripheral Control functions ***********************************************/
bogdanm 86:04dd9b1680ae 596 HAL_StatusTypeDef HAL_SDADC_PrepareChannelConfig(SDADC_HandleTypeDef *hsdadc,
bogdanm 86:04dd9b1680ae 597 uint32_t ConfIndex,
bogdanm 86:04dd9b1680ae 598 SDADC_ConfParamTypeDef* ConfParamStruct);
bogdanm 86:04dd9b1680ae 599 HAL_StatusTypeDef HAL_SDADC_AssociateChannelConfig(SDADC_HandleTypeDef *hsdadc,
bogdanm 86:04dd9b1680ae 600 uint32_t Channel,
bogdanm 86:04dd9b1680ae 601 uint32_t ConfIndex);
bogdanm 86:04dd9b1680ae 602 HAL_StatusTypeDef HAL_SDADC_ConfigChannel(SDADC_HandleTypeDef *hsdadc,
bogdanm 86:04dd9b1680ae 603 uint32_t Channel,
bogdanm 86:04dd9b1680ae 604 uint32_t ContinuousMode);
bogdanm 86:04dd9b1680ae 605 HAL_StatusTypeDef HAL_SDADC_InjectedConfigChannel(SDADC_HandleTypeDef *hsdadc,
bogdanm 86:04dd9b1680ae 606 uint32_t Channel,
bogdanm 86:04dd9b1680ae 607 uint32_t ContinuousMode);
bogdanm 86:04dd9b1680ae 608 HAL_StatusTypeDef HAL_SDADC_SelectInjectedExtTrigger(SDADC_HandleTypeDef *hsdadc,
bogdanm 86:04dd9b1680ae 609 uint32_t InjectedExtTrigger,
bogdanm 86:04dd9b1680ae 610 uint32_t ExtTriggerEdge);
bogdanm 86:04dd9b1680ae 611 HAL_StatusTypeDef HAL_SDADC_SelectInjectedDelay(SDADC_HandleTypeDef *hsdadc,
bogdanm 86:04dd9b1680ae 612 uint32_t InjectedDelay);
bogdanm 86:04dd9b1680ae 613 HAL_StatusTypeDef HAL_SDADC_SelectRegularTrigger(SDADC_HandleTypeDef *hsdadc, uint32_t Trigger);
bogdanm 86:04dd9b1680ae 614 HAL_StatusTypeDef HAL_SDADC_SelectInjectedTrigger(SDADC_HandleTypeDef *hsdadc, uint32_t Trigger);
bogdanm 86:04dd9b1680ae 615 HAL_StatusTypeDef HAL_SDADC_MultiModeConfigChannel(SDADC_HandleTypeDef* hsdadc, uint32_t MultimodeType);
bogdanm 86:04dd9b1680ae 616 HAL_StatusTypeDef HAL_SDADC_InjectedMultiModeConfigChannel(SDADC_HandleTypeDef* hsdadc, uint32_t MultimodeType);
bogdanm 86:04dd9b1680ae 617
bogdanm 92:4fc01daae5a5 618 /**
bogdanm 92:4fc01daae5a5 619 * @}
bogdanm 92:4fc01daae5a5 620 */
bogdanm 92:4fc01daae5a5 621
bogdanm 92:4fc01daae5a5 622 /** @addtogroup SDADC_Exported_Functions_Group3 Input and Output operation functions
bogdanm 92:4fc01daae5a5 623 * @{
bogdanm 92:4fc01daae5a5 624 */
bogdanm 92:4fc01daae5a5 625
bogdanm 86:04dd9b1680ae 626 /* IO operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 627 HAL_StatusTypeDef HAL_SDADC_CalibrationStart(SDADC_HandleTypeDef *hsdadc, uint32_t CalibrationSequence);
bogdanm 86:04dd9b1680ae 628 HAL_StatusTypeDef HAL_SDADC_CalibrationStart_IT(SDADC_HandleTypeDef *hsdadc, uint32_t CalibrationSequence);
bogdanm 86:04dd9b1680ae 629
bogdanm 86:04dd9b1680ae 630 HAL_StatusTypeDef HAL_SDADC_Start(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 631 HAL_StatusTypeDef HAL_SDADC_Start_IT(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 632 HAL_StatusTypeDef HAL_SDADC_Start_DMA(SDADC_HandleTypeDef *hsdadc, uint32_t *pData, uint32_t Length);
bogdanm 86:04dd9b1680ae 633 HAL_StatusTypeDef HAL_SDADC_Stop(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 634 HAL_StatusTypeDef HAL_SDADC_Stop_IT(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 635 HAL_StatusTypeDef HAL_SDADC_Stop_DMA(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 636
bogdanm 86:04dd9b1680ae 637 HAL_StatusTypeDef HAL_SDADC_InjectedStart(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 638 HAL_StatusTypeDef HAL_SDADC_InjectedStart_IT(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 639 HAL_StatusTypeDef HAL_SDADC_InjectedStart_DMA(SDADC_HandleTypeDef *hsdadc, uint32_t *pData, uint32_t Length);
bogdanm 86:04dd9b1680ae 640 HAL_StatusTypeDef HAL_SDADC_InjectedStop(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 641 HAL_StatusTypeDef HAL_SDADC_InjectedStop_IT(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 642 HAL_StatusTypeDef HAL_SDADC_InjectedStop_DMA(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 643
bogdanm 86:04dd9b1680ae 644 HAL_StatusTypeDef HAL_SDADC_MultiModeStart_DMA(SDADC_HandleTypeDef* hsdadc, uint32_t* pData, uint32_t Length);
bogdanm 86:04dd9b1680ae 645 HAL_StatusTypeDef HAL_SDADC_MultiModeStop_DMA(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 646 HAL_StatusTypeDef HAL_SDADC_InjectedMultiModeStart_DMA(SDADC_HandleTypeDef* hsdadc, uint32_t* pData, uint32_t Length);
bogdanm 86:04dd9b1680ae 647 HAL_StatusTypeDef HAL_SDADC_InjectedMultiModeStop_DMA(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 648
bogdanm 86:04dd9b1680ae 649 uint32_t HAL_SDADC_GetValue(SDADC_HandleTypeDef *hsdadc);
bogdanm 86:04dd9b1680ae 650 uint32_t HAL_SDADC_InjectedGetValue(SDADC_HandleTypeDef *hsdadc, uint32_t* Channel);
bogdanm 86:04dd9b1680ae 651 uint32_t HAL_SDADC_MultiModeGetValue(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 652 uint32_t HAL_SDADC_InjectedMultiModeGetValue(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 653
bogdanm 86:04dd9b1680ae 654 void HAL_SDADC_IRQHandler(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 655
bogdanm 86:04dd9b1680ae 656 HAL_StatusTypeDef HAL_SDADC_PollForCalibEvent(SDADC_HandleTypeDef* hsdadc, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 657 HAL_StatusTypeDef HAL_SDADC_PollForConversion(SDADC_HandleTypeDef* hsdadc, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 658 HAL_StatusTypeDef HAL_SDADC_PollForInjectedConversion(SDADC_HandleTypeDef* hsdadc, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 659
bogdanm 86:04dd9b1680ae 660 void HAL_SDADC_CalibrationCpltCallback(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 661 void HAL_SDADC_ConvHalfCpltCallback(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 662 void HAL_SDADC_ConvCpltCallback(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 663 void HAL_SDADC_InjectedConvHalfCpltCallback(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 664 void HAL_SDADC_InjectedConvCpltCallback(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 665 void HAL_SDADC_ErrorCallback(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 666
bogdanm 92:4fc01daae5a5 667 /**
bogdanm 92:4fc01daae5a5 668 * @}
bogdanm 92:4fc01daae5a5 669 */
bogdanm 92:4fc01daae5a5 670
bogdanm 92:4fc01daae5a5 671 /** @defgroup SDADC_Exported_Functions_Group4 Peripheral State functions
bogdanm 92:4fc01daae5a5 672 * @{
bogdanm 92:4fc01daae5a5 673 */
bogdanm 92:4fc01daae5a5 674
bogdanm 86:04dd9b1680ae 675 /* Peripheral State and Error functions ***************************************/
bogdanm 86:04dd9b1680ae 676 HAL_SDADC_StateTypeDef HAL_SDADC_GetState(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 677 uint32_t HAL_SDADC_GetError(SDADC_HandleTypeDef* hsdadc);
bogdanm 86:04dd9b1680ae 678
bogdanm 86:04dd9b1680ae 679 /* Private functions ---------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 680
bogdanm 86:04dd9b1680ae 681 /**
bogdanm 86:04dd9b1680ae 682 * @}
bogdanm 92:4fc01daae5a5 683 */
bogdanm 92:4fc01daae5a5 684
bogdanm 92:4fc01daae5a5 685 /**
bogdanm 92:4fc01daae5a5 686 * @}
bogdanm 92:4fc01daae5a5 687 */
bogdanm 92:4fc01daae5a5 688
bogdanm 92:4fc01daae5a5 689 /**
bogdanm 92:4fc01daae5a5 690 * @}
bogdanm 86:04dd9b1680ae 691 */
bogdanm 86:04dd9b1680ae 692
bogdanm 86:04dd9b1680ae 693 /**
bogdanm 86:04dd9b1680ae 694 * @}
bogdanm 86:04dd9b1680ae 695 */
bogdanm 86:04dd9b1680ae 696
bogdanm 86:04dd9b1680ae 697 #endif /* defined(STM32F373xC) || defined(STM32F378xx) */
bogdanm 86:04dd9b1680ae 698
bogdanm 86:04dd9b1680ae 699 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 700 }
bogdanm 86:04dd9b1680ae 701 #endif
bogdanm 86:04dd9b1680ae 702
bogdanm 86:04dd9b1680ae 703 #endif /*__STM32F3xx_SDADC_H */
bogdanm 86:04dd9b1680ae 704
bogdanm 86:04dd9b1680ae 705
bogdanm 86:04dd9b1680ae 706 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/