/*FUNCTION********************************************************************** * * Function Name : TSI_HAL_MeasurementBlocking * Description : Function do blocking measurement of enabled electrodes * It used just for recalibration process *END**************************************************************************/ static int32_t TSI_HAL_MeasurementBlocking(TSI_Type * base) { int32_t result = -1; uint32_t timeout = 10000000; /* Big timeout */ if (TSI_RD_PEN(base)) { /* measure only if at least one electrode is enabled */ TSI_HAL_EnableSoftwareTriggerScan(base); TSI_HAL_EnableModule(base); TSI_HAL_StartSoftwareTrigger(base); while((TSI_HAL_GetEndOfScanFlag(base) == 0U) && (timeout--)) { /* Do nothing, just to meet MISRA C 2004 rule 14.3 . */ } TSI_HAL_ClearEndOfScanFlag(base); TSI_HAL_DisableModule(base); if(timeout) { result = 0; } } return result; }
/*FUNCTION********************************************************************** * * Function Name : TSI_HAL_MeasurementBlocking * Description : Function do blocking measurement of enabled electrodes * It used just for recalibration process *END**************************************************************************/ static int32_t TSI_HAL_MeasurementBlocking(TSI_Type * base, uint32_t electrode, uint32_t noise_mode) { int32_t result; uint32_t timeout = 1000000; /* measure only if at least one electrode is enabled */ TSI_HAL_EnableSoftwareTriggerScan(base); TSI_HAL_SetMeasuredChannelNumber(base, electrode); TSI_HAL_SetMode(base, TSI_HAL_GetMode(base)); /* force to HW right analog mode. */ TSI_HAL_EnableModule(base); TSI_HAL_StartSoftwareTrigger(base); while((TSI_HAL_GetEndOfScanFlag(base) == 0U) && (--timeout)) { /* Do nothing, just to meet MISRA C 2004 rule 14.3 . */ } if(timeout == 0) { result = 0; }else { if(noise_mode) { result = TSI_HAL_GetNoiseResult(base); }else { result = TSI_HAL_GetCounter(base); } } TSI_HAL_ClearEndOfScanFlag(base); TSI_HAL_DisableModule(base); return result; }