testing
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
build/
|
||||
7
CMakeLists.txt
Normal file
7
CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
set(BOARD nucleo_g474re)
|
||||
find_package(Zephyr REQUIRED)
|
||||
project(app)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
14
Kconfig
Normal file
14
Kconfig
Normal file
@@ -0,0 +1,14 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
mainmenu "First App"
|
||||
|
||||
# Your application configuration options go here
|
||||
|
||||
# Sources Kconfig.zephyr in the Zephyr root directory.
|
||||
#
|
||||
# Note: All 'source' statements work relative to the Zephyr root directory (due
|
||||
# to the $srctree environment variable being set to $ZEPHYR_BASE). If you want
|
||||
# to 'source' relative to the current Kconfig file instead, use 'rsource' (or a
|
||||
# path relative to the Zephyr root).
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
23
boards/nucleo_g474re.overlay
Normal file
23
boards/nucleo_g474re.overlay
Normal file
@@ -0,0 +1,23 @@
|
||||
/ {
|
||||
aliases {
|
||||
/* alias used by DT_ALIAS(led0) in app code */
|
||||
led0 = &ld2;
|
||||
};
|
||||
|
||||
/* simple gpio-leds node */
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
ld2: led_0 {
|
||||
gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>; /* LD2 -> PA5 */
|
||||
label = "LD2";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&gpioa {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&gpioc {
|
||||
status = "okay";
|
||||
};
|
||||
7
prj.conf
Normal file
7
prj.conf
Normal file
@@ -0,0 +1,7 @@
|
||||
# enable gpio driver
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
37
src/main.c
Normal file
37
src/main.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <zephyr/devicetree.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/uart.h>
|
||||
|
||||
#define SLEEP_MS 2000
|
||||
|
||||
#define LED_NODE DT_ALIAS(led0)
|
||||
#if !DT_NODE_HAS_STATUS(LED_NODE, okay)
|
||||
#error "led0 not enabled in devicetree"
|
||||
#endif
|
||||
|
||||
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED_NODE, gpios);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printk("app started\n");
|
||||
|
||||
if (!gpio_is_ready_dt(&led))
|
||||
{
|
||||
printk("LED GPIO not ready\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
|
||||
if (ret < 0)
|
||||
{
|
||||
printk("LED GPIO configure failed: %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char incoming;
|
||||
int i = 0;
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user