I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhon309 0:ac8863619623 1 /**
jhon309 0:ac8863619623 2 ******************************************************************************
jhon309 0:ac8863619623 3 * @file stm32f0xx_hal_comp.h
jhon309 0:ac8863619623 4 * @author MCD Application Team
jhon309 0:ac8863619623 5 * @version V1.2.0
jhon309 0:ac8863619623 6 * @date 11-December-2014
jhon309 0:ac8863619623 7 * @brief Header file of COMP HAL module.
jhon309 0:ac8863619623 8 ******************************************************************************
jhon309 0:ac8863619623 9 * @attention
jhon309 0:ac8863619623 10 *
jhon309 0:ac8863619623 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
jhon309 0:ac8863619623 12 *
jhon309 0:ac8863619623 13 * Redistribution and use in source and binary forms, with or without modification,
jhon309 0:ac8863619623 14 * are permitted provided that the following conditions are met:
jhon309 0:ac8863619623 15 * 1. Redistributions of source code must retain the above copyright notice,
jhon309 0:ac8863619623 16 * this list of conditions and the following disclaimer.
jhon309 0:ac8863619623 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
jhon309 0:ac8863619623 18 * this list of conditions and the following disclaimer in the documentation
jhon309 0:ac8863619623 19 * and/or other materials provided with the distribution.
jhon309 0:ac8863619623 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
jhon309 0:ac8863619623 21 * may be used to endorse or promote products derived from this software
jhon309 0:ac8863619623 22 * without specific prior written permission.
jhon309 0:ac8863619623 23 *
jhon309 0:ac8863619623 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
jhon309 0:ac8863619623 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
jhon309 0:ac8863619623 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
jhon309 0:ac8863619623 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
jhon309 0:ac8863619623 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
jhon309 0:ac8863619623 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
jhon309 0:ac8863619623 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
jhon309 0:ac8863619623 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
jhon309 0:ac8863619623 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
jhon309 0:ac8863619623 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
jhon309 0:ac8863619623 34 *
jhon309 0:ac8863619623 35 ******************************************************************************
jhon309 0:ac8863619623 36 */
jhon309 0:ac8863619623 37
jhon309 0:ac8863619623 38 /* Define to prevent recursive inclusion -------------------------------------*/
jhon309 0:ac8863619623 39 #ifndef __STM32F0xx_HAL_COMP_H
jhon309 0:ac8863619623 40 #define __STM32F0xx_HAL_COMP_H
jhon309 0:ac8863619623 41
jhon309 0:ac8863619623 42 #ifdef __cplusplus
jhon309 0:ac8863619623 43 extern "C" {
jhon309 0:ac8863619623 44 #endif
jhon309 0:ac8863619623 45
jhon309 0:ac8863619623 46 #if defined(STM32F051x8) || defined(STM32F058xx) || \
jhon309 0:ac8863619623 47 defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx) || \
jhon309 0:ac8863619623 48 defined(STM32F091xC) || defined(STM32F098xx)
jhon309 0:ac8863619623 49
jhon309 0:ac8863619623 50 /* Includes ------------------------------------------------------------------*/
jhon309 0:ac8863619623 51 #include "stm32f0xx_hal_def.h"
jhon309 0:ac8863619623 52
jhon309 0:ac8863619623 53 /** @addtogroup STM32F0xx_HAL_Driver
jhon309 0:ac8863619623 54 * @{
jhon309 0:ac8863619623 55 */
jhon309 0:ac8863619623 56
jhon309 0:ac8863619623 57 /** @addtogroup COMP COMP HAL Module Driver
jhon309 0:ac8863619623 58 * @{
jhon309 0:ac8863619623 59 */
jhon309 0:ac8863619623 60
jhon309 0:ac8863619623 61 /* Exported types ------------------------------------------------------------*/
jhon309 0:ac8863619623 62 /** @defgroup COMP_Exported_Types COMP Exported Types
jhon309 0:ac8863619623 63 * @{
jhon309 0:ac8863619623 64 */
jhon309 0:ac8863619623 65
jhon309 0:ac8863619623 66 /**
jhon309 0:ac8863619623 67 * @brief COMP Init structure definition
jhon309 0:ac8863619623 68 */
jhon309 0:ac8863619623 69 typedef struct
jhon309 0:ac8863619623 70 {
jhon309 0:ac8863619623 71
jhon309 0:ac8863619623 72 uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
jhon309 0:ac8863619623 73 This parameter can be a value of @ref COMP_InvertingInput */
jhon309 0:ac8863619623 74
jhon309 0:ac8863619623 75 uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
jhon309 0:ac8863619623 76 This parameter can be a value of @ref COMP_NonInvertingInput */
jhon309 0:ac8863619623 77
jhon309 0:ac8863619623 78 uint32_t Output; /*!< Selects the output redirection of the comparator.
jhon309 0:ac8863619623 79 This parameter can be a value of @ref COMP_Output */
jhon309 0:ac8863619623 80
jhon309 0:ac8863619623 81 uint32_t OutputPol; /*!< Selects the output polarity of the comparator.
jhon309 0:ac8863619623 82 This parameter can be a value of @ref COMP_OutputPolarity */
jhon309 0:ac8863619623 83
jhon309 0:ac8863619623 84 uint32_t Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
jhon309 0:ac8863619623 85 This parameter can be a value of @ref COMP_Hysteresis */
jhon309 0:ac8863619623 86
jhon309 0:ac8863619623 87 uint32_t Mode; /*!< Selects the operating comsumption mode of the comparator
jhon309 0:ac8863619623 88 to adjust the speed/consumption.
jhon309 0:ac8863619623 89 This parameter can be a value of @ref COMP_Mode */
jhon309 0:ac8863619623 90
jhon309 0:ac8863619623 91 uint32_t WindowMode; /*!< Selects the window mode of the comparator 1 & 2.
jhon309 0:ac8863619623 92 This parameter can be a value of @ref COMP_WindowMode */
jhon309 0:ac8863619623 93
jhon309 0:ac8863619623 94 uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator (interrupt mode).
jhon309 0:ac8863619623 95 This parameter can be a value of @ref COMP_TriggerMode */
jhon309 0:ac8863619623 96
jhon309 0:ac8863619623 97 }COMP_InitTypeDef;
jhon309 0:ac8863619623 98
jhon309 0:ac8863619623 99 /**
jhon309 0:ac8863619623 100 * @brief COMP Handle Structure definition
jhon309 0:ac8863619623 101 */
jhon309 0:ac8863619623 102 typedef struct
jhon309 0:ac8863619623 103 {
jhon309 0:ac8863619623 104 COMP_TypeDef *Instance; /*!< Register base address */
jhon309 0:ac8863619623 105 COMP_InitTypeDef Init; /*!< COMP required parameters */
jhon309 0:ac8863619623 106 HAL_LockTypeDef Lock; /*!< Locking object */
jhon309 0:ac8863619623 107 __IO uint32_t State; /*!< COMP communication state
jhon309 0:ac8863619623 108 This parameter can be a value of @ref COMP_State */
jhon309 0:ac8863619623 109 }COMP_HandleTypeDef;
jhon309 0:ac8863619623 110
jhon309 0:ac8863619623 111 /**
jhon309 0:ac8863619623 112 * @}
jhon309 0:ac8863619623 113 */
jhon309 0:ac8863619623 114
jhon309 0:ac8863619623 115 /* Exported constants --------------------------------------------------------*/
jhon309 0:ac8863619623 116 /** @defgroup COMP_Exported_Constants COMP Exported Constants
jhon309 0:ac8863619623 117 * @{
jhon309 0:ac8863619623 118 */
jhon309 0:ac8863619623 119
jhon309 0:ac8863619623 120 /** @defgroup COMP_State COMP State
jhon309 0:ac8863619623 121 * @{
jhon309 0:ac8863619623 122 */
jhon309 0:ac8863619623 123 #define HAL_COMP_STATE_RESET ((uint32_t)0x00000000) /*!< COMP not yet initialized or disabled */
jhon309 0:ac8863619623 124 #define HAL_COMP_STATE_READY ((uint32_t)0x00000001) /*!< COMP initialized and ready for use */
jhon309 0:ac8863619623 125 #define HAL_COMP_STATE_READY_LOCKED ((uint32_t)0x00000011) /*!< COMP initialized but the configuration is locked */
jhon309 0:ac8863619623 126 #define HAL_COMP_STATE_BUSY ((uint32_t)0x00000002) /*!< COMP is running */
jhon309 0:ac8863619623 127 #define HAL_COMP_STATE_BUSY_LOCKED ((uint32_t)0x00000012) /*!< COMP is running and the configuration is locked */
jhon309 0:ac8863619623 128 /**
jhon309 0:ac8863619623 129 * @}
jhon309 0:ac8863619623 130 */
jhon309 0:ac8863619623 131
jhon309 0:ac8863619623 132 /** @defgroup COMP_OutputPolarity COMP OutputPolarity
jhon309 0:ac8863619623 133 * @{
jhon309 0:ac8863619623 134 */
jhon309 0:ac8863619623 135 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
jhon309 0:ac8863619623 136 #define COMP_OUTPUTPOL_INVERTED COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */
jhon309 0:ac8863619623 137
jhon309 0:ac8863619623 138 #define IS_COMP_OUTPUTPOL(POL) (((POL) == COMP_OUTPUTPOL_NONINVERTED) || \
jhon309 0:ac8863619623 139 ((POL) == COMP_OUTPUTPOL_INVERTED))
jhon309 0:ac8863619623 140 /**
jhon309 0:ac8863619623 141 * @}
jhon309 0:ac8863619623 142 */
jhon309 0:ac8863619623 143
jhon309 0:ac8863619623 144 /** @defgroup COMP_Hysteresis COMP Hysteresis
jhon309 0:ac8863619623 145 * @{
jhon309 0:ac8863619623 146 */
jhon309 0:ac8863619623 147 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */
jhon309 0:ac8863619623 148 #define COMP_HYSTERESIS_LOW COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */
jhon309 0:ac8863619623 149 #define COMP_HYSTERESIS_MEDIUM COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */
jhon309 0:ac8863619623 150 #define COMP_HYSTERESIS_HIGH COMP_CSR_COMP1HYST /*!< Hysteresis level high */
jhon309 0:ac8863619623 151
jhon309 0:ac8863619623 152 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \
jhon309 0:ac8863619623 153 ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \
jhon309 0:ac8863619623 154 ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \
jhon309 0:ac8863619623 155 ((HYSTERESIS) == COMP_HYSTERESIS_HIGH))
jhon309 0:ac8863619623 156 /**
jhon309 0:ac8863619623 157 * @}
jhon309 0:ac8863619623 158 */
jhon309 0:ac8863619623 159
jhon309 0:ac8863619623 160 /** @defgroup COMP_Mode COMP Mode
jhon309 0:ac8863619623 161 * @{
jhon309 0:ac8863619623 162 */
jhon309 0:ac8863619623 163 /* Please refer to the electrical characteristics in the device datasheet for
jhon309 0:ac8863619623 164 the power consumption values */
jhon309 0:ac8863619623 165 #define COMP_MODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */
jhon309 0:ac8863619623 166 #define COMP_MODE_MEDIUMSPEED COMP_CSR_COMP1MODE_0 /*!< Medium Speed */
jhon309 0:ac8863619623 167 #define COMP_MODE_LOWPOWER COMP_CSR_COMP1MODE_1 /*!< Low power mode */
jhon309 0:ac8863619623 168 #define COMP_MODE_ULTRALOWPOWER COMP_CSR_COMP1MODE /*!< Ultra-low power mode */
jhon309 0:ac8863619623 169
jhon309 0:ac8863619623 170 #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \
jhon309 0:ac8863619623 171 ((MODE) == COMP_MODE_MEDIUMSPEED) || \
jhon309 0:ac8863619623 172 ((MODE) == COMP_MODE_LOWPOWER) || \
jhon309 0:ac8863619623 173 ((MODE) == COMP_MODE_ULTRALOWPOWER))
jhon309 0:ac8863619623 174
jhon309 0:ac8863619623 175 /**
jhon309 0:ac8863619623 176 * @}
jhon309 0:ac8863619623 177 */
jhon309 0:ac8863619623 178
jhon309 0:ac8863619623 179 /** @defgroup COMP_InvertingInput COMP InvertingInput
jhon309 0:ac8863619623 180 * @{
jhon309 0:ac8863619623 181 */
jhon309 0:ac8863619623 182
jhon309 0:ac8863619623 183 #define COMP_INVERTINGINPUT_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */
jhon309 0:ac8863619623 184 #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */
jhon309 0:ac8863619623 185 #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */
jhon309 0:ac8863619623 186 #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMP1INSEL_1|COMP_CSR_COMP1INSEL_0) /*!< VREFINT connected to comparator inverting input */
jhon309 0:ac8863619623 187 #define COMP_INVERTINGINPUT_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC_OUT1 (PA4) connected to comparator inverting input */
jhon309 0:ac8863619623 188 #define COMP_INVERTINGINPUT_DAC1SWITCHCLOSED (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1SW1) /*!< DAC_OUT1 (PA4) connected to comparator inverting input
jhon309 0:ac8863619623 189 and close switch (PA0 for COMP1 only) */
jhon309 0:ac8863619623 190 #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_0) /*!< DAC_OUT2 (PA5) connected to comparator inverting input */
jhon309 0:ac8863619623 191 #define COMP_INVERTINGINPUT_IO1 (COMP_CSR_COMP1INSEL_2|COMP_CSR_COMP1INSEL_1) /*!< IO (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */
jhon309 0:ac8863619623 192
jhon309 0:ac8863619623 193 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
jhon309 0:ac8863619623 194 ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
jhon309 0:ac8863619623 195 ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
jhon309 0:ac8863619623 196 ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
jhon309 0:ac8863619623 197 ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \
jhon309 0:ac8863619623 198 ((INPUT) == COMP_INVERTINGINPUT_DAC1SWITCHCLOSED) || \
jhon309 0:ac8863619623 199 ((INPUT) == COMP_INVERTINGINPUT_DAC2) || \
jhon309 0:ac8863619623 200 ((INPUT) == COMP_INVERTINGINPUT_IO1))
jhon309 0:ac8863619623 201 /**
jhon309 0:ac8863619623 202 * @}
jhon309 0:ac8863619623 203 */
jhon309 0:ac8863619623 204
jhon309 0:ac8863619623 205 /** @defgroup COMP_NonInvertingInput COMP NonInvertingInput
jhon309 0:ac8863619623 206 * @{
jhon309 0:ac8863619623 207 */
jhon309 0:ac8863619623 208 #define COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA3 for COMP2)
jhon309 0:ac8863619623 209 connected to comparator non inverting input */
jhon309 0:ac8863619623 210 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP_CSR_COMP1SW1 /*!< DAC ouput connected to comparator COMP1 non inverting input */
jhon309 0:ac8863619623 211
jhon309 0:ac8863619623 212 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
jhon309 0:ac8863619623 213 ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
jhon309 0:ac8863619623 214 /**
jhon309 0:ac8863619623 215 * @}
jhon309 0:ac8863619623 216 */
jhon309 0:ac8863619623 217
jhon309 0:ac8863619623 218 /** @defgroup COMP_Output COMP Output
jhon309 0:ac8863619623 219 * @{
jhon309 0:ac8863619623 220 */
jhon309 0:ac8863619623 221
jhon309 0:ac8863619623 222 /* Output Redirection common for COMP1 and COMP2 */
jhon309 0:ac8863619623 223 #define COMP_OUTPUT_NONE ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */
jhon309 0:ac8863619623 224 #define COMP_OUTPUT_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */
jhon309 0:ac8863619623 225 #define COMP_OUTPUT_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */
jhon309 0:ac8863619623 226 #define COMP_OUTPUT_TIM1OCREFCLR (COMP_CSR_COMP1OUTSEL_1|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM1 OCREF Clear */
jhon309 0:ac8863619623 227 #define COMP_OUTPUT_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */
jhon309 0:ac8863619623 228 #define COMP_OUTPUT_TIM2OCREFCLR (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM2 OCREF Clear */
jhon309 0:ac8863619623 229 #define COMP_OUTPUT_TIM3IC1 (COMP_CSR_COMP1OUTSEL_2|COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 Input Capture 1 */
jhon309 0:ac8863619623 230 #define COMP_OUTPUT_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */
jhon309 0:ac8863619623 231
jhon309 0:ac8863619623 232 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
jhon309 0:ac8863619623 233 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
jhon309 0:ac8863619623 234 ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
jhon309 0:ac8863619623 235 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
jhon309 0:ac8863619623 236 ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
jhon309 0:ac8863619623 237 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
jhon309 0:ac8863619623 238 ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
jhon309 0:ac8863619623 239 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))
jhon309 0:ac8863619623 240
jhon309 0:ac8863619623 241 /**
jhon309 0:ac8863619623 242 * @}
jhon309 0:ac8863619623 243 */
jhon309 0:ac8863619623 244
jhon309 0:ac8863619623 245 /** @defgroup COMP_OutputLevel COMP OutputLevel
jhon309 0:ac8863619623 246 * @{
jhon309 0:ac8863619623 247 */
jhon309 0:ac8863619623 248 /* When output polarity is not inverted, comparator output is low when
jhon309 0:ac8863619623 249 the non-inverting input is at a lower voltage than the inverting input*/
jhon309 0:ac8863619623 250 #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
jhon309 0:ac8863619623 251 /* When output polarity is not inverted, comparator output is high when
jhon309 0:ac8863619623 252 the non-inverting input is at a higher voltage than the inverting input */
jhon309 0:ac8863619623 253 #define COMP_OUTPUTLEVEL_HIGH COMP_CSR_COMP1OUT
jhon309 0:ac8863619623 254 /**
jhon309 0:ac8863619623 255 * @}
jhon309 0:ac8863619623 256 */
jhon309 0:ac8863619623 257
jhon309 0:ac8863619623 258 /** @defgroup COMP_TriggerMode COMP TriggerMode
jhon309 0:ac8863619623 259 * @{
jhon309 0:ac8863619623 260 */
jhon309 0:ac8863619623 261 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
jhon309 0:ac8863619623 262 #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
jhon309 0:ac8863619623 263 #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
jhon309 0:ac8863619623 264 #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
jhon309 0:ac8863619623 265
jhon309 0:ac8863619623 266 #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
jhon309 0:ac8863619623 267 ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
jhon309 0:ac8863619623 268 ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
jhon309 0:ac8863619623 269 ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
jhon309 0:ac8863619623 270 /**
jhon309 0:ac8863619623 271 * @}
jhon309 0:ac8863619623 272 */
jhon309 0:ac8863619623 273
jhon309 0:ac8863619623 274 /** @defgroup COMP_WindowMode COMP WindowMode
jhon309 0:ac8863619623 275 * @{
jhon309 0:ac8863619623 276 */
jhon309 0:ac8863619623 277 #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled */
jhon309 0:ac8863619623 278 #define COMP_WINDOWMODE_ENABLED COMP_CSR_WNDWEN /*!< Window mode enabled: non inverting input of comparator 2
jhon309 0:ac8863619623 279 is connected to the non inverting input of comparator 1 (PA1) */
jhon309 0:ac8863619623 280
jhon309 0:ac8863619623 281 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
jhon309 0:ac8863619623 282 ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
jhon309 0:ac8863619623 283 /**
jhon309 0:ac8863619623 284 * @}
jhon309 0:ac8863619623 285 */
jhon309 0:ac8863619623 286
jhon309 0:ac8863619623 287 /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent
jhon309 0:ac8863619623 288 * Elements values convention: XXXX0000
jhon309 0:ac8863619623 289 * - XXXX : Interrupt mask in the EMR/IMR/RTSR/FTSR register
jhon309 0:ac8863619623 290 * @{
jhon309 0:ac8863619623 291 */
jhon309 0:ac8863619623 292 #define COMP_EXTI_LINE_COMP1_EVENT ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to COMP1 */
jhon309 0:ac8863619623 293 #define COMP_EXTI_LINE_COMP2_EVENT ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to COMP2 */
jhon309 0:ac8863619623 294
jhon309 0:ac8863619623 295 /**
jhon309 0:ac8863619623 296 * @}
jhon309 0:ac8863619623 297 */
jhon309 0:ac8863619623 298
jhon309 0:ac8863619623 299 /** @defgroup COMP_Lock COMP Lock
jhon309 0:ac8863619623 300 * @{
jhon309 0:ac8863619623 301 */
jhon309 0:ac8863619623 302 #define COMP_LOCK_DISABLE ((uint32_t)0x00000000)
jhon309 0:ac8863619623 303 #define COMP_LOCK_ENABLE COMP_CSR_COMP1LOCK
jhon309 0:ac8863619623 304
jhon309 0:ac8863619623 305 #define COMP_STATE_BIT_LOCK ((uint32_t)0x10)
jhon309 0:ac8863619623 306 /**
jhon309 0:ac8863619623 307 * @}
jhon309 0:ac8863619623 308 */
jhon309 0:ac8863619623 309
jhon309 0:ac8863619623 310
jhon309 0:ac8863619623 311 /**
jhon309 0:ac8863619623 312 * @}
jhon309 0:ac8863619623 313 */
jhon309 0:ac8863619623 314
jhon309 0:ac8863619623 315 /* Exported macros -----------------------------------------------------------*/
jhon309 0:ac8863619623 316 /** @defgroup COMP_Exported_Macros COMP Exported Macros
jhon309 0:ac8863619623 317 * @{
jhon309 0:ac8863619623 318 */
jhon309 0:ac8863619623 319
jhon309 0:ac8863619623 320 /** @brief Reset COMP handle state
jhon309 0:ac8863619623 321 * @param __HANDLE__: COMP handle.
jhon309 0:ac8863619623 322 * @retval None
jhon309 0:ac8863619623 323 */
jhon309 0:ac8863619623 324 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
jhon309 0:ac8863619623 325
jhon309 0:ac8863619623 326 /**
jhon309 0:ac8863619623 327 * @brief Checks whether the specified EXTI line flag is set or not.
jhon309 0:ac8863619623 328 * @param __FLAG__: specifies the COMP Exti sources to be checked.
jhon309 0:ac8863619623 329 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 330 * @retval The state of __FLAG__ (SET or RESET).
jhon309 0:ac8863619623 331 */
jhon309 0:ac8863619623 332 #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (EXTI->PR & (__FLAG__))
jhon309 0:ac8863619623 333
jhon309 0:ac8863619623 334 /**
jhon309 0:ac8863619623 335 * @brief Clear the COMP Exti flags.
jhon309 0:ac8863619623 336 * @param __FLAG__: specifies the COMP Exti sources to be cleared.
jhon309 0:ac8863619623 337 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 338 * @retval None.
jhon309 0:ac8863619623 339 */
jhon309 0:ac8863619623 340 #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
jhon309 0:ac8863619623 341
jhon309 0:ac8863619623 342 /**
jhon309 0:ac8863619623 343 * @brief Enable the COMP Exti Line.
jhon309 0:ac8863619623 344 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
jhon309 0:ac8863619623 345 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 346 * @retval None.
jhon309 0:ac8863619623 347 */
jhon309 0:ac8863619623 348 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (EXTI->IMR |= (__EXTILINE__))
jhon309 0:ac8863619623 349
jhon309 0:ac8863619623 350 /**
jhon309 0:ac8863619623 351 * @brief Disable the COMP Exti Line.
jhon309 0:ac8863619623 352 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
jhon309 0:ac8863619623 353 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 354 * @retval None.
jhon309 0:ac8863619623 355 */
jhon309 0:ac8863619623 356 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (EXTI->IMR &= ~(__EXTILINE__))
jhon309 0:ac8863619623 357
jhon309 0:ac8863619623 358 /**
jhon309 0:ac8863619623 359 * @brief Enable the Exti Line rising edge trigger.
jhon309 0:ac8863619623 360 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
jhon309 0:ac8863619623 361 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 362 * @retval None.
jhon309 0:ac8863619623 363 */
jhon309 0:ac8863619623 364 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (EXTI->RTSR |= (__EXTILINE__))
jhon309 0:ac8863619623 365
jhon309 0:ac8863619623 366 /**
jhon309 0:ac8863619623 367 * @brief Disable the Exti Line rising edge trigger.
jhon309 0:ac8863619623 368 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
jhon309 0:ac8863619623 369 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 370 * @retval None.
jhon309 0:ac8863619623 371 */
jhon309 0:ac8863619623 372 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (EXTI->RTSR &= ~(__EXTILINE__))
jhon309 0:ac8863619623 373
jhon309 0:ac8863619623 374 /**
jhon309 0:ac8863619623 375 * @brief Enable the Exti Line falling edge trigger.
jhon309 0:ac8863619623 376 * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
jhon309 0:ac8863619623 377 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 378 * @retval None.
jhon309 0:ac8863619623 379 */
jhon309 0:ac8863619623 380 #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (EXTI->FTSR |= (__EXTILINE__))
jhon309 0:ac8863619623 381
jhon309 0:ac8863619623 382 /**
jhon309 0:ac8863619623 383 * @brief Disable the Exti Line falling edge trigger.
jhon309 0:ac8863619623 384 * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
jhon309 0:ac8863619623 385 * This parameter can be a value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 386 * @retval None.
jhon309 0:ac8863619623 387 */
jhon309 0:ac8863619623 388 #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (EXTI->FTSR &= ~(__EXTILINE__))
jhon309 0:ac8863619623 389
jhon309 0:ac8863619623 390 /**
jhon309 0:ac8863619623 391 * @brief Get the specified EXTI line for a comparator instance
jhon309 0:ac8863619623 392 * @param __INSTANCE__: specifies the COMP instance.
jhon309 0:ac8863619623 393 * @retval value of @ref COMP_ExtiLineEvent
jhon309 0:ac8863619623 394 */
jhon309 0:ac8863619623 395 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
jhon309 0:ac8863619623 396 COMP_EXTI_LINE_COMP2_EVENT)
jhon309 0:ac8863619623 397 /**
jhon309 0:ac8863619623 398 * @}
jhon309 0:ac8863619623 399 */
jhon309 0:ac8863619623 400
jhon309 0:ac8863619623 401 /* Exported functions --------------------------------------------------------*/
jhon309 0:ac8863619623 402 /** @addtogroup COMP_Exported_Functions COMP Exported Functions
jhon309 0:ac8863619623 403 * @{
jhon309 0:ac8863619623 404 */
jhon309 0:ac8863619623 405 /** @addtogroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions
jhon309 0:ac8863619623 406 * @brief Initialization and Configuration functions
jhon309 0:ac8863619623 407 * @{
jhon309 0:ac8863619623 408 */
jhon309 0:ac8863619623 409 /* Initialization and de-initialization functions ****************************/
jhon309 0:ac8863619623 410 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 411 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 412 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 413 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 414 /**
jhon309 0:ac8863619623 415 * @}
jhon309 0:ac8863619623 416 */
jhon309 0:ac8863619623 417
jhon309 0:ac8863619623 418 /** @addtogroup COMP_Exported_Functions_Group2 I/O operation functions
jhon309 0:ac8863619623 419 * @brief Data transfers functions
jhon309 0:ac8863619623 420 * @{
jhon309 0:ac8863619623 421 */
jhon309 0:ac8863619623 422 /* IO operation functions *****************************************************/
jhon309 0:ac8863619623 423 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 424 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 425 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 426 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 427 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 428 /**
jhon309 0:ac8863619623 429 * @}
jhon309 0:ac8863619623 430 */
jhon309 0:ac8863619623 431
jhon309 0:ac8863619623 432 /** @addtogroup COMP_Exported_Functions_Group3 Peripheral Control functions
jhon309 0:ac8863619623 433 * @brief management functions
jhon309 0:ac8863619623 434 * @{
jhon309 0:ac8863619623 435 */
jhon309 0:ac8863619623 436 /* Peripheral Control functions ***********************************************/
jhon309 0:ac8863619623 437 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 438 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 439
jhon309 0:ac8863619623 440 /* Callback in Interrupt mode */
jhon309 0:ac8863619623 441 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 442 /**
jhon309 0:ac8863619623 443 * @}
jhon309 0:ac8863619623 444 */
jhon309 0:ac8863619623 445
jhon309 0:ac8863619623 446 /** @addtogroup COMP_Exported_Functions_Group4 Peripheral State functions
jhon309 0:ac8863619623 447 * @brief Peripheral State functions
jhon309 0:ac8863619623 448 * @{
jhon309 0:ac8863619623 449 */
jhon309 0:ac8863619623 450 /* Peripheral State and Error functions ***************************************/
jhon309 0:ac8863619623 451 uint32_t HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
jhon309 0:ac8863619623 452 /**
jhon309 0:ac8863619623 453 * @}
jhon309 0:ac8863619623 454 */
jhon309 0:ac8863619623 455
jhon309 0:ac8863619623 456 /**
jhon309 0:ac8863619623 457 * @}
jhon309 0:ac8863619623 458 */
jhon309 0:ac8863619623 459
jhon309 0:ac8863619623 460 /**
jhon309 0:ac8863619623 461 * @}
jhon309 0:ac8863619623 462 */
jhon309 0:ac8863619623 463
jhon309 0:ac8863619623 464 /**
jhon309 0:ac8863619623 465 * @}
jhon309 0:ac8863619623 466 */
jhon309 0:ac8863619623 467
jhon309 0:ac8863619623 468 #endif /* STM32F051x8 || STM32F058xx || */
jhon309 0:ac8863619623 469 /* STM32F071xB || STM32F072xB || STM32F078xx || */
jhon309 0:ac8863619623 470 /* STM32F091xC || STM32F098xx */
jhon309 0:ac8863619623 471
jhon309 0:ac8863619623 472 #ifdef __cplusplus
jhon309 0:ac8863619623 473 }
jhon309 0:ac8863619623 474 #endif
jhon309 0:ac8863619623 475
jhon309 0:ac8863619623 476 #endif /* __STM32F0xx_HAL_COMP_H */
jhon309 0:ac8863619623 477
jhon309 0:ac8863619623 478 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
jhon309 0:ac8863619623 479