zephyr/blink: copy in example to show how to build
This commit is contained in:
parent
ee90766969
commit
3b63f9d5e5
1
zephyr/.gitignore
vendored
Normal file
1
zephyr/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
build/
|
5
zephyr/blink/CMakeLists.txt
Normal file
5
zephyr/blink/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
|
|
||||||
|
project(blink)
|
||||||
|
target_sources(app PRIVATE src/main.c)
|
3
zephyr/blink/README.txt
Normal file
3
zephyr/blink/README.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Example application to show building:
|
||||||
|
cmake -B build -G Ninja -D BOARD=your_board
|
||||||
|
ninja -C build
|
1
zephyr/blink/prj.conf
Normal file
1
zephyr/blink/prj.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
CONFIG_GPIO=y
|
44
zephyr/blink/src/main.c
Normal file
44
zephyr/blink/src/main.c
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
#include <zephyr/drivers/gpio.h>
|
||||||
|
|
||||||
|
/* 1000 msec = 1 sec */
|
||||||
|
#define SLEEP_TIME_MS 1000
|
||||||
|
|
||||||
|
/* The devicetree node identifier for the "led0" alias. */
|
||||||
|
#define LED0_NODE DT_ALIAS(led0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!gpio_is_ready_dt(&led)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
|
||||||
|
if (ret < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ret = gpio_pin_toggle_dt(&led);
|
||||||
|
if (ret < 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
k_msleep(SLEEP_TIME_MS);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue