/*FUNCTION********************************************************************** * * Function Name : TSI_HAL_SetConfiguration * Description : Function inits the whole TSI peripheral by the handled configuration * *END**************************************************************************/ void TSI_HAL_SetConfiguration(TSI_Type * base, tsi_config_t *config) { assert(config != NULL); TSI_HAL_SetPrescaler(base, config->ps); TSI_HAL_SetNumberOfScans(base, config->nscn); TSI_HAL_SetLowPowerScanInterval(base, config->lpscnitv); TSI_HAL_SetLowPowerClock(base, config->lpclks); TSI_HAL_SetActiveModeSource(base, config->amclks); TSI_HAL_SetActiveModePrescaler(base, config->ampsc); #if (FSL_FEATURE_TSI_VERSION == 1) TSI_HAL_SetActiveModePrescaler(base, config->amclkdiv); TSI_HAL_SetDeltaVoltage(base, config->delvol); TSI_HAL_SetInternalCapacitanceTrim(base, config->captrm); #endif TSI_HAL_SetReferenceChargeCurrent(base, config->refchrg); TSI_HAL_SetElectrodeChargeCurrent(base, config->extchrg); #if (FSL_FEATURE_TSI_VERSION == 1) /* TODO HAL for VER 1 */ for (uint32_t i = 0U; i < 16U; i++) { tsi->threshold[i] = TSI_THRESHOLD_HTHH(config->thresh) | TSI_THRESHOLD_LTHH(config->thresl); } #elif (FSL_FEATURE_TSI_VERSION == 2) TSI_HAL_SetLowThreshold(base, config->thresl); TSI_HAL_SetHighThreshold(base, config->thresh); #endif }
/*FUNCTION********************************************************************** * * Function Name : TSI_HAL_SetConfiguration * Description : Function set the whole TSI peripheral by handled configuration * *END**************************************************************************/ void TSI_HAL_SetConfiguration(TSI_Type * base, tsi_config_t *config) { assert(config != NULL); uint32_t is_enabled = TSI_HAL_IsModuleEnabled(base); uint32_t is_int_enabled = TSI_HAL_IsInterruptEnabled(base); if (is_enabled) { TSI_HAL_DisableModule(base); } if (is_int_enabled) { TSI_HAL_DisableInterrupt(base); } if(config->mode == kTsiAnalogModeSel_AutoNoise) { TSI_HAL_SetMode(base, config->mode); TSI_HAL_SetPrescaler(base, config->ps); TSI_HAL_SetNumberOfScans(base, config->nscn); TSI_HAL_SetReferenceChargeCurrent(base, config->refchrg); TSI_HAL_SetOscilatorVoltageRails(base, config->dvolt); TSI_HAL_SetElectrodeSeriesResistor(base, config->serres); TSI_HAL_SetFilterBits(base, config->filter); } else { TSI_HAL_SetPrescaler(base, config->ps); TSI_HAL_SetNumberOfScans(base, config->nscn); TSI_HAL_SetReferenceChargeCurrent(base, config->refchrg); TSI_HAL_SetElectrodeChargeCurrent(base, config->extchrg); TSI_HAL_SetMode(base, config->mode); TSI_HAL_SetOscilatorVoltageRails(base, config->dvolt); TSI_HAL_SetLowThreshold(base, config->thresl); TSI_HAL_SetHighThreshold(base, config->thresh); } if (is_enabled) { TSI_HAL_EnableModule(base); } if (is_int_enabled) { TSI_HAL_EnableInterrupt(base); } }