Wykres commitów

129 Commity (e7da14421de7dfade754a262f6872989d82ee4a5)

Autor SHA1 Wiadomość Data
jgromes e7da14421d [Mod] Fix SPI command byte order 2024-04-14 20:22:16 +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
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 4ee17cc168 Debugging rework 2024-03-10 11:07:23 +01:00
jgromes a2e2003001 Reworked macro configuration system 2023-11-27 19:38:10 +01:00
Jonathan Bennett f4938ea585
Check for RADIOLIB_SPI_PARANOID = 1 rather than just defined (#883)
* Update BuildOpt.h to set RADIOLIB_SPI_PARANOID to 1 by default

* Update Module.cpp to check for RADIOLIB_SPI_PARANOID set to 1
2023-11-27 18:45:18 +01:00
jgromes 392708f8b5 [MOD] Make regdump and hexdump only available in debug 2023-09-12 17:13:07 +02:00
jgromes 8c63f93820 [MOD] Skip SPI status parsing for single-byte commands 2023-08-12 18:36:12 +02:00
jgromes bfe2c0829a [MOD] Moved debug info to runtime 2023-08-12 18:35:48 +02:00
jgromes 3e5c0d59c7 [MOD] Moved CS pin toggling inside SPI transaction block 2023-08-12 18:35:08 +02:00
Alistair Francis e88cf386d6 Module: Get status from first byte after the command
Instead of getting the status from the very first byte in the input
buffer, which will be what we read when we send the first byte. Let's
instead get the status from the first byte after the command. This
provides a more accurate status value.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2023-06-28 20:43:28 +10:00
Alistair Francis 445bc01450 modules: Don't read excess status data
The SX126x get status command returns a single status byte. The status
byte is automatically read in the `Module::SPItransferStream()` function
when we increment buffLen (see
https://github.com/jgromes/RadioLib/blob/master/src/Module.cpp#L259).

By setting numBytes we incorrectly end up reading 2 bytes. Instead set
numBytes to zero so we only read the single status byte.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2023-06-27 21:29:02 +10:00
jgromes a01b02fae2 [MOD] Rework for buffered SPI (#776) 2023-06-26 19:36:45 +02:00
Kevin Walton f63d228d0b
Bug in waitForMicroseconds prevTimingLen in V6.0.0
In Module::waitForMicroseconds if RADIOLIB_INTERRUPT_TIMING is defined the variable prevTimingLen has been incorrectly upated in v6.0.0 introducing a bug that stops compilation.

Fix: renamed _prevTimingLen to prevTimingLen to match other updates
2023-06-01 21:51:57 +01:00
jgromes 642f1bb157 [MOD] Added missing newlines 2023-05-21 18:24:31 +02:00
jgromes 6d54ea65db [MOD] Added option to use SX126x without GPIO 2023-05-18 20:49:37 +01:00
jgromes 03d2a9bf26 [MOD] Added common reflect method 2023-05-12 20:55:51 +02:00
jgromes 2eff7a358f [MOD] Removed redundant NSS pull 2023-04-30 22:11:05 +02:00
jgromes 044b4789b2 [MOD] Decreased default SPI timeout to 1000 ms 2023-04-24 18:25:42 +02:00
jgromes a22a4df88f [MOD] Added debug message when BUSY pin times out 2023-04-24 18:25:09 +02:00
jgromes 61f6da0cb2 [MOD] Added missing stdarg include for some platforms 2023-04-22 20:19:36 +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 ec3d4eaf20 Improve hardware abstraction layer 2023-04-12 23:16:18 +02:00
Mestery 45e9fd44bb
nitpick 2023-04-12 18:44:12 +02:00
Mestery 27575b8c49
Remove RADIOLIB_DEBUG_PRINT_BIN 2023-04-12 18:43:43 +02:00
Mestery 09fc9290bb
Undefine RADIOLIB_DEBUG_PRINT_BIN macro after use 2023-04-12 16:50:05 +02:00
Mestery 17ae017f89
address changes 2023-04-10 14:51:07 +02:00
Mestery 220b4dad7f
use printf in both build 2023-04-10 09:13:58 +00:00
jgromes 390b425b39 [MOD] Fixed default Arduino callbacks for SPI (#725) 2023-04-10 11:11:17 +02:00
jgromes f59a69f5c4 [MOD] Removed references to Arduino SPI callbacks (#725) 2023-04-10 09:06:40 +02:00
jgromes 9d36ae4bee [MOD] Fixed SPI callbacks on non-Arduino platforms (#725) 2023-04-09 22:37:36 +02:00
jgromes 0210e10a24 [MOD] Fixed swapped NSS/BUSY order (#716) 2023-03-30 23:17:34 +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 e920e1bf07 [MOD] Fixed some signed comparison warnings 2023-03-05 19:14:14 +01:00
jgromes 3c92219488 [MOD] Fixed print format (#685) 2023-03-01 21:50:40 +01:00
jgromes 32a42ee2c6 [MOD] Fixed format type 2023-02-25 13:28:52 +01:00
jgromes b014a1f748 [MOD] Improved regdump and hexdump 2023-02-25 13:20:30 +01:00
jgromes d8c50ae8ad [MOD] Remove default arguments from implementations 2023-02-19 17:12:05 +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 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 2980d8dbf1 [MOD] Fixed signed/unsigned comparison warning 2022-09-18 16:20:16 +02:00
jgromes a8c079f85e [MOD] Fixed hexdump printing when length is not divisible by 16 2022-08-18 20:48:51 +02:00