From 616ef897ad04029161c9c70a04feb4c27b4a7960 Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Wed, 21 Sep 2022 10:11:30 +0100 Subject: [PATCH] init --- .gitignore | 3 +++ CMakeLists.txt | 7 +++++++ app.overlay | 0 prj.conf | 4 ++++ src/main.c | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 app.overlay create mode 100644 prj.conf create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ffff840 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build/ +.vscode/ + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..96c8708 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.20.0) + +set(BOARD adafruit_feather_nrf52840) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(passr) + +target_sources(app PRIVATE src/main.c) diff --git a/app.overlay b/app.overlay new file mode 100644 index 0000000..e69de29 diff --git a/prj.conf b/prj.conf new file mode 100644 index 0000000..53f6453 --- /dev/null +++ b/prj.conf @@ -0,0 +1,4 @@ +CONFIG_GPIO=y +# CONFIG_BT=y +# CONFIG_BT_DEBUG_LOG=y +# CONFIG_BT_DEVICE_NAME="Test beacon" diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..0ac9b11 --- /dev/null +++ b/src/main.c @@ -0,0 +1,37 @@ + +#include +#include + +/* 1000 msec = 1 sec */ +#define SLEEP_TIME_MS 1000 + +/* The devicetree node identifier for the "led0" alias. */ +#define LED0_NODE DT_ALIAS(led1) + +/* + * A build error on this line means your board is unsupported. + * See the sample documentation for information on how to fix this. + */ +static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios); + +void main(void) +{ + int ret; + + if (!device_is_ready(led.port)) { + return; + } + + ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); + if (ret < 0) { + return; + } + + while (1) { + ret = gpio_pin_toggle_dt(&led); + if (ret < 0) { + return; + } + k_msleep(SLEEP_TIME_MS); + } +}