/** * @brief Configures FMPI2C Analog noise filter. * @param hfmpi2c : pointer to a FMPI2C_HandleTypeDef structure that contains * the configuration information for the specified FMPI2Cx peripheral. * @param AnalogFilter : new state of the Analog filter. * @retval HAL status */ HAL_StatusTypeDef HAL_FMPI2CEx_AnalogFilter_Config(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t AnalogFilter) { /* Check the parameters */ assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance)); assert_param(IS_FMPI2C_ANALOG_FILTER(AnalogFilter)); if((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY) || (hfmpi2c->State == HAL_FMPI2C_STATE_MASTER_BUSY_TX) || (hfmpi2c->State == HAL_FMPI2C_STATE_MASTER_BUSY_RX) || (hfmpi2c->State == HAL_FMPI2C_STATE_SLAVE_BUSY_TX) || (hfmpi2c->State == HAL_FMPI2C_STATE_SLAVE_BUSY_RX)) { return HAL_BUSY; } /* Process Locked */ __HAL_LOCK(hfmpi2c); hfmpi2c->State = HAL_FMPI2C_STATE_BUSY; /* Disable the selected FMPI2C peripheral */ __HAL_FMPI2C_DISABLE(hfmpi2c); /* Reset FMPI2Cx ANOFF bit */ hfmpi2c->Instance->CR1 &= ~(FMPI2C_CR1_ANFOFF); /* Set analog filter bit*/ hfmpi2c->Instance->CR1 |= AnalogFilter; __HAL_FMPI2C_ENABLE(hfmpi2c); hfmpi2c->State = HAL_FMPI2C_STATE_READY; /* Process Unlocked */ __HAL_UNLOCK(hfmpi2c); return HAL_OK; }
/** * @brief Disables FMPI2C wakeup from stop mode. * @param hfmpi2c : pointer to a FMPI2C_HandleTypeDef structure that contains * the configuration information for the specified FMPI2Cx peripheral. * @retval HAL status */ HAL_StatusTypeDef HAL_FMPI2CEx_DisableWakeUp (FMPI2C_HandleTypeDef *hfmpi2c) { /* Check the parameters */ assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance)); if((hfmpi2c->State == HAL_FMPI2C_STATE_BUSY) || (hfmpi2c->State == HAL_FMPI2C_STATE_MASTER_BUSY_TX) || (hfmpi2c->State == HAL_FMPI2C_STATE_MASTER_BUSY_RX) || (hfmpi2c->State == HAL_FMPI2C_STATE_SLAVE_BUSY_TX) || (hfmpi2c->State == HAL_FMPI2C_STATE_SLAVE_BUSY_RX)) { return HAL_BUSY; } /* Process Locked */ __HAL_LOCK(hfmpi2c); hfmpi2c->State = HAL_FMPI2C_STATE_BUSY; /* Disable the selected FMPI2C peripheral */ __HAL_FMPI2C_DISABLE(hfmpi2c); /* Enable wakeup from stop mode */ hfmpi2c->Instance->CR1 &= ~(FMPI2C_CR1_WUPEN); __HAL_FMPI2C_ENABLE(hfmpi2c); hfmpi2c->State = HAL_FMPI2C_STATE_READY; /* Process Unlocked */ __HAL_UNLOCK(hfmpi2c); return HAL_OK; }
/** * @brief Configure FMPI2C Digital noise filter. * @param hfmpi2c Pointer to a FMPI2C_HandleTypeDef structure that contains * the configuration information for the specified FMPI2Cx peripheral. * @param DigitalFilter Coefficient of digital noise filter between 0x00 and 0x0F. * @retval HAL status */ HAL_StatusTypeDef HAL_FMPI2CEx_ConfigDigitalFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t DigitalFilter) { uint32_t tmpreg = 0U; /* Check the parameters */ assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance)); assert_param(IS_FMPI2C_DIGITAL_FILTER(DigitalFilter)); if(hfmpi2c->State == HAL_FMPI2C_STATE_READY) { /* Process Locked */ __HAL_LOCK(hfmpi2c); hfmpi2c->State = HAL_FMPI2C_STATE_BUSY; /* Disable the selected FMPI2C peripheral */ __HAL_FMPI2C_DISABLE(hfmpi2c); /* Get the old register value */ tmpreg = hfmpi2c->Instance->CR1; /* Reset FMPI2Cx DNF bits [11:8] */ tmpreg &= ~(FMPI2C_CR1_DFN); /* Set FMPI2Cx DNF coefficient */ tmpreg |= DigitalFilter << 8U; /* Store the new register value */ hfmpi2c->Instance->CR1 = tmpreg; __HAL_FMPI2C_ENABLE(hfmpi2c); hfmpi2c->State = HAL_FMPI2C_STATE_READY; /* Process Unlocked */ __HAL_UNLOCK(hfmpi2c); return HAL_OK; } else { return HAL_BUSY; } }