diff --git a/examples/zephyr-blink/src/main.c b/examples/zephyr-blink/src/main.c index 9c9ab430..4cab4969 100644 --- a/examples/zephyr-blink/src/main.c +++ b/examples/zephyr-blink/src/main.c @@ -4,11 +4,12 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include /* 1000 msec = 1 sec */ -#define SLEEP_TIME_MS 300 +#define SLEEP_TIME_MS 1000 /* The devicetree node identifier for the "led0" alias. */ #define LED0_NODE DT_ALIAS(led0) @@ -19,28 +20,29 @@ */ static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios); -void main(void) +int main(void) { int ret; + bool led_state = true; - if (!gpio_is_ready_dt(&led)) - { - return; + if (!gpio_is_ready_dt(&led)) { + return 0; } ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE); - if (ret < 0) - { - return; + if (ret < 0) { + return 0; } - while (1) - { + while (1) { ret = gpio_pin_toggle_dt(&led); - if (ret < 0) - { - return; + 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/examples/zephyr-blink/zephyr/CMakeLists.txt b/examples/zephyr-blink/zephyr/CMakeLists.txt index dce86233..5272a405 100644 --- a/examples/zephyr-blink/zephyr/CMakeLists.txt +++ b/examples/zephyr-blink/zephyr/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.13.1) -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(blinky) target_sources(app PRIVATE ../src/main.c) diff --git a/examples/zephyr-cpp-synchronization/zephyr/CMakeLists.txt b/examples/zephyr-cpp-synchronization/zephyr/CMakeLists.txt index 0fa9ce86..1ed7c6b6 100644 --- a/examples/zephyr-cpp-synchronization/zephyr/CMakeLists.txt +++ b/examples/zephyr-cpp-synchronization/zephyr/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.13.1) -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(cpp_synchronization) target_sources(app PRIVATE ../src/main.cpp) diff --git a/examples/zephyr-drivers-can/zephyr/CMakeLists.txt b/examples/zephyr-drivers-can/zephyr/CMakeLists.txt index 31126969..dd59da24 100644 --- a/examples/zephyr-drivers-can/zephyr/CMakeLists.txt +++ b/examples/zephyr-drivers-can/zephyr/CMakeLists.txt @@ -1,8 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.13.1) +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(babbling) -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) -project(CAN) - -target_sources(app PRIVATE ../src/main.c) +FILE(GLOB app_sources ../src/*.c) +target_sources(app PRIVATE ${app_sources}) diff --git a/examples/zephyr-net-https-client/src/main.c b/examples/zephyr-net-https-client/src/main.c index 933f4b18..5c89fb42 100644 --- a/examples/zephyr-net-https-client/src/main.c +++ b/examples/zephyr-net-https-client/src/main.c @@ -141,6 +141,8 @@ static int connect_socket(sa_family_t family, const char *server, int port, LOG_ERR("Cannot connect to %s remote (%d)", family == AF_INET ? "IPv4" : "IPv6", -errno); + close(*sock); + *sock = -1; ret = -errno; } @@ -360,20 +362,23 @@ int main(void) { int iterations = CONFIG_NET_SAMPLE_SEND_ITERATIONS; int i = 0; - int ret; + int ret = 0; while (iterations == 0 || i < iterations) { ret = run_queries(); if (ret < 0) { - exit(1); + ret = 1; + break; } if (iterations > 0) { i++; if (i >= iterations) { + ret = 0; break; } } else { + ret = 0; break; } } @@ -382,6 +387,6 @@ int main(void) k_sleep(K_FOREVER); } - exit(0); - return 0; + exit(ret); + return ret; } diff --git a/examples/zephyr-net-https-client/zephyr/CMakeLists.txt b/examples/zephyr-net-https-client/zephyr/CMakeLists.txt index e4afe9e0..29bc61b5 100644 --- a/examples/zephyr-net-https-client/zephyr/CMakeLists.txt +++ b/examples/zephyr-net-https-client/zephyr/CMakeLists.txt @@ -1,10 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 -cmake_minimum_required(VERSION 3.13.1) - -set (CONF_FILE "prj.conf overlay-tls.conf") - -include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) +cmake_minimum_required(VERSION 3.20.0) +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(http_client) FILE(GLOB app_sources ../src/*.c) @@ -16,4 +13,4 @@ generate_inc_file_for_target( app ../src/https-cert.der ${gen_dir}/https-cert.der.inc -) + ) diff --git a/examples/zephyr-net-https-client/zephyr/prj.conf b/examples/zephyr-net-https-client/zephyr/prj.conf index dda4d34b..6f0e8af7 100644 --- a/examples/zephyr-net-https-client/zephyr/prj.conf +++ b/examples/zephyr-net-https-client/zephyr/prj.conf @@ -1,3 +1,7 @@ +# General config +CONFIG_MAIN_STACK_SIZE=3072 +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 + # Networking config CONFIG_NETWORKING=y CONFIG_NET_IPV4=y @@ -7,12 +11,19 @@ CONFIG_NET_SHELL=y # Sockets CONFIG_NET_SOCKETS=y -CONFIG_NET_SOCKETS_POSIX_NAMES=y -CONFIG_NET_SOCKETS_POLL_MAX=4 +CONFIG_ZVFS_POLL_MAX=4 +CONFIG_POSIX_API=y # Network driver config CONFIG_TEST_RANDOM_GENERATOR=y +# Network buffers +CONFIG_NET_PKT_RX_COUNT=16 +CONFIG_NET_PKT_TX_COUNT=16 +CONFIG_NET_BUF_RX_COUNT=128 +CONFIG_NET_BUF_TX_COUNT=128 +CONFIG_NET_CONTEXT_NET_PKT_POOL=y + # Network address config CONFIG_NET_CONFIG_SETTINGS=y CONFIG_NET_CONFIG_NEED_IPV4=y @@ -30,9 +41,8 @@ CONFIG_HTTP_CLIENT=y # Network debug config CONFIG_LOG=y -CONFIG_LOG_MODE_IMMEDIATE=y CONFIG_NET_LOG=y CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n -CONFIG_NET_HTTP_LOG_LEVEL_DBG=y - -CONFIG_MAIN_STACK_SIZE=2048 +CONFIG_NET_HTTP_LOG_LEVEL_DBG=n +CONFIG_NET_IPV6_LOG_LEVEL_DBG=n +CONFIG_NET_IPV6_ND_LOG_LEVEL_DBG=n diff --git a/examples/zephyr-subsys-usb-hid-mouse/include/sample_usbd.h b/examples/zephyr-subsys-usb-hid-mouse/include/sample_usbd.h new file mode 100644 index 00000000..11779fef --- /dev/null +++ b/examples/zephyr-subsys-usb-hid-mouse/include/sample_usbd.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H +#define ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H + +#include +#include + +/* + * The scope of this header is limited to use in USB samples together with the + * new experimental USB device stack, you should not use it in your own + * application. However, you can use the code as a template. + */ + +/* + * This function uses Kconfig.sample_usbd options to configure and initialize a + * USB device. It configures sample's device context, default string descriptors, + * USB device configuration, registers any available class instances, and + * finally initializes USB device. It is limited to a single device with a + * single configuration instantiated in sample_usbd_init.c, which should be + * enough for a simple USB device sample. + * + * It returns the configured and initialized USB device context on success, + * otherwise it returns NULL. + */ +struct usbd_context *sample_usbd_init_device(usbd_msg_cb_t msg_cb); + +#endif /* ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H */ diff --git a/examples/zephyr-subsys-usb-hid-mouse/src/main.c b/examples/zephyr-subsys-usb-hid-mouse/src/main.c index 84913f79..4e579832 100644 --- a/examples/zephyr-subsys-usb-hid-mouse/src/main.c +++ b/examples/zephyr-subsys-usb-hid-mouse/src/main.c @@ -55,10 +55,12 @@ static ALWAYS_INLINE void rwup_if_suspended(void) } } -static void input_cb(struct input_event *evt) +static void input_cb(struct input_event *evt, void *user_data) { static uint8_t tmp[MOUSE_REPORT_COUNT]; + ARG_UNUSED(user_data); + switch (evt->code) { case INPUT_KEY_0: rwup_if_suspended(); @@ -95,7 +97,7 @@ static void input_cb(struct input_event *evt) } -INPUT_CALLBACK_DEFINE(NULL, input_cb); +INPUT_CALLBACK_DEFINE(NULL, input_cb, NULL); #if defined(CONFIG_USB_DEVICE_STACK_NEXT) static int enable_usb_device_next(void) @@ -174,11 +176,11 @@ int main(void) } while (true) { - uint8_t __aligned(sizeof(void *)) report[MOUSE_REPORT_COUNT]; + UDC_STATIC_BUF_DEFINE(report, MOUSE_REPORT_COUNT); k_msgq_get(&mouse_msgq, &report, K_FOREVER); - ret = hid_int_ep_write(hid_dev, report, sizeof(report), NULL); + ret = hid_int_ep_write(hid_dev, report, MOUSE_REPORT_COUNT, NULL); if (ret) { LOG_ERR("HID write error, %d", ret); } else { diff --git a/examples/zephyr-subsys-usb-hid-mouse/src/sample_usbd_init.c b/examples/zephyr-subsys-usb-hid-mouse/src/sample_usbd_init.c index 1cca20d8..1428a956 100644 --- a/examples/zephyr-subsys-usb-hid-mouse/src/sample_usbd_init.c +++ b/examples/zephyr-subsys-usb-hid-mouse/src/sample_usbd_init.c @@ -33,6 +33,9 @@ USBD_DESC_PRODUCT_DEFINE(sample_product, CONFIG_SAMPLE_USBD_PRODUCT); USBD_DESC_SERIAL_NUMBER_DEFINE(sample_sn); /* doc string instantiation end */ +USBD_DESC_CONFIG_DEFINE(fs_cfg_desc, "FS Configuration"); +USBD_DESC_CONFIG_DEFINE(hs_cfg_desc, "HS Configuration"); + /* doc configuration instantiation start */ static const uint8_t attributes = (IS_ENABLED(CONFIG_SAMPLE_USBD_SELF_POWERED) ? USB_SCD_SELF_POWERED : 0) | @@ -42,12 +45,12 @@ static const uint8_t attributes = (IS_ENABLED(CONFIG_SAMPLE_USBD_SELF_POWERED) ? /* Full speed configuration */ USBD_CONFIGURATION_DEFINE(sample_fs_config, attributes, - CONFIG_SAMPLE_USBD_MAX_POWER); + CONFIG_SAMPLE_USBD_MAX_POWER, &fs_cfg_desc); /* High speed configuration */ USBD_CONFIGURATION_DEFINE(sample_hs_config, attributes, - CONFIG_SAMPLE_USBD_MAX_POWER); + CONFIG_SAMPLE_USBD_MAX_POWER, &hs_cfg_desc); /* doc configuration instantiation end */ /* @@ -69,6 +72,7 @@ static void sample_fix_code_triple(struct usbd_context *uds_ctx, /* Always use class code information from Interface Descriptors */ if (IS_ENABLED(CONFIG_USBD_CDC_ACM_CLASS) || IS_ENABLED(CONFIG_USBD_CDC_ECM_CLASS) || + IS_ENABLED(CONFIG_USBD_CDC_NCM_CLASS) || IS_ENABLED(CONFIG_USBD_AUDIO2_CLASS)) { /* * Class with multiple interfaces have an Interface @@ -159,8 +163,8 @@ struct usbd_context *sample_usbd_init_device(usbd_msg_cb_t msg_cb) } if (IS_ENABLED(CONFIG_SAMPLE_USBD_20_EXTENSION_DESC)) { - (void)usbd_device_set_bcd(&sample_usbd, USBD_SPEED_FS, 0x0201); - (void)usbd_device_set_bcd(&sample_usbd, USBD_SPEED_HS, 0x0201); + (void)usbd_device_set_bcd_usb(&sample_usbd, USBD_SPEED_FS, 0x0201); + (void)usbd_device_set_bcd_usb(&sample_usbd, USBD_SPEED_HS, 0x0201); err = usbd_add_descriptor(&sample_usbd, &sample_usbext); if (err) { diff --git a/examples/zephyr-subsys-usb-hid-mouse/zephyr/CMakeLists.txt b/examples/zephyr-subsys-usb-hid-mouse/zephyr/CMakeLists.txt index b2f8c307..3ab90126 100644 --- a/examples/zephyr-subsys-usb-hid-mouse/zephyr/CMakeLists.txt +++ b/examples/zephyr-subsys-usb-hid-mouse/zephyr/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(hid-keyboard) +project(hid-mouse) include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake) FILE(GLOB app_sources ../src/*.c) diff --git a/platform.json b/platform.json index e1c92cf9..bb69c768 100644 --- a/platform.json +++ b/platform.json @@ -298,7 +298,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~2.30700.0" + "version": "~2.40000.0" }, "tool-stm32duino": { "type": "uploader",