From c3b4f159df6b52ac8045fbadaf424a88a2b329a8 Mon Sep 17 00:00:00 2001 From: Abel Tim Date: Tue, 27 May 2025 14:57:06 +0200 Subject: zephyr Multi-line description of commit, feel free to be detailed. Signed-off-by: Abel Tim --- code/main/teensy_goalie/src/main.c | 48 ++++++++++++++++++++++++++++++++++++ code/main/teensy_goalie/src/main.cpp | 18 -------------- 2 files changed, 48 insertions(+), 18 deletions(-) create mode 100644 code/main/teensy_goalie/src/main.c delete mode 100644 code/main/teensy_goalie/src/main.cpp (limited to 'code/main/teensy_goalie/src') diff --git a/code/main/teensy_goalie/src/main.c b/code/main/teensy_goalie/src/main.c new file mode 100644 index 0000000..f8aff35 --- /dev/null +++ b/code/main/teensy_goalie/src/main.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016 Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +/* 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; + bool led_state = true; + + 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; + } + + led_state = !led_state; + printf("LED state: %s\n", led_state ? "ON" : "OFF"); + k_msleep(SLEEP_TIME_MS); + } + return 0; +} diff --git a/code/main/teensy_goalie/src/main.cpp b/code/main/teensy_goalie/src/main.cpp deleted file mode 100644 index cb9fbba..0000000 --- a/code/main/teensy_goalie/src/main.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include - -// put function declarations here: -int myFunction(int, int); - -void setup() { - // put your setup code here, to run once: - int result = myFunction(2, 3); -} - -void loop() { - // put your main code here, to run repeatedly: -} - -// put function definitions here: -int myFunction(int x, int y) { - return x + y; -} \ No newline at end of file -- cgit v1.2.3