-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "../../includes.h" | ||
#include "gpio_input_local.h" | ||
|
||
|
||
void button_pressed(const struct device *dev, struct gpio_callback *cb, | ||
uint32_t pins) | ||
{ | ||
printk("Button pressed at %" PRIu32 "\n", k_cycle_get_32()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "../../includes.h" | ||
|
||
/*** Initilize GPIO input */ | ||
/* | ||
* Get button configuration from the devicetree sw0 alias. This is mandatory. | ||
*/ | ||
#define SW0_NODE DT_ALIAS(sw0) | ||
#if !DT_NODE_HAS_STATUS(SW0_NODE, okay) | ||
#error "Unsupported board: sw0 devicetree alias is not defined" | ||
#endif | ||
|
||
static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(SW0_NODE, gpios, | ||
{0}); | ||
static struct gpio_callback button_cb_data; | ||
|
||
/* | ||
* The led0 devicetree alias is optional. If present, we'll use it | ||
* to turn on the LED whenever the button is pressed. | ||
*/ | ||
static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios, | ||
{0}); | ||
|
||
|
||
void button_pressed(const struct device *dev, struct gpio_callback *cb, | ||
uint32_t pins); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters