Commit graph

1885 commits

Author SHA1 Message Date
jgromes
455ce12eed [AFSK] Added SX126x to examples 2023-02-11 14:12:55 +01:00
jgromes
dc050df8d9 [SX126x] Added support for AFSK transmission 2023-02-11 14:11:44 +01:00
Jan Gromeš
526adc7431
Merge pull request #678 from matthijskooijman/remove-constexpr
[MOD] Remove constexpr usage
2023-02-04 15:49:21 +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
jgromes
1afa947030 [CI] Temporarily disable uncrustify action 2023-01-29 18:31:01 +01:00
jgromes
773b3e10aa [CI] Another attempt at dubious ownership fix (CI_FORCE_UNCRUST) 2023-01-29 18:28:01 +01:00
jgromes
0c2d40fda7 [CI] Fix dubious ownership error 2023-01-29 18:23:46 +01:00
Jan Gromeš
929b7d7179
Merge pull request #676 from jgromes/uncrustify
Added Uncrustify
2023-01-29 18:12:02 +01:00
Jan Gromeš
1a0daa6eb5
Go back to the original action 2023-01-29 17:37:11 +01:00
Jan Gromeš
ef85c5f476
Merge pull request #674 from andrew-moroz/sx126x-rx-gain-persist
sx126x-rx-gain-persist: add ability to persist Rx gain setting when calling SX126x::setRxBoostedGainMode
2023-01-29 16:53:55 +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
dc3fb2d303 [CI] Use patched action 2023-01-22 19:55:59 +01:00
jgromes
ec2da7dc3e [CI] Added option to force check CI_FORCE_UNCRUST 2023-01-22 19:45:51 +01:00
jgromes
67e52ed27a [CI] Added uncrustify workflow 2023-01-22 19:33:36 +01:00
jgromes
e353844afe Added uncrustify config file 2023-01-22 19:13:06 +01: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
Jan Gromeš
7a25b27c31
Merge pull request #663 from andrew-moroz/andrew-moroz/sx126x-rx-boosted-gain
[SX126x] Add method to support SX126x Rx Boosted Gain mode
2023-01-16 23:08:37 +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
b78693b8fb [CI] Fixed options (CI_BUILD_ALL) 2023-01-16 18:58:50 +01:00
jgromes
39aac172a4 [CI] Fixed missing colon (CI_BUILD_ALL) 2023-01-16 18:55:28 +01:00
jgromes
230fd3376a [CI] Fixed remaining output variables (CI_BUILD_ALL) 2023-01-16 18:52:28 +01:00
jgromes
c478d9db20 [CI] Remove extra quotes (esp32:esp32:esp32) 2023-01-16 18:45:37 +01:00
jgromes
143571e0a1 [CI] Try to fix broken index URLs (esp32:esp32:esp32) 2023-01-16 18:43:45 +01:00
jgromes
3da909ec3d [CI] Fixed deprecation warnings (CI_BUILD_ALL) 2023-01-16 18:12:56 +01:00
jgromes
eaaac36f28 Bump version to 5.6.0 2023-01-15 17:42:44 +01:00
jgromes
30489ba010 Added note about STM32WL to readme 2023-01-15 09:50:05 +01:00
jgromes
5b96340332 [CC1101] Fixed setPromiscuousMode(true) always failing 2023-01-14 23:20:27 +01:00
jgromes
2c8b63e038 [Hell] Fixed timing issues on SX126x with TCXO (#659) 2023-01-14 23:13:58 +01:00
jgromes
5ca2c8533c [PHY] Added standby types abstraction 2023-01-14 23:13:27 +01:00
Jan Gromeš
7267e5ffc9
Merge pull request #649 from matthijskooijman/add-stm32wl
Add support for STM32WL integrated transceivers
2023-01-14 18:52:37 +01:00
jgromes
ba05317b72 Added new keywords 2023-01-10 18:09:55 +01:00
Matthijs Kooijman
6531ce7400 [CI]: Set up CI for STM32WLx (CI_BUILD_ALL)
This adds a build for the Nucleo WL55JC1 board, and ensures that
the STM32WLx examples are skipped on all other boards.

To slightly generalize the list of boards, this pushes the pnum option
for the black pill into the boards list, instead of setting it into the
options variable (even though it is technically a board option and not
the board itself, conceptually it is part of the selected board and
these values are just concatenated, so it can go in either place).

Co-Authored-By: jgromes <jan.gromes@gmail.com>
2023-01-10 18:09:55 +01:00
Matthijs Kooijman
e116a20d89 [STM32WLx] Add examples
Co-Authored-By: jgromes <jan.gromes@gmail.com>
2023-01-10 18:09:55 +01:00
Matthijs Kooijman
e52ffb0a69 [STM32WLx] Only build on compatible STM32 boards
This checks for some system macros to be set, but also includes the
doxygen build to generate documentation.

This reuses the RADIOLIB_EXCLUDE_STM32WLX that the code already checks
for to prevent having to duplicate this macro check in four places.

To detect running inside doxygen, this configures doxygen to predefine
a DOXYGEN macro (it seems no such macros are defined by default by
doxygen).
2023-01-10 18:09:55 +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
83ff964b66 [MOD] Generalize rfswitch pin handling
This defines operation modes (IDLE, RX and TX) and allows defining up to
to three pins to be controlled. For each mode a value can be specified
for each pin a table.

Compared to the previous handling, this:
 - Allows up to three pins instead of only two.
 - Gives more control over output pin values (e.g. to simply change
   polarity or support more complex control logic).

In addition, the modes are treated as opaque by the Module code,
allowing radio classes to define their own modes if needed.

Some notes regarding the implementation:
 - The number of pins is limited at three, since most boards seem to need
   only two pins and only the Nucleo STM32WL55 board needs three. If
   more pins are needed in the future, the setRfSwitchTable()
   can be overloaded to accept either a 3-element or e.g. 4-element pins
   array, to allow new and old code to work as-is.

   Note that there is a RFSWITCH_MAX_PINS constant defined, but it is
   not recommended for sketches to use this constant when defining
   a rfswitch pins array, to prevent issues when this value is ever
   increased and such an array gets extra zero elements (that will be
   interpreted as pin 0).

   Note that this is not a problem for the RfSwitchMode_t values array,
   since any extra values in there will only be used if a valid pin was
   set in the pins array.

 - The pins array is passed by reference, so the compiler complains if
   the array passed is not the expected size. Since a reference to an
   array without a length is not supported (at least not by the gcc
   7 used by the AVR core - gcc 10 for STM32 seems to accept it), the
   table array is passed as a pointer instead (but because arrays and
   pointers are reasonably interchangeable, the caller does not see the
   difference).

 - The existing setRfSwitchPins() method is still supported as before.
   Internally it creates a table with the right values and pins and
   passes those to setRfSwitchTable.

 - For easier review, this commit does not modify all calls to
   setRfSwitchState() in all radio modules yet, but has a compatibility
   wrapper to delay this change until the next commit. Similarly, the
   setRfSwitchTable() method is now defined on Module only, a wrapper
   for it will be defined in all radios that already have the
   setRfSwitchPins() wrapper in another commit.

 - To allow future radios to define any number of modes, the modes table
   does not have a fixed length, but instead is terminated by a special
   value. This is a bit fragile (if the terminator is omitted, the code
   will read past the end of the array), but rather flexible. One
   alternative to this approach would be to make setRfSwitchTable
   a template that deduces the array size from a template argument and
   then stores the size explicitly, but using templates probably reduces
   code clarity.
2023-01-09 09:46:39 +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
139a68dfd4 [EXT] Added support for external radios (646) 2023-01-08 15:12:49 +01:00
jgromes
02de83f941 [PHY] Made virtual overloads non-pure 2023-01-08 15:10:48 +01:00
jgromes
27c1eb715a Removed remaining enable interrupt (#657) 2023-01-07 22:31:20 +01:00
jgromes
6666060d52 Removed unnecessary interrupt enable (#657) 2023-01-07 22:21:16 +01:00
jgromes
0cd9dd2983 [SX126x] Added note about allowed OCP range (#654) 2023-01-04 10:22:06 +01:00