mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Mar 21 11:45:09 2014 +0000
Revision:
130:1dec54e4aec3
Synchronized with git revision e5c9ff6781a4e277a5a454e5a0b037f76e31739d

Full URL: https://github.com/mbedmicro/mbed/commit/e5c9ff6781a4e277a5a454e5a0b037f76e31739d/

STM32F0-Discovery (STM32F051R8) initial port

Who changed what in which revision?

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