Commit graph

23353 commits

Author SHA1 Message Date
Jimmy Zheng
89250adea6 drivers: interrupt_controller: intc_nuclei_eclic: fixed $ra polluted
Both $ra and $t2 are caller-saved registers and may be modified in ISR
callback. Save $ra to stack to follow the calling convention.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2024-07-27 10:42:03 +03:00
Fabio Baltieri
ef14c9b867 lib: os: add a header for printk hook functions
Add a zephyr/printk.h header for the __printk_hook functions, these are
currently manually declared by all console drivers for no good reason.

Move the documentation into the header and also unify the way that
console drivers call the function.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-07-27 10:41:01 +03:00
Johann Fischer
c7767e30cf drivers: udc_kinetis: emit Start of Frame events
Everything is in place, just emit SOF events.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-27 10:37:27 +03:00
Armando Visconti
a1f9793e0e drivers/sensor: lis2dux12: fix temperature conversion
Return to sensor_api i/f the temperature in Celsius instead
of the register raw value in LSB.

Fixes #75686

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2024-07-27 10:37:11 +03:00
Armando Visconti
cf20aa050d drivers/sensor: lis2dux12: fix odr and range
The current implementation assumes that sensor odr and range are
always configured in the Device Tree at compile time which might
not be the case.

Instead, application can set odr and range either at compile time
through the DT or using SENSOR_ATTR_SAMPLING_FREQUENCY and
SENSOR_ATTR_FULL_SCALE attributes at runtime, so each driver instance
must keep trace of the latest values set and use them in the sensor
APIs which require them (e.g. lis2dux12_mode_set).

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2024-07-27 10:37:11 +03:00
Armando Visconti
2eaec8b779 sensor: lis2dux12: fix SENSOR_ATTR_FULL_SCALE case
When setting the full scale through SENSOR_ATTR_FULL_SCALE the
driver must convert the g value (i.e. one of 2g/4g/8g/16g) to
the corrispondent sensor fs raw value.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
2024-07-27 10:37:11 +03:00
Jimmy Zheng
7802fffc7f drivers: interrupt_controller: nuclei_eclic: do not modifiy trap entry
RISC-V trap entry is handled in soc/common/riscv-privileged/vector.S.
Remove the redundant modification in CLIC driver.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2024-07-12 16:09:22 -04:00
Jimmy Zheng
f989ed949a driver: interrupt_controller: nuclei_eclic: fixed interrupt level
CLIC should be the first level interrupt controller because it replaces
the basic RISC-V local interrupt.
The interrupt level in CLIC controls preemption between IRQs, rather than
specifying the number of nested interrupt controllers.
Removed CONFIG_MULTI_LEVEL_INTERRUPTS and the incorrect interrupt level.

Signed-off-by: Jimmy Zheng <jimmyzhe@andestech.com>
2024-07-12 16:09:22 -04:00
Bjarki Arge Andreasen
ee69e9fadf drivers: sensor: voltage_divider: revert patch
A patch was added to the voltage divider to handle an erroneous
negative voltage reading for the nrfx_saadc which could return
negative voltages even though the ADC mode was single ended.

This has now been patched in the ADC driver.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Bjarki Arge Andreasen
bb2f49fb51 drivers: adc: adc_nrfx_saadc: remove redundant code
Remove redundant copy of error code and 0 initialization of static
m_data struct.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Bjarki Arge Andreasen
13658a6687 drivers: adc: adc_nrfx_saadc: Patch neg single ended readings
The NRF SAADC produces negative values in single ended mode if the
positive input is below 0V (ground). This behavior does not match
the ADC device driver API, which states that in single ended mode,
the readings must be positive [0 .. 2^resolution - 1].

This commit extends the adc_nrfx_saadc device driver to track which
channels in a sequence are configured to be single ended, to then
corrects negative readings for these channels to 0.

This patch only works if the ADC resolution is lower than the sample
bit size. This is the case for 8, 10, 12 and 14 bit resolutions for
the nRF 52, 53 and 91 series which store readings in a int16_t.

The nRF 54H and 54L series store 8-bit resolution readings in a 8-bit
sample size. A check has been added to start_read() to prevent single
ended mode readings if the resolution is 8-bit for these platforms.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Dat Nguyen Duy
4884262088 drivers: intc: eirq_nxp_s32: allow the same callback to be set
Allow setting the same callback as long as the same data is used

