Skip to content

Commit 0db6b6c

Browse files
committed
Merge branch 'release/v7.0.0'
2 parents 8f79564 + 9610bf1 commit 0db6b6c

File tree

6 files changed

+48
-49
lines changed

6 files changed

+48
-49
lines changed

.github/workflows/examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up Python
2323
uses: actions/setup-python@v3
2424
with:
25-
python-version: "3.9"
25+
python-version: "3.10"
2626
- name: Install dependencies
2727
run: |
2828
pip install -U https://github.com/platformio/platformio/archive/develop.zip

examples/zephyr-blink/src/main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
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

@@ -22,6 +23,7 @@ static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
2223
int main(void)
2324
{
2425
int ret;
26+
bool led_state = true;
2527

2628
if (!gpio_is_ready_dt(&led)) {
2729
return 0;
@@ -37,6 +39,9 @@ int main(void)
3739
if (ret < 0) {
3840
return 0;
3941
}
42+
43+
led_state = !led_state;
44+
printf("LED state: %s\n", led_state ? "ON" : "OFF");
4045
k_msleep(SLEEP_TIME_MS);
4146
}
4247
return 0;
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)

examples/zephyr-synchronization/src/main.c

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* main.c - Hello World demo */
1+
/* main.c - Synchronization demo */
22

