Automatically add code to main.c
All checks were successful
Build & Publish / build (push) Successful in 8m36s

This commit is contained in:
2023-08-03 14:44:16 +02:00
parent 555419f701
commit cfe0381610
6 changed files with 79 additions and 41 deletions

View File

@@ -1,3 +1,10 @@
/* --------------------------- */
/* Buttons */
/* --------------------------- */
/* Imports / Declarations */
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/util.h>
@@ -25,13 +32,14 @@ static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios,
{0});
/* Functions */
void button_pressed(const struct device *dev, struct gpio_callback *cb,
uint32_t pins)
{
printk("Button pressed at %" PRIu32 "\n", k_cycle_get_32());
}
int button(void)
int initialize_button(void)
{
int ret;
@@ -75,6 +83,10 @@ int button(void)
printk("Set up LED at %s pin %d\n", led.port->name, led.pin);
}
}
}
int button_activate_led(void) {
int ret;
printk("Press the button\n");
if (led.port) {
@@ -90,3 +102,15 @@ int button(void)
}
return 0;
}
/*
Example:
int main(void)
{
initialize_button();
button_activate_led();
return 0;
}
*/

View File

@@ -0,0 +1 @@
CONFIG_GPIO=y