function [ADCCLKinMHz, AcquisitionWindowinUS] = calcADCClockAndAcquistionWindow(sysclkoutInMHz, hspclk_div, AdcClockPrescaler, CoreClockPrescaler, AcquisitionWindowPrescaler)

if hspclk_div == 0
    HSPCLKinMHz = sysclkoutInMHz;
else
    HSPCLKinMHz = sysclkoutInMHz / hspclk_div;
end

if AdcClockPrescaler == 0
    AdcClockPrescaler = 1;
else
    AdcClockPrescaler = 2 * AdcClockPrescaler;
end
ADCCLKinMHz = HSPCLKinMHz / (AdcClockPrescaler * (CoreClockPrescaler+1));

AcquisitionWindowinUS = (AcquisitionWindowPrescaler + 1)/ADCCLKinMHz;