/* * Read the state of the port. The port can be input * or output. * @gpio the GPIO pin to read from. * @return GPIO_HIGH if the pin is HIGH, GPIO_LOW if the pin is low. Output * is -1 when an error occurred. */ int gpio_read_and_close(int gpio) { int state; /* The port state */ /* Reserve the port */ if(!gpio_reserve(gpio)) { return -1; } /* Read the port */ state = gpio_get_state(gpio); if(!gpio_release(gpio)) { return -1; } /* Return the port state */ return state; }
/** * Получить состояние питания компьютера */ int desktop_get_power_state(void) { return !gpio_get_state(&gpio_list[MCU_GPIO_POWER_STATE]); }
static void readDiagPin() { diagState = gpio_get_state(DIAG_PIN); }