mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Feb 26 09:45:12 2014 +0000
Revision:
106:ced8cbb51063
Parent:
76:aeb1df146756
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd

Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/

[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license

Who changed what in which revision?

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