0.4.0: builds on Zephyr 4.5 as well as 4.4
This commit is contained in:
1 parent
144efe683e
commit
db6d584807
11 files changed
+95
-14
No files matched your search
@@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2026 Scott Penrose <scottp@dd.com.au>
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
||||
# Before Zephyr 4.5 the ring buffer is built only with CONFIG_RING_BUFFER;
|
||||
# from 4.5 it is header-only and that option is the deprecated legacy one.
|
||||
# The module's Kconfig is not used here: the bridge has no modem node.
|
||||
config BRIDGE_KERNEL_VERSION
|
||||
hex
|
||||
default "$(KERNELVERSION)"
|
||||
|
||||
config BRIDGE_RING_BUFFER
|
||||
def_bool y
|
||||
select RING_BUFFER if BRIDGE_KERNEL_VERSION < 0x4050000
|
||||
@@ -1,6 +1,5 @@
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||
CONFIG_RING_BUFFER=y
|
||||
# Both UARTs carry the bridged bytes; nothing else may print on them.
|
||||
CONFIG_CONSOLE=n
|
||||
CONFIG_UART_CONSOLE=n
|
||||
|
||||
@@ -24,7 +24,14 @@ static void isr(const struct device *dev, void *user)
|
||||
struct ring_buf *back = out == &to_target ? &to_host : &to_target;
|
||||
uint8_t b[64];
|
||||
|
||||
while (uart_irq_update(dev) && uart_irq_is_pending(dev)) {
|
||||
/* uart_irq_update() is void since Zephyr 4.5; the STM32, ESP32
|
||||
* and native drivers returned 1 from it before that. */
|
||||
while (true) {
|
||||
uart_irq_update(dev);
|
||||
if (uart_irq_is_pending(dev) <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (uart_irq_rx_ready(dev)) {
|
||||
int n = uart_fifo_read(dev, b, sizeof(b));
|
||||
|
||||
@@ -34,8 +41,11 @@ static void isr(const struct device *dev, void *user)
|
||||
}
|
||||
}
|
||||
if (uart_irq_tx_ready(dev)) {
|
||||
uint8_t *p;
|
||||
uint32_t n = ring_buf_get_claim(back, &p, 64);
|
||||
/* Peek, fill, then take what the FIFO took: the claim
|
||||
* API this used is legacy from Zephyr 4.5, and peek and
|
||||
* get are in both. */
|
||||
uint8_t t[64];
|
||||
uint32_t n = ring_buf_peek(back, t, sizeof(t));
|
||||
|
||||
if (n == 0) {
|
||||
/* The other port's ISR may have put bytes in `back`
|
||||
@@ -44,9 +54,11 @@ static void isr(const struct device *dev, void *user)
|
||||
* soon. Not worth a lock here. */
|
||||
uart_irq_tx_disable(dev);
|
||||
} else {
|
||||
int w = uart_fifo_fill(dev, p, n);
|
||||
int w = uart_fifo_fill(dev, t, n);
|
||||
|
||||
ring_buf_get_finish(back, w > 0 ? w : 0);
|
||||
if (w > 0) {
|
||||
ring_buf_get(back, t, (uint32_t)w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user