The driver left BURST_LENGTH at the word size and put one frame in each
burst, so a burst carried 8 of the 32 bits a Tx FIFO word holds and cost
an interrupt of its own. A burst is also the controller's chip-select
window, so on the native chip select the CS framed single frames and
dropped in between, which no device expecting a held chip select can use.
Set the burst length per transfer and pack as many frames as fit into the
FIFO word the transfer already writes. A chip-select window now spans up
to 32 bits and raises one interrupt. Any word size up to 32 bits packs,
the frames becoming fields of that word. Longer transfers still split
into 32-bit bursts; spreading a burst over several FIFO words needs a
different alignment rule and is left to a follow-up.
Each frame is masked to the word size on its way into a field, keeping a
caller's spare container bits out of the neighbouring frame; on receive
those bits are now zero where they previously held whatever the received
word carried above the frame width. The frames of a burst also go out
back to back, where each used to be separated by the inter-burst delay:
word_delay is not implemented here, and implementing it would need
PERIODREG and one frame per burst again.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Marvin Gnad <marvin.gnad@gmail.com>
Each direction picks its load or store width from the data frame
size with a switch of its own, inline where the frame is moved.
Give each direction a helper instead, so that moving more than one
frame does not nest a switch inside a loop.
No functional change intended.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Marvin Gnad <marvin.gnad@gmail.com>
PACs require at least 1 ms after a REFRESH per the
Microchip PAC194x/195x datasheet.
Wait 2 ms after refresh operations during channel
enablement to ensure each PAC finishes its refresh cycle
before the next channel on the same PAC is configured.
Signed-off-by: Daniel Balint <dbalint@google.com>
In 2x2 binning, HMAX 0x0280 and 0x0140 give 25.78 and 51.56 fps
instead of 25 and 50. Sony datasheet E18112A84 corrects them to
0x0294 and 0x014A (p.57, revision history p.97), which give 25.00
and 50.00 fps.
Signed-off-by: Kirill Shypachov <kshypachov@outlook.com>
regset_target_lib_buf_read_requested() returns a pointer into the
buffer starting at buffer_idx, but reports the full buffer_size as
the available length rather than the bytes remaining from that
offset to the end of the buffer. When buffer_idx is non-zero, the
I2C controller driver is told it may read buffer_size bytes from
&buffer[buffer_idx], which runs buffer_idx bytes past the end of
the buffer.
Report buffer_size - buffer_idx instead, matching the pointer that
is actually returned.
This code used to live in eeprom_target.c and moved here unchanged
when the register set handling was split out into this library.
Fixes#110548
Signed-off-by: yi chen <94xhn1@gmail.com>
Assisted-by: Claude:claude-opus-5-5
spi_cs_is_gpio() checks the cs_is_gpio flag of the configuration since
commit a60f93d742 ("include: drivers: spi.h: Get CS delay parameters
from DT"), and the spi cs command never set it, so the chip select was
left inactive during spi transceive. Set the flag along with the GPIO.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
The ip register reports the watermark conditions regardless of the ie
register, so with the TX FIFO empty and the TX interrupt disabled
uart_irq_is_pending() kept returning 1 and callbacks that loop until
nothing is pending never terminated. Mask ip with ie.
Fixes the test_uart_pending case of tests/drivers/uart/uart_basic_api,
run on qemu_riscv32_xip.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The ETHERNET_CONFIG_TYPE_MAC_ADDRESS case of set_config returned
while still holding dev_cfg_lock, so every later set_config call
from another thread blocked forever. Leave the switch with break so
the mutex is released.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The members of struct net_if are internal to the network subsystem.
Get the interface configuration through net_if_get_config() instead of
accessing the config member directly.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The members of struct net_if are internal to the network subsystem.
Get the interface configuration through net_if_get_config() instead of
accessing iface->config directly.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
The TX and RX frame buffers are sized from the MTU plus the plain
Ethernet header, but the L2 layer can prepend a VLAN or a DSA tag to a
maximum-size frame. With CONFIG_NET_VLAN, a tagged frame is four bytes
longer than the buffers: it does not fit the receive buffer, and it
overruns the TX buffer.
Size the buffers from NET_ETH_MAX_FRAME_SIZE, which includes both tags.
The size is unchanged when neither option is enabled.
Fixes: 91ac587124 ("drivers: ethernet: Add VIRTIO Network Device")
Fixes#122778
Signed-off-by: Chao Liu <chao.liu@processmission.com>
The reset and pwdn initializer macros were guarded with
DT_ANY_INST_HAS_PROP_STATUS_OKAY(), which is evaluated while
DT_DRV_COMPAT is still ovti_ov7670. When only an ovti,ov7675 node
is enabled, the guards are false, the config struct gets no
reset/pwdn entries and the pins from devicetree are never driven.
Check both compatibles, as the config struct definition already
does.
Found with an OV7675 on an ESP32-DevKitC: the preprocessed config
initializer had no .pwdn member although the node sets pwdn-gpios.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Wojciech Jakubiszyn <wojtekjakubiszyn@gmail.com>
This PR adds dynamic retuning of PLL1 used as a SAI clock source
for MCXN, depending on the requested SAI MCLK. This allows to
accurately support both 44.1kHz and 48kHz sample rate families.
PLL1 is configured to run in fractional mode to minimize bit clock
errors caused by inexact MCLK frequency.
Signed-off-by: Marcin Lyda <elektromarcin@gmail.com>
With CONFIG_I2C_RTIO enabled, the driver API table has no iodev_submit
entry, so i2c_iodev_submit() completes every request with -ENOSYS. This
causes a test failure in the i2c_ram test when running RTIO test
scenarios.
Correct this by setting iodev_submit to i2c_iodev_submit_fallback, which
will run each request through the blocking transfer() call on the RTIO
work queue.
Assisted-by: Copilot:claude-opus-5.5
Signed-off-by: John Batch <john.batch@infineon.com>
CONFIG_ESP_CONSOLE_UART_NUM default value is `-1`. This value will
not change when USB CDC ACM UART is used, for instance.
Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
Record the script each state starts and drop a script result that is
not from it, clearing the record on every state change.
Drop the per-state checks for a non-periodic script result, which the
record covers.
Signed-off-by: Paulo Santos <pauloxrms@gmail.com>
mcux_lpuart_poll_out() waited for the transmit data register to be empty
with interrupts locked, which holds them off for up to a character time.
It now waits with interrupts enabled, and locks them only to check again
and write the character.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
Initialize rx_buf, rx_buf_len, rx_buf_offset, rx_buf_data_len, rx_en,
written, and rx_stopping at declaration. These are always assigned
before use on every path, but static analysis cannot prove this
through the K_SPINLOCK for-loop construct, producing false-positive
uninitialized-read warnings (MISRA C:2012 Rule 9.1).
No functional change.
Signed-off-by: Dominika Kubicz <dominika.kubicz@gmail.com>
With CONFIG_MCUMGR_TRANSPORT_UART_ASYNC, an RX error (overrun, parity,
framing or break) stops reception and the UART driver reports
UART_RX_DISABLED. The callback only reset the buffer index and never
called uart_rx_enable() again, so MCUmgr stopped receiving until reset.
Restart reception with the first buffer on UART_RX_DISABLED, as at
registration. This driver never disables RX itself, so the event only
follows a stop it did not request.
Fixes#122468
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
When a transaction ends, CS must be cleared if SPI_HOLD_ON_CS is
not set, before the next transaction starts. Currently CS is only
cleared if there is no pending transaction.
Update iodev_end_txn() to clear CS if not SPI_HOLD_ON_CS, regardless
of whether a transaction is pending.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
A USB bus reset leaves data already in the USB Serial/JTAG IN
FIFO uncommitted: the FIFO is not marked free and the data is
never sent. The host resets the bus several times while
enumerating, so output written before or during enumeration can
stall TX for good while RX keeps working. Whether it hits depends
on boot timing.
Flush the IN FIFO in poll_out() when it is not writable. In
interrupt mode, arm the EP1 IN token interrupt on each bus reset
and flush on the first token, once the host is reading.
Assisted-by: Claude:opus-5
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Properly release USB buffers when failing to initiate read/writes for a
given endpoint, to be sure they are not leaked.
Signed-off-by: Pete Johanson <pete.johanson@analog.com>
i3g4250d_convert() has two problems since the driver was added in
commit c9f87969c2 ("drivers: sensor: add I3G4250D Gyro driver"):
- It reports degrees per second. The sensor API defines the gyro
channels in rad/s.
- It casts raw_value * 8750 to int16_t before taking the fractional
part, which truncates the product for any |raw_value| > 3. For
example, raw_value 1000 (8.75 dps) gives val1 8 and val2 -31824.
Convert the sensitivity in udps/LSB to 10 udps and use
sensor_10udegrees_to_rad(), as the other ST gyro drivers do.
Tested on stm32f3_disco@E with samples/sensor/i3g4250d and the SPI fix
from #120319 applied: all axes read within 0.005 rad/s at rest, and a
quick quarter turn peaks near 3 rad/s. The conversion was also checked
on the host against the exact values for raw inputs from -32768 to
32767.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Seyoung Jeong <seyoungjeong@gmail.com>
commit f9de2777d9 ("drivers: sensor: i3g4250d: migrate SPI support
to stmemsc") replaced the driver's own SPI read, which set bits 7 and 6
(0xC0) of the register address, with STMEMSC_CTX_SPI, which sets only
bit 7. Without bit 6 the I3G4250D does not auto-increment the register
address, so the 6-byte read starting at OUT_X_L returns OUT_X_L six
times and all three axes report the same value.
Use STMEMSC_CTX_SPI_INCR, which sets bit 6 for multi-byte transfers.
Tested on stm32f3_disco@E: before the change, SENSOR_CHAN_GYRO_XYZ
returned the same value on all three axes; after it, each axis reads a
distinct value near zero with the board at rest.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Seyoung Jeong <seyoungjeong@gmail.com>
SIFIVE_PERIPHERAL_CLOCK_FREQUENCY is the same for every instance, so
use it directly when computing the baud rate divisor instead of
storing a copy in each device config.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
On the ESP32-P4, ESP32-C5, and ESP32-C61, the first 16
software-table entries are reserved. The handler for CPU line N is
stored at entry N + 16. The allocation check still looked at entry N,
so the handler for a low line occupied the slot checked for a high
line. Once the low lines were in use, the high lines looked taken and
allocation failed.
Add the reserved offset when checking whether a line has a handler.
Assisted-by: Grok:4.7
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
For interrupt-driven transfers, PM must be locked until data has
been fully shifted out. Postpone releasing the PM lock until TXC
is reported.
Split handling of TXBL and TXC such that TXBL maps to the user-facing
callback, while TXC is only used internally in the driver. Only handle
TXC and RXOF in the async ISR when an async transfer is active, so the
interrupt-driven API receives them otherwise.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
If the first RX buffer was filled as soon as the DMA started, the DMA
callback could report UART_RX_DISABLED before rx_enable() emitted
UART_RX_BUF_REQUEST, so the request arrived for a disabled receiver.
Lock interrupts from enabling the RX interrupts until the buffer request
has been emitted, so the DMA completion is handled after the request and
can use a buffer provided in response to it. This also keeps an RX
overflow interrupt from disabling RX before the DMA is started.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
If a transfer had completed but its interrupt had not been handled yet,
silabs_ldma_append_block() restarted the channel with the new descriptor
and cleared the pending interrupt. The completion of the previous block
was then never reported.
Link the new descriptor in this case as well. The interrupt handler
reports the completion and then loads the linked descriptor.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The interrupt handler cleared the CHDONE bit of a channel before
loading its linked descriptor with a read-modify-write of CHDONE,
which is shared by all channels. If another channel completed between
the read and the write, its done flag was lost, and
dma_get_status() then reported a non-zero remaining length for a
completed transfer.
Use the CHDONE_CLR register to clear only the flag of the channel
being handled.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
RX could complete in the DMA callback before rx_enable() enabled the
RX overflow and timeout interrupts, leaving them enabled while RX was
disabled.
Enable the interrupts before starting the DMA, and disable them again
if the DMA fails to start.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
When the RX DMA buffer was filled and no next buffer was provided, the
DMA callback stopped RX and reported UART_RX_DISABLED, but left the RXOF
and TCMP1 interrupts enabled. A later overrun or receive timeout then
raised async events for a receiver that was already disabled.
Assisted-by: Claude:claude-opus-5.5
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
The I2C peripheral core was left enabled during PM device suspend,
while the bus clock was gated.
In some scenarios this would cause the peripheral to block deep
sleep.
Safely disable the peripheral upon suspend and re-enable it in
resume.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
RQCP flags in the bxCAN TSR register are write-one-to-clear. Using a
read-modify-write operation can write back completion flags for other
mailboxes that were observed as set, clearing them before their callbacks
run. Write only the current mailbox request-complete flag when
acknowledging each completion.
Signed-off-by: Zewen Zhu <963052936@qq.com>
STM32 series F2, F4 and F7 handle differently their channel number value
from other series. Since the channel number is not directly the field
value, the value from `struct dma_config->dma_slot` to `struct
DMA_InitTypeDef->Channel` needs to be translated.
While at it, correct the pre-processor condition in order to reflect
this and ease the review. Previous condition was confusing and hard for
interpretation.
Signed-off-by: Raphaël Gallais-Pou <raphael.gallais-pou@foss.st.com>
The decoder of the driver only decodes FIFO data, but was also given for
the samples that sensor_read() gets with the default submit, which it
can't decode. Without the stream, give no decoder, so that the default
decoder is used.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
After the soft reset, the sensor is in advanced power save mode, which
ignores accesses less than 450 us apart. Wait between the read and the
write of PWR_CONF, so that the write isn't ignored and the configuration
file is loaded.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-5.5
cache_data_invd_all() invalidated every data-cache line through
XCACHE_InvalidateCache(). On SoCs where XCACHE sits in front of the
SRAM that holds the running stack (i.MX RT700, i.MX RT1180), that
drops the dirty lines backing live stack state and corrupts the
system: the arch.cache.api test (tests/arch/common/cache) starts
test_data_cache_api and never returns, which upstream CI reports
as a timeout / Unknown Error.
Flushing right before the invalidate does not make it safe. The
whole-cache invalidate is a separate call, and the stack is dirtied
again in between, so the live data is still lost. The Arm Cortex-M
L1 backend returns -ENOTSUP from arch_dcache_invd_all() for the same
reason (arch/arm/core/cortex_m/cache.c).
Return -ENOTSUP here as well instead of corrupting memory. The test
accepts -ENOTSUP, and callers that must drop a specific buffer still
use cache_data_invd_range(). The whole-cache flush and
flush-and-invalidate ops are unaffected: they write dirty lines back
first.
Verified on mimxrt700_evk/mimxrt798s/cm33_cpu0 via the Dapeng board
farm: all three cache_api tests pass and the suite prints PROJECT
EXECUTION SUCCESSFUL. frdm_imxrt1186/mimxrt1186/cm33 uses the same
driver and code path.
Fixes#116719
Signed-off-by: Holt Sun <holt.sun@nxp.com>
The driver wrote one 16-bit sample per active channel into the sequence
buffer without checking that the buffer could hold them, so a too small
buffer was accepted and overflowed.
Validate the buffer against the active channel count before starting a
read and return -ENOMEM when it is too small.
Fixes#115285
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Disable the EOT and DXP interrupt before starting a transfer.
This is re-added here to solve #122018.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
The PWT reports a partial measurement on the first pulse-width-ready
event after the timer starts: capture is enabled asynchronously to the
input signal, so it can begin mid-pulse and one of the two pulse-width
registers only times a fraction of its phase. Which register is short
depends on the phase alignment at enable time, so single-shot captures
failed intermittently (~80% in CI) and period capture, which needs
both the positive and negative width, failed outright.
Two changes fix this:
- Keep enableFirstCounterLoad disabled (the HAL default). With it set,
the PWT loads that first incomplete measurement, where the negative
pulse width reads ~0 because PWTRDY fires after the first positive
pulse but before a full negative pulse has been timed.
- Track a first_sample flag per capture and drop the first PWTRDY event
in the ISR, reporting the next one instead. The second event always
spans a complete positive and negative phase, so both pulse-width
registers hold full measurements regardless of enable-time alignment.
Verified on FRDM-KE17Z (frdm_ke17z/mke17z7) with a PTB14->PTE11
loopback: tests/drivers/pwm/pwm_loopback now passes all capture
subtests across 6 consecutive runs (previously ~80% probabilistic
failure on the pulse/period inverted subtests).
Fixes#114920
Assisted-by: Vero-Coder:claude-opus-4-8
Signed-off-by: Holt Sun <holt.sun@nxp.com>
get_i3c_addr_pos() dereferenced desc->controller_priv without checking
it. The pointer is NULL for any descriptor on the bus list that has no
DAT slot bound, which is the state left behind by a failed attach and by
the post-RSTDAA cleanup, and the dereference faults. Assert that
controller_priv isn't NULL first.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Zayne Stites <Zayne.Stites@infineon.com>
The current STM32 flash driver extended operations implementation does
not comply with the API documentation and returns non-zero values on
success. Align the RDP update function to return negative error code
on failure and 0 on success, following flash_ex_op() documentation.
Signed-off-by: Jędrzej Ciupis <jciupis@google.com>
Filter GPIO callbacks against the programmed edge direction so spurious
level samples do not fire handlers. On Apollo3, track output-enabled
pins and mask port writes / combine read status accordingly. Enable the
IRQ only after interrupt setup succeeds.
Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
spi_hal_setup_trans() already adds timing_conf.timing_dummy, the MISO
compensation for the GPIO matrix delay, to half-duplex reads unless
no_compensate is set. Copying it into trans_config.dummy_bits as well
inserted these dummy cycles before every transfer, shifting written
data, and applied them twice on half-duplex reads. Leave dummy_bits at
zero and let the HAL apply the compensation, as ESP-IDF does.
Assisted-by: Claude:opus-5.5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
A request that arrives after a partial line is appended to it, fails
the frame header check and is dropped. A common source of such partial
lines is a host tty echoing back device output before the host
application switches it to raw mode.
The frame start markers never occur inside a frame, so make each of
them start a new line.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
On ESP32 and ESP32-S2 a block larger than the descriptor array's
capacity leaves desc_iter past the array. The subsequent empty-field
check reads out of bounds and can accept an unterminated chain.
Reject the block before touching the descriptors. Compare its size with
the capacity directly so lengths near UINT32_MAX cannot wrap through
DIV_ROUND_UP. Widen the constant multiplication to avoid overflow and
leave dma_pending unchanged on rejection, as for the other early errors.
Reject oversized RX blocks in config_check as well, including BOTH,
since RX always uses the configured block size. Keep the zero-clock
unconfigure path and GDMA validation unchanged. TX retains the runtime
check because queued blocks carry their own lengths.
Assisted-by: Codex:GPT-6
Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>