Hardware Reference
In-Depth Information
printf
(
"Got it (%d), button = %d
\n
"
, *
tmp_count
,
value
);
return
EXIT_SUCCESS
;
}
int
main
(
void
) {
// Enable debug output
libsoc_set_debug
(
1
);
// Request gpios
gpio_output
=
libsoc_gpio_request
(
GPIO_OUTPUT
,
LS_SHARED
);
gpio_input
=
libsoc_gpio_request
(
GPIO_INPUT
,
LS_SHARED
);
// Set direction to OUTPUT
libsoc_gpio_set_direction
(
gpio_output
,
OUTPUT
);
// Set direction to INPUT
libsoc_gpio_set_direction
(
gpio_input
,
INPUT
);
// Set edge to BOTH
libsoc_gpio_set_edge
(
gpio_input
,
BOTH
);
// Set up callback
libsoc_gpio_callback_interrupt
(
gpio_input
, &
callback_test
,
(
void
*) &
interrupt_count
);
printf
(
"Push the button...
\n
"
);
// Disaple debug output so the code will respond faster
libsoc_set_debug
(
0
);
sleep
(
10
);
libsoc_set_debug
(
1
);
// Cancel the callback on interrupt
libsoc_gpio_callback_interrupt_cancel
(
gpio_input
);
//If gpio_request was successful
if
(
gpio_input
) {
// Free gpio request memory
libsoc_gpio_free
(
gpio_input
);
}
if
(
gpio_output
) {
// Free gpio request memory
libsoc_gpio_free
(
gpio_output
);
}