/* * Copyright (C) 2015-2016 Paul Kocialkowski * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #define SEGMENT_HINT_BUTTON #include #include #include #include #include char button_pressed(unsigned char button) { switch (button) { case BUTTON_POWER: return !gpio_input_data(GPIO_BUTTON_POWER); case BUTTON_RECOVERY: return !gpio_input_data(GPIO_BUTTON_RECOVERY); default: return 0; } } signed char button_init(void) { signed char rc = 0; rc |= gpio_input_enable(GPIO_BUTTON_POWER, 1); rc |= gpio_input_enable(GPIO_BUTTON_RECOVERY, 1); rc |= gpwu_trigger_toggle(GPIO_BUTTON_POWER, 1); rc |= gpwu_trigger_toggle(GPIO_BUTTON_RECOVERY, 1); rc |= gpwu_event_enable(GPIO_BUTTON_POWER, 1); rc |= gpwu_event_enable(GPIO_BUTTON_RECOVERY, 1); return rc; }