mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F303VC/stm32f30x_comp.c@308:59cc78a25982, 2014-09-05 (annotated)
- Committer:
- todotani
- Date:
- Fri Sep 05 14:20:33 2014 +0000
- Revision:
- 308:59cc78a25982
- Parent:
- 157:90e3acc479a2
BLE_Health_Thermometer for mbed HRM1017 with BLE library 0.1.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 157:90e3acc479a2 | 1 | /** |
mbed_official | 157:90e3acc479a2 | 2 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 3 | * @file stm32f30x_comp.c |
mbed_official | 157:90e3acc479a2 | 4 | * @author MCD Application Team |
mbed_official | 157:90e3acc479a2 | 5 | * @version V1.1.0 |
mbed_official | 157:90e3acc479a2 | 6 | * @date 27-February-2014 |
mbed_official | 157:90e3acc479a2 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 157:90e3acc479a2 | 8 | * functionalities of the 7 analog comparators (COMP1, COMP2...COMP7) peripheral: |
mbed_official | 157:90e3acc479a2 | 9 | * + Comparators configuration |
mbed_official | 157:90e3acc479a2 | 10 | * + Window mode control |
mbed_official | 157:90e3acc479a2 | 11 | * |
mbed_official | 157:90e3acc479a2 | 12 | @verbatim |
mbed_official | 157:90e3acc479a2 | 13 | |
mbed_official | 157:90e3acc479a2 | 14 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 15 | ##### COMP Peripheral features ##### |
mbed_official | 157:90e3acc479a2 | 16 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 17 | [..] |
mbed_official | 157:90e3acc479a2 | 18 | The device integrates 7 analog comparators COMP1, COMP2...COMP7: |
mbed_official | 157:90e3acc479a2 | 19 | (#) The non inverting input and inverting input can be set to GPIO pins |
mbed_official | 157:90e3acc479a2 | 20 | as shown in table1. COMP Inputs below. |
mbed_official | 157:90e3acc479a2 | 21 | |
mbed_official | 157:90e3acc479a2 | 22 | (#) The COMP output is internally is available using COMP_GetOutputLevel() |
mbed_official | 157:90e3acc479a2 | 23 | and can be set on GPIO pins. Refer to table 2. COMP Outputs below. |
mbed_official | 157:90e3acc479a2 | 24 | |
mbed_official | 157:90e3acc479a2 | 25 | (#) The COMP output can be redirected to embedded timers (TIM1, TIM2, TIM3...) |
mbed_official | 157:90e3acc479a2 | 26 | Refer to table 3. COMP Outputs redirection to embedded timers below. |
mbed_official | 157:90e3acc479a2 | 27 | |
mbed_official | 157:90e3acc479a2 | 28 | (#) The comparators COMP1 and COMP2, COMP3 and COMP4, COMP5 and COMP6 can be combined in window |
mbed_official | 157:90e3acc479a2 | 29 | mode and only COMP1, COMP3 and COMP5 non inverting input can be used as non-inverting input. |
mbed_official | 157:90e3acc479a2 | 30 | |
mbed_official | 157:90e3acc479a2 | 31 | (#) The seven comparators have interrupt capability with wake-up |
mbed_official | 157:90e3acc479a2 | 32 | from Sleep and Stop modes (through the EXTI controller): |
mbed_official | 157:90e3acc479a2 | 33 | (++) COMP1 is internally connected to EXTI Line 21 |
mbed_official | 157:90e3acc479a2 | 34 | (++) COMP2 is internally connected to EXTI Line 22 |
mbed_official | 157:90e3acc479a2 | 35 | (++) COMP3 is internally connected to EXTI Line 29 |
mbed_official | 157:90e3acc479a2 | 36 | (++) COMP4 is internally connected to EXTI Line 30 |
mbed_official | 157:90e3acc479a2 | 37 | (++) COMP5 is internally connected to EXTI Line 31 |
mbed_official | 157:90e3acc479a2 | 38 | (++) COMP6 is internally connected to EXTI Line 32 |
mbed_official | 157:90e3acc479a2 | 39 | (++) COMP7 is internally connected to EXTI Line 33 |
mbed_official | 157:90e3acc479a2 | 40 | |
mbed_official | 157:90e3acc479a2 | 41 | [..] Table 1. COMP Inputs |
mbed_official | 157:90e3acc479a2 | 42 | +------------------------------------------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 43 | | | | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | |
mbed_official | 157:90e3acc479a2 | 44 | |-----------------|----------------|---------------|---------------------------------------| |
mbed_official | 157:90e3acc479a2 | 45 | | | 1/4 VREFINT | OK | OK | OK | OK | OK | OK | OK | |
mbed_official | 157:90e3acc479a2 | 46 | | | 1/2 VREFINT | OK | OK | OK | OK | OK | OK | OK | |
mbed_official | 157:90e3acc479a2 | 47 | | | 3/4 VREFINT | OK | OK | OK | OK | OK | OK | OK | |
mbed_official | 157:90e3acc479a2 | 48 | | Inverting Input | VREFINT | OK | OK | OK | OK | OK | OK | OK | |
mbed_official | 157:90e3acc479a2 | 49 | | | DAC1 OUT1(PA4) | OK | OK | OK | OK | OK | OK | OK | |
mbed_official | 157:90e3acc479a2 | 50 | | | DAC1 OUT2(PA5) | OK | OK | OK | OK | OK | OK | OK | |
mbed_official | 157:90e3acc479a2 | 51 | | | IO1 | PA0 | PA2 | PD15 | PE8 | PD13 | PD10 | PC0 | |
mbed_official | 157:90e3acc479a2 | 52 | | | IO2 | --- | --- | PB12 | PB2 | PB10 | PB15 | --- | |
mbed_official | 157:90e3acc479a2 | 53 | | | DAC2 OUT1(PA6) | --- | OK | --- | OK | --- | OK | --- | |
mbed_official | 157:90e3acc479a2 | 54 | |-----------------|----------------|-------|-------|-------|-------|-------|-------|-------| |
mbed_official | 157:90e3acc479a2 | 55 | | Non Inverting | IO1 | PA1 | PA7 | PB14 | PB0 | PD12 | PD11 | PA0 | |
mbed_official | 157:90e3acc479a2 | 56 | | Input | IO2 | --- | PA3 | PD14 | PE7 | PB13 | PB11 | PC1 | |
mbed_official | 157:90e3acc479a2 | 57 | +------------------------------------------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 58 | |
mbed_official | 157:90e3acc479a2 | 59 | [..] Table 2. COMP Outputs |
mbed_official | 157:90e3acc479a2 | 60 | +-------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 61 | | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | |
mbed_official | 157:90e3acc479a2 | 62 | |-------|-------|-------|-------|-------|-------|-------| |
mbed_official | 157:90e3acc479a2 | 63 | | PA0 | PA2 | PB1 | PC8 | PC7 | PA10 | PC2 | |
mbed_official | 157:90e3acc479a2 | 64 | | PF4 | PA7 | --- | PA8 | PA9 | PC6 | --- | |
mbed_official | 157:90e3acc479a2 | 65 | | PA6 | PA12 | --- | --- | --- | --- | --- | |
mbed_official | 157:90e3acc479a2 | 66 | | PA11 | PB9 | --- | --- | --- | --- | --- | |
mbed_official | 157:90e3acc479a2 | 67 | | PB8 | --- | --- | --- | --- | --- | --- | |
mbed_official | 157:90e3acc479a2 | 68 | +-------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 69 | |
mbed_official | 157:90e3acc479a2 | 70 | [..] Table 3. COMP Outputs redirection to embedded timers |
mbed_official | 157:90e3acc479a2 | 71 | +----------------------------------------------------------------------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 72 | | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | |
mbed_official | 157:90e3acc479a2 | 73 | |----------------|----------------|----------------|----------------|----------------|----------------|----------------| |
mbed_official | 157:90e3acc479a2 | 74 | | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | |
mbed_official | 157:90e3acc479a2 | 75 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 76 | | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | |
mbed_official | 157:90e3acc479a2 | 77 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 78 | | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | |
mbed_official | 157:90e3acc479a2 | 79 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 80 | | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | |
mbed_official | 157:90e3acc479a2 | 81 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 82 | | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | |
mbed_official | 157:90e3acc479a2 | 83 | | + | + | + | + | + | + | + | |
mbed_official | 157:90e3acc479a2 | 84 | | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | |
mbed_official | 157:90e3acc479a2 | 85 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 86 | | TIM1 OCREFCLR | TIM1 OCREFCLR | TIM1 OCREFCLR | TIM8 OCREFCLR | TIM8 OCREFCLR | TIM8 OCREFCLR | TIM1 OCREFCLR | |
mbed_official | 157:90e3acc479a2 | 87 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 88 | | TIM1 IC1 | TIM1 IC1 | TIM2 OCREFCLR | TIM3 IC3 | TIM2 IC1 | TIM2 IC2 | TIM8 OCREFCLR | |
mbed_official | 157:90e3acc479a2 | 89 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 90 | | TIM2 IC4 | TIM2 IC4 | TIM3 IC2 | TIM3 OCREFCLR | TIM3 OCREFCLR | TIM2 OCREFCLR | TIM2 IC3 | |
mbed_official | 157:90e3acc479a2 | 91 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 92 | | TIM2 OCREFCLR | TIM2 OCREFCLR | TIM4 IC1 | TIM4 IC2 | TIM4 IC3 | TIM16 OCREFCLR| TIM1 IC2 | |
mbed_official | 157:90e3acc479a2 | 93 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 94 | | TIM3 IC1 | TIM3 IC1 | TIM15 IC1 | TIM15 OCREFCLR| TIM16 BKIN | TIM16 IC1 | TIM17 OCREFCLR| |
mbed_official | 157:90e3acc479a2 | 95 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 96 | | TIM3 OCREFCLR | TIM3 OCREFCLR | TIM15 BKIN | TIM15 IC2 | TIM17 IC1 | TIM4 IC4 | TIM17 BKIN | |
mbed_official | 157:90e3acc479a2 | 97 | +----------------------------------------------------------------------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 98 | |
mbed_official | 157:90e3acc479a2 | 99 | [..] Table 4. COMP Outputs blanking sources |
mbed_official | 157:90e3acc479a2 | 100 | +----------------------------------------------------------------------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 101 | | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | |
mbed_official | 157:90e3acc479a2 | 102 | |----------------|----------------|----------------|----------------|----------------|----------------|----------------| |
mbed_official | 157:90e3acc479a2 | 103 | | TIM1 OC5 | TIM1 OC5 | TIM1 OC5 | TIM3 OC4 | TIM3 OC3 | TIM2 OC4 | TIM1 OC5 | |
mbed_official | 157:90e3acc479a2 | 104 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 105 | | TIM2 OC3 | TIM2 OC3 | -------- | TIM8 OC5 | TIM8 OC5 | TIM8 OC5 | TIM8 OC5 | |
mbed_official | 157:90e3acc479a2 | 106 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 107 | | TIM3 OC3 | TIM3 OC3 | TIM2 OC4 | TIM15 OC1 | TIM8 BKIN | TIM15 OC2 | TIM15 OC2 | |
mbed_official | 157:90e3acc479a2 | 108 | | | | | | | | | |
mbed_official | 157:90e3acc479a2 | 109 | +----------------------------------------------------------------------------------------------------------------------+ |
mbed_official | 157:90e3acc479a2 | 110 | |
mbed_official | 157:90e3acc479a2 | 111 | |
mbed_official | 157:90e3acc479a2 | 112 | ##### How to use this driver ##### |
mbed_official | 157:90e3acc479a2 | 113 | ============================================================================== |
mbed_official | 157:90e3acc479a2 | 114 | [..] |
mbed_official | 157:90e3acc479a2 | 115 | This driver provides functions to configure and program the Comparators |
mbed_official | 157:90e3acc479a2 | 116 | of all STM32F30x devices. |
mbed_official | 157:90e3acc479a2 | 117 | |
mbed_official | 157:90e3acc479a2 | 118 | To use the comparator, perform the following steps: |
mbed_official | 157:90e3acc479a2 | 119 | |
mbed_official | 157:90e3acc479a2 | 120 | (#) Enable the SYSCFG APB clock to get write access to comparator |
mbed_official | 157:90e3acc479a2 | 121 | register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
mbed_official | 157:90e3acc479a2 | 122 | |
mbed_official | 157:90e3acc479a2 | 123 | (#) Configure the comparator input in analog mode using GPIO_Init() |
mbed_official | 157:90e3acc479a2 | 124 | |
mbed_official | 157:90e3acc479a2 | 125 | (#) Configure the comparator output in alternate function mode |
mbed_official | 157:90e3acc479a2 | 126 | using GPIO_Init() and use GPIO_PinAFConfig() function to map the |
mbed_official | 157:90e3acc479a2 | 127 | comparator output to the GPIO pin |
mbed_official | 157:90e3acc479a2 | 128 | |
mbed_official | 157:90e3acc479a2 | 129 | (#) Configure the comparator using COMP_Init() function: |
mbed_official | 157:90e3acc479a2 | 130 | (++) Select the inverting input |
mbed_official | 157:90e3acc479a2 | 131 | (++) Select the non-inverting input |
mbed_official | 157:90e3acc479a2 | 132 | (++) Select the output polarity |
mbed_official | 157:90e3acc479a2 | 133 | (++) Select the output redirection |
mbed_official | 157:90e3acc479a2 | 134 | (++) Select the hysteresis level |
mbed_official | 157:90e3acc479a2 | 135 | (++) Select the power mode |
mbed_official | 157:90e3acc479a2 | 136 | |
mbed_official | 157:90e3acc479a2 | 137 | (#) Enable the comparator using COMP_Cmd() function |
mbed_official | 157:90e3acc479a2 | 138 | |
mbed_official | 157:90e3acc479a2 | 139 | (#) If required enable the COMP interrupt by configuring and enabling |
mbed_official | 157:90e3acc479a2 | 140 | EXTI line in Interrupt mode and selecting the desired sensitivity |
mbed_official | 157:90e3acc479a2 | 141 | level using EXTI_Init() function. After that enable the comparator |
mbed_official | 157:90e3acc479a2 | 142 | interrupt vector using NVIC_Init() function. |
mbed_official | 157:90e3acc479a2 | 143 | |
mbed_official | 157:90e3acc479a2 | 144 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 145 | * |
mbed_official | 157:90e3acc479a2 | 146 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 147 | * @attention |
mbed_official | 157:90e3acc479a2 | 148 | * |
mbed_official | 157:90e3acc479a2 | 149 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 157:90e3acc479a2 | 150 | * |
mbed_official | 157:90e3acc479a2 | 151 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 157:90e3acc479a2 | 152 | * are permitted provided that the following conditions are met: |
mbed_official | 157:90e3acc479a2 | 153 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 157:90e3acc479a2 | 154 | * this list of conditions and the following disclaimer. |
mbed_official | 157:90e3acc479a2 | 155 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 157:90e3acc479a2 | 156 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 157:90e3acc479a2 | 157 | * and/or other materials provided with the distribution. |
mbed_official | 157:90e3acc479a2 | 158 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 157:90e3acc479a2 | 159 | * may be used to endorse or promote products derived from this software |
mbed_official | 157:90e3acc479a2 | 160 | * without specific prior written permission. |
mbed_official | 157:90e3acc479a2 | 161 | * |
mbed_official | 157:90e3acc479a2 | 162 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 157:90e3acc479a2 | 163 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 157:90e3acc479a2 | 164 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 157:90e3acc479a2 | 165 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 157:90e3acc479a2 | 166 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 157:90e3acc479a2 | 167 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 157:90e3acc479a2 | 168 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 157:90e3acc479a2 | 169 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 157:90e3acc479a2 | 170 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 157:90e3acc479a2 | 171 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 157:90e3acc479a2 | 172 | * |
mbed_official | 157:90e3acc479a2 | 173 | ****************************************************************************** |
mbed_official | 157:90e3acc479a2 | 174 | */ |
mbed_official | 157:90e3acc479a2 | 175 | |
mbed_official | 157:90e3acc479a2 | 176 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 177 | #include "stm32f30x_comp.h" |
mbed_official | 157:90e3acc479a2 | 178 | |
mbed_official | 157:90e3acc479a2 | 179 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 157:90e3acc479a2 | 180 | * @{ |
mbed_official | 157:90e3acc479a2 | 181 | */ |
mbed_official | 157:90e3acc479a2 | 182 | |
mbed_official | 157:90e3acc479a2 | 183 | /** @defgroup COMP |
mbed_official | 157:90e3acc479a2 | 184 | * @brief COMP driver modules |
mbed_official | 157:90e3acc479a2 | 185 | * @{ |
mbed_official | 157:90e3acc479a2 | 186 | */ |
mbed_official | 157:90e3acc479a2 | 187 | |
mbed_official | 157:90e3acc479a2 | 188 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 189 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 190 | /* CSR register Mask */ |
mbed_official | 157:90e3acc479a2 | 191 | #define COMP_CSR_CLEAR_MASK ((uint32_t)0x00000003) |
mbed_official | 157:90e3acc479a2 | 192 | |
mbed_official | 157:90e3acc479a2 | 193 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 194 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 195 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 196 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 157:90e3acc479a2 | 197 | |
mbed_official | 157:90e3acc479a2 | 198 | /** @defgroup COMP_Private_Functions |
mbed_official | 157:90e3acc479a2 | 199 | * @{ |
mbed_official | 157:90e3acc479a2 | 200 | */ |
mbed_official | 157:90e3acc479a2 | 201 | |
mbed_official | 157:90e3acc479a2 | 202 | /** @defgroup COMP_Group1 Initialization and Configuration functions |
mbed_official | 157:90e3acc479a2 | 203 | * @brief Initialization and Configuration functions |
mbed_official | 157:90e3acc479a2 | 204 | * |
mbed_official | 157:90e3acc479a2 | 205 | @verbatim |
mbed_official | 157:90e3acc479a2 | 206 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 207 | ##### Initialization and Configuration functions ##### |
mbed_official | 157:90e3acc479a2 | 208 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 209 | |
mbed_official | 157:90e3acc479a2 | 210 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 211 | * @{ |
mbed_official | 157:90e3acc479a2 | 212 | */ |
mbed_official | 157:90e3acc479a2 | 213 | |
mbed_official | 157:90e3acc479a2 | 214 | /** |
mbed_official | 157:90e3acc479a2 | 215 | * @brief Deinitializes COMP peripheral registers to their default reset values. |
mbed_official | 157:90e3acc479a2 | 216 | * @note Deinitialization can't be performed if the COMP configuration is locked. |
mbed_official | 157:90e3acc479a2 | 217 | * To unlock the configuration, perform a system reset. |
mbed_official | 157:90e3acc479a2 | 218 | * @param COMP_Selection: the selected comparator. |
mbed_official | 157:90e3acc479a2 | 219 | * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 |
mbed_official | 157:90e3acc479a2 | 220 | * to select the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 221 | * @param None |
mbed_official | 157:90e3acc479a2 | 222 | * @retval None |
mbed_official | 157:90e3acc479a2 | 223 | */ |
mbed_official | 157:90e3acc479a2 | 224 | void COMP_DeInit(uint32_t COMP_Selection) |
mbed_official | 157:90e3acc479a2 | 225 | { |
mbed_official | 157:90e3acc479a2 | 226 | /*!< Set COMP_CSR register to reset value */ |
mbed_official | 157:90e3acc479a2 | 227 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) = ((uint32_t)0x00000000); |
mbed_official | 157:90e3acc479a2 | 228 | } |
mbed_official | 157:90e3acc479a2 | 229 | |
mbed_official | 157:90e3acc479a2 | 230 | /** |
mbed_official | 157:90e3acc479a2 | 231 | * @brief Initializes the COMP peripheral according to the specified parameters |
mbed_official | 157:90e3acc479a2 | 232 | * in COMP_InitStruct |
mbed_official | 157:90e3acc479a2 | 233 | * @note If the selected comparator is locked, initialization can't be performed. |
mbed_official | 157:90e3acc479a2 | 234 | * To unlock the configuration, perform a system reset. |
mbed_official | 157:90e3acc479a2 | 235 | * @note By default, PA1 is selected as COMP1 non inverting input. |
mbed_official | 157:90e3acc479a2 | 236 | * To use PA4 as COMP1 non inverting input call COMP_SwitchCmd() after COMP_Init() |
mbed_official | 157:90e3acc479a2 | 237 | * @param COMP_Selection: the selected comparator. |
mbed_official | 157:90e3acc479a2 | 238 | * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 |
mbed_official | 157:90e3acc479a2 | 239 | * to select the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 240 | * @param COMP_InitStruct: pointer to an COMP_InitTypeDef structure that contains |
mbed_official | 157:90e3acc479a2 | 241 | * the configuration information for the specified COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 242 | * - COMP_InvertingInput specifies the inverting input of COMP |
mbed_official | 157:90e3acc479a2 | 243 | * - COMP_NonInvertingInput specifies the non inverting input of COMP |
mbed_official | 157:90e3acc479a2 | 244 | * - COMP_Output connect COMP output to selected timer |
mbed_official | 157:90e3acc479a2 | 245 | * input (Input capture / Output Compare Reference Clear / Break Input) |
mbed_official | 157:90e3acc479a2 | 246 | * - COMP_BlankingSrce specifies the blanking source of COMP |
mbed_official | 157:90e3acc479a2 | 247 | * - COMP_OutputPol select output polarity |
mbed_official | 157:90e3acc479a2 | 248 | * - COMP_Hysteresis configures COMP hysteresis value |
mbed_official | 157:90e3acc479a2 | 249 | * - COMP_Mode configures COMP power mode |
mbed_official | 157:90e3acc479a2 | 250 | * @retval None |
mbed_official | 157:90e3acc479a2 | 251 | */ |
mbed_official | 157:90e3acc479a2 | 252 | void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct) |
mbed_official | 157:90e3acc479a2 | 253 | { |
mbed_official | 157:90e3acc479a2 | 254 | uint32_t tmpreg = 0; |
mbed_official | 157:90e3acc479a2 | 255 | |
mbed_official | 157:90e3acc479a2 | 256 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 257 | assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); |
mbed_official | 157:90e3acc479a2 | 258 | assert_param(IS_COMP_INVERTING_INPUT(COMP_InitStruct->COMP_InvertingInput)); |
mbed_official | 157:90e3acc479a2 | 259 | assert_param(IS_COMP_NONINVERTING_INPUT(COMP_InitStruct->COMP_NonInvertingInput)); |
mbed_official | 157:90e3acc479a2 | 260 | assert_param(IS_COMP_OUTPUT(COMP_InitStruct->COMP_Output)); |
mbed_official | 157:90e3acc479a2 | 261 | assert_param(IS_COMP_BLANKING_SOURCE(COMP_InitStruct->COMP_BlankingSrce)); |
mbed_official | 157:90e3acc479a2 | 262 | assert_param(IS_COMP_OUTPUT_POL(COMP_InitStruct->COMP_OutputPol)); |
mbed_official | 157:90e3acc479a2 | 263 | assert_param(IS_COMP_HYSTERESIS(COMP_InitStruct->COMP_Hysteresis)); |
mbed_official | 157:90e3acc479a2 | 264 | assert_param(IS_COMP_MODE(COMP_InitStruct->COMP_Mode)); |
mbed_official | 157:90e3acc479a2 | 265 | |
mbed_official | 157:90e3acc479a2 | 266 | /*!< Get the COMPx_CSR register value */ |
mbed_official | 157:90e3acc479a2 | 267 | tmpreg = *(__IO uint32_t *) (COMP_BASE + COMP_Selection); |
mbed_official | 157:90e3acc479a2 | 268 | |
mbed_official | 157:90e3acc479a2 | 269 | /*!< Clear the COMP1SW1, COMPxINSEL, COMPxOUTSEL, COMPxPOL, COMPxHYST and COMPxMODE bits */ |
mbed_official | 157:90e3acc479a2 | 270 | tmpreg &= (uint32_t) (COMP_CSR_CLEAR_MASK); |
mbed_official | 157:90e3acc479a2 | 271 | |
mbed_official | 157:90e3acc479a2 | 272 | /*!< Configure COMP: inverting input, output redirection, hysteresis value and power mode */ |
mbed_official | 157:90e3acc479a2 | 273 | /*!< Set COMPxINSEL bits according to COMP_InitStruct->COMP_InvertingInput value */ |
mbed_official | 157:90e3acc479a2 | 274 | /*!< Set COMPxNONINSEL bits according to COMP_InitStruct->COMP_NonInvertingInput value */ |
mbed_official | 157:90e3acc479a2 | 275 | /*!< Set COMPxBLANKING bits according to COMP_InitStruct->COMP_BlankingSrce value */ |
mbed_official | 157:90e3acc479a2 | 276 | /*!< Set COMPxOUTSEL bits according to COMP_InitStruct->COMP_Output value */ |
mbed_official | 157:90e3acc479a2 | 277 | /*!< Set COMPxPOL bit according to COMP_InitStruct->COMP_OutputPol value */ |
mbed_official | 157:90e3acc479a2 | 278 | /*!< Set COMPxHYST bits according to COMP_InitStruct->COMP_Hysteresis value */ |
mbed_official | 157:90e3acc479a2 | 279 | /*!< Set COMPxMODE bits according to COMP_InitStruct->COMP_Mode value */ |
mbed_official | 157:90e3acc479a2 | 280 | tmpreg |= (uint32_t)(COMP_InitStruct->COMP_InvertingInput | COMP_InitStruct->COMP_NonInvertingInput | |
mbed_official | 157:90e3acc479a2 | 281 | COMP_InitStruct->COMP_Output | COMP_InitStruct->COMP_OutputPol | COMP_InitStruct->COMP_BlankingSrce | |
mbed_official | 157:90e3acc479a2 | 282 | COMP_InitStruct->COMP_Hysteresis | COMP_InitStruct->COMP_Mode); |
mbed_official | 157:90e3acc479a2 | 283 | |
mbed_official | 157:90e3acc479a2 | 284 | /*!< Write to COMPx_CSR register */ |
mbed_official | 157:90e3acc479a2 | 285 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) = tmpreg; |
mbed_official | 157:90e3acc479a2 | 286 | } |
mbed_official | 157:90e3acc479a2 | 287 | |
mbed_official | 157:90e3acc479a2 | 288 | /** |
mbed_official | 157:90e3acc479a2 | 289 | * @brief Fills each COMP_InitStruct member with its default value. |
mbed_official | 157:90e3acc479a2 | 290 | * @param COMP_InitStruct: pointer to an COMP_InitTypeDef structure which will |
mbed_official | 157:90e3acc479a2 | 291 | * be initialized. |
mbed_official | 157:90e3acc479a2 | 292 | * @retval None |
mbed_official | 157:90e3acc479a2 | 293 | */ |
mbed_official | 157:90e3acc479a2 | 294 | void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct) |
mbed_official | 157:90e3acc479a2 | 295 | { |
mbed_official | 157:90e3acc479a2 | 296 | COMP_InitStruct->COMP_InvertingInput = COMP_InvertingInput_1_4VREFINT; |
mbed_official | 157:90e3acc479a2 | 297 | COMP_InitStruct->COMP_NonInvertingInput = COMP_NonInvertingInput_IO1; |
mbed_official | 157:90e3acc479a2 | 298 | COMP_InitStruct->COMP_Output = COMP_Output_None; |
mbed_official | 157:90e3acc479a2 | 299 | COMP_InitStruct->COMP_BlankingSrce = COMP_BlankingSrce_None; |
mbed_official | 157:90e3acc479a2 | 300 | COMP_InitStruct->COMP_OutputPol = COMP_OutputPol_NonInverted; |
mbed_official | 157:90e3acc479a2 | 301 | COMP_InitStruct->COMP_Hysteresis = COMP_Hysteresis_No; |
mbed_official | 157:90e3acc479a2 | 302 | COMP_InitStruct->COMP_Mode = COMP_Mode_UltraLowPower; |
mbed_official | 157:90e3acc479a2 | 303 | } |
mbed_official | 157:90e3acc479a2 | 304 | |
mbed_official | 157:90e3acc479a2 | 305 | /** |
mbed_official | 157:90e3acc479a2 | 306 | * @brief Enable or disable the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 307 | * @note If the selected comparator is locked, enable/disable can't be performed. |
mbed_official | 157:90e3acc479a2 | 308 | * To unlock the configuration, perform a system reset. |
mbed_official | 157:90e3acc479a2 | 309 | * @param COMP_Selection: the selected comparator. |
mbed_official | 157:90e3acc479a2 | 310 | * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 |
mbed_official | 157:90e3acc479a2 | 311 | * to select the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 312 | * @param NewState: new state of the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 313 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 157:90e3acc479a2 | 314 | * When enabled, the comparator compares the non inverting input with |
mbed_official | 157:90e3acc479a2 | 315 | * the inverting input and the comparison result is available |
mbed_official | 157:90e3acc479a2 | 316 | * on comparator output. |
mbed_official | 157:90e3acc479a2 | 317 | * When disabled, the comparator doesn't perform comparison and the |
mbed_official | 157:90e3acc479a2 | 318 | * output level is low. |
mbed_official | 157:90e3acc479a2 | 319 | * @retval None |
mbed_official | 157:90e3acc479a2 | 320 | */ |
mbed_official | 157:90e3acc479a2 | 321 | void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState) |
mbed_official | 157:90e3acc479a2 | 322 | { |
mbed_official | 157:90e3acc479a2 | 323 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 324 | assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); |
mbed_official | 157:90e3acc479a2 | 325 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 157:90e3acc479a2 | 326 | |
mbed_official | 157:90e3acc479a2 | 327 | if (NewState != DISABLE) |
mbed_official | 157:90e3acc479a2 | 328 | { |
mbed_official | 157:90e3acc479a2 | 329 | /* Enable the selected COMPx peripheral */ |
mbed_official | 157:90e3acc479a2 | 330 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMPxEN); |
mbed_official | 157:90e3acc479a2 | 331 | } |
mbed_official | 157:90e3acc479a2 | 332 | else |
mbed_official | 157:90e3acc479a2 | 333 | { |
mbed_official | 157:90e3acc479a2 | 334 | /* Disable the selected COMP peripheral */ |
mbed_official | 157:90e3acc479a2 | 335 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMPxEN); |
mbed_official | 157:90e3acc479a2 | 336 | } |
mbed_official | 157:90e3acc479a2 | 337 | } |
mbed_official | 157:90e3acc479a2 | 338 | |
mbed_official | 157:90e3acc479a2 | 339 | /** |
mbed_official | 157:90e3acc479a2 | 340 | * @brief Close or Open the SW1 switch. |
mbed_official | 157:90e3acc479a2 | 341 | * @note If the COMP1 is locked, Close/Open the SW1 switch can't be performed. |
mbed_official | 157:90e3acc479a2 | 342 | * To unlock the configuration, perform a system reset. |
mbed_official | 157:90e3acc479a2 | 343 | * @note This switch is solely intended to redirect signals onto high |
mbed_official | 157:90e3acc479a2 | 344 | * impedance input, such as COMP1 non-inverting input (highly resistive switch) |
mbed_official | 157:90e3acc479a2 | 345 | * @param NewState: New state of the analog switch. |
mbed_official | 157:90e3acc479a2 | 346 | * This parameter can be |
mbed_official | 157:90e3acc479a2 | 347 | * ENABLE so the SW1 is closed; PA1 is connected to PA4 |
mbed_official | 157:90e3acc479a2 | 348 | * or DISABLE so the SW1 switch is open; PA1 is disconnected from PA4 |
mbed_official | 157:90e3acc479a2 | 349 | * @retval None |
mbed_official | 157:90e3acc479a2 | 350 | */ |
mbed_official | 157:90e3acc479a2 | 351 | void COMP_SwitchCmd(uint32_t COMP_Selection, FunctionalState NewState) |
mbed_official | 157:90e3acc479a2 | 352 | { |
mbed_official | 157:90e3acc479a2 | 353 | /* Check the parameter */ |
mbed_official | 157:90e3acc479a2 | 354 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 157:90e3acc479a2 | 355 | |
mbed_official | 157:90e3acc479a2 | 356 | if (NewState != DISABLE) |
mbed_official | 157:90e3acc479a2 | 357 | { |
mbed_official | 157:90e3acc479a2 | 358 | /* Close SW1 switch */ |
mbed_official | 157:90e3acc479a2 | 359 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMP1SW1); |
mbed_official | 157:90e3acc479a2 | 360 | } |
mbed_official | 157:90e3acc479a2 | 361 | else |
mbed_official | 157:90e3acc479a2 | 362 | { |
mbed_official | 157:90e3acc479a2 | 363 | /* Open SW1 switch */ |
mbed_official | 157:90e3acc479a2 | 364 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMP1SW1); |
mbed_official | 157:90e3acc479a2 | 365 | } |
mbed_official | 157:90e3acc479a2 | 366 | } |
mbed_official | 157:90e3acc479a2 | 367 | |
mbed_official | 157:90e3acc479a2 | 368 | /** |
mbed_official | 157:90e3acc479a2 | 369 | * @brief Return the output level (high or low) of the selected comparator. |
mbed_official | 157:90e3acc479a2 | 370 | * The output level depends on the selected polarity. |
mbed_official | 157:90e3acc479a2 | 371 | * If the polarity is not inverted: |
mbed_official | 157:90e3acc479a2 | 372 | * - Comparator output is low when the non-inverting input is at a lower |
mbed_official | 157:90e3acc479a2 | 373 | * voltage than the inverting input |
mbed_official | 157:90e3acc479a2 | 374 | * - Comparator output is high when the non-inverting input is at a higher |
mbed_official | 157:90e3acc479a2 | 375 | * voltage than the inverting input |
mbed_official | 157:90e3acc479a2 | 376 | * If the polarity is inverted: |
mbed_official | 157:90e3acc479a2 | 377 | * - Comparator output is high when the non-inverting input is at a lower |
mbed_official | 157:90e3acc479a2 | 378 | * voltage than the inverting input |
mbed_official | 157:90e3acc479a2 | 379 | * - Comparator output is low when the non-inverting input is at a higher |
mbed_official | 157:90e3acc479a2 | 380 | * voltage than the inverting input |
mbed_official | 157:90e3acc479a2 | 381 | * @param COMP_Selection: the selected comparator. |
mbed_official | 157:90e3acc479a2 | 382 | * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 |
mbed_official | 157:90e3acc479a2 | 383 | * to select the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 384 | * @retval Returns the selected comparator output level: low or high. |
mbed_official | 157:90e3acc479a2 | 385 | * |
mbed_official | 157:90e3acc479a2 | 386 | */ |
mbed_official | 157:90e3acc479a2 | 387 | uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection) |
mbed_official | 157:90e3acc479a2 | 388 | { |
mbed_official | 157:90e3acc479a2 | 389 | uint32_t compout = 0x0; |
mbed_official | 157:90e3acc479a2 | 390 | |
mbed_official | 157:90e3acc479a2 | 391 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 392 | assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); |
mbed_official | 157:90e3acc479a2 | 393 | |
mbed_official | 157:90e3acc479a2 | 394 | /* Check if selected comparator output is high */ |
mbed_official | 157:90e3acc479a2 | 395 | if ((*(__IO uint32_t *) (COMP_BASE + COMP_Selection) & (COMP_CSR_COMPxOUT)) != 0) |
mbed_official | 157:90e3acc479a2 | 396 | { |
mbed_official | 157:90e3acc479a2 | 397 | compout = COMP_OutputLevel_High; |
mbed_official | 157:90e3acc479a2 | 398 | } |
mbed_official | 157:90e3acc479a2 | 399 | else |
mbed_official | 157:90e3acc479a2 | 400 | { |
mbed_official | 157:90e3acc479a2 | 401 | compout = COMP_OutputLevel_Low; |
mbed_official | 157:90e3acc479a2 | 402 | } |
mbed_official | 157:90e3acc479a2 | 403 | |
mbed_official | 157:90e3acc479a2 | 404 | /* Return the comparator output level */ |
mbed_official | 157:90e3acc479a2 | 405 | return (uint32_t)(compout); |
mbed_official | 157:90e3acc479a2 | 406 | } |
mbed_official | 157:90e3acc479a2 | 407 | |
mbed_official | 157:90e3acc479a2 | 408 | /** |
mbed_official | 157:90e3acc479a2 | 409 | * @} |
mbed_official | 157:90e3acc479a2 | 410 | */ |
mbed_official | 157:90e3acc479a2 | 411 | |
mbed_official | 157:90e3acc479a2 | 412 | /** @defgroup COMP_Group2 Window mode control function |
mbed_official | 157:90e3acc479a2 | 413 | * @brief Window mode control function |
mbed_official | 157:90e3acc479a2 | 414 | * |
mbed_official | 157:90e3acc479a2 | 415 | @verbatim |
mbed_official | 157:90e3acc479a2 | 416 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 417 | ##### Window mode control function ##### |
mbed_official | 157:90e3acc479a2 | 418 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 419 | |
mbed_official | 157:90e3acc479a2 | 420 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 421 | * @{ |
mbed_official | 157:90e3acc479a2 | 422 | */ |
mbed_official | 157:90e3acc479a2 | 423 | |
mbed_official | 157:90e3acc479a2 | 424 | /** |
mbed_official | 157:90e3acc479a2 | 425 | * @brief Enables or disables the window mode. |
mbed_official | 157:90e3acc479a2 | 426 | * Window mode for comparators makes use of two comparators: |
mbed_official | 157:90e3acc479a2 | 427 | * COMP1 and COM2, COMP3 and COMP4, COMP5 and COMP6. |
mbed_official | 157:90e3acc479a2 | 428 | * In window mode, COMPx and COMPx-1 (where x can be 2, 4 or 6) |
mbed_official | 157:90e3acc479a2 | 429 | * non inverting inputs are connected together and only COMPx-1 non |
mbed_official | 157:90e3acc479a2 | 430 | * inverting input can be used. |
mbed_official | 157:90e3acc479a2 | 431 | * e.g When window mode enabled for COMP4, COMP3 non inverting input (PB14 or PD14) |
mbed_official | 157:90e3acc479a2 | 432 | * is to be used. |
mbed_official | 157:90e3acc479a2 | 433 | * @note If the COMPx is locked, ENABLE/DISABLE the window mode can't be performed. |
mbed_official | 157:90e3acc479a2 | 434 | * To unlock the configuration, perform a system reset. |
mbed_official | 157:90e3acc479a2 | 435 | * @param COMP_Selection: the selected comparator. |
mbed_official | 157:90e3acc479a2 | 436 | * This parameter can be COMP_Selection_COMPx where x can be 2, 4 or 6 |
mbed_official | 157:90e3acc479a2 | 437 | * to select the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 438 | * param NewState: new state of the window mode. |
mbed_official | 157:90e3acc479a2 | 439 | * This parameter can be ENABLE or DISABLE. |
mbed_official | 157:90e3acc479a2 | 440 | * When enbaled, COMPx and COMPx-1 non inverting inputs are connected together. |
mbed_official | 157:90e3acc479a2 | 441 | * When disabled, COMPx and COMPx-1 non inverting inputs are disconnected. |
mbed_official | 157:90e3acc479a2 | 442 | * @retval None |
mbed_official | 157:90e3acc479a2 | 443 | */ |
mbed_official | 157:90e3acc479a2 | 444 | void COMP_WindowCmd(uint32_t COMP_Selection, FunctionalState NewState) |
mbed_official | 157:90e3acc479a2 | 445 | { |
mbed_official | 157:90e3acc479a2 | 446 | /* Check the parameters */ |
mbed_official | 157:90e3acc479a2 | 447 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 157:90e3acc479a2 | 448 | assert_param(IS_COMP_WINDOW(COMP_Selection)); |
mbed_official | 157:90e3acc479a2 | 449 | |
mbed_official | 157:90e3acc479a2 | 450 | if (NewState != DISABLE) |
mbed_official | 157:90e3acc479a2 | 451 | { |
mbed_official | 157:90e3acc479a2 | 452 | /* Enable the window mode */ |
mbed_official | 157:90e3acc479a2 | 453 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) COMP_CSR_COMPxWNDWEN; |
mbed_official | 157:90e3acc479a2 | 454 | } |
mbed_official | 157:90e3acc479a2 | 455 | else |
mbed_official | 157:90e3acc479a2 | 456 | { |
mbed_official | 157:90e3acc479a2 | 457 | /* Disable the window mode */ |
mbed_official | 157:90e3acc479a2 | 458 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMPxWNDWEN); |
mbed_official | 157:90e3acc479a2 | 459 | } |
mbed_official | 157:90e3acc479a2 | 460 | } |
mbed_official | 157:90e3acc479a2 | 461 | |
mbed_official | 157:90e3acc479a2 | 462 | /** |
mbed_official | 157:90e3acc479a2 | 463 | * @} |
mbed_official | 157:90e3acc479a2 | 464 | */ |
mbed_official | 157:90e3acc479a2 | 465 | |
mbed_official | 157:90e3acc479a2 | 466 | /** @defgroup COMP_Group3 COMP configuration locking function |
mbed_official | 157:90e3acc479a2 | 467 | * @brief COMP1, COMP2,...COMP7 configuration locking function |
mbed_official | 157:90e3acc479a2 | 468 | * COMP1, COMP2,...COMP7 configuration can be locked each separately. |
mbed_official | 157:90e3acc479a2 | 469 | * Unlocking is performed by system reset. |
mbed_official | 157:90e3acc479a2 | 470 | * |
mbed_official | 157:90e3acc479a2 | 471 | @verbatim |
mbed_official | 157:90e3acc479a2 | 472 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 473 | ##### Configuration Lock function ##### |
mbed_official | 157:90e3acc479a2 | 474 | =============================================================================== |
mbed_official | 157:90e3acc479a2 | 475 | |
mbed_official | 157:90e3acc479a2 | 476 | @endverbatim |
mbed_official | 157:90e3acc479a2 | 477 | * @{ |
mbed_official | 157:90e3acc479a2 | 478 | */ |
mbed_official | 157:90e3acc479a2 | 479 | |
mbed_official | 157:90e3acc479a2 | 480 | /** |
mbed_official | 157:90e3acc479a2 | 481 | * @brief Lock the selected comparator (COMP1/COMP2) configuration. |
mbed_official | 157:90e3acc479a2 | 482 | * @note Locking the configuration means that all control bits are read-only. |
mbed_official | 157:90e3acc479a2 | 483 | * To unlock the comparator configuration, perform a system reset. |
mbed_official | 157:90e3acc479a2 | 484 | * @param COMP_Selection: the selected comparator. |
mbed_official | 157:90e3acc479a2 | 485 | * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 |
mbed_official | 157:90e3acc479a2 | 486 | * to select the COMP peripheral. |
mbed_official | 157:90e3acc479a2 | 487 | * @retval None |
mbed_official | 157:90e3acc479a2 | 488 | */ |
mbed_official | 157:90e3acc479a2 | 489 | void COMP_LockConfig(uint32_t COMP_Selection) |
mbed_official | 157:90e3acc479a2 | 490 | { |
mbed_official | 157:90e3acc479a2 | 491 | /* Check the parameter */ |
mbed_official | 157:90e3acc479a2 | 492 | assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); |
mbed_official | 157:90e3acc479a2 | 493 | |
mbed_official | 157:90e3acc479a2 | 494 | /* Set the lock bit corresponding to selected comparator */ |
mbed_official | 157:90e3acc479a2 | 495 | *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMPxLOCK); |
mbed_official | 157:90e3acc479a2 | 496 | } |
mbed_official | 157:90e3acc479a2 | 497 | |
mbed_official | 157:90e3acc479a2 | 498 | /** |
mbed_official | 157:90e3acc479a2 | 499 | * @} |
mbed_official | 157:90e3acc479a2 | 500 | */ |
mbed_official | 157:90e3acc479a2 | 501 | |
mbed_official | 157:90e3acc479a2 | 502 | /** |
mbed_official | 157:90e3acc479a2 | 503 | * @} |
mbed_official | 157:90e3acc479a2 | 504 | */ |
mbed_official | 157:90e3acc479a2 | 505 | |
mbed_official | 157:90e3acc479a2 | 506 | /** |
mbed_official | 157:90e3acc479a2 | 507 | * @} |
mbed_official | 157:90e3acc479a2 | 508 | */ |
mbed_official | 157:90e3acc479a2 | 509 | |
mbed_official | 157:90e3acc479a2 | 510 | /** |
mbed_official | 157:90e3acc479a2 | 511 | * @} |
mbed_official | 157:90e3acc479a2 | 512 | */ |
mbed_official | 157:90e3acc479a2 | 513 | |
mbed_official | 157:90e3acc479a2 | 514 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |