/** * @brief Configures TSC IOs * @param htsc: pointer to a TSC_HandleTypeDef structure that contains * the configuration information for the specified TSC. * @param config: pointer to the configuration structure. * @retval HAL status */ HAL_StatusTypeDef HAL_TSC_IOConfig(TSC_HandleTypeDef* htsc, TSC_IOConfigTypeDef* config) { /* Check the parameters */ assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); /* Process locked */ __HAL_LOCK(htsc); /* Stop acquisition */ __HAL_TSC_STOP_ACQ(htsc); /* Disable Schmitt trigger hysteresis on all used TSC IOs */ htsc->Instance->IOHCR = (uint32_t)(~(config->ChannelIOs | config->ShieldIOs | config->SamplingIOs)); /* Set channel and shield IOs */ htsc->Instance->IOCCR = (config->ChannelIOs | config->ShieldIOs); /* Set sampling IOs */ htsc->Instance->IOSCR = config->SamplingIOs; /* Set groups to be acquired */ htsc->Instance->IOGCSR = TSC_extract_groups(config->ChannelIOs); /* Process unlocked */ __HAL_UNLOCK(htsc); /* Return function status */ return HAL_OK; }
/** * @brief Stops the acquisition previously launched in polling mode * @param htsc: pointer to a TSC_HandleTypeDef structure that contains * the configuration information for the specified TSC. * @retval HAL status */ HAL_StatusTypeDef HAL_TSC_Stop(TSC_HandleTypeDef* htsc) { /* Check the parameters */ assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); /* Process locked */ __HAL_LOCK(htsc); /* Stop the acquisition */ __HAL_TSC_STOP_ACQ(htsc); /* Set touch sensing IOs in low power mode (output push-pull) */ __HAL_TSC_SET_IODEF_OUTPPLOW(htsc); /* Clear flags */ __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); /* Change TSC state */ htsc->State = HAL_TSC_STATE_READY; /* Process unlocked */ __HAL_UNLOCK(htsc); /* Return function status */ return HAL_OK; }
/** * @brief Stops the acquisition previously launched in interrupt mode * @param htsc: pointer to a TSC_HandleTypeDef structure that contains * the configuration information for the specified TSC. * @retval HAL status */ HAL_StatusTypeDef HAL_TSC_Stop_IT(TSC_HandleTypeDef* htsc) { /* Check the parameters */ assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); /* Process locked */ __HAL_LOCK(htsc); /* Stop the acquisition */ __HAL_TSC_STOP_ACQ(htsc); /* Disable interrupts */ __HAL_TSC_DISABLE_IT(htsc, (TSC_IT_EOA | TSC_IT_MCE)); /* Clear flags */ __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); /* Change TSC state */ htsc->State = HAL_TSC_STATE_READY; /* Process unlocked */ __HAL_UNLOCK(htsc); /* Return function status */ return HAL_OK; }