| 662 | } |
| 663 | |
| 664 | static int |
| 665 | mv_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 | |
| 690 | static void |
| 691 | mv_gpio_debounce_start(device_t dev, int pin) |
no test coverage detected