Commit graph

151 commits

Author SHA1 Message Date
Carlo Caione
3186b4185d lora: native: sx126x: wake radio before aborting duty cycle
During RX duty cycle mode the SX126x keeps BUSY asserted even in
the sleep phase. The standby command cannot be sent because the HAL
waits for BUSY LOW first.

Fix by calling sx126x_hal_wakeup() before set_standby when
cancelling duty cycle reception. The wakeup function drives NSS low
directly (bypassing the BUSY check), which forces the radio out of
duty cycle and into STDBY_RC.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-14 22:22:05 -04:00
Carlo Caione
77739f54de lora: native: sx126x: flatten RX done handler and extract restart helper
Reduce nesting in sx126x_handle_irq_rx_done.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-14 22:22:05 -04:00
Carlo Caione
a43ef096c4 lora: native: sx126x: add RX duty cycle support
Implement the recv_duty_cycle API using the SX126x hardware
SetRxDutyCycle command. The radio autonomously alternates between
short RX windows and sleep, waking the MCU only on packet reception.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-04-14 22:22:05 -04:00
Pisit Sawangvonganan
c259c78097 drivers: fix typo in (interrupt_controller, led_strip, lora, memc, mfd)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/interrupt_controller`
- `drivers/led_strip`
- `drivers/lora`
- `drivers/memc`
- `drivers/mfd`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-03-27 20:21:24 -04:00
Carlo Caione
cb959fdb58 lorawan: native: add PM_DEVICE support to sx126x driver
Register a pm_action callback that disconnects RF GPIO pins
(antenna enable, TX/RX FE_CTRL) on suspend and reconfigures
them on resume.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-03-25 07:58:52 -04:00
Carlo Caione
7592b10996 lorawan: native: fix DIO1 interrupt not re-enabled when sleep disabled
When CONFIG_LORA_SX126X_NATIVE_SLEEP=n, sx126x_ensure_ready() returned
immediately without re-enabling the DIO1 interrupt. On the STM32WL the
radio ISR disables itself on entry (irq_disable), so the interrupt must be
explicitly re-armed before each TX/RX operation.

This caused every send after the first to time out because the TX_DONE
interrupt was never delivered.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-03-25 07:58:52 -04:00
Carlo Caione
18ead6a5ee drivers: lora: sx126x: add Kconfig for conditional sleep mode
Add CONFIG_LORA_SX126X_NATIVE_SLEEP (default y) to allow disabling
sleep mode power management. When disabled, the radio stays in
standby for faster response times at the cost of higher idle current.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-03-09 11:06:29 +01:00
Carlo Caione
be682b5257 drivers: lora: sx126x: add sleep mode power management
Place the SX126x radio into sleep mode whenever it is not actively
transmitting or receiving.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-03-09 11:06:29 +01:00
Carlo Caione
5966427a22 drivers: lora: sx126x: fix async RX callback error handling
Two fixes for the async RX path:

1. Only invoke the user callback for valid packets.

2. Re-check rx_cb != NULL before restarting RX. The user's callback may
   call lora_recv_async(dev, NULL) to stop reception.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-03-09 11:06:29 +01:00
Carlo Caione
e5c9889d57 drivers: lora: sx126x: fix SPI transfer for correct read/write behavior
Fix three issues in the spi_transfer() helper:

1. pass NULL instead of the data pointer so the SPI driver sends dummy
   bytes during reads rather than the caller's buffer contents (usually
   rubbish)

2. unify TX and RX buf_set count. The old logic used different counts for
   TX and RX, which caused a length mismatch when data_len > 0 on reads.

3. pass NULL for the rx buf_set on write operations. The chip's MISO output
   during command writes is undefined, so a full-duplex transceive is only
   needed for reads.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-03-09 11:06:29 +01:00
Carlo Caione
ed7f33df6e drivers: lora: sx126x: add STM32WL sub-GHz radio support
Add support for the STM32WL integrated sub-GHz radio to the native
SX126x driver. The STM32WL has an SX126x-compatible radio core but
uses internal peripherals instead of external GPIOs.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-02-23 11:34:35 +00:00
Carlo Caione
ea3fa9a819 drivers: lora: sx126x: factor out common HAL code
Extract common HAL functions shared between different SX126x
implementations into sx126x_hal_common.c, this prepares the driver for
supporting additional platforms like the STM32WL integrated radio.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-02-23 11:34:35 +00:00
Pieter De Gendt
b606996c29 drivers: lora: sx126x: Put driver API into iterable sections
Use DEVICE_API to put driver API into the correct linker section.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-23 08:49:10 +01:00
Carlo Caione
c575e648e9 drivers: lora: add native SX126x driver
Add a native Zephyr driver for Semtech SX1261/SX1262 LoRa transceivers that
does not depend on external modules (loramac-node or lora-basics-modem).

The driver is experimental and must be explicitly enabled by selecting
CONFIG_LORA_MODULE_BACKEND_NONE.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-02-09 13:29:42 +01:00
Carlo Caione
4303a3d7d8 lora: Fix bandwidth enum breakage in loramac-node driver
Commit 6b2f1c19ac changed the lora_signal_bandwidth enum values from
sequential indices (0, 1, 2) to actual kHz values (125, 250, 500).

With the new enum values (125, 250, 500), this causes on loramac-node an
array out-of-bounds access, resulting in undefined behavior and crashes
(USAGE FAULT: undefined instruction).

Fix this by adding a translation function that converts the Zephyr
bandwidth enum values to the array indices expected by loramac-node.

Fixes: 6b2f1c19ac

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-01-29 16:12:25 -06:00
Camille BAUD
bc07d91cca drivers: lora: Add ability to force enable LDRO
Allows Enabling LDRO all the time via DTS

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-01-16 11:43:43 +00:00
Camille BAUD
cd65845ba2 drivers: lora: Enable LDRO when symbol time > 16.38ms
Enable LDRO when it should be enabled

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-01-16 11:43:43 +00:00
Camille BAUD
6b2f1c19ac drivers: lora: Add missing Bandwidth and Spreading Factor values
Add missing values and replace arbitrary BW enum with actual value

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-01-16 11:43:43 +00:00
Carlo Caione
ca0703f9e6 modules: lora-basics-modem: Refactor and fix CMake
A set of preliminary (but harmless) changes to prepare for adding the HAL
implementation.

- Rename CMake variables for clarity and consistency, adding an 'LBM_LIB_'
  prefix when the path is a library / module path.

- Change zephyr_library_include_directories to zephyr_include_directories
  for the RAL/RALF includes, since these headers may be needed outside the
  library itself.

- Make lbm_common.h available to code outside the driver directory.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-01-16 11:42:37 +00:00
Carlo Caione
5e35f14b1e drivers: lora: rename lora_basics_modem directory to lora-basics-modem
Rename the lora_basics_modem backend directory to lora-basics-modem
for consistency with the module naming convention.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-01-14 09:55:43 +01:00
Carlo Caione
a309b3c127 drivers: lora: rename loramac_node directory to loramac-node
Rename drivers/lora/loramac_node to drivers/lora/loramac-node to align
with the module naming convention (modules/loramac-node).

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2026-01-14 09:55:43 +01:00
Carlo Caione
54d4cdc897 drivers: lora: lbm: Defer radio initialization until first config
Split device initialization into two phases across all LBM drivers:

1. Boot-time init: Minimal device initialization
2. First config: Radio hardware initialization

This deferred initialization approach provides full control over the
radio hardware, allowing applications to perform any necessary setup
before the radio is initialized. The radio init is automatically
triggered on the first call to lora_config().

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2025-12-23 09:32:34 +01:00
Carlo Caione
c6b369e1a3 drivers: lora: lbm: Add DIO1 GPIO callback API
Add functions to register and unregister user GPIO callbacks for DIO1
interrupts on LBM lora radio devices. This allows external code (e.g., the
LoRa Basics Modem HAL) to receive notifications when DIO1 fires.

The driver configures the pin mask automatically based on the DIO1 pin
from devicetree.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2025-12-23 09:32:34 +01:00
Jordan Yates
08f74a2638 lora: add lora_airtime
Add a simple function that exposes the airtime of a packet of a given
length.

Use the new internal implementations of the airtime function when
calculating TX durations inside the send functions to reduce code
duplication on a complex function.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-12-15 17:06:49 +00:00
Jordan Yates
fab5f57455 lora: optional disable CRC
Add the option to disable the builtin 16 bit CRC on the LoRa payload.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-12-15 17:06:49 +00:00
Camille BAUD
7a1e2d7509 drivers: lora: Add explicit support for variants
Add explicit support for sx1268, sx1278, llcc68

Signed-off-by: Camille BAUD <mail@massdriver.space>
2025-12-12 09:57:09 -05:00
Camille BAUD
287f40edbe drivers: lora: Add regulator-ldo for sx126x
Adds ability to set usage of LDO instead of DCDC

Signed-off-by: Camille BAUD <mail@massdriver.space>
2025-12-12 09:57:09 -05:00
Kiara Navarro
ee7792c343 lora: remove EXPERIMENTAL from already unstable api
Based on api lifecycle documentation, the lora driver has been recently
moved to unstable. This means that the state of this driver is no longer
experimental. Due this new state, the change should be updated on
Kconfig.

This commit remove the `EXPERIMENTAL` symbol selection from the driver
itself. It also remove the word `experimental` from the lora basic
modem backend since the api lifecycle documentation only describes the
state of the api based upon the api itself and not any particular
backend implementation.

Signed-off-by: Kiara Navarro <knavarro@paltatech.com>
2025-11-27 11:33:59 +01:00
Josuah Demangeon
30950b888d style: drivers: sort Kconfig and CMake includes
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.

Signed-off-by: Josuah Demangeon <me@josuah.net>
2025-11-17 13:48:03 -05:00
Mathieu Choplain
21b2283fc5 drivers: *: stm32: use series-agnostic STM32 LL headers
Use the series-agnostic STM32 LL headers from the STM32Cube HAL module
instead of series-specific ones in STM32 drivers.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2025-11-14 12:19:48 +02:00
Declan Snyder
570b445a61 drivers: Convert to use SPI macro without delay parameters
Convert all drivers and other consumers to use SPI macros without the
delay parameters.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-10-01 14:39:36 +03:00
Jordan Yates
03513a6910 lora: lbm: choice of reported RSSI type
Add a choice of which RSSI type should be reported to the application
layer, packet RSSI (which stops at the noise floor) or signal RSSI
(which estimates the LoRa signal strength into the noise floor).

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-09-02 18:41:44 +02:00
Jordan Yates
611e14bd6d lora: lbm: enable SX126x RX boost option
Add the option to enable the RX boost mode in devicetree.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-09-02 18:41:44 +02:00
Jordan Yates
38384e1233 lora: LoRa Basics Modem backend for SX12xx chips
As a first integration of the LoRa Basics Modem backend, implement the
LoRa API for the standard SX126x/SX127x chips.

Much of the logic from `lbm_common.c` is taken from the loramac-node
`sx12xx_common` implementation, but it should now be agnostic for all
LoRa RF transceivers.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-09-02 18:41:44 +02:00
Jordan Yates
01c97e205d lora: shift drivers to dedicated loramac-node folder
Move the current implementation of the LoRa API using `loramac-node` to
a dedicated folder in preparation for the LoRa basics modem
implementation.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-09-02 18:41:44 +02:00
Jordan Yates
9c6e6d781d drivers: lora: rylrxxx: fix snprintf usage
The second argument should unconditionally be the size of the output
memory area, not computationally derived from the input payload length.
The previous length validations would be incorrect when
`cmd_len == CONFIG_LORA_RYLRXX_CMD_BUF_SIZE`, as `snprintf` would be
told the output buffer was `CONFIG_LORA_RYLRXX_CMD_BUF_SIZE + 1` bytes
long.

Fixes #92619
Fixes #92624

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-07-04 16:40:46 -10:00
Benjamin Cabé
b95f8d88df lora: adopt SHELL_HELP
Adopt SHELL_HELP macro for lora_shell

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 07:37:10 +02:00
Benjamin Cabé
312ad783b4 drivers: lora: fix spelling of "operation"
s/opperation/operation/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-19 18:51:13 +01:00
Aleksander Dejewski
a4e31487d5 drivers: lora: Add user_data to lora_recv_async
The LoRa driver does not allow to pass void* user_data to callback in
lora_recv_async function. This leads to complex way of using the API. This
commit fixes the issue and adds the field to the function and to the
callback.

Signed-off-by: Aleksander Dejewski <aleksander.dejewski@gmail.com>
2024-12-21 05:51:52 +01:00
Pieter De Gendt
9518dbf3e0 drivers: lora: Place API into iterable section
Add wrapper DEVICE_API macro to all lora_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 18:18:08 +01:00
Gerard Marull-Paretas
55cdc5a93e drivers: lora: sx12xx: select SPI and GPIO
Instead of depending on SPI/GPIO. This allows to just enable
CONFIG_LORA=y + DT node in the application layer. The same
pattern is nowadays followed by most drivers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2024-11-28 20:53:11 +01:00
TOKITA Hiroshi
042a40d0e3 drivers: lora: rylrxxx: Add stdio.h to resolve function prototypes
The source code uses functions from stdio.h,
such as `sprintf()`, but they are not explicitly included
so that we will add it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-10-15 04:09:56 -04:00
TOKITA Hiroshi
1d4c29ab29 drivers: lora: rylrxxx: Fix missing default y in LORA_RYLRXXX
The `default y`, which is coupled with
`depends on DT_HAS_REYAX_RYLRXXX_ENABLED` to link the settings with
DeviceTree, which was missing, so I added it.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
2024-10-15 04:09:56 -04:00
Yong Cong Sin
52a202309b zephyr: bulk update to DT_NODE_HAS_STATUS_OKAY
Change instances of:

DT_NODE_HAS_STATUS(<node_id>, okay)

to

DT_NODE_HAS_STATUS_OKAY(<node_id>)

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2024-10-03 17:06:52 +01:00
Patryk Biel
59eb3eac92 lora: driver: sx12xx: fix driver recv func when RX error occurs
The sx12xx driver does not provide RxError event handler therefore
when such error occurs, the driver does not handle it at all.
As a result, when the lora_recv function is called with infinite timeout,
it never returns as it waits on k_poll forever, with radio operation mode
set to STDBY_RC. Therefore, once the rx error occurs, radio is no longer
able to receive any subsequent incoming transmission. Fix it by adding
RxError event handler which releases modem usage and signals error
allowing lora_recv to return with a value indicating receive error.
Tested on lora e5 mini by transmitting multiple LoRa messages over a
short period of time that caused CRC error, thus RX errors.
Once the fix is applied, the descibed behaviour no longer occurs despite
the CRC errors caused by test.

Signed-off-by: Patryk Biel <pbiel7@gmail.com>
2024-08-05 18:37:11 -04:00
Jordan Yates
e2549cc3c9 lora: rylrxxx: add missing timeout
Add the missing timeout parameter to `modem_pipe_open`. 10 seconds
appears to be the default value added to other in-tree drivers.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-07-30 11:44:04 +02:00
David Ullmann
35740a8322 drivers: lora: implement reyax lora driver
implementation of reyax lora module

Signed-off-by: David Ullmann <davidl.ullmann@gmail.com>
2024-06-14 17:12:49 -04:00
David Ullmann
de6274f302 lora: add config for reyax lora module
adding the Kconfig for reyax lora module

Signed-off-by: David Ullmann <davidl.ullmann@gmail.com>
2024-06-14 17:12:49 -04:00
Henrik Brix Andersen
c0c8952739 shell: do not enable subsystem/driver shell modules by default
Do not enable subsystem/driver shell modules by default and stop abusing
CONFIG_SHELL_MINIMAL, which is internal to the shell subsystem, to decide
when to enable a driver shell.

The list of shell modules has grown considerably through the
years. Enabling CONFIG_SHELL for doing e.g. an interactive debug session
leads to a large number of shell modules also being enabled unless
explicitly disabled, which again leads to non-negligible increases in
RAM/ROM usage.

This commit attempts to establish a policy of subsystem/driver shell
modules being disabled by default, requiring the user/application to
explicitly enable only those needed.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-20 09:21:40 +01:00
Nick Ward
2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00