The patch can be applied to ChibiOS/RT version 2.6.7 and changes the files
The adcerror_t enum was extended by the value ADC_ERR_WATCHDOG = 2
The ADCConversionGroup struct was extended by the two threshold registers htr and ltr.
Introduced two new macros (ADC_HTR(n) and ADC_LTR(n)) that limit given threshold values to the maximum possible value, thus overflows are omitted.
The IRQ handler now checks the status register for the ADC_SR_AWD bit and generates an error code, using the new ADC_ERR_WATCHDOG error.
As a result, it is now possible to set the ADC watchdog thresholds via the ADCConversionGroup. As soon as the measured value is out of bounds, the error callback function is called with the according error code.