34#define LOG_DOMAIN "buttons"
56 pynq_error(
"get_button_state: invalid button=%d, must be 0..%d-1\n",
66 pynq_error(
"get_button_state: invalid button=%d, must be 0..%d-1\n", button,
71 pynq_error(
"get_button_state: button %d has not been set as input\n",
74 struct timeval call, close;
76 gettimeofday(&call, NULL);
77 const unsigned int check =
81 gettimeofday(&close, NULL);
82 dTime = (close.tv_sec - call.tv_sec) * 1000.0;
83 dTime += (close.tv_usec - call.tv_usec) / 1000.0;
89 pynq_error(
"sleep_msec_button_pushed: invalid button=%d, must be 0..%d-1\n",
95 "sleep_msec_button_pushed: button %d has not been set as input\n",
99 struct timeval call, close;
102 gettimeofday(&call, NULL);
108 (void)gettimeofday(&close, NULL);
109 dTime = (close.tv_sec - call.tv_sec) * 1000.0;
110 dTime += (close.tv_usec - call.tv_usec) / 1000.0;
111 }
while (dTime < ms);
116 if (button_states == NULL) {
117 pynq_error(
"sleep_msec_buttons_pushed: button_states is NULL\n");
119 struct timeval call, close;
123 (void)gettimeofday(&call, NULL);
132 (void)gettimeofday(&close, NULL);
133 dTime = (close.tv_sec - call.tv_sec) * 1000.0;
134 dTime += (close.tv_usec - call.tv_usec) / 1000.0;
135 }
while (dTime < ms);
151 "wait_until_any_button_pushed: button %d has not been set as input\n",
168 pynq_error(
"wait_until_any_button_released: button %d has not been set "
183 pynq_error(
"get_switch_state: invalid switch_num=%d, must be 0..%i-1\n",
gpio_direction_t gpio_get_direction(const gpio_t pin)
Returns the direction the set pin is initialized in.
gpio_level_t gpio_get_level(const gpio_t pin)
Return the level of the GPIO pin.
void gpio_set_direction(const gpio_t pin, const gpio_direction_t dir)
Set the GPIO pin as in input or output.
#define SWB_BTN0
Button input pins.
#define SWB_SW0
Switch input pins.