Commit graph

901 commits

Author SHA1 Message Date
jgromes
dc050df8d9 [SX126x] Added support for AFSK transmission 2023-02-11 14:11:44 +01:00
Matthijs Kooijman
4c712c1f2c [MOD] Remove constexpr usage
This was introduced when STM32WL support was added. Using constexpr for
the END_OF_MODE_TABLE constant allows it to be initialized in the class
declaration, but this needs C++11. This moves the initialization out of
the class declaration to the .cpp file, which does not need constexpr.
It also lets STM32WLx::END_OF_MODE_TABLE define its value directly
(instead of aliasing Module::END_OF_MODE_TABLE) to prevent reduce
runtime overhead (see below).

The downside of this change is that the value of the END_OF_MODE_TABLE
is no longer visible in other compilation units and thus cannot be
inlined into the rfswitch_table (if used).

For example, on STM32, this means that instead of having a pre-cooked
rfswitch_table that lives in the .rodata section (so can be read
directly from flash), the table lives in RAM and is initialized at
runtime (the actual modes and pins are copied from flash to RAM by the
standard startup loop that copies all of the .data section, and the
END_OF_MODE_TABLE value is copied by a bit of new generated code). This
means a little more runtime overhead, but the cost is mostly in RAM size
(80 bytes for the SMT32WL sketches, 16 per mode plus 16 for the
END_OF_MODE_TABLE).

In a first attempt at this commit, STM32WLx::END_OF_MODE_TABLE was still
initialized using the Module::END_OF_MODE_TABLE value, but since the
latter is also not available at compiletime, this meant initialization
of the former also needed to happen at runtime, adding even more code
overhead (and possibly leading to ordering issues as well). To avoid
this, the STM32WLx::END_OF_MODE_TABLE initialization now just duplicates
that of Module::END_OF_MODE_TABLE.

On AVR, the impact is not so much: Since AVR cannot address flash
directly, the table was already copied from flash to RAM at startup, so
the extra RAM usage is just 4 bytes because END_OF_MODE_TABLE is now
also present in RAM, to be copied into rfswitch_table at startup.

Options for avoiding this overhead (not implemented in this commit)
could be (in no particular order):

1. Use a macro instead of a constant. Downside is that these cannot be
   scoped inside the Module/STM32WLx classes like now, so this requires
   changes to sketches that use a rfswitch_table (and reduced scoping
   and using macros adds more opportunity for conflicts and weird
   errors).
2. Apply the change in this commit only when C++11 is not available.
   Downside is that the initialization value of these constants must be
   duplicated in the .h and .cpp file for C++ and older versions
   respectively.
3. Let sketches just use `{Module::MODE_END_OF_TABLE, {}}` explicitly
   instead of `Module::END_OF_MODE_TABLE`. Downside of this is that this
   requires sketches to be modified and that it lets the sketch encode
   more of the table structure, potentially making future API changes
   harder (but it probably does not really matter in practice).
4. Turn END_OF_MODE_TABLE into a static method, which *can* then be
   defined in the class declaration and inlined. The method can then be
   conditionally marked as constexpr, which allows C++11 compilers to
   completely resolve the rfswitch_table value at compiletime, producing
   a binary identical to before this commit. When constexpr is omitted
   (e.g. on older compilers), some runtime overhead is added (pretty
   much the same as the result from this commit).  Downside is that
   sketches must be modified, and the `END_OF_MODE_TABLE` "constant"
   must now be called, e.g.  `END_OF_MODE_TABLE()` which might be a bit
   unexpected syntax.
2023-02-03 12:42:49 +01:00
Andrew Moroz
5f3fb5fa0d sx126x-rx-gain-persist: add ability to persist Rx gain setting when calling SX126x::setRxBoostedGainMode 2023-01-28 18:09:39 -05:00
jgromes
18ff62890a [SX127x] Fixed packet length not proagating correctly (#666) 2023-01-18 22:00:26 +01:00
jgromes
91d42ebf0e [SX127x] Set minimum bit rate to 0.5 kbps (#665) 2023-01-18 18:58:52 +01:00
jgromes
0a0f6979dd [RF69] Set minimum bit rate to 0.5 kbps 2023-01-18 18:58:26 +01:00
Andrew Moroz
35ed685c8a andrew-moroz/sx126x-rx-boosted-gain: Add method to support SX126x Rx Boosted Gain mode 2023-01-16 16:37:14 -05:00
jgromes
5b96340332 [CC1101] Fixed setPromiscuousMode(true) always failing 2023-01-14 23:20:27 +01:00
Matthijs Kooijman
3e2810cfbb [STM32WLx] Make reading IRQ flag more reliable
Now that clearIrqStatus also clears the pending flag, reading the IRQ
flag no longer has to, making this more reliable.
2023-01-10 18:09:55 +01:00
Matthijs Kooijman
cd138dd6c7 [STM32WLx] Apply PA clamp workaround for HP only
This modifies SX1262::begin and beginFSK to call setOutputPower after
applying the workaround, so that can undo the workaround if needed.
2023-01-10 18:09:55 +01:00
Matthijs Kooijman
9252cf53d3 [STM32WLx] Implement setDio1Action / interrupts
Because this interrupt is not connected to a GPIO or even the EXTI unit,
but directly to the MCU NVIC, the regular attachInterrupt flow cannot be
used.

Instead, this lets STM32WLx override the setDio1Action() and
clearDio1Action() methods to register the radio IRQ directly. Note that
it would have been nicer to implement this by overriding attachInterrupt
in STM32WLx_Module, but that is never called for virtual pins (because
the STM32Duino digitalPinToInterrupt() macro does not work for virtual
pins).

In addition, because the NVIC is level-sensitive and the code expects
edge-sensitive interrupts (for GPIO, the EXTI module in front of the
NVIC makes the interrupts edge-sensitive), this adds some additional
handling around the user-registered interrupt callback. To prevent the
ISR from triggering over and over again (and also to not require SPI
transactions in the ISR to clear the IRQ flags inside the radio), the
interrupt is disabled in the NVIC whenever it is trigered. Then,
whenever the IRQ flags *are* cleared in the radio, the IRQ is enabled in
the NVIC again. This requires making the SX126x::clearIrqStatus() method
virtual so STM32WLx can override it.
2023-01-10 18:09:55 +01:00
Matthijs Kooijman
5e47d94418 [STM32WLx] Add module for STM32WL MCUs with integrated radio (#588)
This is a nearly complete implementation, except that the Dio1 interrupt
is not yet supported (this will be added in a subsequent commit to
simplify review).

This fixes #588.
2023-01-10 18:09:55 +01:00
Matthijs Kooijman
da6c3f6a6b [SX126x] Allow subclasses to change the TX mode used
This prepares for adding a STM32WLx subclass later.
2023-01-09 10:26:28 +01:00
Matthijs Kooijman
52ec165643 Update radios to use new setRfSwitchState
This removes the compatibility wrapper and applies the following
replacements:

    sed -i 's/setRfSwitchState(LOW, LOW)/setRfSwitchState(Module::MODE_IDLE)/' src/modules/*/*.cpp
    sed -i 's/setRfSwitchState(HIGH, LOW)/setRfSwitchState(Module::MODE_RX)/' src/modules/*/*.cpp
    sed -i 's/setRfSwitchState(LOW, HIGH)/setRfSwitchState(Module::MODE_TX)/' src/modules/*/*.cpp
2023-01-09 10:26:28 +01:00
Matthijs Kooijman
3779faf600 Add setRfSwitchTable() wrapper methods
This gives all radios that use an rfswitch (i.e. have
a setRfSwitchPins() wrapper already) a wrapper method for
setRfSwitchTable() too. This wrapper just calls the same method on
Module, to make it easier for sketches to use it.
2023-01-09 10:26:27 +01:00
Matthijs Kooijman
90b28d7722 Remove duplicated setRfSwitchPins documentation
All radios that support RfSwitch define this method that simply forwards
to the `Module::setRfSwitchPins()` method. Previously, all these methods
duplicated the documentation as well, but this uses the doxygen \copydoc
to remove this duplication.
2023-01-09 09:46:31 +01:00
jgromes
0cd9dd2983 [SX126x] Added note about allowed OCP range (#654) 2023-01-04 10:22:06 +01:00
jgromes
3a34594b5b [SX126x] Fixed incorrect OCP step in documentation (#654) 2023-01-03 20:20:58 +01:00
jgromes
a0884bf120 [SX128x] Added option to set custom ranging calibration (#293) 2023-01-01 18:31:03 +01:00
jgromes
088207df4c [SX1280] Only check ranging address on slave 2023-01-01 18:03:48 +01:00
jgromes
0144faf02a [RF69] Fixed stream mode (#651) 2022-12-22 18:18:16 +01:00
jgromes
18fefc0ca9 [SX127x] Removed unnecessary volatile 2022-12-22 18:17:41 +01:00
Mitrokhin Anton
e073da15da Fix FSK Stream mode TX and RX 2022-12-22 12:21:01 +07:00
Matthijs Kooijman
dfbe6934bb [SX126x] Set DIO2 to RF switch by default for FSK too
In commit a1f94d9f ([SX126x] Set DIO2 to RF switch by default), this was
changed for LoRa modulation in begin(), but since this is really
a board-specific attribute, independent of the modulation used, there is
no reason to have a different default for FSK (so this was probably just
forgotten).
2022-12-20 23:33:02 +01:00
Matthijs Kooijman
47163f4398 [SX126x] Make begin parameter docs consistent
This:
 - Updates syncWord comments after changing it from uint16_t to uint8_t
   in commit 55aff74a ([SX126x] Changed pin mapping, added reset,
   changed LoRa sync word to 1B).
 - Adds missing useRegulatorLDO comments forgoten in commit ea85a663
   ([SX126x] Pass useRegulatorLDO to SX1262/SX1261/SX1268).
 - Makes useRegulatorLDO comments the same in all places (using the more
   explicit version).
 - Fixes a typo in the doxygen \parma -> \param command.
2022-12-20 23:33:02 +01:00
Thomas Göttgens
0aa59f6abc Fix coding style 2022-12-06 07:53:14 +01:00
Thomas Göttgens
08de95e15e Access getIrqStatus() without Godmode and change the flag setting like SX126x handles it. 2022-12-05 11:17:59 +01:00
jgromes
aa8330cf57 [Si443x] Added GFSK with BT 0.5 (#625) 2022-12-04 10:19:42 +01:00
Federico Maggi
7b4c27b702
[RF69] Missing 1000.0 multipler in 2022-12-04 00:21:22 +01:00
Federico Maggi
09669eeb26
[CC1101] Fix setPromiscuousMode(false) bug
Signed-off-by: Federico Maggi <federico.maggi@gmail.com>
2022-12-01 13:32:47 +01:00
Federico Maggi
894e912252
[RF69] Fixed setPromiscuousMode(false) corner case
Signed-off-by: Federico Maggi <federico.maggi@gmail.com>
2022-12-01 13:24:42 +01:00
Federico Maggi
9422723bb7
[CC1101] Validate freq-dev unless special value 0
Signed-off-by: Federico Maggi <federico.maggi@gmail.com>
2022-11-27 10:20:29 +01:00
Federico Maggi
befba28629
No bound checks on frequency deviation if ~FSK 2022-11-26 19:38:36 +01:00
Federico Maggi
05217c095b
- Defined new RADIOLIB_ERR_NULL_POINTER
- all `begin()` now use macros for init values
- addressed other styling comments as per PR#612 review

Signed-off-by: Federico Maggi <federico.maggi@gmail.com>
2022-11-21 09:09:56 +01:00
Federico Maggi
1322796542
[RF69 & CC1101] Reworked cached parameters into getters
Signed-off-by: Federico Maggi <federico.maggi@gmail.com>
2022-11-20 01:35:08 +01:00
jgromes
f942ccaec7 [SX126x] Added option to specify custom CAD parameters 2022-11-18 13:39:51 +01:00
jgromes
e02b3f2ce0 [SX126x] Added missing Rx write arguments 2022-11-18 11:35:32 +01:00
Amalinda Gamage
a7e56800a8
Update SX126x.cpp 2022-11-18 16:08:57 +08:00
jgromes
feb9aaa227 [SX127x] Added option to keep received data despite CRC error (#610) 2022-11-16 19:21:55 +01:00
jgromes
4667c26448 [SX128x] Removed slowdown macro (#158) 2022-11-13 22:12:34 +01:00
jgromes
b11deda33d [SX126x] Removed slowdown macro (#158) 2022-11-13 22:12:04 +01:00
jgromes
5efdeedd67 [SX1262] Fixed allowed output power range (-9 dBm minimum). 2022-11-06 22:51:21 +01:00
jgromes
df7d1a99fe [SX126x] Fixed incorrect method called from derived class (#599) 2022-10-31 20:17:05 +01:00
jgromes
1316a805f3 [SX127x] Added option to specify interrupt direction for DIO 2022-10-23 20:39:15 +02:00
jgromes
d80f87410e [SX127x] Removed redundant IRQ clear 2022-10-23 20:38:36 +02:00
jgromes
9497cd3af1 [SX127x] Minor formatting fixes 2022-10-23 20:38:11 +02:00
jgromes
45e65a2811 [SX127x] Removed comment suggesting setGain only available on LoRa mode 2022-10-22 23:48:37 +02:00
jgromes
baf2a78981 [SX127x] Added missing GPIO input configuration in FSK mode 2022-10-22 23:48:17 +02:00
jgromes
6eeee45968 [CC1101] Use GDO2 for transmit interrupt (#357) 2022-10-09 19:21:39 +02:00
jgromes
ae64ec1911 [CC1101] Fixed incorrect GPIO NC check logic 2022-10-09 19:14:07 +02:00