Add blinky sample

This commit is contained in:
rbaron 2022-11-28 19:38:32 +01:00
parent 46a8285f59
commit fc3a0652aa
9 changed files with 90 additions and 2 deletions

View file

@ -1,3 +1,2 @@
build
build_*
*.code-workspace

View file

@ -0,0 +1,16 @@
{
"folders": [
{
"path": "."
},
{
"path": "../../prstlib"
}
],
"settings": {
"C_Cpp.autoAddFileAssociations": false,
"nrf-connect.applications": [
"${workspaceFolder}"
]
}
}

View file

@ -0,0 +1,2 @@
build
build_*

View file

@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.20.0)
# Pull in the dts/ and boards/ from prstlib.
set(DTS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../prstlib)
set(BOARD_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../prstlib)
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(blinky)
target_sources(app PRIVATE src/main.c)

View file

@ -0,0 +1,16 @@
{
"folders": [
{
"path": "."
},
{
"path": "../../prstlib"
}
],
"settings": {
"C_Cpp.autoAddFileAssociations": false,
"nrf-connect.applications": [
"${workspaceFolder}"
]
}
}

View file

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

View file

@ -0,0 +1,28 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/zephyr.h>
#define SLEEP_TIME_MS 1000
static const struct gpio_dt_spec led =
GPIO_DT_SPEC_GET(DT_NODELABEL(led0), 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);
}
}

View file

@ -1,3 +1,2 @@
build
build_*
*.code-workspace

View file

@ -0,0 +1,16 @@
{
"folders": [
{
"path": "."
},
{
"path": "../../prstlib"
}
],
"settings": {
"C_Cpp.autoAddFileAssociations": false,
"nrf-connect.applications": [
"${workspaceFolder}"
]
}
}