/* Enables or disables ADC upper threshold detect function.  */
void ADC_UpperTHDCmd(uint32_t THDChannel, uint32_t NewState)
/* Enables or disables ADC upper threshold detect function.  */
void ADC_UpperTHDCmd(uint32_t THDChannel, uint32_t NewState)
{
  assert_parameters(IS_ADC_THDCHANNEL(THDChannel));
  assert_parameters(IS_FUNCTIONAL_STATE(NewState)); 
  if (NewState == DISABLE)
  {
    ANA->ADCCTRL1 &= ~(ANA_ADCCTRL1_UPPER_THD0_EN << (THDChannel*2));
  }
  else
  {
    ANA->ADCCTRL1 |= (ANA_ADCCTRL1_UPPER_THD0_EN << (THDChannel*2));
  }
}