Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/gpio/gpioiic.c
Show First 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | #endif | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
gpioiic_setsda(device_t dev, int val) | gpioiic_setsda(device_t dev, int val) | ||||
{ | { | ||||
struct gpioiic_softc *sc = device_get_softc(dev); | struct gpioiic_softc *sc = device_get_softc(dev); | ||||
int err; | |||||
/* | if (val) { | ||||
* Some controllers cannot set an output value while a pin is in input | gpio_pin_setflags(sc->sdapin, GPIO_PIN_INPUT); | ||||
* mode; in that case we set the pin again after changing mode. | } else { | ||||
*/ | gpio_pin_setflags(sc->sdapin, | ||||
err = gpio_pin_set_active(sc->sdapin, val); | GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN); | ||||
gpio_pin_setflags(sc->sdapin, GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN); | gpio_pin_set_active(sc->sdapin, 0); | ||||
if (err != 0) | |||||
gpio_pin_set_active(sc->sdapin, val); | |||||
} | } | ||||
} | |||||
static void | static void | ||||
gpioiic_setscl(device_t dev, int val) | gpioiic_setscl(device_t dev, int val) | ||||
{ | { | ||||
struct gpioiic_softc *sc = device_get_softc(dev); | struct gpioiic_softc *sc = device_get_softc(dev); | ||||
gpio_pin_setflags(sc->sclpin, GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN); | if (val) { | ||||
gpio_pin_set_active(sc->sclpin, val); | gpio_pin_setflags(sc->sclpin, GPIO_PIN_INPUT); | ||||
} else { | |||||
gpio_pin_setflags(sc->sclpin, | |||||
GPIO_PIN_OUTPUT | GPIO_PIN_OPENDRAIN); | |||||
gpio_pin_set_active(sc->sclpin, 0); | |||||
} | |||||
} | } | ||||
static int | static int | ||||
gpioiic_getscl(device_t dev) | gpioiic_getscl(device_t dev) | ||||
{ | { | ||||
struct gpioiic_softc *sc = device_get_softc(dev); | struct gpioiic_softc *sc = device_get_softc(dev); | ||||
bool val; | bool val; | ||||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |