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:
emilmont
Date:
Fri Feb 14 14:36:43 2014 +0000
Revision:
77:869cf507173a
Child:
81:7d30d6019079
Release 77 of the mbed library

Main changes:
* Add target NUCLEO_F030R8
* Add target NUCLEO_F401RE
* Add target NUCLEO_F103RB
* Add target NUCLEO_L152RE

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 *
emilmont 77:869cf507173a 12 * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
emilmont 77:869cf507173a 13 *
emilmont 77:869cf507173a 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
emilmont 77:869cf507173a 15 * You may not use this file except in compliance with the License.
emilmont 77:869cf507173a 16 * You may obtain a copy of the License at:
emilmont 77:869cf507173a 17 *
emilmont 77:869cf507173a 18 * http://www.st.com/software_license_agreement_liberty_v2
emilmont 77:869cf507173a 19 *
emilmont 77:869cf507173a 20 * Unless required by applicable law or agreed to in writing, software
emilmont 77:869cf507173a 21 * distributed under the License is distributed on an "AS IS" BASIS,
emilmont 77:869cf507173a 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
emilmont 77:869cf507173a 23 * See the License for the specific language governing permissions and
emilmont 77:869cf507173a 24 * limitations under the License.
emilmont 77:869cf507173a 25 *
emilmont 77:869cf507173a 26 ******************************************************************************
emilmont 77:869cf507173a 27 */
emilmont 77:869cf507173a 28
emilmont 77:869cf507173a 29 /* Define to prevent recursive inclusion -------------------------------------*/
emilmont 77:869cf507173a 30 #ifndef __STM32F0XX_COMP_H
emilmont 77:869cf507173a 31 #define __STM32F0XX_COMP_H
emilmont 77:869cf507173a 32
emilmont 77:869cf507173a 33 #ifdef __cplusplus
emilmont 77:869cf507173a 34 extern "C" {
emilmont 77:869cf507173a 35 #endif
emilmont 77:869cf507173a 36
emilmont 77:869cf507173a 37 /* Includes ------------------------------------------------------------------*/
emilmont 77:869cf507173a 38 #include "stm32f0xx.h"
emilmont 77:869cf507173a 39
emilmont 77:869cf507173a 40 /** @addtogroup STM32F0xx_StdPeriph_Driver
emilmont 77:869cf507173a 41 * @{
emilmont 77:869cf507173a 42 */
emilmont 77:869cf507173a 43
emilmont 77:869cf507173a 44 /** @addtogroup COMP
emilmont 77:869cf507173a 45 * @{
emilmont 77:869cf507173a 46 */
emilmont 77:869cf507173a 47
emilmont 77:869cf507173a 48 /* Exported types ------------------------------------------------------------*/
emilmont 77:869cf507173a 49
emilmont 77:869cf507173a 50 /**
emilmont 77:869cf507173a 51 * @brief COMP Init structure definition
emilmont 77:869cf507173a 52 */
emilmont 77:869cf507173a 53
emilmont 77:869cf507173a 54 typedef struct
emilmont 77:869cf507173a 55 {
emilmont 77:869cf507173a 56
emilmont 77:869cf507173a 57 uint32_t COMP_InvertingInput; /*!< Selects the inverting input of the comparator.
emilmont 77:869cf507173a 58 This parameter can be a value of @ref COMP_InvertingInput */
emilmont 77:869cf507173a 59
emilmont 77:869cf507173a 60 uint32_t COMP_Output; /*!< Selects the output redirection of the comparator.
emilmont 77:869cf507173a 61 This parameter can be a value of @ref COMP_Output */
emilmont 77:869cf507173a 62
emilmont 77:869cf507173a 63 uint32_t COMP_OutputPol; /*!< Selects the output polarity of the comparator.
emilmont 77:869cf507173a 64 This parameter can be a value of @ref COMP_OutputPolarity */
emilmont 77:869cf507173a 65
emilmont 77:869cf507173a 66 uint32_t COMP_Hysteresis; /*!< Selects the hysteresis voltage of the comparator.
emilmont 77:869cf507173a 67 This parameter can be a value of @ref COMP_Hysteresis */
emilmont 77:869cf507173a 68
emilmont 77:869cf507173a 69 uint32_t COMP_Mode; /*!< Selects the operating mode of the comparator
emilmont 77:869cf507173a 70 and allows to adjust the speed/consumption.
emilmont 77:869cf507173a 71 This parameter can be a value of @ref COMP_Mode */
emilmont 77:869cf507173a 72
emilmont 77:869cf507173a 73 }COMP_InitTypeDef;
emilmont 77:869cf507173a 74
emilmont 77:869cf507173a 75 /* Exported constants --------------------------------------------------------*/
emilmont 77:869cf507173a 76
emilmont 77:869cf507173a 77 /** @defgroup COMP_Exported_Constants
emilmont 77:869cf507173a 78 * @{
emilmont 77:869cf507173a 79 */
emilmont 77:869cf507173a 80
emilmont 77:869cf507173a 81 /** @defgroup COMP_Selection
emilmont 77:869cf507173a 82 * @{
emilmont 77:869cf507173a 83 */
emilmont 77:869cf507173a 84
emilmont 77:869cf507173a 85 #define COMP_Selection_COMP1 ((uint32_t)0x00000000) /*!< COMP1 Selection */
emilmont 77:869cf507173a 86 #define COMP_Selection_COMP2 ((uint32_t)0x00000010) /*!< COMP2 Selection */
emilmont 77:869cf507173a 87
emilmont 77:869cf507173a 88 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
emilmont 77:869cf507173a 89 ((PERIPH) == COMP_Selection_COMP2))
emilmont 77:869cf507173a 90
emilmont 77:869cf507173a 91 /**
emilmont 77:869cf507173a 92 * @}
emilmont 77:869cf507173a 93 */
emilmont 77:869cf507173a 94
emilmont 77:869cf507173a 95 /** @defgroup COMP_InvertingInput
emilmont 77:869cf507173a 96 * @{
emilmont 77:869cf507173a 97 */
emilmont 77:869cf507173a 98
emilmont 77:869cf507173a 99 #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 100 #define COMP_InvertingInput_1_2VREFINT COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 101 #define COMP_InvertingInput_3_4VREFINT COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 102 #define COMP_InvertingInput_VREFINT ((uint32_t)0x00000030) /*!< VREFINT connected to comparator inverting input */
emilmont 77:869cf507173a 103 #define COMP_InvertingInput_DAC1 COMP_CSR_COMP1INSEL_2 /*!< DAC1_OUT (PA4) connected to comparator inverting input */
emilmont 77:869cf507173a 104 #define COMP_InvertingInput_DAC2 ((uint32_t)0x00000050) /*!< DAC2_OUT (PA5) connected to comparator inverting input, applicable only for STM32F072 devices */
emilmont 77:869cf507173a 105 #define COMP_InvertingInput_IO ((uint32_t)0x00000060) /*!< I/O (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */
emilmont 77:869cf507173a 106
emilmont 77:869cf507173a 107 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
emilmont 77:869cf507173a 108 ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
emilmont 77:869cf507173a 109 ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
emilmont 77:869cf507173a 110 ((INPUT) == COMP_InvertingInput_VREFINT) || \
emilmont 77:869cf507173a 111 ((INPUT) == COMP_InvertingInput_DAC1) || \
emilmont 77:869cf507173a 112 ((INPUT) == COMP_InvertingInput_DAC2) || \
emilmont 77:869cf507173a 113 ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
emilmont 77:869cf507173a 114 ((INPUT) == COMP_InvertingInput_IO))
emilmont 77:869cf507173a 115 /**
emilmont 77:869cf507173a 116 * @}
emilmont 77:869cf507173a 117 */
emilmont 77:869cf507173a 118
emilmont 77:869cf507173a 119 /** @defgroup COMP_Output
emilmont 77:869cf507173a 120 * @{
emilmont 77:869cf507173a 121 */
emilmont 77:869cf507173a 122
emilmont 77:869cf507173a 123 #define COMP_Output_None ((uint32_t)0x00000000) /*!< COMP output isn't connected to other peripherals */
emilmont 77:869cf507173a 124 #define COMP_Output_TIM1BKIN COMP_CSR_COMP1OUTSEL_0 /*!< COMP output connected to TIM1 Break Input (BKIN) */
emilmont 77:869cf507173a 125 #define COMP_Output_TIM1IC1 COMP_CSR_COMP1OUTSEL_1 /*!< COMP output connected to TIM1 Input Capture 1 */
emilmont 77:869cf507173a 126 #define COMP_Output_TIM1OCREFCLR ((uint32_t)0x00000300) /*!< COMP output connected to TIM1 OCREF Clear */
emilmont 77:869cf507173a 127 #define COMP_Output_TIM2IC4 COMP_CSR_COMP1OUTSEL_2 /*!< COMP output connected to TIM2 Input Capture 4 */
emilmont 77:869cf507173a 128 #define COMP_Output_TIM2OCREFCLR ((uint32_t)0x00000500) /*!< COMP output connected to TIM2 OCREF Clear */
emilmont 77:869cf507173a 129 #define COMP_Output_TIM3IC1 ((uint32_t)0x00000600) /*!< COMP output connected to TIM3 Input Capture 1 */
emilmont 77:869cf507173a 130 #define COMP_Output_TIM3OCREFCLR COMP_CSR_COMP1OUTSEL /*!< COMP output connected to TIM3 OCREF Clear */
emilmont 77:869cf507173a 131
emilmont 77:869cf507173a 132
emilmont 77:869cf507173a 133 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None) || \
emilmont 77:869cf507173a 134 ((OUTPUT) == COMP_Output_TIM1BKIN) || \
emilmont 77:869cf507173a 135 ((OUTPUT) == COMP_Output_TIM1IC1) || \
emilmont 77:869cf507173a 136 ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \
emilmont 77:869cf507173a 137 ((OUTPUT) == COMP_Output_TIM2IC4) || \
emilmont 77:869cf507173a 138 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \
emilmont 77:869cf507173a 139 ((OUTPUT) == COMP_Output_TIM3IC1) || \
emilmont 77:869cf507173a 140 ((OUTPUT) == COMP_Output_TIM3OCREFCLR))
emilmont 77:869cf507173a 141 /**
emilmont 77:869cf507173a 142 * @}
emilmont 77:869cf507173a 143 */
emilmont 77:869cf507173a 144
emilmont 77:869cf507173a 145 /** @defgroup COMP_OutputPolarity
emilmont 77:869cf507173a 146 * @{
emilmont 77:869cf507173a 147 */
emilmont 77:869cf507173a 148 #define COMP_OutputPol_NonInverted ((uint32_t)0x00000000) /*!< COMP output on GPIO isn't inverted */
emilmont 77:869cf507173a 149 #define COMP_OutputPol_Inverted COMP_CSR_COMP1POL /*!< COMP output on GPIO is inverted */
emilmont 77:869cf507173a 150
emilmont 77:869cf507173a 151 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted) || \
emilmont 77:869cf507173a 152 ((POL) == COMP_OutputPol_Inverted))
emilmont 77:869cf507173a 153
emilmont 77:869cf507173a 154 /**
emilmont 77:869cf507173a 155 * @}
emilmont 77:869cf507173a 156 */
emilmont 77:869cf507173a 157
emilmont 77:869cf507173a 158 /** @defgroup COMP_Hysteresis
emilmont 77:869cf507173a 159 * @{
emilmont 77:869cf507173a 160 */
emilmont 77:869cf507173a 161 /* Please refer to the electrical characteristics in the device datasheet for
emilmont 77:869cf507173a 162 the hysteresis level */
emilmont 77:869cf507173a 163 #define COMP_Hysteresis_No 0x00000000 /*!< No hysteresis */
emilmont 77:869cf507173a 164 #define COMP_Hysteresis_Low COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */
emilmont 77:869cf507173a 165 #define COMP_Hysteresis_Medium COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */
emilmont 77:869cf507173a 166 #define COMP_Hysteresis_High COMP_CSR_COMP1HYST /*!< Hysteresis level high */
emilmont 77:869cf507173a 167
emilmont 77:869cf507173a 168 #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_Hysteresis_No) || \
emilmont 77:869cf507173a 169 ((HYSTERESIS) == COMP_Hysteresis_Low) || \
emilmont 77:869cf507173a 170 ((HYSTERESIS) == COMP_Hysteresis_Medium) || \
emilmont 77:869cf507173a 171 ((HYSTERESIS) == COMP_Hysteresis_High))
emilmont 77:869cf507173a 172 /**
emilmont 77:869cf507173a 173 * @}
emilmont 77:869cf507173a 174 */
emilmont 77:869cf507173a 175
emilmont 77:869cf507173a 176 /** @defgroup COMP_Mode
emilmont 77:869cf507173a 177 * @{
emilmont 77:869cf507173a 178 */
emilmont 77:869cf507173a 179 /* Please refer to the electrical characteristics in the device datasheet for
emilmont 77:869cf507173a 180 the power consumption values */
emilmont 77:869cf507173a 181 #define COMP_Mode_HighSpeed 0x00000000 /*!< High Speed */
emilmont 77:869cf507173a 182 #define COMP_Mode_MediumSpeed COMP_CSR_COMP1MODE_0 /*!< Medium Speed */
emilmont 77:869cf507173a 183 #define COMP_Mode_LowPower COMP_CSR_COMP1MODE_1 /*!< Low power mode */
emilmont 77:869cf507173a 184 #define COMP_Mode_UltraLowPower COMP_CSR_COMP1MODE /*!< Ultra-low power mode */
emilmont 77:869cf507173a 185
emilmont 77:869cf507173a 186 #define IS_COMP_MODE(MODE) (((MODE) == COMP_Mode_UltraLowPower) || \
emilmont 77:869cf507173a 187 ((MODE) == COMP_Mode_LowPower) || \
emilmont 77:869cf507173a 188 ((MODE) == COMP_Mode_MediumSpeed) || \
emilmont 77:869cf507173a 189 ((MODE) == COMP_Mode_HighSpeed))
emilmont 77:869cf507173a 190 /**
emilmont 77:869cf507173a 191 * @}
emilmont 77:869cf507173a 192 */
emilmont 77:869cf507173a 193
emilmont 77:869cf507173a 194 /** @defgroup COMP_OutputLevel
emilmont 77:869cf507173a 195 * @{
emilmont 77:869cf507173a 196 */
emilmont 77:869cf507173a 197 /* When output polarity is not inverted, comparator output is high when
emilmont 77:869cf507173a 198 the non-inverting input is at a higher voltage than the inverting input */
emilmont 77:869cf507173a 199 #define COMP_OutputLevel_High COMP_CSR_COMP1OUT
emilmont 77:869cf507173a 200 /* When output polarity is not inverted, comparator output is low when
emilmont 77:869cf507173a 201 the non-inverting input is at a lower voltage than the inverting input*/
emilmont 77:869cf507173a 202 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
emilmont 77:869cf507173a 203
emilmont 77:869cf507173a 204 /**
emilmont 77:869cf507173a 205 * @}
emilmont 77:869cf507173a 206 */
emilmont 77:869cf507173a 207
emilmont 77:869cf507173a 208 /**
emilmont 77:869cf507173a 209 * @}
emilmont 77:869cf507173a 210 */
emilmont 77:869cf507173a 211
emilmont 77:869cf507173a 212 /* Exported macro ------------------------------------------------------------*/
emilmont 77:869cf507173a 213 /* Exported functions ------------------------------------------------------- */
emilmont 77:869cf507173a 214
emilmont 77:869cf507173a 215 /* Function used to set the COMP configuration to the default reset state ****/
emilmont 77:869cf507173a 216 void COMP_DeInit(void);
emilmont 77:869cf507173a 217
emilmont 77:869cf507173a 218 /* Initialization and Configuration functions *********************************/
emilmont 77:869cf507173a 219 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);
emilmont 77:869cf507173a 220 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);
emilmont 77:869cf507173a 221 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);
emilmont 77:869cf507173a 222 void COMP_SwitchCmd(FunctionalState NewState);
emilmont 77:869cf507173a 223 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);
emilmont 77:869cf507173a 224
emilmont 77:869cf507173a 225 /* Window mode control function ***********************************************/
emilmont 77:869cf507173a 226 void COMP_WindowCmd(FunctionalState NewState);
emilmont 77:869cf507173a 227
emilmont 77:869cf507173a 228 /* COMP configuration locking function ****************************************/
emilmont 77:869cf507173a 229 void COMP_LockConfig(uint32_t COMP_Selection);
emilmont 77:869cf507173a 230
emilmont 77:869cf507173a 231 #ifdef __cplusplus
emilmont 77:869cf507173a 232 }
emilmont 77:869cf507173a 233 #endif
emilmont 77:869cf507173a 234
emilmont 77:869cf507173a 235 #endif /*__STM32F0XX_COMP_H */
emilmont 77:869cf507173a 236
emilmont 77:869cf507173a 237 /**
emilmont 77:869cf507173a 238 * @}
emilmont 77:869cf507173a 239 */
emilmont 77:869cf507173a 240
emilmont 77:869cf507173a 241 /**
emilmont 77:869cf507173a 242 * @}
emilmont 77:869cf507173a 243 */
emilmont 77:869cf507173a 244
emilmont 77:869cf507173a 245 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/