Signed-off-by: Dat Nguyen Duy <dat.nguyenduy@nxp.com>
2024-07-12 09:39:12 -04:00
Johann Fischer
c5b93effe1 drivers: usb_dc_rpi_pico: set AVAILABLE bit separately
The DPSRAM ports can run at different clocks, this is the default
configuration, follow the advice in the datasheet and wait 3 nop
instructions before setting the AVAILABLE bit.

It can be observed that when the controller is continuously sending data
to the host, it rarely has a 0-byte transaction instead of a short
packet. The reason for this is not easy to find, it also seems to depend
on the runtime of individual components. This may fix the problem, but
there is no sure proof that this is the solution.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-07-12 09:38:30 -04:00
Liam Beguin
67544a6d2d spi: shell: add missing newline character
Add missing newline in help string.

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
2024-07-12 09:12:47 -04:00
Simon Guinot
740d7f735e drivers: serial: lpc11u6x: allow to configure data polarity
This patch adds support for the rx-invert and tx-invert device-tree
properties to the uart_lpc11u6x driver for USARTs 1, 2, 3 and 4.

Note that this feature is not supported by USART 0.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
2024-07-12 06:29:56 -04:00
Marcio Ribeiro
3416f9ab47 drivers: adc: esp32: fix invalid width mask and calibration
Fixed WIDTH_MASK invalid values and use HW calibration.

Fixes #72983
Fixes #73798
Fixes #73400

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2024-07-12 06:25:53 -04:00
Luis Ubieda
9c516db69c sensor: coverity-fix: Simplify unsigned comparison
- VEML7700 - Coverity CID 363733, GH: #74759.
- VEML7700 - CID 363719, GH: #74755.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-12 05:56:30 -04:00
Fin Maaß
de82190e13 drivers: clock_control: litex: remove redundant entry
remove litex,sys-clock-frequency from litex,clk,
because we already define that in the clock-frequency of cpu0.
This can be accessed via
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-07-12 05:49:01 -04:00
Ben Marsh
74c871dce2 build: Prefix missed generated syscall includes
PR #63973 namespaced generated headers with zephyr/, including generated
syscall headers.

Since then, some new generated syscall header includes have been added
without the zephyr/ prefix, breaking builds when
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is disabled.

This commit adds the zephyr/ prefix to includes for generated syscall
headers where it has been missed.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
2024-07-11 18:24:58 -04:00
Sylvio Alves
43a559080b soc: esp32s2: fix wifi clock gate
ESP32-S2 Wi-Fi clock is not initialized properly, causing
instability when scanning or connecting to a SSID.

Fixes #74899
Fixes #74417

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-07-11 16:19:55 -04:00
Brett Witherspoon
f320535f84 drivers: dac: dac_ad569x: Add bit shift for 14/12-bit variants
The 14/12-bit variants (AD5692R/AD5691R) require the data to be in the
upper bits of the two byte data field of the write command. See table 12
and the associated footnotes in the AD5693R/AD5692R/AD5691R/AD5693
datasheet.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2024-07-11 09:37:12 +02:00
Alberto Escolar Piedras
0cf89bb8b4 drivers/spi/spi_xlnx_axi_quadspi: Build fix w CONFIG_SPI_ASYNC
Fix a build error when CONFIG_SPI_ASYNC is set.
The issue was detected by CI

```
spi_xlnx_axi_quadspi.c: In function 'xlnx_quadspi_isr':
spi_xlnx_axi_quadspi.c:489:21: error: 'ctx' undeclared
  489 |                 if (ctx->asynchronous) {
      |                     ^~~
```

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-07-10 19:13:46 -04:00
Declan Snyder
6ac0d8bf84 drivers: mdio_nxp_enet: Fix busy wait
Fix the busy wait in the MDIO driver that was causing timing
problems in systems with real time requirements performing tasks
more frequently than about a millisecond.

Restructure the code to be less redundant and change the busy wait
kconfig to microseconds instead of millliseconds. Also actually signal
to the mdio driver that it can use the interrupt instead of busy
waiting, this seems to have been forgotten.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-07-10 19:13:27 -04:00
Ryan Erickson
7bef3fd8af modem: hl7800: set RX socket remote address
Set the remote address of received sockets.
This is necessary for services that rely on the remote address.
DNS relies on the remote address to be set properly.

Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
2024-07-10 16:16:03 -04:00
Jordan Yates
063d2ff6ec watchdog: cmsdk_apb: only support a single channel
The CMSDK watchdog hardware only supports a single timeout channel.
Return the documented error if more than one timeout is requested to be
installed.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-10 14:39:36 +02:00
Jordan Yates
9138763430 watchdog: cmsdk_apb: validate timeout window
Validate the maximum timeout window, as required by the API tests.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-10 14:39:36 +02:00
Jordan Yates
74f3b587fc watchdog: cmsdk_apb: fix period calculation
The previous calculation was multiplying the timeout in milliseconds
by the clock frequency, giving a cycle count 1000x larger than it should
be.

