version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
erezi
Date:
Wed Jun 25 06:08:49 2014 +0000
Revision:
86:4f9a848d74c7
Parent:
81:7d30d6019079
version_2.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 77:869cf507173a 1 /**
emilmont 77:869cf507173a 2 ******************************************************************************
emilmont 77:869cf507173a 3 * @file stm32f0xx_comp.h
emilmont 77:869cf507173a 4 * @author MCD Application Team
emilmont 77:869cf507173a 5 * @version V1.3.0
emilmont 77:869cf507173a 6 * @date 16-January-2014
emilmont 77:869cf507173a 7 * @brief This file contains all the functions prototypes for the COMP firmware
emilmont 77:869cf507173a 8 * library, applicable only for STM32F051 and STM32F072 devices.
emilmont 77:869cf507173a 9 ******************************************************************************
emilmont 77:869cf507173a 10 * @attention
emilmont 77:869cf507173a 11 *
bogdanm 81:7d30d6019079 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
emilmont 77:869cf507173a 13 *
bogdanm 81:7d30d6019079 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 81:7d30d6019079 15 * are permitted provided that the following conditions are met:
bogdanm 81:7d30d6019079 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 81:7d30d6019079 17 * this list of conditions and the following disclaimer.
bogdanm 81:7d30d6019079 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 81:7d30d6019079 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 81:7d30d6019079 20 * and/or other materials provided with the distribution.
bogdanm 81:7d30d6019079 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 81:7d30d6019079 22 * may be used to endorse or promote products derived from this software
bogdanm 81:7d30d6019079 23 * without specific prior written permission.
emilmont 77:869cf507173a 24 *
bogdanm 81:7d30d6019079 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 81:7d30d6019079 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 81:7d30d6019079 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 81:7d30d6019079 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 81:7d30d6019079 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 81:7d30d6019079 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 81:7d30d6019079 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 81:7d30d6019079 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 81:7d30d6019079 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 81:7d30d6019079 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
emilmont 77:869cf507173a 35 *
emilmont 77:869cf507173a 36 ******************************************************************************
emilmont 77:869cf507173a 37 */
emilmont 77:869cf507173a 38
emilmont 77:869cf507173a 39 /* Define to prevent recursive inclusion -------------------------------------*/
emilmont 77:869cf507173a 40 #ifndef __STM32F0XX_COMP_H
emilmont 77:869cf507173a 41 #define __STM32F0XX_COMP_H
emilmont 77:869cf507173a 42
emilmont 77:869cf507173a 43 #ifdef __cplusplus
emilmont 77:869cf507173a 44 extern "C" {
emilmont 77:869cf507173a 45 #endif
emilmont 77:869cf507173a 46
emilmont 77:869cf507173a 47 /* Includes ------------------------------------------------------------------*/
emilmont 77:869cf507173a 48 #include "stm32f0xx.h"
emilmont 77:869cf507173a 49
emilmont 77:869cf507173a 50 /** @addtogroup STM32F0xx_StdPeriph_Driver
emilmont 77:869cf507173a 51 * @{
emilmont 77:869cf507173a 52 */
emilmont 77:869cf507173a 53
emilmont 77:869cf507173a 54 /** @addtogroup COMP
emilmont 77:869cf507173a 55 * @{
emilmont 77:869cf507173a 56 */
emilmont 77:869cf507173a 57
emilmont 77:869cf507173a 58 /* Exported types ------------------------------------------------------------*/
emilmont 77:869cf507173a 59
emilmont 77:869cf507173a 60 /**
emilmont 77:869cf507173a 61 * @brief COMP Init structure definition
emilmont 77:869cf507173a 62 */
emilmont 77:869cf507173a 63
emilmont 77:869cf507173a 64 typedef struct
emilmont 77:869cf507173a 65 {
emilmont 77:869cf507173a 66
emilmont 77:869cf507173a 67 uint32_t COMP_InvertingInput; /*!< Selects the inverting input of the comparator.
emilmont 77:869cf507173a 68 This parameter can be a value of @ref COMP_InvertingInput */
emilmont 77:869cf507173a 69
emilmont 77:869cf507173a 70 uint32_t COMP_Output; /*!< Selects the output redirection of the comparator.
emilmont 77:869cf507173a 71 This parameter can be a value of @ref COMP_Output */
emilmont 77:869cf507173a 72
emilmont 77:869cf507173a 73 uint32_t COMP_OutputPol; /*!< Selects the output polarity of the comparator.
emilmont 77:869cf507173a 74 This parameter can be a value of @ref COMP_OutputPolarity */
emilmont 77:869cf507173a 75
emilmont 77:869cf507173a 76 uint32_t COMP_Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
emilmont 77:869cf507173a 77 This parameter can be a value of @ref COMP_Hysteresis */
emilmont 77:869cf507173a 78
emilmont 77:869cf507173a 79 uint32_t COMP_Mode; /*!< Selects the operating mode of the comparator
emilmont 77:869cf507173a 80 and allows to adjust the speed/consumption.
emilmont 77:869cf507173a 81 This parameter can be a value of @ref COMP_Mode */
emilmont 77:869cf507173a 82
emilmont 77:869cf507173a 83 }COMP_InitTypeDef;
emilmont 77:869cf507173a 84
emilmont 77:869cf507173a 85 /* Exported constants --------------------------------------------------------*/
emilmont 77:869cf507173a 86
emilmont 77:869cf507173a 87 /** @defgroup COMP_Exported_Constants
emilmont 77:869cf507173a 88 * @{
emilmont 77:869cf507173a 89 */
emilmont 77:869cf507173a 90
emilmont 77:869cf507173a 91 /** @defgroup COMP_Selection
emilmont 77:869cf507173a 92 * @{
emilmont 77:869cf507173a 93 */
emilmont 77:869cf507173a 94
emilmont 77:869cf507173a 95 #define COMP_Selection_COMP1 ((uint32_t)0x00000000) /*!< COMP1 Selection */
emilmont 77:869cf507173a 96 #define COMP_Selection_COMP2 ((uint32_t)0x00000010) /*!< COMP2 Selection */
emilmont 77:869cf507173a 97
emilmont 77:869cf507173a 98 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
emilmont 77:869cf507173a 99 ((PERIPH) == COMP_Selection_COMP2))
emilmont 77:869cf507173a 100
emilmont 77:869cf507173a 101 /**
emilmont 77:869cf507173a 102 * @}
emilmont 77:869cf507173a 103 */
emilmont 77:869cf507173a 104
emilmont 77:869cf507173a 105 /** @defgroup COMP_InvertingInput
emilmont 77:869cf507173a 106 * @{
emilmont 77:869cf507173a 107 */
emilmont 77:869cf507173a 108
emilmont 77:869cf507173a 109 #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 110 #define COMP_InvertingInput_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 111 #define COMP_InvertingInput_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 112 #define COMP_InvertingInput_VREFINT ((uint32_t)0x00000030) /*!< VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 113 #define COMP_InvertingInput_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC1_OUT (PA4) connected to comparator inverting input */
emilmont 77:869cf507173a 114 #define COMP_InvertingInput_DAC2 ((uint32_t)0x00000050) /*!< DAC2_OUT (PA5) connected to comparator inverting input, applicable only for STM32F072 devices */
emilmont 77:869cf507173a 115 #define COMP_InvertingInput_IO ((uint32_t)0x00000060) /*!< I/O (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */
emilmont 77:869cf507173a 116
emilmont 77:869cf507173a 117 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
emilmont 77:869cf507173a 118 ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
emilmont 77:869cf507173a 119 ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
emilmont 77:869cf507173a 120 ((INPUT) == COMP_InvertingInput_VREFINT) || \
emilmont 77:869cf507173a 121 ((INPUT) == COMP_InvertingInput_DAC1) || \
emilmont 77:869cf507173a 122 ((INPUT) == COMP_InvertingInput_DAC2) || \
emilmont 77:869cf507173a 123 ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
emilmont 77:869cf507173a 124 ((INPUT) == COMP_InvertingInput_IO))
emilmont 77:869cf507173a 125 /**
emilmont 77:869cf507173a 126 * @}
emilmont 77:869cf507173a 127 */
emilmont 77:869cf507173a 128
emilmont 77:869cf507173a 129 /** @defgroup COMP_Output
emilmont 77:869cf507173a 130 * @{
emilmont 77:869cf507173a 131 */
emilmont 77:869cf507173a 132
emilmont 77:869cf507173a 133 #define COMP_Output_None ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */
emilmont 77:869cf507173a 134 #define COMP_Output_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */
emilmont 77:869cf507173a 135 #define COMP_Output_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */
emilmont 77:869cf507173a 136 #define COMP_Output_TIM1OCREFCLR ((uint32_t)0x00000300) /*!< COMP output connected to TIM1 OCREF Clear */
emilmont 77:869cf507173a 137 #define COMP_Output_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */
emilmont 77:869cf507173a 138 #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00000500) /*!< COMP output connected to TIM2 OCREF Clear */
emilmont 77:869cf507173a 139 #define COMP_Output_TIM3IC1 ((uint32_t)0x00000600) /*!< COMP output connected to TIM3 Input Capture 1 */
emilmont 77:869cf507173a 140 #define COMP_Output_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */
emilmont 77:869cf507173a 141
emilmont 77:869cf507173a 142
emilmont 77:869cf507173a 143 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \
emilmont 77:869cf507173a 144 ((OUTPUT) == COMP_Output_TIM1BKIN) || \
emilmont 77:869cf507173a 145 ((OUTPUT) == COMP_Output_TIM1IC1) || \
emilmont 77:869cf507173a 146 ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \
emilmont 77:869cf507173a 147 ((OUTPUT) == COMP_Output_TIM2IC4) || \
emilmont 77:869cf507173a 148 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \
emilmont 77:869cf507173a 149 ((OUTPUT) == COMP_Output_TIM3IC1) || \
emilmont 77:869cf507173a 150 ((OUTPUT) == COMP_Output_TIM3OCREFCLR))
emilmont 77:869cf507173a 151 /**
emilmont 77:869cf507173a 152 * @}
emilmont 77:869cf507173a 153 */
emilmont 77:869cf507173a 154
emilmont 77:869cf507173a 155 /** @defgroup COMP_OutputPolarity
emilmont 77:869cf507173a 156 * @{
emilmont 77:869cf507173a 157 */
emilmont 77:869cf507173a 158 #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
emilmont 77:869cf507173a 159 #define COMP_OutputPol_Inverted COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */
emilmont 77:869cf507173a 160
emilmont 77:869cf507173a 161 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \
emilmont 77:869cf507173a 162 ((POL) == COMP_OutputPol_Inverted))
emilmont 77:869cf507173a 163
emilmont 77:869cf507173a 164 /**
emilmont 77:869cf507173a 165 * @}
emilmont 77:869cf507173a 166 */
emilmont 77:869cf507173a 167
emilmont 77:869cf507173a 168 /** @defgroup COMP_Hysteresis
emilmont 77:869cf507173a 169 * @{
emilmont 77:869cf507173a 170 */
emilmont 77:869cf507173a 171 /* Please refer to the electrical characteristics in the device datasheet for
emilmont 77:869cf507173a 172 the hysteresis level */
emilmont 77:869cf507173a 173 #define COMP_Hysteresis_No 0x00000000 /*!< No hysteresis */
emilmont 77:869cf507173a 174 #define COMP_Hysteresis_Low COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */
emilmont 77:869cf507173a 175 #define COMP_Hysteresis_Medium COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */
emilmont 77:869cf507173a 176 #define COMP_Hysteresis_High COMP_CSR_COMP1HYST /*!< Hysteresis level high */
emilmont 77:869cf507173a 177
emilmont 77:869cf507173a 178 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \
emilmont 77:869cf507173a 179 ((HYSTERESIS) == COMP_Hysteresis_Low) || \
emilmont 77:869cf507173a 180 ((HYSTERESIS) == COMP_Hysteresis_Medium) || \
emilmont 77:869cf507173a 181 ((HYSTERESIS) == COMP_Hysteresis_High))
emilmont 77:869cf507173a 182 /**
emilmont 77:869cf507173a 183 * @}
emilmont 77:869cf507173a 184 */
emilmont 77:869cf507173a 185
emilmont 77:869cf507173a 186 /** @defgroup COMP_Mode
emilmont 77:869cf507173a 187 * @{
emilmont 77:869cf507173a 188 */
emilmont 77:869cf507173a 189 /* Please refer to the electrical characteristics in the device datasheet for
emilmont 77:869cf507173a 190 the power consumption values */
emilmont 77:869cf507173a 191 #define COMP_Mode_HighSpeed 0x00000000 /*!< High Speed */
emilmont 77:869cf507173a 192 #define COMP_Mode_MediumSpeed COMP_CSR_COMP1MODE_0 /*!< Medium Speed */
emilmont 77:869cf507173a 193 #define COMP_Mode_LowPower COMP_CSR_COMP1MODE_1 /*!< Low power mode */
emilmont 77:869cf507173a 194 #define COMP_Mode_UltraLowPower COMP_CSR_COMP1MODE /*!< Ultra-low power mode */
emilmont 77:869cf507173a 195
emilmont 77:869cf507173a 196 #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \
emilmont 77:869cf507173a 197 ((MODE) == COMP_Mode_LowPower) || \
emilmont 77:869cf507173a 198 ((MODE) == COMP_Mode_MediumSpeed) || \
emilmont 77:869cf507173a 199 ((MODE) == COMP_Mode_HighSpeed))
emilmont 77:869cf507173a 200 /**
emilmont 77:869cf507173a 201 * @}
emilmont 77:869cf507173a 202 */
emilmont 77:869cf507173a 203
emilmont 77:869cf507173a 204 /** @defgroup COMP_OutputLevel
emilmont 77:869cf507173a 205 * @{
emilmont 77:869cf507173a 206 */
emilmont 77:869cf507173a 207 /* When output polarity is not inverted, comparator output is high when
emilmont 77:869cf507173a 208 the non-inverting input is at a higher voltage than the inverting input */
emilmont 77:869cf507173a 209 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
emilmont 77:869cf507173a 210 /* When output polarity is not inverted, comparator output is low when
emilmont 77:869cf507173a 211 the non-inverting input is at a lower voltage than the inverting input*/
emilmont 77:869cf507173a 212 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
emilmont 77:869cf507173a 213
emilmont 77:869cf507173a 214 /**
emilmont 77:869cf507173a 215 * @}
emilmont 77:869cf507173a 216 */
emilmont 77:869cf507173a 217
emilmont 77:869cf507173a 218 /**
emilmont 77:869cf507173a 219 * @}
emilmont 77:869cf507173a 220 */
emilmont 77:869cf507173a 221
emilmont 77:869cf507173a 222 /* Exported macro ------------------------------------------------------------*/
emilmont 77:869cf507173a 223 /* Exported functions ------------------------------------------------------- */
emilmont 77:869cf507173a 224
emilmont 77:869cf507173a 225 /* Function used to set the COMP configuration to the default reset state ****/
emilmont 77:869cf507173a 226 void COMP_DeInit(void);
emilmont 77:869cf507173a 227
emilmont 77:869cf507173a 228 /* Initialization and Configuration functions *********************************/
emilmont 77:869cf507173a 229 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
emilmont 77:869cf507173a 230 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
emilmont 77:869cf507173a 231 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
emilmont 77:869cf507173a 232 void COMP_SwitchCmd(FunctionalState NewState);
emilmont 77:869cf507173a 233 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
emilmont 77:869cf507173a 234
emilmont 77:869cf507173a 235 /* Window mode control function ***********************************************/
emilmont 77:869cf507173a 236 void COMP_WindowCmd(FunctionalState NewState);
emilmont 77:869cf507173a 237
emilmont 77:869cf507173a 238 /* COMP configuration locking function ****************************************/
emilmont 77:869cf507173a 239 void COMP_LockConfig(uint32_t COMP_Selection);
emilmont 77:869cf507173a 240
emilmont 77:869cf507173a 241 #ifdef __cplusplus
emilmont 77:869cf507173a 242 }
emilmont 77:869cf507173a 243 #endif
emilmont 77:869cf507173a 244
emilmont 77:869cf507173a 245 #endif /*__STM32F0XX_COMP_H */
emilmont 77:869cf507173a 246
emilmont 77:869cf507173a 247 /**
emilmont 77:869cf507173a 248 * @}
emilmont 77:869cf507173a 249 */
emilmont 77:869cf507173a 250
emilmont 77:869cf507173a 251 /**
emilmont 77:869cf507173a 252 * @}
emilmont 77:869cf507173a 253 */
emilmont 77:869cf507173a 254
emilmont 77:869cf507173a 255 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/