From c4a61d27086200ef4bc7cc19278d0c9ae5ac6d4c Mon Sep 17 00:00:00 2001 From: crosstyan Date: Thu, 7 Aug 2025 12:01:12 +0800 Subject: [PATCH] feat: add TX continuous wave mode and update regulator mode handling --- inc/llcc68.hpp | 78 ++++++++++++++++++++++++-------------- inc/llcc68_definitions.hpp | 5 +++ 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/inc/llcc68.hpp b/inc/llcc68.hpp index 9b9583f..3244cf6 100644 --- a/inc/llcc68.hpp +++ b/inc/llcc68.hpp @@ -99,7 +99,7 @@ constexpr bool USE_REGULATOR_LDO = false; TCXO (Temperature Compensated Crystal Oscillator) will be disabled if this is set to true */ -constexpr bool USE_XTAL = true; +constexpr bool USE_TXCO = false; constexpr llcc68::TcxoVoltage DEFAULT_TCXO_VOLTAGE = TcxoVoltage::V_1_6; using error_t = spi::error_t; @@ -117,9 +117,7 @@ struct transmit_state_t { /** * @brief private namespace; Don't use anything in this namespace outside of this file */ -namespace details { - inline uint32_t __tcxo_delay__; -} +namespace details {} constexpr auto delay_ms = app::utils::delay_ms; @@ -235,7 +233,7 @@ set_buffer_base_address(const uint8_t txBaseAddress = DEFAULT_TX_BUFFER_ADDRESS, } inline Result -set_regulator_mode(const uint8_t mode) { +set_regulator_mode(const enum RegulatorMode mode) { const uint8_t data[] = {mode}; return spi::write_stream(RADIOLIB_SX126X_CMD_SET_REGULATOR_MODE, data); } @@ -703,6 +701,23 @@ set_cad() { return spi::write_stream(RADIOLIB_SX126X_CMD_SET_CAD, data); } +/** + * \brief Set the TX continuous wave mode + * \note CW + */ +inline Result +set_tx_continuous_wave() { + const uint8_t data[] = {spi::SPI_NOP_COMMAND}; + return spi::write_stream(RADIOLIB_SX126X_CMD_SET_TX_CONTINUOUS_WAVE, data); +} + +inline Result +set_tx_infinite_preamble() { + const uint8_t data[] = {spi::SPI_NOP_COMMAND}; + return spi::write_stream(RADIOLIB_SX126X_CMD_SET_TX_INFINITE_PREAMBLE, data); +} + + /** * \brief Set the PA configuration * \param pa_duty_cycle paDutyCycle controls the duty cycle (conduction angle) of both PAs (SX1261 and SX1262). The maximum output power, the @@ -871,16 +886,6 @@ set_output_power(const int8_t power) { return write_register(RADIOLIB_SX126X_REG_OCP_CONFIGURATION, std::span{&ocp, 1}); } -inline Result -set_regulator_ldo() { - return set_regulator_mode(RADIOLIB_SX126X_REGULATOR_LDO); -} - -inline Result -set_regulator_dc_dc() { - return set_regulator_mode(RADIOLIB_SX126X_REGULATOR_DC_DC); -} - /** * \brief checks if BUSY pin is low * \return true if BUSY pin is low, false otherwise @@ -1250,12 +1255,34 @@ static constexpr auto begin = [](const lora_parameters_t ¶ms) -> Result Result(); APP_RADIO_RETURN_ERR_CTX(res, "current limit"); diff --git a/inc/llcc68_definitions.hpp b/inc/llcc68_definitions.hpp index 12e4767..d86fcba 100644 --- a/inc/llcc68_definitions.hpp +++ b/inc/llcc68_definitions.hpp @@ -27,6 +27,11 @@ enum LoRaBandwidth : uint8_t { BW_500_0 = 0x06, }; +enum RegulatorMode : uint8_t { + REGULATOR_LDO = RADIOLIB_SX126X_REGULATOR_LDO, + REGULATOR_DC_DC = RADIOLIB_SX126X_REGULATOR_DC_DC, +}; + inline const char *to_str(LoRaBandwidth bw) { switch (bw) { case LoRaBandwidth::BW_7_8: