From 2f867153f9754ef9eada65bc8862343ab4774a5d Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 11 May 2024 17:15:25 +0100 Subject: [PATCH] [Si443x] Fixed issues found by cppcheck --- src/modules/Si443x/Si4430.h | 6 +++--- src/modules/Si443x/Si4431.h | 4 ++-- src/modules/Si443x/Si4432.h | 6 +++--- src/modules/Si443x/Si443x.cpp | 10 +++------- src/modules/Si443x/Si443x.h | 28 ++++++++++++++-------------- 5 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/modules/Si443x/Si4430.h b/src/modules/Si443x/Si4430.h index 6acac97d..2d212e05 100644 --- a/src/modules/Si443x/Si4430.h +++ b/src/modules/Si443x/Si4430.h @@ -21,7 +21,7 @@ class Si4430: public Si4432 { \brief Default constructor. \param mod Instance of Module that will be used to communicate with the radio chip. */ - Si4430(Module* mod); + Si4430(Module* mod); // cppcheck-suppress noExplicitConstructor // basic methods @@ -44,14 +44,14 @@ class Si4430: public Si4432 { \param freq Carrier frequency to be set in MHz. \returns \ref status_codes */ - int16_t setFrequency(float freq); + int16_t setFrequency(float freq) override; /*! \brief Sets output power. Allowed values range from -8 to 13 dBm in 3 dBm steps. \param power Output power to be set in dBm. \returns \ref status_codes */ - int16_t setOutputPower(int8_t power); + int16_t setOutputPower(int8_t power) override; #if !RADIOLIB_GODMODE protected: diff --git a/src/modules/Si443x/Si4431.h b/src/modules/Si443x/Si4431.h index 8d3d9dd9..a8939ea1 100644 --- a/src/modules/Si443x/Si4431.h +++ b/src/modules/Si443x/Si4431.h @@ -21,7 +21,7 @@ class Si4431: public Si4432 { \brief Default constructor. \param mod Instance of Module that will be used to communicate with the radio chip. */ - Si4431(Module* mod); + Si4431(Module* mod); // cppcheck-suppress noExplicitConstructor // basic methods @@ -44,7 +44,7 @@ class Si4431: public Si4432 { \param power Output power to be set in dBm. \returns \ref status_codes */ - int16_t setOutputPower(int8_t power); + int16_t setOutputPower(int8_t power) override; #if !RADIOLIB_GODMODE protected: diff --git a/src/modules/Si443x/Si4432.h b/src/modules/Si443x/Si4432.h index b0a8cb87..f3ac0661 100644 --- a/src/modules/Si443x/Si4432.h +++ b/src/modules/Si443x/Si4432.h @@ -21,7 +21,7 @@ class Si4432: public Si443x { \brief Default constructor. \param mod Instance of Module that will be used to communicate with the radio chip. */ - Si4432(Module* mod); + Si4432(Module* mod); // cppcheck-suppress noExplicitConstructor // basic methods @@ -44,14 +44,14 @@ class Si4432: public Si443x { \param freq Carrier frequency to be set in MHz. \returns \ref status_codes */ - int16_t setFrequency(float freq); + int16_t setFrequency(float freq) override; /*! \brief Sets output power. Allowed values range from -1 to 20 dBm in 3 dBm steps. \param power Output power to be set in dBm. \returns \ref status_codes */ - int16_t setOutputPower(int8_t power); + int16_t setOutputPower(int8_t power) override; #if !RADIOLIB_GODMODE protected: diff --git a/src/modules/Si443x/Si443x.cpp b/src/modules/Si443x/Si443x.cpp index 78120992..7dfd8eb8 100644 --- a/src/modules/Si443x/Si443x.cpp +++ b/src/modules/Si443x/Si443x.cpp @@ -558,11 +558,11 @@ int16_t Si443x::setEncoding(uint8_t encoding) { /// \todo - add inverted Manchester? switch(encoding) { case RADIOLIB_ENCODING_NRZ: - return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_INVERTED_OFF | RADIOLIB_SI443X_MANCHESTER_OFF | RADIOLIB_SI443X_WHITENING_OFF, 2, 0)); + return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_OFF | RADIOLIB_SI443X_WHITENING_OFF, 2, 0)); case RADIOLIB_ENCODING_MANCHESTER: - return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_INVERTED_OFF | RADIOLIB_SI443X_MANCHESTER_ON | RADIOLIB_SI443X_WHITENING_OFF, 2, 0)); + return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_ON | RADIOLIB_SI443X_WHITENING_OFF, 2, 0)); case RADIOLIB_ENCODING_WHITENING: - return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_INVERTED_OFF | RADIOLIB_SI443X_MANCHESTER_OFF | RADIOLIB_SI443X_WHITENING_ON, 2, 0)); + return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_OFF | RADIOLIB_SI443X_WHITENING_ON, 2, 0)); default: return(RADIOLIB_ERR_INVALID_ENCODING); } @@ -577,12 +577,8 @@ int16_t Si443x::setDataShaping(uint8_t sh) { switch(sh) { case RADIOLIB_SHAPING_NONE: return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_INVERTED_OFF | RADIOLIB_SI443X_MANCHESTER_OFF | RADIOLIB_SI443X_WHITENING_OFF, 2, 0)); - case RADIOLIB_SHAPING_0_3: - return(RADIOLIB_ERR_INVALID_ENCODING); case RADIOLIB_SHAPING_0_5: return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_2, RADIOLIB_SI443X_MODULATION_GFSK, 1, 0)); - case RADIOLIB_SHAPING_1_0: - return(this->mod->SPIsetRegValue(RADIOLIB_SI443X_REG_MODULATION_MODE_CONTROL_1, RADIOLIB_SI443X_MANCHESTER_INVERTED_OFF | RADIOLIB_SI443X_MANCHESTER_OFF | RADIOLIB_SI443X_WHITENING_ON, 2, 0)); default: return(RADIOLIB_ERR_INVALID_ENCODING); } diff --git a/src/modules/Si443x/Si443x.h b/src/modules/Si443x/Si443x.h index b8986b65..24f8bb06 100644 --- a/src/modules/Si443x/Si443x.h +++ b/src/modules/Si443x/Si443x.h @@ -564,7 +564,7 @@ class Si443x: public PhysicalLayer { \brief Default constructor. \param mod Instance of Module that will be used to communicate with the radio. */ - Si443x(Module* mod); + explicit Si443x(Module* mod); // basic methods @@ -607,7 +607,7 @@ class Si443x: public PhysicalLayer { %Module will wake up automatically when methods like transmit or receive are called. \returns \ref status_codes */ - int16_t sleep(); + int16_t sleep() override; /*! \brief Sets the module to standby (with XTAL on). @@ -658,23 +658,23 @@ class Si443x: public PhysicalLayer { \brief Sets interrupt service routine to call when a packet is received. \param func ISR to call. */ - void setPacketReceivedAction(void (*func)(void)); + void setPacketReceivedAction(void (*func)(void)) override; /*! \brief Clears interrupt service routine to call when a packet is received. */ - void clearPacketReceivedAction(); + void clearPacketReceivedAction() override; /*! \brief Sets interrupt service routine to call when a packet is sent. \param func ISR to call. */ - void setPacketSentAction(void (*func)(void)); + void setPacketSentAction(void (*func)(void)) override; /*! \brief Clears interrupt service routine to call when a packet is sent. */ - void clearPacketSentAction(); + void clearPacketSentAction() override; /*! \brief Interrupt-driven binary transmit method. Will start transmitting arbitrary binary data up to 64 bytes long. @@ -695,7 +695,7 @@ class Si443x: public PhysicalLayer { \brief Interrupt-driven receive method. IRQ will be activated when full valid packet is received. \returns \ref status_codes */ - int16_t startReceive(); + int16_t startReceive() override; /*! \brief Interrupt-driven receive method, implemented for compatibility with PhysicalLayer. @@ -705,7 +705,7 @@ class Si443x: public PhysicalLayer { \param len Ignored. \returns \ref status_codes */ - int16_t startReceive(uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len); + int16_t startReceive(uint32_t timeout, uint32_t irqFlags, uint32_t irqMask, size_t len) override; /*! \brief Reads data that was received after calling startReceive method. When the packet length is not known in advance, @@ -724,7 +724,7 @@ class Si443x: public PhysicalLayer { \param br Bit rate to be set (in kbps). \returns \ref status_codes */ - int16_t setBitRate(float br); + int16_t setBitRate(float br) override; /*! \brief Sets FSK frequency deviation from carrier frequency. Allowed values range from 0.625 to 320.0 kHz. @@ -745,7 +745,7 @@ class Si443x: public PhysicalLayer { \param syncWord Pointer to the array of sync word bytes. \param len Sync word length in bytes. */ - int16_t setSyncWord(uint8_t* syncWord, size_t len); + int16_t setSyncWord(uint8_t* syncWord, size_t len) override; /*! \brief Sets preamble length. @@ -787,7 +787,7 @@ class Si443x: public PhysicalLayer { \brief Get one truly random byte from RSSI noise. \returns TRNG byte. */ - uint8_t randomByte(); + uint8_t randomByte() override; /*! \brief Read version SPI register. Should return RADIOLIB_SI443X_DEVICE_VERSION (0x06) if Si443x is connected and working. @@ -800,13 +800,13 @@ class Si443x: public PhysicalLayer { \brief Set interrupt service routine function to call when data bit is received in direct mode. \param func Pointer to interrupt service routine. */ - void setDirectAction(void (*func)(void)); + void setDirectAction(void (*func)(void)) override; /*! \brief Function to read and process data bit in direct reception mode. \param pin Pin on which to read. */ - void readBit(uint32_t pin); + void readBit(uint32_t pin) override; #endif /*! @@ -826,7 +826,7 @@ class Si443x: public PhysicalLayer { #if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL protected: #endif - Module* getMod(); + Module* getMod() override; #if !RADIOLIB_GODMODE protected: