Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Improvements for newer Zephyr versions #170

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
#ifndef _U_SECTIONS_ZEPHYR_H_
#define _U_SECTIONS_ZEPHYR_H_

#include <version.h>

/* No other #includes allowed here. */
#include "linker/linker-defs.h"
#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/linker/linker-defs.h>
#else
#include <linker/linker-defs.h>
#endif

/** @file
* @brief This file is internally used to map Zephyr linker sections.
Expand Down
9 changes: 8 additions & 1 deletion port/platform/common/debug_utils/src/zephyr/u_dump_threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
/** @file
* @brief Thread dumper for Zephyr.
*/
#include "kernel.h"

#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#else
#include <kernel.h>
#endif

/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
Expand Down
2 changes: 1 addition & 1 deletion port/platform/zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ zephyr_include_directories(
cfg
src
${UBXLIB_BASE}/port/clib
${ZEPHYR_BASE}/include/zephyr
${ZEPHYR_BASE}/include
)

# Add any compile options that came out of ubxlib.cmake
Expand Down
8 changes: 7 additions & 1 deletion port/platform/zephyr/app/u_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
#include "u_port_debug.h"
#include "u_port_os.h"

#include "kernel.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#else
#include <kernel.h>
#endif

#ifdef CONFIG_ARCH_POSIX
#include "posix_board_if.h"
Expand Down
14 changes: 9 additions & 5 deletions port/platform/zephyr/cfg/u_cfg_app_platform_specific.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
#ifndef _U_CFG_APP_PLATFORM_SPECIFIC_H_
#define _U_CFG_APP_PLATFORM_SPECIFIC_H_

/* This inclusion is required to get the UART CTS/RTS pin assignments
* from the Zephyr device tree.
/* This inclusion is required to get the Zephyr version.
*/
#include "devicetree.h"
#include <version.h>

/* This inclusion is required to get the Zephyr version.
/* This inclusion is required to get the UART CTS/RTS pin assignments
* from the Zephyr device tree.
*/
#include "version.h"
#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/devicetree.h>
#else
#include <devicetree.h>
#endif

/** @file
* @brief This header file contains configuration information for
Expand Down
8 changes: 6 additions & 2 deletions port/platform/zephyr/cfg/u_cfg_test_platform_specific.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
* for the module is likely different to that from the MCU: check the
* data sheet for the module to determine the mapping.
*/
#include "devicetree.h"
#include <version.h> // For KERNEL_VERSION_MAJOR
#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/devicetree.h>
#else
#include <devicetree.h>
#endif
#include "u_runner.h"
#include "u_port_clib_platform_specific.h" // For rand
#include "version.h" // For KERNEL_VERSION_MAJOR

/** @file
* @brief Porting layer and configuration items passed in at application
Expand Down
14 changes: 13 additions & 1 deletion port/platform/zephyr/src/u_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@
#include "u_port_event_queue_private.h"
#include "u_port_private.h"

#include "kernel.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#else
#include <kernel.h>
#include <device.h>
#endif

/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
Expand Down Expand Up @@ -182,9 +189,14 @@ int32_t uPortGetTimezoneOffsetSeconds()
return offset;
}

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,4,0)
static int ubxlib_preinit(void)
{
#else
static int ubxlib_preinit(const struct device *arg)
{
ARG_UNUSED(arg);
#endif

k_thread_system_pool_assign(k_current_get());
return 0;
Expand Down
13 changes: 12 additions & 1 deletion port/platform/zephyr/src/u_port_clib.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@
# include "u_cfg_override.h" // For a customer's configuration override
#endif

#include "random/rand32.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,5,0)
#include <zephyr/random/random.h>
#else
#include <zephyr/random/rand32.h>
#endif
#else
#include <random/rand32.h>
#endif

#include "string.h"

#include "u_assert.h"
Expand Down
8 changes: 7 additions & 1 deletion port/platform/zephyr/src/u_port_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@

#include "u_error_common.h"

#include "sys/printk.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/sys/printk.h>
#else
#include <sys/printk.h>
#endif

/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
Expand Down
16 changes: 15 additions & 1 deletion port/platform/zephyr/src/u_port_gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@

#ifdef CONFIG_BT

#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#else
#include <zephyr/types.h>
#include <kernel.h>

#include <device.h>
#endif

#include <soc.h>

#include "stddef.h" // NULL, size_t etc.
Expand All @@ -44,9 +52,15 @@
#include "u_port_os.h"
#include "u_port_event_queue.h"

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/bluetooth/gatt.h>
#else
#include <bluetooth/conn.h>
#include <bluetooth/uuid.h>
#include <bluetooth/gatt.h>
#endif

#include "string.h" // For memcpy()

Expand Down
15 changes: 11 additions & 4 deletions port/platform/zephyr/src/u_port_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
#include "u_port_os.h" // Needed by u_port_private.h
#include "u_port_gpio.h"

#include "kernel.h"
#include "device.h"
#include "drivers/gpio.h"
#include "version.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#else
#include <kernel.h>
#include <device.h>
#include <drivers/gpio.h>
#endif

#include "u_port_private.h" // Down here because it needs to know about the Zephyr device tree

Expand Down
12 changes: 10 additions & 2 deletions port/platform/zephyr/src/u_port_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@
* @brief Implementation of the port I2C API for the Zephyr platform.
*/

