/** * @brief Lock the selected comparator configuration. * @note A system reset is required to unlock the comparator configuration. * @note Locking the comparator from reset state is possible * if __HAL_RCC_SYSCFG_CLK_ENABLE() is being called before. * @param hcomp COMP handle * @retval HAL status */ HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp) { HAL_StatusTypeDef status = HAL_OK; /* Check the COMP handle allocation and lock status */ if((hcomp == NULL) || (__HAL_COMP_IS_LOCKED(hcomp))) { status = HAL_ERROR; } else { /* Check the parameter */ assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); /* Set HAL COMP handle state */ hcomp->State = ((HAL_COMP_StateTypeDef)(hcomp->State | COMP_STATE_BITFIELD_LOCK)); } if(status == HAL_OK) { /* Set the lock bit corresponding to selected comparator */ __HAL_COMP_LOCK(hcomp); } return status; }
/** * @brief Lock the selected comparator configuration. * @note A system reset is required to unlock the comparator configuration. * @param hcomp COMP handle * @retval HAL status */ HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp) { HAL_StatusTypeDef status = HAL_OK; /* Check the COMP handle allocation and lock status */ if((hcomp == NULL) || ((hcomp->State & COMP_STATE_BIT_LOCK) != RESET)) { status = HAL_ERROR; } else { /* Check the parameter */ assert_param(IS_COMP_ALL_INSTANCE(hcomp->Instance)); /* Set lock flag on state */ switch(hcomp->State) { case HAL_COMP_STATE_BUSY: hcomp->State = HAL_COMP_STATE_BUSY_LOCKED; break; case HAL_COMP_STATE_READY: hcomp->State = HAL_COMP_STATE_READY_LOCKED; break; default: /* unexpected state */ status = HAL_ERROR; break; } } if(status == HAL_OK) { /* Set the lock bit corresponding to selected comparator */ __HAL_COMP_LOCK(hcomp); } return status; }