mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
shaoziyang
Date:
Sat Sep 13 14:25:46 2014 +0000
Revision:
323:9e901b0a5aa1
Parent:
181:a4cbdfbbd2f4
test with CLOCK_SETUP = 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 181:a4cbdfbbd2f4 1 /**
mbed_official 181:a4cbdfbbd2f4 2 ******************************************************************************
mbed_official 181:a4cbdfbbd2f4 3 * @file stm32l0xx_hal_comp.c
mbed_official 181:a4cbdfbbd2f4 4 * @author MCD Application Team
mbed_official 181:a4cbdfbbd2f4 5 * @version V1.0.0
mbed_official 181:a4cbdfbbd2f4 6 * @date 22-April-2014
mbed_official 181:a4cbdfbbd2f4 7 * @brief COMP HAL module driver.
mbed_official 181:a4cbdfbbd2f4 8 *
mbed_official 181:a4cbdfbbd2f4 9 * This file provides firmware functions to manage the following
mbed_official 181:a4cbdfbbd2f4 10 * functionalities of the COMP peripheral:
mbed_official 181:a4cbdfbbd2f4 11 * + Initialization/de-initialization functions
mbed_official 181:a4cbdfbbd2f4 12 * + I/O operation functions
mbed_official 181:a4cbdfbbd2f4 13 * + Peripheral Control functions
mbed_official 181:a4cbdfbbd2f4 14 * + Peripheral State functions
mbed_official 181:a4cbdfbbd2f4 15 *
mbed_official 181:a4cbdfbbd2f4 16 @verbatim
mbed_official 181:a4cbdfbbd2f4 17 ================================================================================
mbed_official 181:a4cbdfbbd2f4 18 ##### COMP Peripheral features #####
mbed_official 181:a4cbdfbbd2f4 19 ================================================================================
mbed_official 181:a4cbdfbbd2f4 20
mbed_official 181:a4cbdfbbd2f4 21 [..]
mbed_official 181:a4cbdfbbd2f4 22 The STM32L0xx device family integrates 2 analog comparators COMP1 and COMP2:
mbed_official 181:a4cbdfbbd2f4 23 (#) The non inverting input and inverting input can be set to GPIO pins
mbed_official 181:a4cbdfbbd2f4 24 as shown in table1. COMP Inputs below.
mbed_official 181:a4cbdfbbd2f4 25
mbed_official 181:a4cbdfbbd2f4 26 (#) The COMP output is available using HAL_COMP_GetOutputLevel()
mbed_official 181:a4cbdfbbd2f4 27 and can be set on GPIO pins. Refer to table 2. COMP Outputs below.
mbed_official 181:a4cbdfbbd2f4 28
mbed_official 181:a4cbdfbbd2f4 29 (#) The COMP output can be redirected to embedded timers (TIM2, TIM21, TIM22...) and LPTIM
mbed_official 181:a4cbdfbbd2f4 30 Refer to TIM and LPTIM drivers.
mbed_official 181:a4cbdfbbd2f4 31
mbed_official 181:a4cbdfbbd2f4 32 (#) The comparators COMP1 and COMP2 can be combined in window mode and only COMP2 non inverting input can be used as non-inverting input.
mbed_official 181:a4cbdfbbd2f4 33
mbed_official 181:a4cbdfbbd2f4 34 (#) The 2 comparators have interrupt capability with wake-up
mbed_official 181:a4cbdfbbd2f4 35 from Sleep and Stop modes (through the EXTI controller):
mbed_official 181:a4cbdfbbd2f4 36 (++) COMP1 is internally connected to EXTI Line 21
mbed_official 181:a4cbdfbbd2f4 37 (++) COMP2 is internally connected to EXTI Line 22
mbed_official 181:a4cbdfbbd2f4 38
mbed_official 181:a4cbdfbbd2f4 39 From the corresponding IRQ handler, the right interrupt source can be retrieved with the
mbed_official 181:a4cbdfbbd2f4 40 macro __HAL_COMP_EXTI_GET_FLAG(). Possible values are:
mbed_official 181:a4cbdfbbd2f4 41 (++) COMP_EXTI_LINE_COMP1_EVENT
mbed_official 181:a4cbdfbbd2f4 42 (++) COMP_EXTI_LINE_COMP2_EVENT
mbed_official 181:a4cbdfbbd2f4 43
mbed_official 181:a4cbdfbbd2f4 44
mbed_official 181:a4cbdfbbd2f4 45 [..] Table 1. COMP Inputs for the STM32L0xx devices
mbed_official 181:a4cbdfbbd2f4 46 +--------------------------------------------------+
mbed_official 181:a4cbdfbbd2f4 47 | | | COMP1 | COMP2 |
mbed_official 181:a4cbdfbbd2f4 48 |-----------------|----------------|---------------|
mbed_official 181:a4cbdfbbd2f4 49 | | 1/4 VREFINT | -- | OK |
mbed_official 181:a4cbdfbbd2f4 50 | | 1/2 VREFINT | -- | OK |
mbed_official 181:a4cbdfbbd2f4 51 | | 3/4 VREFINT | -- | OK |
mbed_official 181:a4cbdfbbd2f4 52 | Inverting Input | VREFINT | OK | OK |
mbed_official 181:a4cbdfbbd2f4 53 | | DAC OUT (PA4) | OK | OK |
mbed_official 181:a4cbdfbbd2f4 54 | | IO1 | PA0 | PA2 |
mbed_official 181:a4cbdfbbd2f4 55 | | IO2 | PA5 | PA5 |
mbed_official 181:a4cbdfbbd2f4 56 | | IO3 | --- | PB3 |
mbed_official 181:a4cbdfbbd2f4 57 |-----------------|----------------|-------|-------|
mbed_official 181:a4cbdfbbd2f4 58 | Non Inverting | IO1 | PA1 | PA3 |
mbed_official 181:a4cbdfbbd2f4 59 | Input | IO2 | --- | PB4 |
mbed_official 181:a4cbdfbbd2f4 60 | | IO3 | --- | PB5 |
mbed_official 181:a4cbdfbbd2f4 61 | | IO4 | --- | PB6 |
mbed_official 181:a4cbdfbbd2f4 62 | | IO5 | --- | PB7 |
mbed_official 181:a4cbdfbbd2f4 63 +--------------------------------------------------+
mbed_official 181:a4cbdfbbd2f4 64
mbed_official 181:a4cbdfbbd2f4 65 [..] Table 2. COMP Outputs for the STM32L0xx devices
mbed_official 181:a4cbdfbbd2f4 66 +---------------+
mbed_official 181:a4cbdfbbd2f4 67 | COMP1 | COMP2 |
mbed_official 181:a4cbdfbbd2f4 68 |-------|-------|
mbed_official 181:a4cbdfbbd2f4 69 | PA0 | PA2 |
mbed_official 181:a4cbdfbbd2f4 70 | PA6 | PA7 |
mbed_official 181:a4cbdfbbd2f4 71 | PA11 | PA12 |
mbed_official 181:a4cbdfbbd2f4 72 +---------------+
mbed_official 181:a4cbdfbbd2f4 73
mbed_official 181:a4cbdfbbd2f4 74
mbed_official 181:a4cbdfbbd2f4 75 ##### How to use this driver #####
mbed_official 181:a4cbdfbbd2f4 76 ================================================================================
mbed_official 181:a4cbdfbbd2f4 77 [..]
mbed_official 181:a4cbdfbbd2f4 78 This driver provides functions to configure and program the Comparators of all STM32L0xx devices.
mbed_official 181:a4cbdfbbd2f4 79
mbed_official 181:a4cbdfbbd2f4 80 To use the comparator, perform the following steps:
mbed_official 181:a4cbdfbbd2f4 81
mbed_official 181:a4cbdfbbd2f4 82 (#) Initialize the COMP low level resources by implementing the HAL_COMP_MspInit().
mbed_official 181:a4cbdfbbd2f4 83 (++) Enable the SYSCFG APB clock to get write access to comparator register using __SYSCFG_CLK_ENABLE().
mbed_official 181:a4cbdfbbd2f4 84 (++) Configure the comparator input in analog mode using HAL_GPIO_Init().
mbed_official 181:a4cbdfbbd2f4 85 (++) Configure the comparator output in alternate function mode using HAL_GPIO_Init() to map the comparator
mbed_official 181:a4cbdfbbd2f4 86 output to the GPIO pin.
mbed_official 181:a4cbdfbbd2f4 87 (++) If required enable the VREFINT reference using HAL_VREFINT_Cmd() and HAL_COMP_EnableBuffer_Cmd().
mbed_official 181:a4cbdfbbd2f4 88 (++) If required enable the COMP interrupt by configuring and enabling EXTI line in Interrupt mode and
mbed_official 181:a4cbdfbbd2f4 89 selecting the desired sensitivity level using HAL_GPIO_Init() function. After that enable the comparator
mbed_official 181:a4cbdfbbd2f4 90 interrupt vector using HAL_NVIC_EnableIRQ() function.
mbed_official 181:a4cbdfbbd2f4 91
mbed_official 181:a4cbdfbbd2f4 92 (#) Configure the comparator using HAL_COMP_Init() function:
mbed_official 181:a4cbdfbbd2f4 93 (++) Select the inverting input
mbed_official 181:a4cbdfbbd2f4 94 (++) Select the non-inverting input
mbed_official 181:a4cbdfbbd2f4 95 (++) Select the output polarity
mbed_official 181:a4cbdfbbd2f4 96 (++) Select the power mode
mbed_official 181:a4cbdfbbd2f4 97 (++) Select the window mode
mbed_official 181:a4cbdfbbd2f4 98
mbed_official 181:a4cbdfbbd2f4 99 (#) Enable the comparator using HAL_COMP_Start() function
mbed_official 181:a4cbdfbbd2f4 100
mbed_official 181:a4cbdfbbd2f4 101 @endverbatim
mbed_official 181:a4cbdfbbd2f4 102 ******************************************************************************
mbed_official 181:a4cbdfbbd2f4 103 * @attention
mbed_official 181:a4cbdfbbd2f4 104 *
mbed_official 181:a4cbdfbbd2f4 105 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 181:a4cbdfbbd2f4 106 *
mbed_official 181:a4cbdfbbd2f4 107 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 181:a4cbdfbbd2f4 108 * are permitted provided that the following conditions are met:
mbed_official 181:a4cbdfbbd2f4 109 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 181:a4cbdfbbd2f4 110 * this list of conditions and the following disclaimer.
mbed_official 181:a4cbdfbbd2f4 111 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 181:a4cbdfbbd2f4 112 * this list of conditions and the following disclaimer in the documentation
mbed_official 181:a4cbdfbbd2f4 113 * and/or other materials provided with the distribution.
mbed_official 181:a4cbdfbbd2f4 114 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 181:a4cbdfbbd2f4 115 * may be used to endorse or promote products derived from this software
mbed_official 181:a4cbdfbbd2f4 116 * without specific prior written permission.
mbed_official 181:a4cbdfbbd2f4 117 *
mbed_official 181:a4cbdfbbd2f4 118 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 181:a4cbdfbbd2f4 119 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 181:a4cbdfbbd2f4 120 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 181:a4cbdfbbd2f4 121 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 181:a4cbdfbbd2f4 122 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 181:a4cbdfbbd2f4 123 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 181:a4cbdfbbd2f4 124 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 181:a4cbdfbbd2f4 125 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 181:a4cbdfbbd2f4 126 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 181:a4cbdfbbd2f4 127 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 181:a4cbdfbbd2f4 128 *
mbed_official 181:a4cbdfbbd2f4 129 ******************************************************************************
mbed_official 181:a4cbdfbbd2f4 130 */
mbed_official 181:a4cbdfbbd2f4 131
mbed_official 181:a4cbdfbbd2f4 132 /* Includes ------------------------------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 133 #include "stm32l0xx_hal.h"
mbed_official 181:a4cbdfbbd2f4 134
mbed_official 181:a4cbdfbbd2f4 135 /** @addtogroup STM32L0xx_HAL_Driver
mbed_official 181:a4cbdfbbd2f4 136 * @{
mbed_official 181:a4cbdfbbd2f4 137 */
mbed_official 181:a4cbdfbbd2f4 138
mbed_official 181:a4cbdfbbd2f4 139 /** @defgroup COMP
mbed_official 181:a4cbdfbbd2f4 140 * @brief COMP HAL module driver
mbed_official 181:a4cbdfbbd2f4 141 * @{
mbed_official 181:a4cbdfbbd2f4 142 */
mbed_official 181:a4cbdfbbd2f4 143
mbed_official 181:a4cbdfbbd2f4 144 #ifdef HAL_COMP_MODULE_ENABLED
mbed_official 181:a4cbdfbbd2f4 145
mbed_official 181:a4cbdfbbd2f4 146 /* Private typedef -----------------------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 147 /* Private define ------------------------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 148 /* CSR register reset value */
mbed_official 181:a4cbdfbbd2f4 149 #define COMP_CSR_RESET_VALUE ((uint32_t)0x00000000)
mbed_official 181:a4cbdfbbd2f4 150
mbed_official 181:a4cbdfbbd2f4 151 /* Private macro -------------------------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 152 /* Private variables ---------------------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 153 /* Private function prototypes -----------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 154 /* Private functions ---------------------------------------------------------*/
mbed_official 181:a4cbdfbbd2f4 155
mbed_official 181:a4cbdfbbd2f4 156 /** @defgroup COMP_Private_Functions
mbed_official 181:a4cbdfbbd2f4 157 * @{
mbed_official 181:a4cbdfbbd2f4 158 */
mbed_official 181:a4cbdfbbd2f4 159
mbed_official 181:a4cbdfbbd2f4 160 /** @defgroup HAL_COMP_Group1 Initialization/de-initialization functions
mbed_official 181:a4cbdfbbd2f4 161 * @brief Initialization and Configuration functions
mbed_official 181:a4cbdfbbd2f4 162 *
mbed_official 181:a4cbdfbbd2f4 163 @verbatim
mbed_official 181:a4cbdfbbd2f4 164 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 165 ##### Initialization/de-initialization functions #####
mbed_official 181:a4cbdfbbd2f4 166 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 167 [..] This section provides functions to initialize and de-initialize comparators
mbed_official 181:a4cbdfbbd2f4 168
mbed_official 181:a4cbdfbbd2f4 169 @endverbatim
mbed_official 181:a4cbdfbbd2f4 170 * @{
mbed_official 181:a4cbdfbbd2f4 171 */
mbed_official 181:a4cbdfbbd2f4 172
mbed_official 181:a4cbdfbbd2f4 173 /**
mbed_official 181:a4cbdfbbd2f4 174 * @brief Initializes the COMP according to the specified
mbed_official 181:a4cbdfbbd2f4 175 * parameters in the COMP_InitTypeDef and create the associated handle.
mbed_official 181:a4cbdfbbd2f4 176 * @note If the selected comparator is locked, initialization can't be performed.
mbed_official 181:a4cbdfbbd2f4 177 * To unlock the configuration, perform a system reset.
mbed_official 181:a4cbdfbbd2f4 178 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 179 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 180 */
mbed_official 181:a4cbdfbbd2f4 181 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 182 {
mbed_official 181:a4cbdfbbd2f4 183 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 184
mbed_official 181:a4cbdfbbd2f4 185 /* Check the COMP handle allocation and lock status */
mbed_official 181:a4cbdfbbd2f4 186 if((hcomp == NULL) || ((hcomp->State & COMP_STATE_BIT_LOCK) != 0x00))
mbed_official 181:a4cbdfbbd2f4 187 {
mbed_official 181:a4cbdfbbd2f4 188 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 189 }
mbed_official 181:a4cbdfbbd2f4 190 else
mbed_official 181:a4cbdfbbd2f4 191 {
mbed_official 181:a4cbdfbbd2f4 192 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 193 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 194 assert_param(IS_COMP_INVERTINGINPUT(hcomp->Init.InvertingInput));
mbed_official 181:a4cbdfbbd2f4 195 assert_param(IS_COMP_NONINVERTINGINPUT(hcomp->Init.NonInvertingInput));
mbed_official 181:a4cbdfbbd2f4 196 assert_param(IS_COMP_OUTPUTPOL(hcomp->Init.OutputPol));
mbed_official 181:a4cbdfbbd2f4 197 assert_param(IS_COMP_MODE(hcomp->Init.Mode));
mbed_official 181:a4cbdfbbd2f4 198
mbed_official 181:a4cbdfbbd2f4 199 if(hcomp->Init.WindowMode != COMP_WINDOWMODE_DISABLED)
mbed_official 181:a4cbdfbbd2f4 200 {
mbed_official 181:a4cbdfbbd2f4 201 assert_param(IS_COMP_WINDOWMODE_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 202 assert_param(IS_COMP_WINDOWMODE(hcomp->Init.WindowMode));
mbed_official 181:a4cbdfbbd2f4 203 }
mbed_official 181:a4cbdfbbd2f4 204
mbed_official 181:a4cbdfbbd2f4 205 if(hcomp->State == HAL_COMP_STATE_RESET)
mbed_official 181:a4cbdfbbd2f4 206 {
mbed_official 181:a4cbdfbbd2f4 207 /* Init the low level hardware : SYSCFG to access comparators */
mbed_official 181:a4cbdfbbd2f4 208 HAL_COMP_MspInit(hcomp);
mbed_official 181:a4cbdfbbd2f4 209 }
mbed_official 181:a4cbdfbbd2f4 210
mbed_official 181:a4cbdfbbd2f4 211 /* Change COMP peripheral state */
mbed_official 181:a4cbdfbbd2f4 212 hcomp->State = HAL_COMP_STATE_BUSY;
mbed_official 181:a4cbdfbbd2f4 213
mbed_official 181:a4cbdfbbd2f4 214 /* Set COMP parameters */
mbed_official 181:a4cbdfbbd2f4 215 /* Set COMPxINSEL bits according to hcomp->Init.InvertingInput value */
mbed_official 181:a4cbdfbbd2f4 216 /* Set COMPxNONINSEL bits according to hcomp->Init.NonInvertingInput value */
mbed_official 181:a4cbdfbbd2f4 217 /* Set COMPxPOL bit according to hcomp->Init.OutputPol value */
mbed_official 181:a4cbdfbbd2f4 218 /* Set COMPxMODE bits according to hcomp->Init.Mode value */
mbed_official 181:a4cbdfbbd2f4 219 /* Set COMP1WM bit according to hcomp->Init.WindowMode value */
mbed_official 181:a4cbdfbbd2f4 220 MODIFY_REG(hcomp->Instance->CSR, COMP_CSR_UPDATE_PARAMETERS_MASK, \
mbed_official 181:a4cbdfbbd2f4 221 hcomp->Init.InvertingInput | \
mbed_official 181:a4cbdfbbd2f4 222 hcomp->Init.NonInvertingInput | \
mbed_official 181:a4cbdfbbd2f4 223 hcomp->Init.OutputPol | \
mbed_official 181:a4cbdfbbd2f4 224 hcomp->Init.Mode | \
mbed_official 181:a4cbdfbbd2f4 225 hcomp->Init.WindowMode);
mbed_official 181:a4cbdfbbd2f4 226
mbed_official 181:a4cbdfbbd2f4 227
mbed_official 181:a4cbdfbbd2f4 228 /* Initialize the COMP state*/
mbed_official 181:a4cbdfbbd2f4 229 hcomp->State = HAL_COMP_STATE_READY;
mbed_official 181:a4cbdfbbd2f4 230
mbed_official 181:a4cbdfbbd2f4 231 }
mbed_official 181:a4cbdfbbd2f4 232
mbed_official 181:a4cbdfbbd2f4 233 return status;
mbed_official 181:a4cbdfbbd2f4 234 }
mbed_official 181:a4cbdfbbd2f4 235
mbed_official 181:a4cbdfbbd2f4 236 /**
mbed_official 181:a4cbdfbbd2f4 237 * @brief DeInitializes the COMP peripheral
mbed_official 181:a4cbdfbbd2f4 238 * @note Deinitialization can't be performed if the COMP configuration is locked.
mbed_official 181:a4cbdfbbd2f4 239 * To unlock the configuration, perform a system reset.
mbed_official 181:a4cbdfbbd2f4 240 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 241 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 242 */
mbed_official 181:a4cbdfbbd2f4 243 HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 244 {
mbed_official 181:a4cbdfbbd2f4 245 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 246
mbed_official 181:a4cbdfbbd2f4 247 /* Check the COMP handle allocation and lock status */
mbed_official 181:a4cbdfbbd2f4 248 if((hcomp == NULL) || ((hcomp->State & COMP_STATE_BIT_LOCK) != 0x00))
mbed_official 181:a4cbdfbbd2f4 249 {
mbed_official 181:a4cbdfbbd2f4 250 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 251 }
mbed_official 181:a4cbdfbbd2f4 252 else
mbed_official 181:a4cbdfbbd2f4 253 {
mbed_official 181:a4cbdfbbd2f4 254 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 255 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 256
mbed_official 181:a4cbdfbbd2f4 257 /* Set COMP_CSR register to reset value */
mbed_official 181:a4cbdfbbd2f4 258 WRITE_REG(hcomp->Instance->CSR, COMP_CSR_RESET_VALUE);
mbed_official 181:a4cbdfbbd2f4 259
mbed_official 181:a4cbdfbbd2f4 260 /* DeInit the low level hardware: SYSCFG, GPIO, CLOCK and NVIC */
mbed_official 181:a4cbdfbbd2f4 261 HAL_COMP_MspDeInit(hcomp);
mbed_official 181:a4cbdfbbd2f4 262
mbed_official 181:a4cbdfbbd2f4 263 hcomp->State = HAL_COMP_STATE_RESET;
mbed_official 181:a4cbdfbbd2f4 264
mbed_official 181:a4cbdfbbd2f4 265 /* Release Lock */
mbed_official 181:a4cbdfbbd2f4 266 __HAL_UNLOCK(hcomp);
mbed_official 181:a4cbdfbbd2f4 267 }
mbed_official 181:a4cbdfbbd2f4 268
mbed_official 181:a4cbdfbbd2f4 269 return status;
mbed_official 181:a4cbdfbbd2f4 270 }
mbed_official 181:a4cbdfbbd2f4 271
mbed_official 181:a4cbdfbbd2f4 272 /**
mbed_official 181:a4cbdfbbd2f4 273 * @brief Initializes the COMP MSP.
mbed_official 181:a4cbdfbbd2f4 274 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 275 * @retval None
mbed_official 181:a4cbdfbbd2f4 276 */
mbed_official 181:a4cbdfbbd2f4 277 __weak void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 278 {
mbed_official 181:a4cbdfbbd2f4 279 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 181:a4cbdfbbd2f4 280 the HAL_COMP_MspInit could be implenetd in the user file
mbed_official 181:a4cbdfbbd2f4 281 */
mbed_official 181:a4cbdfbbd2f4 282 }
mbed_official 181:a4cbdfbbd2f4 283
mbed_official 181:a4cbdfbbd2f4 284 /**
mbed_official 181:a4cbdfbbd2f4 285 * @brief DeInitializes COMP MSP.
mbed_official 181:a4cbdfbbd2f4 286 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 287 * @retval None
mbed_official 181:a4cbdfbbd2f4 288 */
mbed_official 181:a4cbdfbbd2f4 289 __weak void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 290 {
mbed_official 181:a4cbdfbbd2f4 291 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 181:a4cbdfbbd2f4 292 the HAL_COMP_MspDeInit could be implenetd in the user file
mbed_official 181:a4cbdfbbd2f4 293 */
mbed_official 181:a4cbdfbbd2f4 294 }
mbed_official 181:a4cbdfbbd2f4 295
mbed_official 181:a4cbdfbbd2f4 296 /**
mbed_official 181:a4cbdfbbd2f4 297 * @}
mbed_official 181:a4cbdfbbd2f4 298 */
mbed_official 181:a4cbdfbbd2f4 299
mbed_official 181:a4cbdfbbd2f4 300 /** @defgroup HAL_COMP_Group2 I/O operation functions
mbed_official 181:a4cbdfbbd2f4 301 * @brief Data transfers functions
mbed_official 181:a4cbdfbbd2f4 302 *
mbed_official 181:a4cbdfbbd2f4 303 @verbatim
mbed_official 181:a4cbdfbbd2f4 304 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 305 ##### IO operation functions #####
mbed_official 181:a4cbdfbbd2f4 306 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 307 [..]
mbed_official 181:a4cbdfbbd2f4 308 This subsection provides a set of functions allowing to manage the COMP data
mbed_official 181:a4cbdfbbd2f4 309 transfers.
mbed_official 181:a4cbdfbbd2f4 310
mbed_official 181:a4cbdfbbd2f4 311 @endverbatim
mbed_official 181:a4cbdfbbd2f4 312 * @{
mbed_official 181:a4cbdfbbd2f4 313 */
mbed_official 181:a4cbdfbbd2f4 314
mbed_official 181:a4cbdfbbd2f4 315 /**
mbed_official 181:a4cbdfbbd2f4 316 * @brief Start the comparator
mbed_official 181:a4cbdfbbd2f4 317 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 318 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 319 */
mbed_official 181:a4cbdfbbd2f4 320 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 321 {
mbed_official 181:a4cbdfbbd2f4 322 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 323
mbed_official 181:a4cbdfbbd2f4 324 /* Check the COMP handle allocation and lock status */
mbed_official 181:a4cbdfbbd2f4 325 if((hcomp == NULL) || ((hcomp->State & COMP_STATE_BIT_LOCK) != 0x00))
mbed_official 181:a4cbdfbbd2f4 326 {
mbed_official 181:a4cbdfbbd2f4 327 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 328 }
mbed_official 181:a4cbdfbbd2f4 329 else
mbed_official 181:a4cbdfbbd2f4 330 {
mbed_official 181:a4cbdfbbd2f4 331 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 332 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 333
mbed_official 181:a4cbdfbbd2f4 334 if(hcomp->State == HAL_COMP_STATE_READY)
mbed_official 181:a4cbdfbbd2f4 335 {
mbed_official 181:a4cbdfbbd2f4 336 /* Enable the selected comparator */
mbed_official 181:a4cbdfbbd2f4 337 __HAL_COMP_ENABLE(hcomp);
mbed_official 181:a4cbdfbbd2f4 338
mbed_official 181:a4cbdfbbd2f4 339 hcomp->State = HAL_COMP_STATE_BUSY;
mbed_official 181:a4cbdfbbd2f4 340 }
mbed_official 181:a4cbdfbbd2f4 341 else
mbed_official 181:a4cbdfbbd2f4 342 {
mbed_official 181:a4cbdfbbd2f4 343 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 344 }
mbed_official 181:a4cbdfbbd2f4 345 }
mbed_official 181:a4cbdfbbd2f4 346
mbed_official 181:a4cbdfbbd2f4 347 return status;
mbed_official 181:a4cbdfbbd2f4 348 }
mbed_official 181:a4cbdfbbd2f4 349
mbed_official 181:a4cbdfbbd2f4 350 /**
mbed_official 181:a4cbdfbbd2f4 351 * @brief Stop the comparator
mbed_official 181:a4cbdfbbd2f4 352 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 353 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 354 */
mbed_official 181:a4cbdfbbd2f4 355 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 356 {
mbed_official 181:a4cbdfbbd2f4 357 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 358
mbed_official 181:a4cbdfbbd2f4 359 /* Check the COMP handle allocation and lock status */
mbed_official 181:a4cbdfbbd2f4 360 if((hcomp == NULL) || ((hcomp->State & COMP_STATE_BIT_LOCK) != 0x00))
mbed_official 181:a4cbdfbbd2f4 361 {
mbed_official 181:a4cbdfbbd2f4 362 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 363 }
mbed_official 181:a4cbdfbbd2f4 364 else
mbed_official 181:a4cbdfbbd2f4 365 {
mbed_official 181:a4cbdfbbd2f4 366 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 367 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 368
mbed_official 181:a4cbdfbbd2f4 369 if(hcomp->State == HAL_COMP_STATE_BUSY)
mbed_official 181:a4cbdfbbd2f4 370 {
mbed_official 181:a4cbdfbbd2f4 371 /* Disable the selected comparator */
mbed_official 181:a4cbdfbbd2f4 372 __HAL_COMP_DISABLE(hcomp);
mbed_official 181:a4cbdfbbd2f4 373
mbed_official 181:a4cbdfbbd2f4 374 hcomp->State = HAL_COMP_STATE_READY;
mbed_official 181:a4cbdfbbd2f4 375 }
mbed_official 181:a4cbdfbbd2f4 376 else
mbed_official 181:a4cbdfbbd2f4 377 {
mbed_official 181:a4cbdfbbd2f4 378 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 379 }
mbed_official 181:a4cbdfbbd2f4 380 }
mbed_official 181:a4cbdfbbd2f4 381
mbed_official 181:a4cbdfbbd2f4 382 return status;
mbed_official 181:a4cbdfbbd2f4 383 }
mbed_official 181:a4cbdfbbd2f4 384
mbed_official 181:a4cbdfbbd2f4 385 /**
mbed_official 181:a4cbdfbbd2f4 386 * @brief Enables the interrupt and starts the comparator
mbed_official 181:a4cbdfbbd2f4 387 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 388 * @param mode: IT trigger mode: a value of @ref COMP_TriggerMode
mbed_official 181:a4cbdfbbd2f4 389 * @retval HAL status.
mbed_official 181:a4cbdfbbd2f4 390 */
mbed_official 181:a4cbdfbbd2f4 391 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 392 {
mbed_official 181:a4cbdfbbd2f4 393 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 394 uint32_t extiline = 0;
mbed_official 181:a4cbdfbbd2f4 395
mbed_official 181:a4cbdfbbd2f4 396 status = HAL_COMP_Start(hcomp);
mbed_official 181:a4cbdfbbd2f4 397 if(status == HAL_OK)
mbed_official 181:a4cbdfbbd2f4 398 {
mbed_official 181:a4cbdfbbd2f4 399 /* Check the Exti Line output configuration */
mbed_official 181:a4cbdfbbd2f4 400 extiline = __HAL_COMP_GET_EXTI_LINE(hcomp->Instance);
mbed_official 181:a4cbdfbbd2f4 401
mbed_official 181:a4cbdfbbd2f4 402 /* Configure the rising edge */
mbed_official 181:a4cbdfbbd2f4 403 if((hcomp->Init.TriggerMode & COMP_TRIGGERMODE_IT_RISING) != 0x00)
mbed_official 181:a4cbdfbbd2f4 404 {
mbed_official 181:a4cbdfbbd2f4 405 __HAL_COMP_EXTI_RISING_IT_ENABLE(extiline);
mbed_official 181:a4cbdfbbd2f4 406 }
mbed_official 181:a4cbdfbbd2f4 407 else
mbed_official 181:a4cbdfbbd2f4 408 {
mbed_official 181:a4cbdfbbd2f4 409 __HAL_COMP_EXTI_RISING_IT_DISABLE(extiline);
mbed_official 181:a4cbdfbbd2f4 410 }
mbed_official 181:a4cbdfbbd2f4 411
mbed_official 181:a4cbdfbbd2f4 412 /* Configure the falling edge */
mbed_official 181:a4cbdfbbd2f4 413 if((hcomp->Init.TriggerMode & COMP_TRIGGERMODE_IT_FALLING) != 0x00)
mbed_official 181:a4cbdfbbd2f4 414 {
mbed_official 181:a4cbdfbbd2f4 415 __HAL_COMP_EXTI_FALLING_IT_ENABLE(extiline);
mbed_official 181:a4cbdfbbd2f4 416 }
mbed_official 181:a4cbdfbbd2f4 417 else
mbed_official 181:a4cbdfbbd2f4 418 {
mbed_official 181:a4cbdfbbd2f4 419 __HAL_COMP_EXTI_FALLING_IT_DISABLE(extiline);
mbed_official 181:a4cbdfbbd2f4 420 }
mbed_official 181:a4cbdfbbd2f4 421
mbed_official 181:a4cbdfbbd2f4 422 /* Enable Exti interrupt mode */
mbed_official 181:a4cbdfbbd2f4 423 __HAL_COMP_EXTI_ENABLE_IT(extiline);
mbed_official 181:a4cbdfbbd2f4 424
mbed_official 181:a4cbdfbbd2f4 425 /* Clear COMP Exti pending bit */
mbed_official 181:a4cbdfbbd2f4 426 __HAL_COMP_EXTI_CLEAR_FLAG(extiline);
mbed_official 181:a4cbdfbbd2f4 427 }
mbed_official 181:a4cbdfbbd2f4 428
mbed_official 181:a4cbdfbbd2f4 429 return status;
mbed_official 181:a4cbdfbbd2f4 430 }
mbed_official 181:a4cbdfbbd2f4 431
mbed_official 181:a4cbdfbbd2f4 432 /**
mbed_official 181:a4cbdfbbd2f4 433 * @brief Disable the interrupt and Stop the comparator
mbed_official 181:a4cbdfbbd2f4 434 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 435 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 436 */
mbed_official 181:a4cbdfbbd2f4 437 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 438 {
mbed_official 181:a4cbdfbbd2f4 439 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 440
mbed_official 181:a4cbdfbbd2f4 441 /* Disable the Exti Line interrupt mode */
mbed_official 181:a4cbdfbbd2f4 442 __HAL_COMP_EXTI_DISABLE_IT(__HAL_COMP_GET_EXTI_LINE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 443
mbed_official 181:a4cbdfbbd2f4 444 status = HAL_COMP_Stop(hcomp);
mbed_official 181:a4cbdfbbd2f4 445
mbed_official 181:a4cbdfbbd2f4 446 return status;
mbed_official 181:a4cbdfbbd2f4 447 }
mbed_official 181:a4cbdfbbd2f4 448
mbed_official 181:a4cbdfbbd2f4 449 /**
mbed_official 181:a4cbdfbbd2f4 450 * @brief Comparator IRQ Handler
mbed_official 181:a4cbdfbbd2f4 451 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 452 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 453 */
mbed_official 181:a4cbdfbbd2f4 454 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 455 {
mbed_official 181:a4cbdfbbd2f4 456 uint32_t extiline = __HAL_COMP_GET_EXTI_LINE(hcomp->Instance);
mbed_official 181:a4cbdfbbd2f4 457
mbed_official 181:a4cbdfbbd2f4 458 /* Check COMP Exti flag */
mbed_official 181:a4cbdfbbd2f4 459 if(__HAL_COMP_EXTI_GET_FLAG(extiline) != RESET)
mbed_official 181:a4cbdfbbd2f4 460 {
mbed_official 181:a4cbdfbbd2f4 461 /* Clear COMP Exti pending bit */
mbed_official 181:a4cbdfbbd2f4 462 __HAL_COMP_EXTI_CLEAR_FLAG(extiline);
mbed_official 181:a4cbdfbbd2f4 463 }
mbed_official 181:a4cbdfbbd2f4 464
mbed_official 181:a4cbdfbbd2f4 465 /* COMP trigger user callback */
mbed_official 181:a4cbdfbbd2f4 466 HAL_COMP_TriggerCallback(hcomp);
mbed_official 181:a4cbdfbbd2f4 467 }
mbed_official 181:a4cbdfbbd2f4 468
mbed_official 181:a4cbdfbbd2f4 469 /**
mbed_official 181:a4cbdfbbd2f4 470 * @}
mbed_official 181:a4cbdfbbd2f4 471 */
mbed_official 181:a4cbdfbbd2f4 472
mbed_official 181:a4cbdfbbd2f4 473 /** @defgroup HAL_COMP_Group3 Peripheral Control functions
mbed_official 181:a4cbdfbbd2f4 474 * @brief management functions
mbed_official 181:a4cbdfbbd2f4 475 *
mbed_official 181:a4cbdfbbd2f4 476 @verbatim
mbed_official 181:a4cbdfbbd2f4 477 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 478 ##### Peripheral Control functions #####
mbed_official 181:a4cbdfbbd2f4 479 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 480 [..]
mbed_official 181:a4cbdfbbd2f4 481 This subsection provides a set of functions allowing to control the COMP data
mbed_official 181:a4cbdfbbd2f4 482 transfers.
mbed_official 181:a4cbdfbbd2f4 483
mbed_official 181:a4cbdfbbd2f4 484 @endverbatim
mbed_official 181:a4cbdfbbd2f4 485 * @{
mbed_official 181:a4cbdfbbd2f4 486 */
mbed_official 181:a4cbdfbbd2f4 487
mbed_official 181:a4cbdfbbd2f4 488 /**
mbed_official 181:a4cbdfbbd2f4 489 * @brief Lock the selected comparator configuration.
mbed_official 181:a4cbdfbbd2f4 490 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 491 * @retval HAL status
mbed_official 181:a4cbdfbbd2f4 492 */
mbed_official 181:a4cbdfbbd2f4 493 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 494 {
mbed_official 181:a4cbdfbbd2f4 495 HAL_StatusTypeDef status = HAL_OK;
mbed_official 181:a4cbdfbbd2f4 496
mbed_official 181:a4cbdfbbd2f4 497 /* Check the COMP handle allocation and lock status */
mbed_official 181:a4cbdfbbd2f4 498 if((hcomp == NULL) || ((hcomp->State & COMP_STATE_BIT_LOCK) != 0x00))
mbed_official 181:a4cbdfbbd2f4 499 {
mbed_official 181:a4cbdfbbd2f4 500 status = HAL_ERROR;
mbed_official 181:a4cbdfbbd2f4 501 }
mbed_official 181:a4cbdfbbd2f4 502 else
mbed_official 181:a4cbdfbbd2f4 503 {
mbed_official 181:a4cbdfbbd2f4 504 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 505 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 506
mbed_official 181:a4cbdfbbd2f4 507 /* Set lock flag */
mbed_official 181:a4cbdfbbd2f4 508 hcomp->State |= COMP_STATE_BIT_LOCK;
mbed_official 181:a4cbdfbbd2f4 509
mbed_official 181:a4cbdfbbd2f4 510 /* Set the lock bit corresponding to selected comparator */
mbed_official 181:a4cbdfbbd2f4 511 __HAL_COMP_LOCK(hcomp);
mbed_official 181:a4cbdfbbd2f4 512 }
mbed_official 181:a4cbdfbbd2f4 513
mbed_official 181:a4cbdfbbd2f4 514 return status;
mbed_official 181:a4cbdfbbd2f4 515 }
mbed_official 181:a4cbdfbbd2f4 516
mbed_official 181:a4cbdfbbd2f4 517 /**
mbed_official 181:a4cbdfbbd2f4 518 * @brief Return the output level (high or low) of the selected comparator.
mbed_official 181:a4cbdfbbd2f4 519 * The output level depends on the selected polarity.
mbed_official 181:a4cbdfbbd2f4 520 * If the polarity is not inverted:
mbed_official 181:a4cbdfbbd2f4 521 * - Comparator output is low when the non-inverting input is at a lower
mbed_official 181:a4cbdfbbd2f4 522 * voltage than the inverting input
mbed_official 181:a4cbdfbbd2f4 523 * - Comparator output is high when the non-inverting input is at a higher
mbed_official 181:a4cbdfbbd2f4 524 * voltage than the inverting input
mbed_official 181:a4cbdfbbd2f4 525 * If the polarity is inverted:
mbed_official 181:a4cbdfbbd2f4 526 * - Comparator output is high when the non-inverting input is at a lower
mbed_official 181:a4cbdfbbd2f4 527 * voltage than the inverting input
mbed_official 181:a4cbdfbbd2f4 528 * - Comparator output is low when the non-inverting input is at a higher
mbed_official 181:a4cbdfbbd2f4 529 * voltage than the inverting input
mbed_official 181:a4cbdfbbd2f4 530 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 531 * @retval Returns the selected comparator output level: COMP_OUTPUTLEVEL_LOW or COMP_OUTPUTLEVEL_HIGH.
mbed_official 181:a4cbdfbbd2f4 532 *
mbed_official 181:a4cbdfbbd2f4 533 */
mbed_official 181:a4cbdfbbd2f4 534 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 535 {
mbed_official 181:a4cbdfbbd2f4 536 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 537 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 538
mbed_official 181:a4cbdfbbd2f4 539 return((uint32_t)(hcomp->Instance->CSR & COMP_OUTPUTLEVEL_HIGH));
mbed_official 181:a4cbdfbbd2f4 540 }
mbed_official 181:a4cbdfbbd2f4 541
mbed_official 181:a4cbdfbbd2f4 542 /**
mbed_official 181:a4cbdfbbd2f4 543 * @brief Comparator callback.
mbed_official 181:a4cbdfbbd2f4 544 * @param hcomp: COMP handle
mbed_official 181:a4cbdfbbd2f4 545 * @retval None
mbed_official 181:a4cbdfbbd2f4 546 */
mbed_official 181:a4cbdfbbd2f4 547 __weak void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 548 {
mbed_official 181:a4cbdfbbd2f4 549 /* NOTE : This function should not be modified, when the callback is needed,
mbed_official 181:a4cbdfbbd2f4 550 the HAL_COMP_TriggerCallback should be implemented in the user file
mbed_official 181:a4cbdfbbd2f4 551 */
mbed_official 181:a4cbdfbbd2f4 552 }
mbed_official 181:a4cbdfbbd2f4 553
mbed_official 181:a4cbdfbbd2f4 554
mbed_official 181:a4cbdfbbd2f4 555 /**
mbed_official 181:a4cbdfbbd2f4 556 * @}
mbed_official 181:a4cbdfbbd2f4 557 */
mbed_official 181:a4cbdfbbd2f4 558
mbed_official 181:a4cbdfbbd2f4 559 /** @defgroup HAL_COMP_Group4 Peripheral State functions
mbed_official 181:a4cbdfbbd2f4 560 * @brief Peripheral State functions
mbed_official 181:a4cbdfbbd2f4 561 *
mbed_official 181:a4cbdfbbd2f4 562 @verbatim
mbed_official 181:a4cbdfbbd2f4 563 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 564 ##### Peripheral State functions #####
mbed_official 181:a4cbdfbbd2f4 565 ===============================================================================
mbed_official 181:a4cbdfbbd2f4 566 [..]
mbed_official 181:a4cbdfbbd2f4 567 This subsection permit to get in run-time the status of the peripheral
mbed_official 181:a4cbdfbbd2f4 568 and the data flow.
mbed_official 181:a4cbdfbbd2f4 569
mbed_official 181:a4cbdfbbd2f4 570 @endverbatim
mbed_official 181:a4cbdfbbd2f4 571 * @{
mbed_official 181:a4cbdfbbd2f4 572 */
mbed_official 181:a4cbdfbbd2f4 573
mbed_official 181:a4cbdfbbd2f4 574 /**
mbed_official 181:a4cbdfbbd2f4 575 * @brief Return the COMP state
mbed_official 181:a4cbdfbbd2f4 576 * @param hcomp : COMP handle
mbed_official 181:a4cbdfbbd2f4 577 * @retval HAL state
mbed_official 181:a4cbdfbbd2f4 578 */
mbed_official 181:a4cbdfbbd2f4 579 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp)
mbed_official 181:a4cbdfbbd2f4 580 {
mbed_official 181:a4cbdfbbd2f4 581 /* Check the COMP handle allocation */
mbed_official 181:a4cbdfbbd2f4 582 if(hcomp == NULL)
mbed_official 181:a4cbdfbbd2f4 583 {
mbed_official 181:a4cbdfbbd2f4 584 return HAL_COMP_STATE_RESET;
mbed_official 181:a4cbdfbbd2f4 585 }
mbed_official 181:a4cbdfbbd2f4 586
mbed_official 181:a4cbdfbbd2f4 587 /* Check the parameter */
mbed_official 181:a4cbdfbbd2f4 588 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance));
mbed_official 181:a4cbdfbbd2f4 589
mbed_official 181:a4cbdfbbd2f4 590 return hcomp->State;
mbed_official 181:a4cbdfbbd2f4 591 }
mbed_official 181:a4cbdfbbd2f4 592 /**
mbed_official 181:a4cbdfbbd2f4 593 * @}
mbed_official 181:a4cbdfbbd2f4 594 */
mbed_official 181:a4cbdfbbd2f4 595
mbed_official 181:a4cbdfbbd2f4 596 /**
mbed_official 181:a4cbdfbbd2f4 597 * @}
mbed_official 181:a4cbdfbbd2f4 598 */
mbed_official 181:a4cbdfbbd2f4 599
mbed_official 181:a4cbdfbbd2f4 600 #endif /* HAL_COMP_MODULE_ENABLED */
mbed_official 181:a4cbdfbbd2f4 601 /**
mbed_official 181:a4cbdfbbd2f4 602 * @}
mbed_official 181:a4cbdfbbd2f4 603 */
mbed_official 181:a4cbdfbbd2f4 604
mbed_official 181:a4cbdfbbd2f4 605 /**
mbed_official 181:a4cbdfbbd2f4 606 * @}
mbed_official 181:a4cbdfbbd2f4 607 */
mbed_official 181:a4cbdfbbd2f4 608
mbed_official 181:a4cbdfbbd2f4 609 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/