Fix the calculation and rename `reload_s` to `reload_cycles`, as the
cycle count is what this actually contains.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-10 14:39:36 +02:00
Rahul Goyal
f1e38e73d7 Drivers: max17048: updated voltage parameter output
present output shows voltage in mV.
updated output shows voltage in uV.

Signed-off-by: Rahul Goyal <goyalrahul1516@gmail.com>
2024-07-10 11:36:28 +02:00
Frank Lin
6fc525cc20 drivers: serial: uart_cdns: fix interrupt driven
Fix interrupt driven for shell

Signed-off-by: Frank Lin <linfrank@meta.com>
2024-07-09 19:45:18 -04:00
Brett Witherspoon
cb8db004d7 drivers: dac: dac_ad569x: Fix reset error return
The intention here appears to be to return an error. Use an early return
to implement this.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2024-07-09 19:43:23 -04:00
Kevin Wang
6cb8956a08 drivers: watchdog: Refine the atcwdt200 driver's code.
Remove the reset vector setting from driver layer,
the reset vector is more suitable to be set at the board layer.

Signed-off-by: Kevin Wang <kevinwang821020@google.com>
2024-07-09 17:21:28 -04:00
Luis Ubieda
00a3be90d7 sensor: icm42688: Use RTIO workq on icm42688_submit
To make its execution path non-blocking from the caller's perspective.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Luis Ubieda
8d0c2f15df sensor: bme280: Use RTIO workq on bme280_submit
To make its execution path non-blocking from the caller's perspective.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Luis Ubieda
5521fc4410 sensor: bma4xx: Use RTIO workq on bma4xx_submit
To make its execution path non-blocking from the caller's perspective.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Luis Ubieda
59e8919da7 sensor: akm09918c: Use RTIO workq on akm09918c_submit
To make its execution path non-blocking from the caller's perspective.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Luis Ubieda
aff6e31ec4 sensor: fallback: Decouple RTIO request using RTIO workqueues service
Incorporate RTIO workqueues to turn sensor_submit_callback into an
asynchronous request.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Luis Ubieda
cc139b85df sensor: Enable RTIO Semaphores for Async API
In order to decouple the read request from its implementation, we need
to be able to yield to potential lower-priority threads, which is not
possible with k_yield() itself. As such, using RTIO Consume semaphore
enables us to achieve this.

This patch also refactors blocking API (sensor_read) to also block upon
consumption, so as not to require RTIO_SUBMIT_SEM enabled.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 17:21:05 -04:00
Devansh Tanna
6d4fba1f86 drivers: cc13xx_cc26xx: pwm: enable pwm(gpt) in sleep/deepsleep mode
- enabled GPT(PWM) peripheral for sleep/deepsleep mode in init_pwm()
- Fixed: undefined behaviour when using k_sleep()

Signed-off-by: Devansh Tanna <devansht0210@gmail.com>
2024-07-09 17:20:46 -04:00
Benjamin Cabé
95caf476f1 drivers: ptp_clock_nxp_enet: add module_dev to driver config
c8d8dce755 introduced a regression whereby driver config should hold
module device pointer, except it didn't.
This commit adds module_dev to the driver config.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-07-09 17:20:12 -04:00
Jean Nanchen
77f9f0e965 drivers: sensor: maxim: max31865: Fix fault bit clearing
Ensures D1 sets and D5, D3, D2 reset, preventing undefined states.

Signed-off-by: Jean Nanchen <jean.nanchen@gmail.com>
2024-07-09 15:38:19 -04:00
Thomas Stranger
b5d3dea894 drivers: sensor: ds18b20: indicate error for missing response
When multiple devices are on the bus, and no slave matches
the sent rom, the master receives only ones.
This should be handled explicitly and the error reporting
should not rely on the crc mismatch of the scratchpad.

