Skip to content

Commit

Permalink
Merge branch 'release/v7.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Nov 29, 2024
2 parents 8f79564 + 9610bf1 commit 0db6b6c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
python-version: "3.10"
- name: Install dependencies
run: |
pip install -U https://github.com/platformio/platformio/archive/develop.zip
Expand Down
5 changes: 5 additions & 0 deletions examples/zephyr-blink/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

Expand All @@ -22,6 +23,7 @@ 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;
Expand All @@ -37,6 +39,9 @@ int main(void)
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;
Expand Down
4 changes: 2 additions & 2 deletions examples/zephyr-blink/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
77 changes: 36 additions & 41 deletions examples/zephyr-synchronization/src/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* main.c - Hello World demo */
/* main.c - Synchronization demo */

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

/*
* The hello world demo has two threads that utilize semaphores and sleeping
* The synchronization demo has two threads that utilize semaphores and sleeping
* to take turns printing a greeting message at a controlled rate. The demo
* shows both the static and dynamic approaches for spawning a thread; a real
* world application would likely use the static approach for both threads.
Expand All @@ -33,8 +33,8 @@
* @param my_sem thread's own semaphore
* @param other_sem other thread's semaphore
*/
void helloLoop(const char *my_name,
struct k_sem *my_sem, struct k_sem *other_sem)
void hello_loop(const char *my_name,
struct k_sem *my_sem, struct k_sem *other_sem)
{
const char *tname;
uint8_t cpu;
Expand Down Expand Up @@ -68,66 +68,61 @@ void helloLoop(const char *my_name,
}

/* define semaphores */
K_SEM_DEFINE(thread_a_sem, 1, 1); /* starts off "available" */
K_SEM_DEFINE(thread_b_sem, 0, 1); /* starts off "not available" */

K_SEM_DEFINE(threadA_sem, 1, 1); /* starts off "available" */
K_SEM_DEFINE(threadB_sem, 0, 1); /* starts off "not available" */


/* threadB is a dynamic thread that is spawned by threadA */

void threadB(void *dummy1, void *dummy2, void *dummy3)
/* thread_a is a dynamic thread that is spawned in main */
void thread_a_entry_point(void *dummy1, void *dummy2, void *dummy3)
{
ARG_UNUSED(dummy1);
ARG_UNUSED(dummy2);
ARG_UNUSED(dummy3);

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

K_THREAD_STACK_DEFINE(threadA_stack_area, STACKSIZE);
static struct k_thread threadA_data;

K_THREAD_STACK_DEFINE(threadB_stack_area, STACKSIZE);
static struct k_thread threadB_data;

/* threadA is a static thread that is spawned automatically */

void threadA(void *dummy1, void *dummy2, void *dummy3)
/* thread_b is a static thread spawned immediately */
void thread_b_entry_point(void *dummy1, void *dummy2, void *dummy3)
{
ARG_UNUSED(dummy1);
ARG_UNUSED(dummy2);
ARG_UNUSED(dummy3);

/* invoke routine to ping-pong hello messages with threadB */
helloLoop(__func__, &threadA_sem, &threadB_sem);
/* invoke routine to ping-pong hello messages with thread_a */
hello_loop(__func__, &thread_b_sem, &thread_a_sem);
}
K_THREAD_DEFINE(thread_b, STACKSIZE,
thread_b_entry_point, NULL, NULL, NULL,
PRIORITY, 0, 0);
extern const k_tid_t thread_b;

int main(void)
{
k_thread_create(&threadA_data, threadA_stack_area,
K_THREAD_STACK_SIZEOF(threadA_stack_area),
threadA, NULL, NULL, NULL,
k_thread_create(&thread_a_data, thread_a_stack_area,
K_THREAD_STACK_SIZEOF(thread_a_stack_area),
thread_a_entry_point, NULL, NULL, NULL,
PRIORITY, 0, K_FOREVER);
k_thread_name_set(&threadA_data, "thread_a");
#if PIN_THREADS
if (arch_num_cpus() > 1) {
k_thread_cpu_pin(&threadA_data, 0);
}
#endif
k_thread_name_set(&thread_a_data, "thread_a");

k_thread_create(&threadB_data, threadB_stack_area,
K_THREAD_STACK_SIZEOF(threadB_stack_area),
threadB, NULL, NULL, NULL,
PRIORITY, 0, K_FOREVER);
k_thread_name_set(&threadB_data, "thread_b");
#if PIN_THREADS
if (arch_num_cpus() > 1) {
k_thread_cpu_pin(&threadB_data, 1);
k_thread_cpu_pin(&thread_a_data, 0);

/*
* Thread b is a static thread that is spawned immediately. This means that the
* following `k_thread_cpu_pin` call can fail with `-EINVAL` if the thread is
* actively running. Let's suspend the thread and resume it after the affinity mask
* is set.
*/
k_thread_suspend(thread_b);
k_thread_cpu_pin(thread_b, 1);
k_thread_resume(thread_b);
}
#endif

k_thread_start(&threadA_data);
k_thread_start(&threadB_data);
k_thread_start(&thread_a_data);
return 0;
}
5 changes: 2 additions & 3 deletions examples/zephyr-synchronization/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +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(synchronization)

target_sources(app PRIVATE ../src/main.c)
4 changes: 2 additions & 2 deletions platform.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "git",
"url": "https://github.com/platformio/platform-nxpimxrt.git"
},
"version": "6.3.0",
"version": "7.0.0",
"frameworks": {
"mbed": {
"package": "framework-mbed",
Expand Down Expand Up @@ -48,7 +48,7 @@
"type": "framework",
"optional": true,
"owner": "platformio",
"version": "~2.30700.0"
"version": "~2.40000.0"
},
"tool-openocd": {
"type": "debugger",
Expand Down

0 comments on commit 0db6b6c

Please sign in to comment.