MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mv_gpio_debounce_init

Function mv_gpio_debounce_init

freebsd/arm/mv/gpio.c:664–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

662}
663
664static int
665mv_gpio_debounce_init(device_t dev, int pin)
666{
667 uint8_t raw_read;
668 int *cnt;
669 struct mv_gpio_softc *sc;
670
671 sc = (struct mv_gpio_softc *)device_get_softc(dev);
672
673 MV_GPIO_ASSERT_LOCKED();
674
675 cnt = &sc->debounce_counters[pin];
676 raw_read = (mv_gpio_value_get(dev, pin, 1) ? 1 : 0);
677 if (raw_read) {
678 mv_gpio_polarity(dev, pin, 1, 0);
679 *cnt = DEBOUNCE_HI_LO_MS / DEBOUNCE_CHECK_MS;
680 } else {
681 mv_gpio_polarity(dev, pin, 0, 0);
682 *cnt = DEBOUNCE_LO_HI_MS / DEBOUNCE_CHECK_MS;
683 }
684
685 mv_gpio_debounced_state_set(dev, pin, raw_read);
686
687 return (0);
688}
689
690static void
691mv_gpio_debounce_start(device_t dev, int pin)

Callers 1

Calls 4

device_get_softcFunction · 0.85
mv_gpio_value_getFunction · 0.85
mv_gpio_polarityFunction · 0.85

Tested by

no test coverage detected