STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_comp.c 00004 * @author MCD Application Team 00005 * @brief COMP HAL module driver. 00006 * This file provides firmware functions to manage the following 00007 * functionalities of the COMP peripheral: 00008 * + Initialization and de-initialization functions 00009 * + Peripheral control functions 00010 * + Peripheral state functions 00011 ****************************************************************************** 00012 * @attention 00013 * 00014 * Copyright (c) 2017 STMicroelectronics. 00015 * All rights reserved. 00016 * 00017 * This software is licensed under terms that can be found in the LICENSE file 00018 * in the root directory of this software component. 00019 * If no LICENSE file comes with this software, it is provided AS-IS. 00020 * 00021 ****************************************************************************** 00022 @verbatim 00023 ================================================================================ 00024 ##### COMP Peripheral features ##### 00025 ================================================================================ 00026 00027 [..] 00028 The STM32H7xx device family integrates two analog comparators instances 00029 COMP1 and COMP2: 00030 (#) The COMP input minus (inverting input) and input plus (non inverting input) 00031 can be set to internal references or to GPIO pins 00032 (refer to GPIO list in reference manual). 00033 00034 (#) The COMP output level is available using HAL_COMP_GetOutputLevel() 00035 and can be redirected to other peripherals: GPIO pins (in mode 00036 alternate functions for comparator), timers. 00037 (refer to GPIO list in reference manual). 00038 00039 (#) Pairs of comparators instances can be combined in window mode 00040 (2 consecutive instances odd and even COMP<x> and COMP<x+1>). 00041 00042 (#) The comparators have interrupt capability through the EXTI controller 00043 with wake-up from sleep and stop modes: 00044 (++) COMP1 is internally connected to EXTI Line 20 00045 (++) COMP2 is internally connected to EXTI Line 21 00046 00047 [..] 00048 From the corresponding IRQ handler, the right interrupt source can be retrieved 00049 using macro __HAL_COMP_COMP1_EXTI_GET_FLAG() and __HAL_COMP_COMP2_EXTI_GET_FLAG(). 00050 00051 00052 00053 ##### How to use this driver ##### 00054 ================================================================================ 00055 [..] 00056 This driver provides functions to configure and program the comparator instances of 00057 STM32H7xx devices. 00058 00059 To use the comparator, perform the following steps: 00060 00061 (#) Initialize the COMP low level resources by implementing the HAL_COMP_MspInit(): 00062 (++) Configure the GPIO connected to comparator inputs plus and minus in analog mode 00063 using HAL_GPIO_Init(). 00064 (++) If needed, configure the GPIO connected to comparator output in alternate function mode 00065 using HAL_GPIO_Init(). 00066 (++) If required enable the COMP interrupt by configuring and enabling EXTI line in Interrupt mode and 00067 selecting the desired sensitivity level using HAL_GPIO_Init() function. After that enable the comparator 00068 interrupt vector using HAL_NVIC_EnableIRQ() function. 00069 00070 (#) Configure the comparator using HAL_COMP_Init() function: 00071 (++) Select the input minus (inverting input) 00072 (++) Select the input plus (non-inverting input) 00073 (++) Select the hysteresis 00074 (++) Select the blanking source 00075 (++) Select the output polarity 00076 (++) Select the power mode 00077 (++) Select the window mode 00078 -@@- HAL_COMP_Init() calls internally __HAL_RCC_SYSCFG_CLK_ENABLE() 00079 to enable internal control clock of the comparators. 00080 However, this is a legacy strategy. 00081 Therefore, for compatibility anticipation, it is recommended to 00082 implement __HAL_RCC_SYSCFG_CLK_ENABLE() in "HAL_COMP_MspInit()". 00083 In STM32H7,COMP clock enable __HAL_RCC_COMP12_CLK_ENABLE() must 00084 be implemented by user in "HAL_COMP_MspInit()". 00085 (#) Reconfiguration on-the-fly of comparator can be done by calling again 00086 function HAL_COMP_Init() with new input structure parameters values. 00087 00088 (#) Enable the comparator using HAL_COMP_Start() or HAL_COMP_Start_IT()to be enabled 00089 with the interrupt through NVIC of the CPU. 00090 Note: HAL_COMP_Start_IT() must be called after each interrupt otherwise the interrupt 00091 mode will stay disabled. 00092 00093 (#) Use HAL_COMP_GetOutputLevel() or HAL_COMP_TriggerCallback() 00094 functions to manage comparator outputs(output level or events) 00095 00096 (#) Disable the comparator using HAL_COMP_Stop() or HAL_COMP_Stop_IT() 00097 to disable the interrupt too. 00098 00099 (#) De-initialize the comparator using HAL_COMP_DeInit() function. 00100 00101 (#) For safety purpose, comparator configuration can be locked using HAL_COMP_Lock() function. 00102 The only way to unlock the comparator is a device hardware reset. 00103 00104 *** Callback registration *** 00105 ============================================= 00106 [..] 00107 00108 The compilation flag USE_HAL_COMP_REGISTER_CALLBACKS, when set to 1, 00109 allows the user to configure dynamically the driver callbacks. 00110 Use Functions HAL_COMP_RegisterCallback() 00111 to register an interrupt callback. 00112 [..] 00113 00114 Function HAL_COMP_RegisterCallback() allows to register following callbacks: 00115 (+) TriggerCallback : callback for COMP trigger. 00116 (+) MspInitCallback : callback for Msp Init. 00117 (+) MspDeInitCallback : callback for Msp DeInit. 00118 This function takes as parameters the HAL peripheral handle, the Callback ID 00119 and a pointer to the user callback function. 00120 [..] 00121 00122 Use function HAL_COMP_UnRegisterCallback to reset a callback to the default 00123 weak function. 00124 [..] 00125 00126 HAL_COMP_UnRegisterCallback takes as parameters the HAL peripheral handle, 00127 and the Callback ID. 00128 This function allows to reset following callbacks: 00129 (+) TriggerCallback : callback for COMP trigger. 00130 (+) MspInitCallback : callback for Msp Init. 00131 (+) MspDeInitCallback : callback for Msp DeInit. 00132 [..] 00133 00134 By default, after the HAL_COMP_Init() and when the state is HAL_COMP_STATE_RESET 00135 all callbacks are set to the corresponding weak functions: 00136 example HAL_COMP_TriggerCallback(). 00137 Exception done for MspInit and MspDeInit functions that are 00138 reset to the legacy weak functions in the HAL_COMP_Init()/ HAL_COMP_DeInit() only when 00139 these callbacks are null (not registered beforehand). 00140 [..] 00141 00142 If MspInit or MspDeInit are not null, the HAL_COMP_Init()/ HAL_COMP_DeInit() 00143 keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. 00144 [..] 00145 00146 Callbacks can be registered/unregistered in HAL_COMP_STATE_READY state only. 00147 Exception done MspInit/MspDeInit functions that can be registered/unregistered 00148 in HAL_COMP_STATE_READY or HAL_COMP_STATE_RESET state, 00149 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. 00150 [..] 00151 00152 Then, the user first registers the MspInit/MspDeInit user callbacks 00153 using HAL_COMP_RegisterCallback() before calling HAL_COMP_DeInit() 00154 or HAL_COMP_Init() function. 00155 [..] 00156 00157 When the compilation flag USE_HAL_COMP_REGISTER_CALLBACKS is set to 0 or 00158 not defined, the callback registration feature is not available and all callbacks 00159 are set to the corresponding weak functions. 00160 00161 @endverbatim 00162 ****************************************************************************** 00163 00164 Table 1. COMP inputs and output for STM32H7xx devices 00165 +---------------------------------------------------------+ 00166 | | | COMP1 | COMP2 | 00167 |----------------|----------------|-----------|-----------| 00168 | | IO1 | PB0 | PE9 | 00169 | Input plus | IO2 | PB2 | PE11 | 00170 | | | | | 00171 |----------------|----------------|-----------------------| 00172 | | 1/4 VrefInt | Available | Available | 00173 | | 1/2 VrefInt | Available | Available | 00174 | | 3/4 VrefInt | Available | Available | 00175 | Input minus | VrefInt | Available | Available | 00176 | | DAC1 channel 1 | Available | Available | 00177 | | DAC1 channel 2 | Available | Available | 00178 | | IO1 | PB1 | PE10 | 00179 | | IO2 | PC4 | PE7 | 00180 | | | | | 00181 | | | | | 00182 | | | | | 00183 +---------------------------------------------------------+ 00184 | Output | | PC5 (1) | PE8 (1) | 00185 | | | PE12 (1) | PE13 (1) | 00186 | | | TIM (2) | TIM (2) | 00187 +---------------------------------------------------------+ 00188 (1) GPIO must be set to alternate function for comparator 00189 (2) Comparators output to timers is set in timers instances. 00190 00191 ****************************************************************************** 00192 */ 00193 00194 /* Includes ------------------------------------------------------------------*/ 00195 #include "stm32h7xx_hal.h" 00196 00197 /** @addtogroup STM32H7xx_HAL_Driver 00198 * @{ 00199 */ 00200 00201 /** @defgroup COMP COMP 00202 * @brief COMP HAL module driver 00203 * @{ 00204 */ 00205 00206 #ifdef HAL_COMP_MODULE_ENABLED 00207 00208 /* Private typedef -----------------------------------------------------------*/ 00209 /* Private define ------------------------------------------------------------*/ 00210 /** @addtogroup COMP_Private_Constants 00211 * @{ 00212 */ 00213 00214 /* Delay for COMP startup time. */ 00215 /* Note: Delay required to reach propagation delay specification. */ 00216 /* Literal set to maximum value (refer to device datasheet, */ 00217 /* parameter "tSTART"). */ 00218 /* Unit: us */ 00219 #define COMP_DELAY_STARTUP_US (80UL) /*!< Delay for COMP startup time */ 00220 00221 /* Delay for COMP voltage scaler stabilization time. */ 00222 /* Literal set to maximum value (refer to device datasheet, */ 00223 /* parameter "tSTART_SCALER"). */ 00224 /* Unit: us */ 00225 #define COMP_DELAY_VOLTAGE_SCALER_STAB_US (200UL) /*!< Delay for COMP voltage scaler stabilization time */ 00226 00227 00228 /** 00229 * @} 00230 */ 00231 00232 /* Private macro -------------------------------------------------------------*/ 00233 /* Private variables ---------------------------------------------------------*/ 00234 /* Private function prototypes -----------------------------------------------*/ 00235 /* Exported functions --------------------------------------------------------*/ 00236 00237 /** @defgroup COMP_Exported_Functions COMP Exported Functions 00238 * @{ 00239 */ 00240 00241 /** @defgroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions 00242 * @brief Initialization and de-initialization functions. 00243 * 00244 @verbatim 00245 =============================================================================== 00246 ##### Initialization and de-initialization functions ##### 00247 =============================================================================== 00248 [..] This section provides functions to initialize and de-initialize comparators 00249 00250 @endverbatim 00251 * @{ 00252 */ 00253 00254 /** 00255 * @brief Initialize the COMP according to the specified 00256 * parameters in the COMP_InitTypeDef and initialize the associated handle. 00257 * @note If the selected comparator is locked, initialization can't be performed. 00258 * To unlock the configuration, perform a system reset. 00259 * @param hcomp COMP handle 00260 * @retval HAL status 00261 */ 00262 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp) 00263 { 00264 uint32_t tmp_csr ; 00265 uint32_t exti_line ; 00266 uint32_t comp_voltage_scaler_initialized; /* Value "0" is comparator voltage scaler is not initialized */ 00267 __IO uint32_t wait_loop_index = 0UL; 00268 00269 HAL_StatusTypeDef status = HAL_OK; 00270 00271 /* Check the COMP handle allocation and lock status */ 00272 if(hcomp == NULL) 00273 { 00274 status = HAL_ERROR; 00275 } 00276 else if(__HAL_COMP_IS_LOCKED(hcomp)) 00277 { 00278 status = HAL_ERROR; 00279 } 00280 else 00281 { 00282 /* Check the parameters */ 00283 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 00284 assert_param(IS_COMP_INPUT_PLUS(hcomp->Instance, hcomp->Init.NonInvertingInput)); 00285 assert_param(IS_COMP_INPUT_MINUS(hcomp->Instance, hcomp->Init.InvertingInput)); 00286 assert_param(IS_COMP_OUTPUTPOL(hcomp->Init.OutputPol)); 00287 assert_param(IS_COMP_POWERMODE(hcomp->Init.Mode)); 00288 assert_param(IS_COMP_HYSTERESIS(hcomp->Init.Hysteresis)); 00289 assert_param(IS_COMP_BLANKINGSRCE(hcomp->Init.BlankingSrce)); 00290 assert_param(IS_COMP_TRIGGERMODE(hcomp->Init.TriggerMode)); 00291 assert_param(IS_COMP_WINDOWMODE(hcomp->Init.WindowMode)); 00292 00293 if(hcomp->State == HAL_COMP_STATE_RESET) 00294 { 00295 /* Allocate lock resource and initialize it */ 00296 hcomp->Lock = HAL_UNLOCKED; 00297 00298 /* Set COMP error code to none */ 00299 COMP_CLEAR_ERRORCODE(hcomp); 00300 00301 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00302 /* Init the COMP Callback settings */ 00303 hcomp->TriggerCallback = HAL_COMP_TriggerCallback; /* Legacy weak callback */ 00304 00305 if (hcomp->MspInitCallback == NULL) 00306 { 00307 hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ 00308 } 00309 00310 /* Init the low level hardware */ 00311 hcomp->MspInitCallback(hcomp); 00312 #else 00313 /* Init the low level hardware */ 00314 HAL_COMP_MspInit(hcomp); 00315 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00316 } 00317 /* Memorize voltage scaler state before initialization */ 00318 comp_voltage_scaler_initialized = READ_BIT(hcomp->Instance->CFGR, COMP_CFGRx_SCALEN); 00319 00320 /* Set COMP parameters */ 00321 /* Set INMSEL bits according to hcomp->Init.InvertingInput value */ 00322 /* Set INPSEL bits according to hcomp->Init.NonInvertingInput value */ 00323 /* Set BLANKING bits according to hcomp->Init.BlankingSrce value */ 00324 /* Set HYST bits according to hcomp->Init.Hysteresis value */ 00325 /* Set POLARITY bit according to hcomp->Init.OutputPol value */ 00326 /* Set POWERMODE bits according to hcomp->Init.Mode value */ 00327 00328 tmp_csr = (hcomp->Init.InvertingInput | \ 00329 hcomp->Init.NonInvertingInput | \ 00330 hcomp->Init.BlankingSrce | \ 00331 hcomp->Init.Hysteresis | \ 00332 hcomp->Init.OutputPol | \ 00333 hcomp->Init.Mode ); 00334 00335 /* Set parameters in COMP register */ 00336 /* Note: Update all bits except read-only, lock and enable bits */ 00337 #if defined (COMP_CFGRx_INP2SEL) 00338 MODIFY_REG(hcomp->Instance->CFGR, 00339 COMP_CFGRx_PWRMODE | COMP_CFGRx_INMSEL | COMP_CFGRx_INPSEL | 00340 COMP_CFGRx_INP2SEL | COMP_CFGRx_WINMODE | COMP_CFGRx_POLARITY | COMP_CFGRx_HYST | 00341 COMP_CFGRx_BLANKING | COMP_CFGRx_BRGEN | COMP_CFGRx_SCALEN, 00342 tmp_csr 00343 ); 00344 #else 00345 MODIFY_REG(hcomp->Instance->CFGR, 00346 COMP_CFGRx_PWRMODE | COMP_CFGRx_INMSEL | COMP_CFGRx_INPSEL | 00347 COMP_CFGRx_WINMODE | COMP_CFGRx_POLARITY | COMP_CFGRx_HYST | 00348 COMP_CFGRx_BLANKING | COMP_CFGRx_BRGEN | COMP_CFGRx_SCALEN, 00349 tmp_csr 00350 ); 00351 #endif 00352 /* Set window mode */ 00353 /* Note: Window mode bit is located into 1 out of the 2 pairs of COMP */ 00354 /* instances. Therefore, this function can update another COMP */ 00355 /* instance that the one currently selected. */ 00356 if(hcomp->Init.WindowMode == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) 00357 { 00358 SET_BIT(hcomp->Instance->CFGR, COMP_CFGRx_WINMODE); 00359 } 00360 else 00361 { 00362 CLEAR_BIT(hcomp->Instance->CFGR, COMP_CFGRx_WINMODE); 00363 } 00364 /* Delay for COMP scaler bridge voltage stabilization */ 00365 /* Apply the delay if voltage scaler bridge is enabled for the first time */ 00366 if ((READ_BIT(hcomp->Instance->CFGR, COMP_CFGRx_SCALEN) != 0UL) && 00367 (comp_voltage_scaler_initialized != 0UL) ) 00368 { 00369 /* Wait loop initialization and execution */ 00370 /* Note: Variable divided by 2 to compensate partially */ 00371 /* CPU processing cycles.*/ 00372 00373 wait_loop_index = ((COMP_DELAY_VOLTAGE_SCALER_STAB_US / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL)); 00374 00375 while(wait_loop_index != 0UL) 00376 { 00377 wait_loop_index --; 00378 } 00379 } 00380 00381 /* Get the EXTI line corresponding to the selected COMP instance */ 00382 exti_line = COMP_GET_EXTI_LINE(hcomp->Instance); 00383 00384 /* Manage EXTI settings */ 00385 if((hcomp->Init.TriggerMode & (COMP_EXTI_IT | COMP_EXTI_EVENT)) != 0UL) 00386 { 00387 /* Configure EXTI rising edge */ 00388 if((hcomp->Init.TriggerMode & COMP_EXTI_RISING) != 0UL) 00389 { 00390 SET_BIT(EXTI->RTSR1, exti_line); 00391 } 00392 else 00393 { 00394 CLEAR_BIT(EXTI->RTSR1, exti_line); 00395 } 00396 00397 /* Configure EXTI falling edge */ 00398 if((hcomp->Init.TriggerMode & COMP_EXTI_FALLING) != 0UL) 00399 { 00400 SET_BIT(EXTI->FTSR1, exti_line); 00401 } 00402 else 00403 { 00404 CLEAR_BIT(EXTI->FTSR1, exti_line); 00405 } 00406 00407 #if !defined (CORE_CM4) 00408 /* Clear COMP EXTI pending bit (if any) */ 00409 WRITE_REG(EXTI->PR1, exti_line); 00410 00411 /* Configure EXTI event mode */ 00412 if((hcomp->Init.TriggerMode & COMP_EXTI_EVENT) != 0UL) 00413 { 00414 SET_BIT(EXTI->EMR1, exti_line); 00415 } 00416 else 00417 { 00418 CLEAR_BIT(EXTI->EMR1, exti_line); 00419 } 00420 00421 /* Configure EXTI interrupt mode */ 00422 if((hcomp->Init.TriggerMode & COMP_EXTI_IT) != 0UL) 00423 { 00424 SET_BIT(EXTI->IMR1, exti_line); 00425 } 00426 else 00427 { 00428 CLEAR_BIT(EXTI->IMR1, exti_line); 00429 } 00430 } 00431 else 00432 { 00433 /* Disable EXTI event mode */ 00434 CLEAR_BIT(EXTI->EMR1, exti_line); 00435 00436 /* Disable EXTI interrupt mode */ 00437 CLEAR_BIT(EXTI->IMR1, exti_line); 00438 } 00439 #else 00440 /* Clear COMP EXTI pending bit (if any) */ 00441 WRITE_REG(EXTI->C2PR1, exti_line); 00442 00443 /* Configure EXTI event mode */ 00444 if((hcomp->Init.TriggerMode & COMP_EXTI_EVENT) != 0UL) 00445 { 00446 SET_BIT(EXTI->C2EMR1, exti_line); 00447 } 00448 else 00449 { 00450 CLEAR_BIT(EXTI->C2EMR1, exti_line); 00451 } 00452 00453 /* Configure EXTI interrupt mode */ 00454 if((hcomp->Init.TriggerMode & COMP_EXTI_IT) != 0UL) 00455 { 00456 SET_BIT(EXTI->C2IMR1, exti_line); 00457 } 00458 else 00459 { 00460 CLEAR_BIT(EXTI->C2IMR1, exti_line); 00461 } 00462 } 00463 else 00464 { 00465 /* Disable EXTI event mode */ 00466 CLEAR_BIT(EXTI->C2EMR1, exti_line); 00467 00468 /* Disable EXTI interrupt mode */ 00469 CLEAR_BIT(EXTI->C2IMR1, exti_line); 00470 } 00471 #endif 00472 /* Set HAL COMP handle state */ 00473 /* Note: Transition from state reset to state ready, */ 00474 /* otherwise (coming from state ready or busy) no state update. */ 00475 if (hcomp->State == HAL_COMP_STATE_RESET) 00476 { 00477 00478 hcomp->State = HAL_COMP_STATE_READY; 00479 } 00480 00481 } 00482 00483 return status; 00484 } 00485 00486 /** 00487 * @brief DeInitialize the COMP peripheral. 00488 * @note Deinitialization cannot be performed if the COMP configuration is locked. 00489 * To unlock the configuration, perform a system reset. 00490 * @param hcomp COMP handle 00491 * @retval HAL status 00492 */ 00493 HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp) 00494 { 00495 HAL_StatusTypeDef status = HAL_OK; 00496 00497 /* Check the COMP handle allocation and lock status */ 00498 if(hcomp == NULL) 00499 { 00500 status = HAL_ERROR; 00501 } 00502 else if(__HAL_COMP_IS_LOCKED(hcomp)) 00503 { 00504 status = HAL_ERROR; 00505 } 00506 else 00507 { 00508 /* Check the parameter */ 00509 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 00510 00511 /* Set COMP_CFGR register to reset value */ 00512 WRITE_REG(hcomp->Instance->CFGR, 0x00000000UL); 00513 00514 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00515 if (hcomp->MspDeInitCallback == NULL) 00516 { 00517 hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ 00518 } 00519 00520 /* DeInit the low level hardware */ 00521 hcomp->MspDeInitCallback(hcomp); 00522 #else 00523 /* DeInit the low level hardware */ 00524 HAL_COMP_MspDeInit(hcomp); 00525 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00526 00527 /* Set HAL COMP handle state */ 00528 hcomp->State = HAL_COMP_STATE_RESET; 00529 00530 /* Release Lock */ 00531 __HAL_UNLOCK(hcomp); 00532 } 00533 00534 return status; 00535 } 00536 00537 /** 00538 * @brief Initialize the COMP MSP. 00539 * @param hcomp COMP handle 00540 * @retval None 00541 */ 00542 __weak void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp) 00543 { 00544 /* Prevent unused argument(s) compilation warning */ 00545 UNUSED(hcomp); 00546 /* NOTE : This function should not be modified, when the callback is needed, 00547 the HAL_COMP_MspInit could be implemented in the user file 00548 */ 00549 } 00550 00551 /** 00552 * @brief DeInitialize the COMP MSP. 00553 * @param hcomp COMP handle 00554 * @retval None 00555 */ 00556 __weak void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp) 00557 { 00558 /* Prevent unused argument(s) compilation warning */ 00559 UNUSED(hcomp); 00560 /* NOTE : This function should not be modified, when the callback is needed, 00561 the HAL_COMP_MspDeInit could be implemented in the user file 00562 */ 00563 } 00564 00565 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00566 /** 00567 * @brief Register a User COMP Callback 00568 * To be used instead of the weak predefined callback 00569 * @param hcomp Pointer to a COMP_HandleTypeDef structure that contains 00570 * the configuration information for the specified COMP. 00571 * @param CallbackID ID of the callback to be registered 00572 * This parameter can be one of the following values: 00573 * @arg @ref HAL_COMP_TRIGGER_CB_ID Trigger callback ID 00574 * @arg @ref HAL_COMP_MSPINIT_CB_ID MspInit callback ID 00575 * @arg @ref HAL_COMP_MSPDEINIT_CB_ID MspDeInit callback ID 00576 * @param pCallback pointer to the Callback function 00577 * @retval HAL status 00578 */ 00579 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, pCOMP_CallbackTypeDef pCallback) 00580 { 00581 HAL_StatusTypeDef status = HAL_OK; 00582 00583 if (pCallback == NULL) 00584 { 00585 /* Update the error code */ 00586 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00587 00588 return HAL_ERROR; 00589 } 00590 00591 if (HAL_COMP_STATE_READY == hcomp->State) 00592 { 00593 switch (CallbackID) 00594 { 00595 case HAL_COMP_TRIGGER_CB_ID : 00596 hcomp->TriggerCallback = pCallback; 00597 break; 00598 00599 case HAL_COMP_MSPINIT_CB_ID : 00600 hcomp->MspInitCallback = pCallback; 00601 break; 00602 00603 case HAL_COMP_MSPDEINIT_CB_ID : 00604 hcomp->MspDeInitCallback = pCallback; 00605 break; 00606 00607 default : 00608 /* Update the error code */ 00609 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00610 00611 /* Return error status */ 00612 status = HAL_ERROR; 00613 break; 00614 } 00615 } 00616 else if (HAL_COMP_STATE_RESET == hcomp->State) 00617 { 00618 switch (CallbackID) 00619 { 00620 case HAL_COMP_MSPINIT_CB_ID : 00621 hcomp->MspInitCallback = pCallback; 00622 break; 00623 00624 case HAL_COMP_MSPDEINIT_CB_ID : 00625 hcomp->MspDeInitCallback = pCallback; 00626 break; 00627 00628 default : 00629 /* Update the error code */ 00630 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00631 00632 /* Return error status */ 00633 status = HAL_ERROR; 00634 break; 00635 } 00636 } 00637 else 00638 { 00639 /* Update the error code */ 00640 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00641 00642 /* Return error status */ 00643 status = HAL_ERROR; 00644 } 00645 00646 return status; 00647 } 00648 00649 /** 00650 * @brief Unregister a COMP Callback 00651 * COMP callback is redirected to the weak predefined callback 00652 * @param hcomp Pointer to a COMP_HandleTypeDef structure that contains 00653 * the configuration information for the specified COMP. 00654 * @param CallbackID ID of the callback to be unregistered 00655 * This parameter can be one of the following values: 00656 * @arg @ref HAL_COMP_TRIGGER_CB_ID Trigger callback ID 00657 * @arg @ref HAL_COMP_MSPINIT_CB_ID MspInit callback ID 00658 * @arg @ref HAL_COMP_MSPDEINIT_CB_ID MspDeInit callback ID 00659 * @retval HAL status 00660 */ 00661 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID) 00662 { 00663 HAL_StatusTypeDef status = HAL_OK; 00664 00665 if (HAL_COMP_STATE_READY == hcomp->State) 00666 { 00667 switch (CallbackID) 00668 { 00669 case HAL_COMP_TRIGGER_CB_ID : 00670 hcomp->TriggerCallback = HAL_COMP_TriggerCallback; /* Legacy weak callback */ 00671 break; 00672 00673 case HAL_COMP_MSPINIT_CB_ID : 00674 hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ 00675 break; 00676 00677 case HAL_COMP_MSPDEINIT_CB_ID : 00678 hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ 00679 break; 00680 00681 default : 00682 /* Update the error code */ 00683 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00684 00685 /* Return error status */ 00686 status = HAL_ERROR; 00687 break; 00688 } 00689 } 00690 else if (HAL_COMP_STATE_RESET == hcomp->State) 00691 { 00692 switch (CallbackID) 00693 { 00694 case HAL_COMP_MSPINIT_CB_ID : 00695 hcomp->MspInitCallback = HAL_COMP_MspInit; /* Legacy weak MspInit */ 00696 break; 00697 00698 case HAL_COMP_MSPDEINIT_CB_ID : 00699 hcomp->MspDeInitCallback = HAL_COMP_MspDeInit; /* Legacy weak MspDeInit */ 00700 break; 00701 00702 default : 00703 /* Update the error code */ 00704 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00705 00706 /* Return error status */ 00707 status = HAL_ERROR; 00708 break; 00709 } 00710 } 00711 else 00712 { 00713 /* Update the error code */ 00714 hcomp->ErrorCode |= HAL_COMP_ERROR_INVALID_CALLBACK; 00715 00716 /* Return error status */ 00717 status = HAL_ERROR; 00718 } 00719 00720 return status; 00721 } 00722 00723 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00724 /** 00725 * @} 00726 */ 00727 00728 /** @defgroup COMP_Exported_Functions_Group2 Start-Stop operation functions 00729 * @brief Start-Stop operation functions. 00730 * 00731 @verbatim 00732 =============================================================================== 00733 ##### IO operation functions ##### 00734 =============================================================================== 00735 [..] This section provides functions allowing to: 00736 (+) Start a Comparator instance without interrupt. 00737 (+) Stop a Comparator instance without interrupt. 00738 (+) Start a Comparator instance with interrupt generation. 00739 (+) Stop a Comparator instance with interrupt generation. 00740 00741 @endverbatim 00742 * @{ 00743 */ 00744 00745 /** 00746 * @brief Start the comparator. 00747 * @param hcomp COMP handle 00748 * @retval HAL status 00749 */ 00750 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp) 00751 { 00752 __IO uint32_t wait_loop_index = 0UL; 00753 00754 HAL_StatusTypeDef status = HAL_OK; 00755 00756 /* Check the COMP handle allocation and lock status */ 00757 if(hcomp == NULL) 00758 { 00759 status = HAL_ERROR; 00760 } 00761 else if(__HAL_COMP_IS_LOCKED(hcomp)) 00762 { 00763 status = HAL_ERROR; 00764 } 00765 else 00766 { 00767 /* Check the parameter */ 00768 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 00769 00770 if(hcomp->State == HAL_COMP_STATE_READY) 00771 { 00772 /* Enable the selected comparator */ 00773 SET_BIT(hcomp->Instance->CFGR, COMP_CFGRx_EN); 00774 00775 /* Set HAL COMP handle state */ 00776 hcomp->State = HAL_COMP_STATE_BUSY; 00777 00778 /* Delay for COMP startup time */ 00779 /* Wait loop initialization and execution */ 00780 /* Note: Variable divided by 2 to compensate partially */ 00781 /* CPU processing cycles. */ 00782 00783 wait_loop_index = ((COMP_DELAY_STARTUP_US / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL)); 00784 while(wait_loop_index != 0UL) 00785 { 00786 wait_loop_index--; 00787 } 00788 } 00789 else 00790 { 00791 status = HAL_ERROR; 00792 } 00793 } 00794 00795 return status; 00796 } 00797 00798 /** 00799 * @brief Stop the comparator. 00800 * @param hcomp COMP handle 00801 * @retval HAL status 00802 */ 00803 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp) 00804 { 00805 HAL_StatusTypeDef status = HAL_OK; 00806 00807 /* Check the COMP handle allocation and lock status */ 00808 if(hcomp == NULL) 00809 { 00810 status = HAL_ERROR; 00811 } 00812 else if(__HAL_COMP_IS_LOCKED(hcomp)) 00813 { 00814 status = HAL_ERROR; 00815 } 00816 else 00817 { 00818 /* Check the parameter */ 00819 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 00820 00821 /* Check compliant states: HAL_COMP_STATE_READY or HAL_COMP_STATE_BUSY */ 00822 /* (all states except HAL_COMP_STATE_RESET and except locked status. */ 00823 if(hcomp->State != HAL_COMP_STATE_RESET) 00824 { 00825 00826 /* Disable the selected comparator */ 00827 CLEAR_BIT(hcomp->Instance->CFGR, COMP_CFGRx_EN); 00828 00829 /* Set HAL COMP handle state */ 00830 hcomp->State = HAL_COMP_STATE_READY; 00831 } 00832 else 00833 { 00834 status = HAL_ERROR; 00835 } 00836 } 00837 00838 return status; 00839 } 00840 00841 /** 00842 * @brief Enable the interrupt and start the comparator. 00843 * @param hcomp COMP handle 00844 * @retval HAL status 00845 */ 00846 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp) 00847 { 00848 00849 __IO uint32_t wait_loop_index = 0UL; 00850 HAL_StatusTypeDef status = HAL_OK; 00851 00852 /* Check the COMP handle allocation and lock status */ 00853 if(hcomp == NULL) 00854 { 00855 status = HAL_ERROR; 00856 } 00857 else if(__HAL_COMP_IS_LOCKED(hcomp)) 00858 { 00859 status = HAL_ERROR; 00860 } 00861 else 00862 { 00863 /* Check the parameter */ 00864 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 00865 /* Set HAL COMP handle state */ 00866 if(hcomp->State == HAL_COMP_STATE_READY) 00867 { 00868 00869 /* Enable the selected comparator */ 00870 SET_BIT(hcomp->Instance->CFGR, COMP_CFGRx_EN); 00871 /* Enable the Interrupt comparator */ 00872 SET_BIT(hcomp->Instance->CFGR, COMP_CFGRx_ITEN); 00873 00874 hcomp->State = HAL_COMP_STATE_BUSY; 00875 /* Delay for COMP startup time */ 00876 /* Wait loop initialization and execution */ 00877 /* Note: Variable divided by 2 to compensate partially */ 00878 /* CPU processing cycles. */ 00879 00880 wait_loop_index = ((COMP_DELAY_STARTUP_US / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL)); 00881 while(wait_loop_index != 0UL) 00882 { 00883 wait_loop_index--; 00884 } 00885 00886 } 00887 else 00888 { 00889 status = HAL_ERROR; 00890 } 00891 } 00892 00893 return status; 00894 } 00895 00896 /** 00897 * @brief Disable the interrupt and Stop the comparator. 00898 * @param hcomp COMP handle 00899 * @retval HAL status 00900 */ 00901 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp) 00902 { 00903 HAL_StatusTypeDef status; 00904 /* Disable the EXTI Line interrupt mode */ 00905 #if !defined (CORE_CM4) 00906 CLEAR_BIT(EXTI->IMR1, COMP_GET_EXTI_LINE(hcomp->Instance)); 00907 #else 00908 CLEAR_BIT(EXTI->C2IMR1, COMP_GET_EXTI_LINE(hcomp->Instance)); 00909 #endif 00910 /* Disable the Interrupt comparator */ 00911 CLEAR_BIT(hcomp->Instance->CFGR, COMP_CFGRx_ITEN); 00912 00913 status = HAL_COMP_Stop(hcomp); 00914 00915 return status; 00916 00917 } 00918 00919 /** 00920 * @brief Comparator IRQ Handler. 00921 * @param hcomp COMP handle 00922 * @retval HAL status 00923 */ 00924 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp) 00925 { 00926 /* Get the EXTI line corresponding to the selected COMP instance */ 00927 uint32_t exti_line = COMP_GET_EXTI_LINE(hcomp->Instance); 00928 00929 00930 #if defined(DUAL_CORE) 00931 /* EXTI line interrupt detected */ 00932 if (HAL_GetCurrentCPUID() == CM7_CPUID) 00933 { 00934 /* Check COMP EXTI flag */ 00935 if(READ_BIT(EXTI->PR1, exti_line) != 0UL) 00936 { 00937 /* Check whether comparator is in independent or window mode */ 00938 if(READ_BIT(COMP12_COMMON->CFGR, COMP_CFGRx_WINMODE) != 0UL) 00939 { 00940 /* Clear COMP EXTI line pending bit of the pair of comparators */ 00941 /* in window mode. */ 00942 /* Note: Pair of comparators in window mode can both trig IRQ when */ 00943 /* input voltage is changing from "out of window" area */ 00944 /* (low or high ) to the other "out of window" area (high or low).*/ 00945 /* Both flags must be cleared to call comparator trigger */ 00946 /* callback is called once. */ 00947 WRITE_REG(EXTI->PR1, (COMP_EXTI_LINE_COMP1 | COMP_EXTI_LINE_COMP2)); 00948 } 00949 else 00950 { 00951 /* Clear COMP EXTI line pending bit */ 00952 WRITE_REG(EXTI->PR1, exti_line); 00953 } 00954 00955 /* COMP trigger user callback */ 00956 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00957 hcomp->TriggerCallback(hcomp); 00958 #else 00959 HAL_COMP_TriggerCallback(hcomp); 00960 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00961 } 00962 00963 00964 } 00965 else 00966 { 00967 /* Check COMP EXTI flag */ 00968 if(READ_BIT(EXTI->C2PR1, exti_line) != 0UL) 00969 { 00970 /* Check whether comparator is in independent or window mode */ 00971 if(READ_BIT(COMP12_COMMON->CFGR, COMP_CFGRx_WINMODE) != 0UL) 00972 { 00973 /* Clear COMP EXTI line pending bit of the pair of comparators */ 00974 /* in window mode. */ 00975 /* Note: Pair of comparators in window mode can both trig IRQ when */ 00976 /* input voltage is changing from "out of window" area */ 00977 /* (low or high ) to the other "out of window" area (high or low).*/ 00978 /* Both flags must be cleared to call comparator trigger */ 00979 /* callback is called once. */ 00980 WRITE_REG(EXTI->C2PR1, (COMP_EXTI_LINE_COMP1 | COMP_EXTI_LINE_COMP2)); 00981 } 00982 else 00983 { 00984 /* Clear COMP EXTI line pending bit */ 00985 WRITE_REG(EXTI->C2PR1, exti_line); 00986 } 00987 00988 /* COMP trigger user callback */ 00989 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00990 hcomp->TriggerCallback(hcomp); 00991 #else 00992 HAL_COMP_TriggerCallback(hcomp); 00993 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00994 } 00995 00996 00997 } 00998 #else 00999 /* Check COMP EXTI flag */ 01000 if(READ_BIT(EXTI->PR1, exti_line) != 0UL) 01001 { 01002 /* Check whether comparator is in independent or window mode */ 01003 if(READ_BIT(COMP12_COMMON->CFGR, COMP_CFGRx_WINMODE) != 0UL) 01004 { 01005 /* Clear COMP EXTI line pending bit of the pair of comparators */ 01006 /* in window mode. */ 01007 /* Note: Pair of comparators in window mode can both trig IRQ when */ 01008 /* input voltage is changing from "out of window" area */ 01009 /* (low or high ) to the other "out of window" area (high or low).*/ 01010 /* Both flags must be cleared to call comparator trigger */ 01011 /* callback is called once. */ 01012 WRITE_REG(EXTI->PR1, (COMP_EXTI_LINE_COMP1 | COMP_EXTI_LINE_COMP2)); 01013 } 01014 else 01015 { 01016 /* Clear COMP EXTI line pending bit */ 01017 WRITE_REG(EXTI->PR1, exti_line); 01018 } 01019 01020 /* COMP trigger user callback */ 01021 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 01022 hcomp->TriggerCallback(hcomp); 01023 #else 01024 HAL_COMP_TriggerCallback(hcomp); 01025 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 01026 } 01027 #endif /*DUAL_CORE*/ 01028 01029 /* Get COMP interrupt source */ 01030 if (__HAL_COMP_GET_IT_SOURCE(hcomp, COMP_IT_EN) != RESET) 01031 { 01032 01033 if((__HAL_COMP_GET_FLAG( COMP_FLAG_C1I)) != 0UL) 01034 { 01035 /* Clear the COMP channel 1 interrupt flag */ 01036 __HAL_COMP_CLEAR_C1IFLAG(); 01037 01038 /* Disable COMP interrupt */ 01039 __HAL_COMP_DISABLE_IT(hcomp,COMP_IT_EN); 01040 01041 } 01042 if((__HAL_COMP_GET_FLAG( COMP_FLAG_C2I)) != 0UL) 01043 { 01044 /* Clear the COMP channel 2 interrupt flag */ 01045 __HAL_COMP_CLEAR_C2IFLAG(); 01046 01047 /* Disable COMP interrupt */ 01048 __HAL_COMP_DISABLE_IT(hcomp,COMP_IT_EN); 01049 01050 } 01051 01052 /* Change COMP state */ 01053 hcomp->State = HAL_COMP_STATE_READY; 01054 01055 /* COMP trigger user callback */ 01056 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 01057 hcomp->TriggerCallback(hcomp); 01058 #else 01059 HAL_COMP_TriggerCallback(hcomp); 01060 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 01061 } 01062 01063 01064 } 01065 01066 /** 01067 * @} 01068 */ 01069 01070 /** @defgroup COMP_Exported_Functions_Group3 Peripheral Control functions 01071 * @brief Management functions. 01072 * 01073 @verbatim 01074 =============================================================================== 01075 ##### Peripheral Control functions ##### 01076 =============================================================================== 01077 [..] 01078 This subsection provides a set of functions allowing to control the comparators. 01079 01080 @endverbatim 01081 * @{ 01082 */ 01083 01084 /** 01085 * @brief Lock the selected comparator configuration. 01086 * @note A system reset is required to unlock the comparator configuration. 01087 * @param hcomp COMP handle 01088 * @retval HAL status 01089 */ 01090 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp) 01091 { 01092 HAL_StatusTypeDef status = HAL_OK; 01093 01094 /* Check the COMP handle allocation and lock status */ 01095 if(hcomp == NULL) 01096 { 01097 status = HAL_ERROR; 01098 } 01099 else if(__HAL_COMP_IS_LOCKED(hcomp)) 01100 { 01101 status = HAL_ERROR; 01102 } 01103 else 01104 { 01105 /* Check the parameter */ 01106 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 01107 01108 /* Set HAL COMP handle state */ 01109 switch(hcomp->State) 01110 { 01111 case HAL_COMP_STATE_RESET: 01112 hcomp->State = HAL_COMP_STATE_RESET_LOCKED; 01113 break; 01114 case HAL_COMP_STATE_READY: 01115 hcomp->State = HAL_COMP_STATE_READY_LOCKED; 01116 break; 01117 default: /* HAL_COMP_STATE_BUSY */ 01118 hcomp->State = HAL_COMP_STATE_BUSY_LOCKED; 01119 break; 01120 } 01121 } 01122 01123 if(status == HAL_OK) 01124 { 01125 /* Set the lock bit corresponding to selected comparator */ 01126 __HAL_COMP_LOCK(hcomp); 01127 } 01128 01129 return status; 01130 } 01131 01132 /** 01133 * @brief Return the output level (high or low) of the selected comparator. 01134 * @note The output level depends on the selected polarity. 01135 * If the polarity is not inverted: 01136 * - Comparator output is low when the input plus is at a lower 01137 * voltage than the input minus 01138 * - Comparator output is high when the input plus is at a higher 01139 * voltage than the input minus 01140 * If the polarity is inverted: 01141 * - Comparator output is high when the input plus is at a lower 01142 * voltage than the input minus 01143 * - Comparator output is low when the input plus is at a higher 01144 * voltage than the input minus 01145 * @param hcomp COMP handle 01146 * @retval Returns the selected comparator output level: 01147 * @arg @ref COMP_OUTPUT_LEVEL_LOW 01148 * @arg @ref COMP_OUTPUT_LEVEL_HIGH 01149 * 01150 */ 01151 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp) 01152 { 01153 /* Check the parameter */ 01154 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 01155 01156 if (hcomp->Instance == COMP1) 01157 { 01158 return (uint32_t)(READ_BIT(COMP12->SR, COMP_SR_C1VAL)); 01159 } 01160 else 01161 { 01162 return (uint32_t)((READ_BIT(COMP12->SR, COMP_SR_C2VAL))>> 1UL); 01163 } 01164 } 01165 01166 /** 01167 * @brief Comparator trigger callback. 01168 * @param hcomp COMP handle 01169 * @retval None 01170 */ 01171 __weak void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp) 01172 { 01173 /* Prevent unused argument(s) compilation warning */ 01174 UNUSED(hcomp); 01175 /* NOTE : This function should not be modified, when the callback is needed, 01176 the HAL_COMP_TriggerCallback should be implemented in the user file 01177 */ 01178 } 01179 01180 01181 /** 01182 * @} 01183 */ 01184 01185 /** @defgroup COMP_Exported_Functions_Group4 Peripheral State functions 01186 * @brief Peripheral State functions. 01187 * 01188 @verbatim 01189 =============================================================================== 01190 ##### Peripheral State functions ##### 01191 =============================================================================== 01192 [..] 01193 This subsection permit to get in run-time the status of the peripheral. 01194 01195 @endverbatim 01196 * @{ 01197 */ 01198 01199 /** 01200 * @brief Return the COMP handle state. 01201 * @param hcomp COMP handle 01202 * @retval HAL state 01203 */ 01204 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp) 01205 { 01206 /* Check the COMP handle allocation */ 01207 if(hcomp == NULL) 01208 { 01209 return HAL_COMP_STATE_RESET; 01210 } 01211 01212 /* Check the parameter */ 01213 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 01214 01215 /* Return HAL COMP handle state */ 01216 return hcomp->State; 01217 } 01218 01219 /** 01220 * @brief Return the COMP error code. 01221 * @param hcomp COMP handle 01222 * @retval COMP error code 01223 */ 01224 uint32_t HAL_COMP_GetError(COMP_HandleTypeDef *hcomp) 01225 { 01226 /* Check the parameters */ 01227 assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); 01228 01229 return hcomp->ErrorCode; 01230 } 01231 /** 01232 * @} 01233 */ 01234 01235 /** 01236 * @} 01237 */ 01238 01239 #endif /* HAL_COMP_MODULE_ENABLED */ 01240 /** 01241 * @} 01242 */ 01243 01244 /** 01245 * @} 01246 */ 01247