/** * @brief Stop 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); /* Set touch sensing IOs in low power mode (output push-pull) */ __HAL_TSC_SET_IODEF_OUTPPLOW(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; }
/** * @brief Start the acquisition 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_Start_IT(TSC_HandleTypeDef* htsc) { /* Check the parameters */ assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); assert_param(IS_TSC_MCE_IT(htsc->Init.MaxCountInterrupt)); /* Process locked */ __HAL_LOCK(htsc); /* Change TSC state */ htsc->State = HAL_TSC_STATE_BUSY; /* Enable end of acquisition interrupt */ __HAL_TSC_ENABLE_IT(htsc, TSC_IT_EOA); /* Enable max count error interrupt (optional) */ if (htsc->Init.MaxCountInterrupt == ENABLE) { __HAL_TSC_ENABLE_IT(htsc, TSC_IT_MCE); } else { __HAL_TSC_DISABLE_IT(htsc, TSC_IT_MCE); } /* Clear flags */ __HAL_TSC_CLEAR_FLAG(htsc, (TSC_FLAG_EOA | TSC_FLAG_MCE)); /* Set touch sensing IOs not acquired to the specified IODefaultMode */ if (htsc->Init.IODefaultMode == TSC_IODEF_OUT_PP_LOW) { __HAL_TSC_SET_IODEF_OUTPPLOW(htsc); } else { __HAL_TSC_SET_IODEF_INFLOAT(htsc); } /* Launch the acquisition */ __HAL_TSC_START_ACQ(htsc); /* Process unlocked */ __HAL_UNLOCK(htsc); /* Return function status */ return HAL_OK; }
/** * @brief Acquisition completed callback in non blocking mode * @param htsc: pointer to a TSC_HandleTypeDef structure that contains * the configuration information for the specified TSC. * @retval None */ void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef* htsc) { static __IO TSL_tTick_ms_T ECSLastTick; /* Hold the last time value for ECS */ /* Discharge all capacitors */ #if TSLPRM_IODEF > 0 __HAL_TSC_SET_IODEF_OUTPPLOW(&TscHandle); #endif TSL_acq_BankGetResult(idx_bank++, 0, 0); /* Read current bank result */ /* Check if we have acquired all the banks */ if (idx_bank > TSLPRM_TOTAL_BANKS - 1) { /* Process the objects state machine, DxS and ECS */ TSL_obj_GroupProcess(&MyObjGroup); TSL_dxs_FirstObj(&MyObjGroup); if (TSL_tim_CheckDelay_ms(100, &ECSLastTick) == TSL_STATUS_OK) { if(TSL_ecs_Process(&MyObjGroup) == TSL_STATUS_OK) { BSP_LED_Toggle(LED6); } else { BSP_LED_Off(LED6); } } /* Start again with the first bank */ idx_bank = 0; } /* Configure bank */ TSL_acq_BankConfig(idx_bank); /* Start bank acquisition in Interrupt mode */ TSL_acq_BankStartAcq_IT(); }
/** * @brief Discharge TSC IOs. * @param htsc: pointer to a TSC_HandleTypeDef structure that contains * the configuration information for the specified TSC. * @param choice: enable or disable * @retval HAL status */ HAL_StatusTypeDef HAL_TSC_IODischarge(TSC_HandleTypeDef* htsc, uint32_t choice) { /* Check the parameters */ assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance)); /* Process locked */ __HAL_LOCK(htsc); if (choice == ENABLE) { __HAL_TSC_SET_IODEF_OUTPPLOW(htsc); } else { __HAL_TSC_SET_IODEF_INFLOAT(htsc); } /* Process unlocked */ __HAL_UNLOCK(htsc); /* Return the group acquisition counter */ return HAL_OK; }