Skip to content

Commit

Permalink
Update Zephyr to v3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Sep 29, 2023
1 parent e74bdd6 commit f7a0f68
Show file tree
Hide file tree
Showing 26 changed files with 284 additions and 1,021 deletions.
5 changes: 5 additions & 0 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
else:
target_elf = env.BuildProgram()
target_firm = env.ElfToBin(join("$BUILD_DIR", "${PROGNAME}"), target_elf)

if "zephyr" in frameworks and "mcuboot-image" in COMMAND_LINE_TARGETS:
target_firm = env.MCUbootImage(
join("$BUILD_DIR", "${PROGNAME}.mcuboot.bin"), target_firm)

env.Depends(target_firm, "checkprogsize")

AlwaysBuild(env.Alias("nobuild", target_firm))
Expand Down
45 changes: 20 additions & 25 deletions examples/zephyr-blink/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,43 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>

/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS 1000
#define SLEEP_TIME_MS 300

/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)

#if DT_NODE_HAS_STATUS(LED0_NODE, okay)
#define LED0 DT_GPIO_LABEL(LED0_NODE, gpios)
#define PIN DT_GPIO_PIN(LED0_NODE, gpios)
#define FLAGS DT_GPIO_FLAGS(LED0_NODE, gpios)
#else
/* A build error here means your board isn't set up to blink an LED. */
#error "Unsupported board: led0 devicetree alias is not defined"
#define LED0 ""
#define PIN 0
#define FLAGS 0
#endif
/*
* 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);

void main(void)
{
const struct device *dev;
bool led_is_on = true;
int ret;

dev = device_get_binding(LED0);
if (dev == NULL) {
if (!gpio_is_ready_dt(&led))
{
return;
}

ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
if (ret < 0) {
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
if (ret < 0)
{
return;
}

while (1) {
gpio_pin_set(dev, PIN, (int)led_is_on);
led_is_on = !led_is_on;
while (1)
{
ret = gpio_pin_toggle_dt(&led);
if (ret < 0)
{
return;
}
k_msleep(SLEEP_TIME_MS);
}
}
2 changes: 1 addition & 1 deletion examples/zephyr-blink/zephyr/prj.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# nothing here
CONFIG_GPIO=y
11 changes: 4 additions & 7 deletions examples/zephyr-cpp-synchronization/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
*/

#include <stdio.h>
#include <zephyr.h>
#include <arch/cpu.h>
#include <sys/printk.h>
#include <zephyr/kernel.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/sys/printk.h>

/**
* @class semaphore the basic pure virtual semaphore class
Expand Down Expand Up @@ -64,7 +64,7 @@ class cpp_semaphore: public semaphore {
cpp_semaphore::cpp_semaphore()
{
printk("Create semaphore %p\n", this);
k_sem_init(&_sema_internal, 0, UINT_MAX);
k_sem_init(&_sema_internal, 0, K_SEM_MAX_LIMIT);
}

/*
Expand Down Expand Up @@ -98,12 +98,9 @@ int cpp_semaphore::wait(int timeout)
}

/**
*
* @brief Signal a semaphore
*
* This routine signals the specified semaphore.
*
* @return N/A
*/
void cpp_semaphore::give(void)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/zephyr-cpp-synchronization/zephyr/prj.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CONFIG_CPLUSPLUS=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=128
CONFIG_CPP=y
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=128
Loading

0 comments on commit f7a0f68

Please sign in to comment.