Wykres commitów

98 Commity (master)

Autor SHA1 Wiadomość Data
jgromes f78b3ccc97 [MOD] Increase maximum number of RF switch pins to 5 2024-05-26 16:36:42 +02:00
jgromes ffbcdd0d57 [MOD] Move SPI timeout to SPI config struct 2024-05-19 13:55:22 +02:00
jgromes 26fb617062 [MOD] Make cmd pointer const 2024-05-05 19:47:09 +01:00
Elizabeth Myers 205031550b
Use RadioLibTime_t (aka unsigned long) when dealing with millis() and micros() (#1075)
* Use unsigned long when dealing with millis() and micros().

Although sizeof(uint32_t) == sizeof(unsigned long) on Arduino, this is
not the case on 64-bit Linux, where sizeof(unsigned long) ==
sizeof(uint64_t).

Most timestamp arithmetic and comparisons have been left alone, to
reduce code churn. This is fine, as uint32_t is perfectly wide to store
most timestamp deltas this library will deal with, and C will promote
the integer rather than do a narrowing conversion. The real problem
arises with narrowing conversions being done by assuming timestamps are
32-bit.

No functional changes intended for platforms where sizeof(uint32_t) ==
sizeof(unsigned long) (so most 8/16/32-bit platforms).

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>

* Change most timestamps to use RadioLibTime_t.

This makes it obvious what is and isn't a timestamp.

Not everything has been converted; anything dealing with protocol and
chip-level timestamps has been left alone on purpose, to make it clear
that these functions do require 32-bit timestamps.

No functional changes intended on platforms where sizeof(uint32_t) ==
sizeof(unsigned long).

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>

* Use uint32_t internally in getTimeOnAir.

We need to not overflow the integers with the shifts and
multiplications, so this is correct behaviour.

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>

---------

Signed-off-by: Elizabeth Myers <elizabeth.jennifer.myers@gmail.com>
2024-04-25 21:50:58 +02:00
jgromes c9d8c601df [Mod] Use enum for bit widths 2024-04-07 17:34:31 +01:00
Jan Gromeš 4fa0656ddd
[MOD] SPI configuration interface rework (#1057)
* [MOD] Rework SPI config interface

* [CC1101] Rework SPI config interface

* [nRF24] Rework SPI config interface

* [SX126x] Rework SPI config interface

* [SX128x] Rework SPI config interface

* Fix missing moved debug info

* [MOD] Fix signed warnings
2024-04-07 17:05:07 +02:00
jgromes e7ee407b0d [Doc] Additional doxygen fixes 2024-04-01 12:11:13 +02:00
Jan Gromeš e57c9b08ea
[Doxygen] Warnings fixes (#1046)
* [APRS] Fix Doxygen warnings

* [Print] Fix Doxygen warnings

* [CC1101] Fixed doxygen warnings

* [nRF24] Fixed doxygen warnings

* [RF69] Fixed doxygen warnings

* [SX126x] Fixed doxygen warnings

* [SX127x] Fixed doxygen warnings

* [AFSK] Fixed doxygen warnings

* [APRS] Fixed doxygen warnings

* [Bell] Fixed doxygen warnings

* [Ext] Fixed doxygen warnings

* [LoRaWAN] Fixed doxygen warnings

* [PHY] Fixed doxygen warnings

* [Print] Fixed doxygen warnings

* [Mod] Fixed doxygen warnings
2024-04-01 11:11:24 +02:00
Jan Gromeš cfc425970c
[LoRaWAN] Resolve warnings, fix bugs for fixed bands (#1021)
* [LoRaWAN] Resolve warnings

* [LoRaWAN] Fixed bands: improve initial datarate, fix CFList bug

* [LoRaWAN] Improve MAC debug output formatting

* Fix hexdump debug level

* Remove unnecessary error, add new ones to keywords

* [LoRaWAN] Discard useless check

---------

Co-authored-by: StevenCellist <steven@boonstoppel.nu>
2024-03-18 16:39:55 +01:00
jgromes a2e2003001 Reworked macro configuration system 2023-11-27 19:38:10 +01:00
jgromes 392708f8b5 [MOD] Make regdump and hexdump only available in debug 2023-09-12 17:13:07 +02:00
jgromes 8fd0a67a78 Typo fixes 2023-07-15 19:13:16 +02:00
jgromes 03d2a9bf26 [MOD] Added common reflect method 2023-05-12 20:55:51 +02:00
jgromes 044b4789b2 [MOD] Decreased default SPI timeout to 1000 ms 2023-04-24 18:25:42 +02:00
jgromes 9749083573 [MOD] Use compact Doxygen and stop using reserved format 2023-04-22 18:50:12 +02:00
jgromes 09c3ac4f6b [HAL] Formatting cleanup, added doxygen comments 2023-04-22 18:11:00 +02:00
Mestery 9a68a3c901 use uint32 instead of uint8 for pin type 2023-04-16 21:39:00 +02:00
Mestery 6695133576 fix documentation 2023-04-16 21:10:57 +02:00
Mestery f37c0b55c0 try move include inside 2023-04-16 20:54:48 +02:00
Mestery ec3d4eaf20 Improve hardware abstraction layer 2023-04-12 23:16:18 +02:00
Mestery 17ae017f89
address changes 2023-04-10 14:51:07 +02:00
jgromes 7c0fc5305a [STM32WL] Fixed build for Platformio (#718) 2023-04-10 10:29:21 +02:00
jgromes 9d36ae4bee [MOD] Fixed SPI callbacks on non-Arduino platforms (#725) 2023-04-09 22:37:36 +02:00
jgromes 5ba6f41230 [MOD] Convert end of RF switch mode to macro (https://github.com/jgromes/RadioLib/actions/runs/4337180408) 2023-03-05 19:16:37 +01:00
jgromes b014a1f748 [MOD] Improved regdump and hexdump 2023-02-25 13:20:30 +01:00
jgromes 6bf9cebc43 [MOD] Added SPI stream read/write 2023-02-19 16:59:03 +01:00
jgromes a8d35f7881 [MOD] Use SPI stream for register read/write 2023-02-19 14:22:30 +01:00
jgromes 308ad87320 [MOD] Port 16-bit address from ax5x43 dev 2023-02-19 12:41:49 +01:00
jgromes e07d1d9dc1 [MOD] Added stream SPI transfer 2023-02-19 12:32:17 +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
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 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 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
jgromes 04357cb306 [MOD] Added support for interrupt-based timing 2022-11-18 17:03:34 +01:00
jgromes a28aff7971 Moved callback generators to the end of Module declaration (#605) 2022-11-13 11:03:05 +01:00
Peter Lawrence 4bdec52f88 remedy Module when RADIOLIB_BUILD_ARDUINO is not defined 2022-08-04 17:46:58 -05:00
jgromes 8675f13e5d [Morse] Added basic Morse receive support (#545) CI_BUILD_ALL 2022-07-30 08:53:57 +02:00
jgromes 8ae092ac81 [MOD] Added regdump function 2022-07-04 15:30:37 +02:00
jgromes f8f73d2ccb [MOD] Added helper hexdump function 2022-07-03 11:05:56 +02:00
Thomas Göttgens 1ebf420a86
change locking mechanism in patch to transactions 2022-06-12 21:20:48 +02:00
Thomas Göttgens 08989ff6fa
Allow SPItransfer to be overridden by subclasses
This allows API clients to provide 'smarter' versions of Module that can do things like add thread safety so that multiple devices (and service threads) can share the same SPI bus. i.e. a subclass would lock some sort of mutex.

This is used in the Radiolib Fork for Meshtastic to share an SPI bus with SD Card and TFT Display but we want to move back to upstream and not maintain our own fork.
2022-06-10 12:28:32 +02:00
jgromes 97f3b94c4f [MOD] Added missing default SPI settings (#416) 2021-12-02 23:31:12 +01:00
jgromes 9e9a65e19e Added missing macro guard 2021-11-14 11:47:33 +01:00
jgromes 10ec10d233 Removerd reference to UART 2021-11-14 11:35:32 +01:00
jgromes 8111bc058f Added HAL 2021-11-14 11:33:35 +01:00
jgromes 5bb9887364 Swapped SerialModule rst and serial arguments 2021-09-24 08:48:23 +02:00
jgromes 0f1140e5ad Added SerialModule wrapper class (#305) 2021-09-05 12:00:30 +02:00
jgromes 5c0b4dbb10 Extract common bit reflection methods 2021-06-14 20:59:16 +02:00
jgromes d49a107c7e Added SPI readout check bitmask 2021-04-15 19:34:53 +02:00
jgromes aad4b84b89 Added default argument for SPISettings (#239) 2021-02-05 23:15:09 +01:00