Note: Make sure that the sensor configuration is loaded to the
eeprom (copy scratchpad), otherwise the resolution will not match
the expectations in case a node looses power and recovers.
As in that case the configuration will not be applied again.
Also the sensor may still report the power on reset value
of +85°C just after the sensor powered up.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2024-07-09 15:37:58 -04:00
Thomas Stranger
6fd767d6e4 drivers: sensor: ds18b20: verify scratchpad write
Verify that the scratchpad write was successful by
reading back the configuration.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2024-07-09 15:37:58 -04:00
Thomas Stranger
53e3936a2e drivers: sensor: ds18b20: verify crc of scratchpad.
After each read of the scratchpad the crc of the data
is checked and in case of a mismatch an error is returned.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2024-07-09 15:37:58 -04:00
Thomas Stranger
f4acf390dd drivers: sensor: ds18b20: cleanup header/includes
- Move the content of the header file into the source file,
and drop unnecessary includes.
- Also, drop the bus access function.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2024-07-09 15:37:58 -04:00
Brett Witherspoon
97190d76ec drivers: dac: dac_ad56xx: Fix channel range check
An off by one error in the channel range check results in an out of
bound access to the channel lookup array.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2024-07-09 15:31:58 -04:00
Omer Gozderesi
1fc97561ed config: esp32: configurable UART FIFO thresholds
The existing configuration of the ESP32 UART FIFO thresholds
was fixed, leading to inefficiencies in handling
Modbus RTU packages exceeding this size.
This commit introduces two new Kconfig options,
allowing users to adjust the esp32 fifo thresholds as needed.
fixes #74311

Signed-off-by: Omer Gozderesi <omer.gozderesi@enda.com>

config: esp32:  configurable UART FIFO thresholds

The existing configuration of the ESP32 UART FIFO thresholds
was fixed, leading to inefficiencies in handling
Modbus RTU packages exceeding this size.
This commit introduces two new Kconfig options,
allowing users to adjust the esp32 fifo thresholds as needed.
fixes #74311
Signed-off-by: Omer Gozderesi <omer.gozderesi@enda.com>
2024-07-09 15:24:02 -04:00
Marcin Niestroj
c368c332c4 drivers: wifi: esp_at: fix UDP socket setup
Right now AT+CIPSTART command is called with both "remote port" and "local
port" being set to the same number. This means that for outgoing UDP
traffic (e.g. when resolving DNS or when reaching out some application
server with CoAP over UDP) always the same outgoing port is used. Such
behavior is wrong, since by default a random outgoing port should be used.

Reusing the same port confuses server implementation that is reached out,
since especially in context of DTLS over UDP, outgoing port defines TLS
context/session to be used. Such servers often ignore TLS packets from new
sessions (e.g. after device reboot) and result in failed DTLS connection
attempts.

Commit dbf3d6e911 ("drivers: esp_at: implement bind() and recvfrom() for
UDP sockets") added support for "server-side listening" for incoming
traffic on UDP sockets, which introduced broken behavior of using the same
remote and local port.

In esp_bind() implementation assign newly intorduced 'src' member, instead
of reusing 'dst'. Don't call AT+CIPSTART yet at this stage, as in case of
connect() Zephyr syscall esp_bind() (via bind_default() helper function) is
called implicitly to assign random generated local port, so remote port is
yet to be assigned. Check in esp_recv() whether socket was already
connected (i.e. esp_connect() was called) and if not, invoke
AT+CIPSTART (via _sock_connect()) to start listening on "server-side" UDP
socket.

This patch fixes broken behavior of always reusing the same local port for
outgoing UDP traffic. Instead, randomly generated (by Zephyr net_context
subsys) local port is used. Additionally bind() and recvfrom()
implementation (to handle server-side UDP sockets) is improved, so that
binding to 0.0.0.0 (on any interface) is possible.

Fixes: dbf3d6e911 ("drivers: esp_at: implement bind() and recvfrom() for
  UDP sockets")
Fixes: 424ea9f5e4 ("drivers: wifi: esp_at: do not connect socket on
  bind(INADDR_ANY)")
Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2024-07-09 19:06:12 +02:00
Luis Ubieda
95e299ad39 sensor: lis2dux12: fix: CID 363712: Initialize mode-fs
Following the same pattern used in `lis2dux12_sample_fetch_accel`.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-07-09 19:05:03 +02:00
Henrik Brix Andersen
09d189cb71 drivers: can: loopback: increase default TX thread stack size
Increase the default TX thread stack size for the CAN loopback driver from
256 to 512 bytes as the former has shown to be too little when using the
loopback driver on real hardware.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-07-09 17:18:34 +02:00
Henrik Brix Andersen
7a25fbb2d7 drivers: can: loopback: set TX thread name
Set TX thread name to aid in debugging.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-07-09 17:18:34 +02:00