pub fn set_filter(&self, threshold: Option<u16>) -> Result<(), InvalidFilterThreshold> {
        let pcnt = PCNT::regs();
        let unit = pcnt.unit(NUM);

        match threshold {
            None => {
                unit.conf0().modify(|_, w| w.filter_en().clear_bit());
            }
            Some(threshold) => {
                if threshold > 1023 {
                    return Err(InvalidFilterThreshold);
                }
                unit.conf0().modify(|_, w| unsafe {
                    w.filter_thres().bits(threshold).filter_en().set_bit()
                });
            }
        }
        Ok(())
    }
Configures the glitch filter hardware of the unit.

`threshold` is the minimum number of APB_CLK cycles for a pulse to be
considered valid. If it is None, the filter is disabled.

Note: This maximum possible threshold is 1023.
esp-hal/src/pcnt/unit.rs