Add blinky sample
This commit is contained in:
parent
46a8285f59
commit
fc3a0652aa
9 changed files with 90 additions and 2 deletions
1
code/nrf-connect/samples/ble/.gitignore
vendored
1
code/nrf-connect/samples/ble/.gitignore
vendored
|
|
@ -1,3 +1,2 @@
|
|||
build
|
||||
build_*
|
||||
*.code-workspace
|
||||
16
code/nrf-connect/samples/ble/ble.code-workspace
Normal file
16
code/nrf-connect/samples/ble/ble.code-workspace
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../../prstlib"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"C_Cpp.autoAddFileAssociations": false,
|
||||
"nrf-connect.applications": [
|
||||
"${workspaceFolder}"
|
||||
]
|
||||
}
|
||||
}
|
||||
2
code/nrf-connect/samples/blinky/.gitignore
vendored
Normal file
2
code/nrf-connect/samples/blinky/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
build
|
||||
build_*
|
||||
11
code/nrf-connect/samples/blinky/CMakeLists.txt
Normal file
11
code/nrf-connect/samples/blinky/CMakeLists.txt
Normal 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)
|
||||
16
code/nrf-connect/samples/blinky/blinky.code-workspace
Normal file
16
code/nrf-connect/samples/blinky/blinky.code-workspace
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../../prstlib"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"C_Cpp.autoAddFileAssociations": false,
|
||||
"nrf-connect.applications": [
|
||||
"${workspaceFolder}"
|
||||
]
|
||||
}
|
||||
}
|
||||
1
code/nrf-connect/samples/blinky/prj.conf
Normal file
1
code/nrf-connect/samples/blinky/prj.conf
Normal file
|
|
@ -0,0 +1 @@
|
|||
CONFIG_GPIO=y
|
||||
28
code/nrf-connect/samples/blinky/src/main.c
Normal file
28
code/nrf-connect/samples/blinky/src/main.c
Normal 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,2 @@
|
|||
build
|
||||
build_*
|
||||
*.code-workspace
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
},
|
||||
{
|
||||
"path": "../../prstlib"
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"C_Cpp.autoAddFileAssociations": false,
|
||||
"nrf-connect.applications": [
|
||||
"${workspaceFolder}"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue