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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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#92619Fixes#92624
Signed-off-by: Jordan Yates <jordan@embeint.com>
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>
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>
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>
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>
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>
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>
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>