boards: pinetime_devkit0 basic sample.
Basic sample program that uses the one led and button from the Pinetime. Led will turn on everytime the button is pushed. Signed-off-by: Rafa Couto <caligari@treboada.net>
This commit is contained in:
parent
0dbc7e20be
commit
ce9947c243
|
@ -101,9 +101,9 @@
|
|||
};
|
||||
|
||||
/* Hynitron CST816S Capacitive Touch Controller (400KHz) */
|
||||
cst816s: cst816s@37 {
|
||||
cst816s: cst816s@15 {
|
||||
compatible = "hynitron,cst816s";
|
||||
reg = <0x37>; /* datasheet pending! */
|
||||
reg = <0x15>;
|
||||
label = "CST816S";
|
||||
irq-gpios = <&gpio0 28 GPIO_INT_ACTIVE_LOW>;
|
||||
rst-gpios = <&gpio0 10 GPIO_INT_ACTIVE_LOW>;
|
||||
|
|
9
samples/boards/pine64_pinetime/CMakeLists.txt
Normal file
9
samples/boards/pine64_pinetime/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Boilerplate code, which pulls in the Zephyr build system.
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
|
||||
project(sample_pinetime_app)
|
||||
|
||||
# Add your source file to the "app" target. This must come after
|
||||
# the boilerplate code, which defines the target.
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
|
0
samples/boards/pine64_pinetime/prj.conf
Normal file
0
samples/boards/pine64_pinetime/prj.conf
Normal file
32
samples/boards/pine64_pinetime/src/main.c
Normal file
32
samples/boards/pine64_pinetime/src/main.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <drivers/gpio.h>
|
||||
|
||||
#define LED_PORT DT_ALIAS_STATUS_LED_GPIOS_CONTROLLER
|
||||
#define LED_PIN DT_ALIAS_STATUS_LED_GPIOS_PIN
|
||||
|
||||
#define BTN_PORT DT_ALIAS_KEY_IN_GPIOS_CONTROLLER
|
||||
#define BTN_PIN DT_ALIAS_KEY_IN_GPIOS_PIN
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct device *dev_led = device_get_binding(LED_PORT);
|
||||
gpio_pin_configure(dev_led, LED_PIN, GPIO_DIR_OUT);
|
||||
|
||||
struct device *dev_btn = device_get_binding(BTN_PORT);
|
||||
gpio_pin_configure(dev_btn, BTN_PIN, GPIO_DIR_IN);
|
||||
|
||||
while (1)
|
||||
{
|
||||
// button is pressed ==> turn on status LED
|
||||
u32_t val = 0U;
|
||||
gpio_pin_read(dev_btn, BTN_PIN, &val);
|
||||
gpio_pin_write(dev_led, LED_PIN, val);
|
||||
|
||||
// dont burn the CPU
|
||||
k_sleep(10);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue