zephyr
This commit is contained in:
@@ -13,8 +13,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# pass TOOLCHAIN_CPU to
|
||||
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake)
|
||||
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_CPU)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_CPU}.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Compile flags
|
||||
|
@@ -5,6 +5,11 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
||||
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if (BUILD_ZEPHYR)
|
||||
set(BOARD_ROOT ${TOP}/hw/bsp/${FAMILY})
|
||||
find_package(Zephyr REQUIRED HINTS ${TOP}/lib/zephyr)
|
||||
endif ()
|
||||
|
||||
project(${PROJECT} C CXX ASM)
|
||||
|
||||
# Checks this example is valid for the family and initializes the project
|
||||
@@ -15,18 +20,27 @@ if(FAMILY STREQUAL "espressif")
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT})
|
||||
if (BUILD_ZEPHYR)
|
||||
set(EXE_NAME app)
|
||||
else()
|
||||
set(EXE_NAME ${PROJECT})
|
||||
add_executable(${EXE_NAME})
|
||||
endif()
|
||||
|
||||
# Example source
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
target_sources(${EXE_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
||||
)
|
||||
|
||||
# Example include
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
target_include_directories(${EXE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
# Configure compilation flags and libraries for the example without RTOS.
|
||||
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
|
||||
family_configure_device_example(${PROJECT} noos)
|
||||
if (BUILD_ZEPHYR)
|
||||
family_configure_device_example(${EXE_NAME} zephyr)
|
||||
else()
|
||||
family_configure_device_example(${EXE_NAME} noos)
|
||||
endif()
|
||||
|
@@ -23,6 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if 1
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -51,7 +52,7 @@ int main(void) {
|
||||
|
||||
// Blink and print every interval ms
|
||||
if (!(board_millis() - start_ms < interval_ms)) {
|
||||
board_uart_write(HELLO_STR, strlen(HELLO_STR));
|
||||
// board_uart_write(HELLO_STR, strlen(HELLO_STR));
|
||||
|
||||
start_ms = board_millis();
|
||||
|
||||
@@ -60,13 +61,58 @@ int main(void) {
|
||||
}
|
||||
|
||||
// echo
|
||||
uint8_t ch;
|
||||
if (board_uart_read(&ch, 1) > 0) {
|
||||
board_uart_write(&ch, 1);
|
||||
}
|
||||
// uint8_t ch;
|
||||
// if (board_uart_read(&ch, 1) > 0) {
|
||||
// board_uart_write(&ch, 1);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
|
||||
/* 1000 msec = 1 sec */
|
||||
#define SLEEP_TIME_MS 200
|
||||
|
||||
/* 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TUSB_MCU_VENDOR_ESPRESSIF
|
||||
void app_main(void) {
|
||||
main();
|
||||
|
@@ -6,6 +6,11 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../../hw/bsp/family_support.cmake)
|
||||
# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
|
||||
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
if (BUILD_ZEPHYR)
|
||||
set(BOARD_ROOT ${TOP}/hw/bsp/${FAMILY})
|
||||
find_package(Zephyr REQUIRED HINTS ${TOP}/lib/zephyr)
|
||||
endif ()
|
||||
|
||||
project(${PROJECT} C CXX ASM)
|
||||
|
||||
# Checks this example is valid for the family and initializes the project
|
||||
@@ -16,20 +21,29 @@ if(FAMILY STREQUAL "espressif")
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT})
|
||||
if (BUILD_ZEPHYR)
|
||||
set(EXE_NAME app)
|
||||
else()
|
||||
set(EXE_NAME ${PROJECT})
|
||||
add_executable(${EXE_NAME})
|
||||
endif()
|
||||
|
||||
# Example source
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
target_sources(${EXE_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/msc_disk.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
|
||||
)
|
||||
|
||||
# Example include
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
target_include_directories(${EXE_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
# Configure compilation flags and libraries for the example... see the corresponding function
|
||||
# in hw/bsp/FAMILY/family.cmake for details.
|
||||
family_configure_device_example(${PROJECT} noos)
|
||||
# Configure compilation flags and libraries for the example without RTOS.
|
||||
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
|
||||
if (BUILD_ZEPHYR)
|
||||
family_configure_device_example(${EXE_NAME} zephyr)
|
||||
else()
|
||||
family_configure_device_example(${EXE_NAME} noos)
|
||||
endif()
|
||||
|
12
examples/west.yml
Normal file
12
examples/west.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
manifest:
|
||||
remotes:
|
||||
- name: zephyrproject-rtos
|
||||
url-base: https://github.com/zephyrproject-rtos
|
||||
projects:
|
||||
- name: zephyr
|
||||
remote: zephyrproject-rtos
|
||||
revision: v4.0.0
|
||||
path: lib/zephyr
|
||||
import: true
|
||||
self:
|
||||
path: .
|
Reference in New Issue
Block a user