From b42729876b2ff2c083d6644f37feba7d681b16cd Mon Sep 17 00:00:00 2001 From: Davide Mor <davide.mor@skywarder.eu> Date: Wed, 13 Mar 2024 10:52:43 +0100 Subject: [PATCH] [sx1278] Added documentation --- src/shared/radio/SX1278/SX1278Fsk.cpp | 6 ++++++ src/shared/radio/SX1278/SX1278Lora.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/shared/radio/SX1278/SX1278Fsk.cpp b/src/shared/radio/SX1278/SX1278Fsk.cpp index 4ca766477..768d05858 100644 --- a/src/shared/radio/SX1278/SX1278Fsk.cpp +++ b/src/shared/radio/SX1278/SX1278Fsk.cpp @@ -34,6 +34,10 @@ namespace Boardcore using namespace SX1278; using namespace SX1278::Fsk; +// Value used as a magic value in the packet to check that the packet does +// indeed come from us. This is implemented in hardware by the SX1278. This +// value is also used to check if the device has been resetted or not, as we +// this custom value is different from the default one at reset. static constexpr uint16_t FSK_SYNC_VALUE = 0x12ad; long long now() { return miosix::getTick() * 1000 / miosix::TICK_FREQ; } @@ -63,6 +67,8 @@ SX1278Fsk::Error SX1278Fsk::init(const Config &config) assert(config.power >= min_power && config.power <= max_power && "[sx1278] Configured power invalid for given frontend!"); + // OCP values range from 0 to 240, with ranges from 120 to 130 being + // unusable assert(((config.ocp >= 0 && config.ocp <= 120) || (config.ocp >= 130 && config.ocp <= 240)) && "[sx1278] Invalid ocp!"); diff --git a/src/shared/radio/SX1278/SX1278Lora.cpp b/src/shared/radio/SX1278/SX1278Lora.cpp index e9c4759ae..9918ed8de 100644 --- a/src/shared/radio/SX1278/SX1278Lora.cpp +++ b/src/shared/radio/SX1278/SX1278Lora.cpp @@ -32,6 +32,10 @@ namespace Boardcore using namespace SX1278; using namespace SX1278::Lora; +// Value used as a magic value in the packet to check that the packet does +// indeed come from us. This is implemented in hardware by the SX1278. This +// value is also used to check if the device has been resetted or not, as we +// this custom value is different from the default one at reset. static constexpr uint8_t LORA_SYNC_VALUE = 0x69; static constexpr uint8_t MAX_PAYLOAD_LENGTH = 0xff; @@ -151,6 +155,8 @@ SX1278Lora::Error SX1278Lora::init(const Config &config) assert(config.power >= min_power && config.power <= max_power && "[sx1278] Configured power invalid for given frontend!"); + // OCP values range from 0 to 240, with ranges from 120 to 130 being + // unusable assert(((config.ocp >= 0 && config.ocp <= 120) || (config.ocp >= 130 && config.ocp <= 240)) && "[sx1278] Invalid ocp!"); -- GitLab