Skip to content

Commit 6a4b320

Browse files
committed
Merge branch 'feature/z4' into develop
2 parents 810b08c + 5c0f918 commit 6a4b320

File tree

13 files changed

+101
-49
lines changed

13 files changed

+101
-49
lines changed

.github/workflows/examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Set up Python
5555
uses: actions/setup-python@v3
5656
with:
57-
python-version: "3.9"
57+
python-version: "3.10"
5858
- name: Install dependencies
5959
run: |
6060
pip install -U https://github.com/platformio/platformio/archive/develop.zip

examples/zephyr-blink/src/main.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <stdio.h>
78
#include <zephyr/kernel.h>
89
#include <zephyr/drivers/gpio.h>
910

1011
/* 1000 msec = 1 sec */
11-
#define SLEEP_TIME_MS 300
12+
#define SLEEP_TIME_MS 1000
1213

1314
/* The devicetree node identifier for the "led0" alias. */
1415
#define LED0_NODE DT_ALIAS(led0)
@@ -19,28 +20,29 @@
1920
*/
2021
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
2122

22-
void main(void)
23+
int main(void)
2324
{
2425
int ret;
26+
bool led_state = true;
2527

26-
if (!gpio_is_ready_dt(&led))
27-
{
28-
return;
28+
if (!gpio_is_ready_dt(&led)) {
29+
return 0;
2930
}
3031

3132
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
32-
if (ret < 0)
33-
{
34-
return;
33+
if (ret < 0) {
34+
return 0;
3535
}
3636

37-
while (1)
38-
{
37+
while (1) {
3938
ret = gpio_pin_toggle_dt(&led);
40-
if (ret < 0)
41-
{
42-
return;
39+
if (ret < 0) {
40+
return 0;
4341
}
42+
43+
led_state = !led_state;
44+
printf("LED state: %s\n", led_state ? "ON" : "OFF");
4445
k_msleep(SLEEP_TIME_MS);
4546
}
47+
return 0;
4648
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
55
project(blinky)
66

77
target_sources(app PRIVATE ../src/main.c)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
cmake_minimum_required(VERSION 3.13.1)
4-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
55
project(cpp_synchronization)
66

77
target_sources(app PRIVATE ../src/main.cpp)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
cmake_minimum_required(VERSION 3.13.1)
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(babbling)
46

5-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
6-
project(CAN)
7-
8-
target_sources(app PRIVATE ../src/main.c)
7+
FILE(GLOB app_sources ../src/*.c)
8+
target_sources(app PRIVATE ${app_sources})

examples/zephyr-net-https-client/src/main.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ static int connect_socket(sa_family_t family, const char *server, int port,
141141
LOG_ERR("Cannot connect to %s remote (%d)",
142142
family == AF_INET ? "IPv4" : "IPv6",
143143
-errno);
144+
close(*sock);
145+
*sock = -1;
144146
ret = -errno;
145147
}
146148

@@ -360,20 +362,23 @@ int main(void)
360362
{
361363
int iterations = CONFIG_NET_SAMPLE_SEND_ITERATIONS;
362364
int i = 0;
363-
int ret;
365+
int ret = 0;
364366

365367
while (iterations == 0 || i < iterations) {
366368
ret = run_queries();
367369
if (ret < 0) {
368-
exit(1);
370+
ret = 1;
371+
break;
369372
}
370373

371374
if (iterations > 0) {
372375
i++;
373376
if (i >= iterations) {
377+
ret = 0;
374378
break;
375379
}
376380
} else {
381+
ret = 0;
377382
break;
378383
}
379384
}
@@ -382,6 +387,6 @@ int main(void)
382387
k_sleep(K_FOREVER);
383388
}
384389

385-
exit(0);
386-
return 0;
390+
exit(ret);
391+
return ret;
387392
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
cmake_minimum_required(VERSION 3.13.1)
4-
5-
set (CONF_FILE "prj.conf overlay-tls.conf")
6-
7-
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
85
project(http_client)
96

107
FILE(GLOB app_sources ../src/*.c)
@@ -16,4 +13,4 @@ generate_inc_file_for_target(
1613
app
1714
../src/https-cert.der
1815
${gen_dir}/https-cert.der.inc
19-
)
16+
)

examples/zephyr-net-https-client/zephyr/prj.conf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# General config
2+
CONFIG_MAIN_STACK_SIZE=3072
3+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
4+
15
# Networking config
26
CONFIG_NETWORKING=y
37
CONFIG_NET_IPV4=y
@@ -7,12 +11,19 @@ CONFIG_NET_SHELL=y
711

812
# Sockets
913
CONFIG_NET_SOCKETS=y
10-
CONFIG_NET_SOCKETS_POSIX_NAMES=y
11-
CONFIG_NET_SOCKETS_POLL_MAX=4
14+
CONFIG_ZVFS_POLL_MAX=4
15+
CONFIG_POSIX_API=y
1216

1317
# Network driver config
1418
CONFIG_TEST_RANDOM_GENERATOR=y
1519

20+
# Network buffers
21+
CONFIG_NET_PKT_RX_COUNT=16
22+
CONFIG_NET_PKT_TX_COUNT=16
23+
CONFIG_NET_BUF_RX_COUNT=128
24+
CONFIG_NET_BUF_TX_COUNT=128
25+
CONFIG_NET_CONTEXT_NET_PKT_POOL=y
26+
1627
# Network address config
1728
CONFIG_NET_CONFIG_SETTINGS=y
1829
CONFIG_NET_CONFIG_NEED_IPV4=y
@@ -30,9 +41,8 @@ CONFIG_HTTP_CLIENT=y
3041

3142
# Network debug config
3243
CONFIG_LOG=y
33-
CONFIG_LOG_MODE_IMMEDIATE=y
3444
CONFIG_NET_LOG=y
3545
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
36-
CONFIG_NET_HTTP_LOG_LEVEL_DBG=y
37-
38-
CONFIG_MAIN_STACK_SIZE=2048
46+
CONFIG_NET_HTTP_LOG_LEVEL_DBG=n
47+
CONFIG_NET_IPV6_LOG_LEVEL_DBG=n
48+
CONFIG_NET_IPV6_ND_LOG_LEVEL_DBG=n
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2023 Nordic Semiconductor ASA.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H
8+
#define ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H
9+
10+
#include <stdint.h>
11+
#include <zephyr/usb/usbd.h>
12+
13+
/*
14+
* The scope of this header is limited to use in USB samples together with the
15+
* new experimental USB device stack, you should not use it in your own
16+
* application. However, you can use the code as a template.
17+
*/
18+
19+
/*
20+
* This function uses Kconfig.sample_usbd options to configure and initialize a
21+
* USB device. It configures sample's device context, default string descriptors,
22+
* USB device configuration, registers any available class instances, and
23+
* finally initializes USB device. It is limited to a single device with a
24+
* single configuration instantiated in sample_usbd_init.c, which should be
25+
* enough for a simple USB device sample.
26+
*
27+
* It returns the configured and initialized USB device context on success,
28+
* otherwise it returns NULL.
29+
*/
30+
struct usbd_context *sample_usbd_init_device(usbd_msg_cb_t msg_cb);
31+
32+
#endif /* ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H */

examples/zephyr-subsys-usb-hid-mouse/src/main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ static ALWAYS_INLINE void rwup_if_suspended(void)
5555
}
5656
}
5757

58-
static void input_cb(struct input_event *evt)
58+
static void input_cb(struct input_event *evt, void *user_data)
5959
{
6060
static uint8_t tmp[MOUSE_REPORT_COUNT];
6161

62+
ARG_UNUSED(user_data);
63+
6264
switch (evt->code) {
6365
case INPUT_KEY_0:
6466
rwup_if_suspended();
@@ -95,7 +97,7 @@ static void input_cb(struct input_event *evt)
9597

9698
}
9799

98-
INPUT_CALLBACK_DEFINE(NULL, input_cb);
100+
INPUT_CALLBACK_DEFINE(NULL, input_cb, NULL);
99101

100102
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
101103
static int enable_usb_device_next(void)
@@ -174,11 +176,11 @@ int main(void)
174176
}
175177

176178
while (true) {
177-
uint8_t __aligned(sizeof(void *)) report[MOUSE_REPORT_COUNT];
179+
UDC_STATIC_BUF_DEFINE(report, MOUSE_REPORT_COUNT);
178180

179181
k_msgq_get(&mouse_msgq, &report, K_FOREVER);
180182

181-
ret = hid_int_ep_write(hid_dev, report, sizeof(report), NULL);
183+
ret = hid_int_ep_write(hid_dev, report, MOUSE_REPORT_COUNT, NULL);
182184
if (ret) {
183185
LOG_ERR("HID write error, %d", ret);
184186
} else {

0 commit comments

Comments
 (0)