#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/i2c.h>
#else
#include <zephyr/types.h>
#include <kernel.h>
#include <device.h>
#include <drivers/i2c.h>
#endif

#include <device.h>
#include <soc.h>

#include "stddef.h"
Expand All @@ -37,7 +46,6 @@
#include "u_port_os.h"
#include "u_cfg_os_platform_specific.h"
#include "u_port_i2c.h"
#include "version.h"

/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
Expand Down
9 changes: 8 additions & 1 deletion port/platform/zephyr/src/u_port_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@
#include "u_port.h"
#include "u_port_os.h"

#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#else
#include <kernel.h>
#include "device.h"
#include <device.h>
#endif

#include "u_port_private.h" // Down here because it needs to know about the Zephyr device tree

Expand Down
15 changes: 11 additions & 4 deletions port/platform/zephyr/src/u_port_private.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,17 @@
#include "u_port_heap.h"
#include "u_port_event_queue.h"

#include "kernel.h"
#include "device.h"
#include "drivers/gpio.h"
#include "version.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#else
#include <kernel.h>
#include <device.h>
#include <drivers/gpio.h>
#endif

#include "u_port_private.h" // Down here because it needs to know about the Zephyr device tree

Expand Down
14 changes: 12 additions & 2 deletions port/platform/zephyr/src/u_port_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@
* @brief Implementation of the port SPI API for the Zephyr platform.
*/

#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/devicetree/spi.h>
#else
#include <zephyr/types.h>
#include <kernel.h>
#include <device.h>
#include <drivers/spi.h>
#include <drivers/gpio.h>
#include <devicetree/spi.h>
#endif

#include <device.h>
#include <soc.h>

#include "stddef.h"
Expand All @@ -44,7 +55,6 @@
#include "u_port_spi.h"
#include "u_port_private.h"
#include "u_cfg_os_platform_specific.h"
#include "version.h"

/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
Expand Down
12 changes: 10 additions & 2 deletions port/platform/zephyr/src/u_port_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@
# include "u_cfg_override.h" // For a customer's configuration override
#endif

#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/uart.h>
#else
#include <zephyr/types.h>
#include <kernel.h>
#include <device.h>
#include <drivers/uart.h>
#endif

#include <device.h>
#include <soc.h>

#include "stddef.h" // NULL, size_t etc.
Expand All @@ -50,7 +59,6 @@
#include "u_port_os.h"
#include "u_port_event_queue.h"
#include "u_port_uart.h"
#include "version.h"

#include "string.h" // For memcpy()

Expand Down
9 changes: 7 additions & 2 deletions port/test/u_port_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@

#include "u_test_util_resource_check.h"

#ifdef CONFIG_IRQ_OFFLOAD
# include <irq_offload.h> // To test semaphore from ISR in zephyr
#ifdef CONFIG_IRQ_OFFLOAD // To test semaphore from ISR in zephyr
#include <version.h>
#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/irq_offload.h>
#else
#include <irq_offload.h>
#endif
#endif

/* ----------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion zephyr/test/u_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@

#include "u_cfg_app_platform_specific.h"

#include "kernel.h"
#include <version.h>

#if KERNEL_VERSION_NUMBER >= ZEPHYR_VERSION(3,1,0)
#include <zephyr/kernel.h>
#else
#include <kernel.h>
#endif

/* ----------------------------------------------------------------
* COMPILE-TIME MACROS
Expand Down