33
/*
44
* Copyright (c) 2012-2014 Wind River Systems, Inc.
@@ -10,7 +10,7 @@
1010
#include <zephyr/sys/printk.h>
1111

1212
/*
13-
* The hello world demo has two threads that utilize semaphores and sleeping
13+
* The synchronization demo has two threads that utilize semaphores and sleeping
1414
* to take turns printing a greeting message at a controlled rate. The demo
1515
* shows both the static and dynamic approaches for spawning a thread; a real
1616
* world application would likely use the static approach for both threads.
@@ -33,8 +33,8 @@
3333
* @param my_sem thread's own semaphore
3434
* @param other_sem other thread's semaphore
3535
*/
36-
void helloLoop(const char *my_name,
37-
struct k_sem *my_sem, struct k_sem *other_sem)
36+
void hello_loop(const char *my_name,
37+
struct k_sem *my_sem, struct k_sem *other_sem)
3838
{
3939
const char *tname;
4040
uint8_t cpu;
@@ -68,66 +68,61 @@ void helloLoop(const char *my_name,
6868
}
6969

7070
/* define semaphores */
71+
K_SEM_DEFINE(thread_a_sem, 1, 1); /* starts off "available" */
72+
K_SEM_DEFINE(thread_b_sem, 0, 1); /* starts off "not available" */
7173

72-
K_SEM_DEFINE(threadA_sem, 1, 1); /* starts off "available" */
73-
K_SEM_DEFINE(threadB_sem, 0, 1); /* starts off "not available" */
74-
75-
76-
/* threadB is a dynamic thread that is spawned by threadA */
77-
78-
void threadB(void *dummy1, void *dummy2, void *dummy3)
74+
/* thread_a is a dynamic thread that is spawned in main */
75+
void thread_a_entry_point(void *dummy1, void *dummy2, void *dummy3)
7976
{
8077
ARG_UNUSED(dummy1);
8178
ARG_UNUSED(dummy2);
8279
ARG_UNUSED(dummy3);
8380

84-
/* invoke routine to ping-pong hello messages with threadA */
85-
helloLoop(__func__, &threadB_sem, &threadA_sem);
81+
/* invoke routine to ping-pong hello messages with thread_b */
82+
hello_loop(__func__, &thread_a_sem, &thread_b_sem);
8683
}
84+
K_THREAD_STACK_DEFINE(thread_a_stack_area, STACKSIZE);
85+
static struct k_thread thread_a_data;
8786

88-
K_THREAD_STACK_DEFINE(threadA_stack_area, STACKSIZE);
89-
static struct k_thread threadA_data;
90-
91-
K_THREAD_STACK_DEFINE(threadB_stack_area, STACKSIZE);
92-
static struct k_thread threadB_data;
93-
94-
/* threadA is a static thread that is spawned automatically */
95-
96-
void threadA(void *dummy1, void *dummy2, void *dummy3)
87+
/* thread_b is a static thread spawned immediately */
88+
void thread_b_entry_point(void *dummy1, void *dummy2, void *dummy3)
9789
{
9890
ARG_UNUSED(dummy1);
9991
ARG_UNUSED(dummy2);
10092
ARG_UNUSED(dummy3);
10193

102-
/* invoke routine to ping-pong hello messages with threadB */
103-
helloLoop(__func__, &threadA_sem, &threadB_sem);
94+
/* invoke routine to ping-pong hello messages with thread_a */
95+
hello_loop(__func__, &thread_b_sem, &thread_a_sem);
10496
}
97+
K_THREAD_DEFINE(thread_b, STACKSIZE,
98+
thread_b_entry_point, NULL, NULL, NULL,
99+
PRIORITY, 0, 0);
100+
extern const k_tid_t thread_b;
105101

106102
int main(void)
107103
{
108-
k_thread_create(&threadA_data, threadA_stack_area,
109-
K_THREAD_STACK_SIZEOF(threadA_stack_area),
110-
threadA, NULL, NULL, NULL,
104+
k_thread_create(&thread_a_data, thread_a_stack_area,
105+
K_THREAD_STACK_SIZEOF(thread_a_stack_area),
106+
thread_a_entry_point, NULL, NULL, NULL,
111107
PRIORITY, 0, K_FOREVER);
112-
k_thread_name_set(&threadA_data, "thread_a");
113-
#if PIN_THREADS
114-
if (arch_num_cpus() > 1) {
115-
k_thread_cpu_pin(&threadA_data, 0);
116-
}
117-
#endif
108+
k_thread_name_set(&thread_a_data, "thread_a");
118109

119-
k_thread_create(&threadB_data, threadB_stack_area,
120-
K_THREAD_STACK_SIZEOF(threadB_stack_area),
121-
threadB, NULL, NULL, NULL,
122-
PRIORITY, 0, K_FOREVER);
123-
k_thread_name_set(&threadB_data, "thread_b");
124110
#if PIN_THREADS
125111
if (arch_num_cpus() > 1) {
126-
k_thread_cpu_pin(&threadB_data, 1);
112+
k_thread_cpu_pin(&thread_a_data, 0);
113+
114+
/*
115+
* Thread b is a static thread that is spawned immediately. This means that the
116+
* following `k_thread_cpu_pin` call can fail with `-EINVAL` if the thread is
117+
* actively running. Let's suspend the thread and resume it after the affinity mask
118+
* is set.
119+
*/
120+
k_thread_suspend(thread_b);
121+
k_thread_cpu_pin(thread_b, 1);
122+
k_thread_resume(thread_b);
127123
}
128124
#endif
129125

130-
k_thread_start(&threadA_data);
131-
k_thread_start(&threadB_data);
126+
k_thread_start(&thread_a_data);
132127
return 0;
133128
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
cmake_minimum_required(VERSION 3.13.1)
4-
5-
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})
65
project(synchronization)
76

87
target_sources(app PRIVATE ../src/main.c)

platform.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"type": "git",
1919
"url": "https://github.com/platformio/platform-nxpimxrt.git"
2020
},
21-
"version": "6.3.0",
21+
"version": "7.0.0",
2222
"frameworks": {
2323
"mbed": {
2424
"package": "framework-mbed",
@@ -48,7 +48,7 @@
4848
"type": "framework",
4949
"optional": true,
5050
"owner": "platformio",
51-
"version": "~2.30700.0"
51+
"version": "~2.40000.0"
5252
},
5353
"tool-openocd": {
5454
"type": "debugger",

0 commit comments

Comments
 (0)