2 ******************************************************************************
\r
3 * @file stm32l1xx_comp.h
\r
4 * @author MCD Application Team
\r
6 * @date 05-March-2012
\r
7 * @brief This file contains all the functions prototypes for the COMP firmware
\r
9 ******************************************************************************
\r
12 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
\r
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
\r
15 * You may not use this file except in compliance with the License.
\r
16 * You may obtain a copy of the License at:
\r
18 * http://www.st.com/software_license_agreement_liberty_v2
\r
20 * Unless required by applicable law or agreed to in writing, software
\r
21 * distributed under the License is distributed on an "AS IS" BASIS,
\r
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
23 * See the License for the specific language governing permissions and
\r
24 * limitations under the License.
\r
26 ******************************************************************************
\r
29 /* Define to prevent recursive inclusion -------------------------------------*/
\r
30 #ifndef __STM32L1xx_COMP_H
\r
31 #define __STM32L1xx_COMP_H
\r
37 /* Includes ------------------------------------------------------------------*/
\r
38 #include "stm32l1xx.h"
\r
40 /** @addtogroup STM32L1xx_StdPeriph_Driver
\r
44 /** @addtogroup COMP
\r
48 /* Exported types ------------------------------------------------------------*/
\r
51 * @brief COMP Init structure definition
\r
56 uint32_t COMP_Speed; /*!< Defines the speed of comparator 2.
\r
57 This parameter can be a value of @ref COMP_Speed */
\r
58 uint32_t COMP_InvertingInput; /*!< Selects the inverting input of the comparator 2.
\r
59 This parameter can be a value of @ref COMP_InvertingInput */
\r
60 uint32_t COMP_OutputSelect; /*!< Selects the output redirection of the comparator 2.
\r
61 This parameter can be a value of @ref COMP_OutputSelect */
\r
65 /* Exported constants --------------------------------------------------------*/
\r
67 /** @defgroup COMP_Exported_Constants
\r
71 #define COMP_OutputLevel_High ((uint32_t)0x00000001)
\r
72 #define COMP_OutputLevel_Low ((uint32_t)0x00000000)
\r
74 /** @defgroup COMP_Selection
\r
78 #define COMP_Selection_COMP1 ((uint32_t)0x00000001)
\r
79 #define COMP_Selection_COMP2 ((uint32_t)0x00000002)
\r
81 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \
\r
82 ((PERIPH) == COMP_Selection_COMP2))
\r
88 /** @defgroup COMP_InvertingInput
\r
92 #define COMP_InvertingInput_None ((uint32_t)0x00000000) /* COMP2 is disabled when this parameter is selected */
\r
93 #define COMP_InvertingInput_IO ((uint32_t)0x00040000)
\r
94 #define COMP_InvertingInput_VREFINT ((uint32_t)0x00080000)
\r
95 #define COMP_InvertingInput_3_4VREFINT ((uint32_t)0x000C0000)
\r
96 #define COMP_InvertingInput_1_2VREFINT ((uint32_t)0x00100000)
\r
97 #define COMP_InvertingInput_1_4VREFINT ((uint32_t)0x00140000)
\r
98 #define COMP_InvertingInput_DAC1 ((uint32_t)0x00180000)
\r
99 #define COMP_InvertingInput_DAC2 ((uint32_t)0x001C0000)
\r
101 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_None) || \
\r
102 ((INPUT) == COMP_InvertingInput_IO) || \
\r
103 ((INPUT) == COMP_InvertingInput_VREFINT) || \
\r
104 ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \
\r
105 ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \
\r
106 ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \
\r
107 ((INPUT) == COMP_InvertingInput_DAC1) || \
\r
108 ((INPUT) == COMP_InvertingInput_DAC2))
\r
113 /** @defgroup COMP_OutputSelect
\r
117 #define COMP_OutputSelect_TIM2IC4 ((uint32_t)0x00000000)
\r
118 #define COMP_OutputSelect_TIM2OCREFCLR ((uint32_t)0x00200000)
\r
119 #define COMP_OutputSelect_TIM3IC4 ((uint32_t)0x00400000)
\r
120 #define COMP_OutputSelect_TIM3OCREFCLR ((uint32_t)0x00600000)
\r
121 #define COMP_OutputSelect_TIM4IC4 ((uint32_t)0x00800000)
\r
122 #define COMP_OutputSelect_TIM4OCREFCLR ((uint32_t)0x00A00000)
\r
123 #define COMP_OutputSelect_TIM10IC1 ((uint32_t)0x00C00000)
\r
124 #define COMP_OutputSelect_None ((uint32_t)0x00E00000)
\r
126 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OutputSelect_TIM2IC4) || \
\r
127 ((OUTPUT) == COMP_OutputSelect_TIM2OCREFCLR) || \
\r
128 ((OUTPUT) == COMP_OutputSelect_TIM3IC4) || \
\r
129 ((OUTPUT) == COMP_OutputSelect_TIM3OCREFCLR) || \
\r
130 ((OUTPUT) == COMP_OutputSelect_TIM4IC4) || \
\r
131 ((OUTPUT) == COMP_OutputSelect_TIM4OCREFCLR) || \
\r
132 ((OUTPUT) == COMP_OutputSelect_TIM10IC1) || \
\r
133 ((OUTPUT) == COMP_OutputSelect_None))
\r
138 /** @defgroup COMP_Speed
\r
142 #define COMP_Speed_Slow ((uint32_t)0x00000000)
\r
143 #define COMP_Speed_Fast ((uint32_t)0x00001000)
\r
145 #define IS_COMP_SPEED(SPEED) (((SPEED) == COMP_Speed_Slow) || \
\r
146 ((SPEED) == COMP_Speed_Fast))
\r
155 /* Exported macro ------------------------------------------------------------*/
\r
156 /* Exported functions ------------------------------------------------------- */
\r
158 /* Function used to set the COMP configuration to the default reset state ****/
\r
159 void COMP_DeInit(void);
\r
161 /* Initialization and Configuration functions *********************************/
\r
162 void COMP_Init(COMP_InitTypeDef* COMP_InitStruct);
\r
163 void COMP_Cmd(FunctionalState NewState);
\r
164 uint8_t COMP_GetOutputLevel(uint32_t COMP_Selection);
\r
165 void COMP_SW1SwitchConfig(FunctionalState NewState);
\r
167 /* Window mode control function ***********************************************/
\r
168 void COMP_WindowCmd(FunctionalState NewState);
\r
170 /* Internal Reference Voltage (VREFINT) output function ***********************/
\r
171 void COMP_VrefintOutputCmd(FunctionalState NewState);
\r
177 #endif /*__STM32L1xx_COMP_H */
\r
187 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r