summaryrefslogtreecommitdiff
path: root/firmware/src/main.c
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-02-11 06:58:50 +0100
committerxengineering <me@xengineering.eu>2025-02-11 06:58:50 +0100
commit304e1e443dc1283efbd1fe8b4a72c13f6cfc2fe4 (patch)
treed116911b7876abc796eee4ae649c3d6749c525c5 /firmware/src/main.c
parent2c18a99bd24ddadd165eeabe5299ac094b0c0ee3 (diff)
downloadiot-contact-304e1e443dc1283efbd1fe8b4a72c13f6cfc2fe4.tar
iot-contact-304e1e443dc1283efbd1fe8b4a72c13f6cfc2fe4.tar.zst
iot-contact-304e1e443dc1283efbd1fe8b4a72c13f6cfc2fe4.zip
fw: Move content of `firmware` here
This makes the name shorter which is especially relevant for Git commit messages.
Diffstat (limited to 'firmware/src/main.c')
-rw-r--r--firmware/src/main.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/firmware/src/main.c b/firmware/src/main.c
deleted file mode 100644
index 1ee66d1..0000000
--- a/firmware/src/main.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <zephyr/kernel.h>
-#include <zephyr/device.h>
-#include <zephyr/drivers/gpio.h>
-
-#define SW0_NODE DT_ALIAS(sw0)
-#if !DT_NODE_HAS_STATUS(SW0_NODE, okay)
-#error "Unsupported board: Devicetree alias for button is not defined"
-#endif
-static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET(SW0_NODE, gpios);
-static struct gpio_callback button_cb_data;
-
-void button_pressed(const struct device *dev, struct gpio_callback *cb,
- uint32_t pins)
-{
- printk("Button pressed\n");
-}
-
-int main(void)
-{
- int ret;
-
- if (!gpio_is_ready_dt(&button)) {
- printk("Error: button device %s is not ready\n",
- button.port->name);
- return 0;
- }
-
- ret = gpio_pin_configure_dt(&button, GPIO_INPUT);
- if (ret != 0) {
- printk("Error %d: failed to configure %s pin %d\n",
- ret, button.port->name, button.pin);
- return 0;
- }
-
- ret = gpio_pin_interrupt_configure_dt(&button, GPIO_INT_EDGE_TO_ACTIVE);
- if (ret != 0) {
- printk("Error %d: failed to configure interrupt on %s pin %d\n",
- ret, button.port->name, button.pin);
- return 0;
- }
-
- gpio_init_callback(&button_cb_data, button_pressed, BIT(button.pin));
- gpio_add_callback(button.port, &button_cb_data);
-
- return 0;
-}