Polishing code (#803)
This commit is contained in:
committed by
Embedded Innovation
parent
f84960dc28
commit
818f887926
@@ -1093,7 +1093,7 @@ LOCAL void RFM69_listenModeSendBurst(const uint8_t recipient, uint8_t* data, con
|
||||
RFM69_DEBUG(PSTR("RFM69:LSM:Send burst for %d ms\n"), cycleDurationMs);
|
||||
|
||||
(void)RFM69_setRadioMode(RFM69_RADIO_MODE_TX);
|
||||
uint32_t startTime = millis();
|
||||
uint32_t startTime = hwMillis();
|
||||
|
||||
while (timeRemaining.l > 0) {
|
||||
// send burst
|
||||
@@ -1119,7 +1119,7 @@ LOCAL void RFM69_listenModeSendBurst(const uint8_t recipient, uint8_t* data, con
|
||||
|
||||
while ((RFM69_readReg(RFM69_REG_IRQFLAGS2) & RFM69_IRQFLAGS2_FIFONOTEMPTY) !=
|
||||
0x00); // make sure packet is sent before putting more into the FIFO
|
||||
timeRemaining.l = cycleDurationMs - (millis() - startTime);
|
||||
timeRemaining.l = cycleDurationMs - (hwMillis() - startTime);
|
||||
}
|
||||
|
||||
(void)RFM69_setRadioMode(RFM69_RADIO_MODE_TX);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
/**
|
||||
* @file RFM69.h
|
||||
*
|
||||
* @defgroup RFM69grp RFM69
|
||||
* @defgroup RFM69Newgrp RFM69New
|
||||
* @ingroup internals
|
||||
* @{
|
||||
*
|
||||
@@ -144,13 +144,17 @@ extern HardwareSPI SPI; //!< SPI
|
||||
// RFM69H(C)W
|
||||
#define RFM69_VERSION_HW //!< HW version
|
||||
#define RFM69_MIN_POWER_LEVEL_DBM ((rfm69_powerlevel_t)-2) //!< min. power level, -18dBm
|
||||
#if !defined(RFM69_MAX_POWER_LEVEL_DBM)
|
||||
#if defined(MY_RFM69_MAX_POWER_LEVEL_DBM)
|
||||
#define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM //!< MY_RFM69_MAX_POWER_LEVEL_DBM
|
||||
#else
|
||||
#define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)20) //!< max. power level, +20dBm
|
||||
#endif
|
||||
#else
|
||||
// RFM69(C)W
|
||||
#define RFM69_MIN_POWER_LEVEL_DBM ((rfm69_powerlevel_t)-18) //!< min. power level, -18dBm
|
||||
#if !defined(RFM69_MAX_POWER_LEVEL_DBM)
|
||||
#if defined(MY_RFM69_MAX_POWER_LEVEL_DBM)
|
||||
#define RFM69_MAX_POWER_LEVEL_DBM MY_RFM69_MAX_POWER_LEVEL_DBM //!< MY_RFM69_MAX_POWER_LEVEL_DBM
|
||||
#else
|
||||
#define RFM69_MAX_POWER_LEVEL_DBM ((rfm69_powerlevel_t)13) //!< max. power level, +13dBm
|
||||
#endif
|
||||
#endif
|
||||
@@ -352,7 +356,7 @@ LOCAL uint8_t RFM69_getAddress(void);
|
||||
|
||||
/**
|
||||
* @brief Tests whether a new message is available
|
||||
* @return True if a new, complete, error-free uncollected message is available to be retreived by @ref RFM95_recv()
|
||||
* @return True if a new, complete, error-free uncollected message is available to be retreived by @ref RFM69_recv()
|
||||
*/
|
||||
LOCAL bool RFM69_available(void);
|
||||
|
||||
|
||||
@@ -325,7 +325,6 @@ bool RFM69::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferS
|
||||
uint32_t sentTime = hwMillis();
|
||||
while (hwMillis() - sentTime < retryWaitTime) {
|
||||
if (ACKReceived(toAddress)) {
|
||||
//Serial.print(" ~ms:"); Serial.print(millis() - sentTime);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ LOCAL uint8_t RFM95_RAW_writeByteRegister(const uint8_t address, uint8_t value)
|
||||
#define RFM95_burstReadReg(__reg, __buf, __len) RFM95_spiMultiByteTransfer( __reg & RFM95_READ_REGISTER, (uint8_t*)__buf, __len, true )
|
||||
#define RFM95_burstWriteReg(__reg, __buf, __len) RFM95_spiMultiByteTransfer( __reg | RFM95_WRITE_REGISTER, (uint8_t*)__buf, __len, false )
|
||||
|
||||
LOCAL bool RFM95_initialise(const float frequency)
|
||||
LOCAL bool RFM95_initialise(const uint32_t frequencyHz)
|
||||
{
|
||||
RFM95_DEBUG(PSTR("RFM95:INIT\n"));
|
||||
// reset radio module if rst pin defined
|
||||
@@ -181,7 +181,7 @@ LOCAL bool RFM95_initialise(const float frequency)
|
||||
const rfm95_modemConfig_t configuration = { MY_RFM95_MODEM_CONFIGRUATION };
|
||||
RFM95_setModemRegisters(&configuration);
|
||||
RFM95_setPreambleLength(RFM95_PREAMBLE_LENGTH);
|
||||
RFM95_setFrequency(frequency);
|
||||
RFM95_setFrequency(frequencyHz);
|
||||
(void)RFM95_setTxPowerLevel(MY_RFM95_TX_POWER_DBM);
|
||||
// IRQ
|
||||
hwPinMode(MY_RFM95_IRQ_PIN, INPUT);
|
||||
@@ -438,7 +438,7 @@ LOCAL void RFM95_powerUp(void)
|
||||
LOCAL void RFM95_powerDown(void)
|
||||
{
|
||||
#if defined(MY_RFM95_POWER_PIN)
|
||||
hwDigitalWrite(RFM69_POWER_PIN, LOW);
|
||||
hwDigitalWrite(MY_RFM95_POWER_PIN, LOW);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -60,14 +60,14 @@
|
||||
* CR = Error correction code
|
||||
* SF = Spreading factor, chips / symbol
|
||||
*
|
||||
* | CONFIG | REG_1D | REG_1E | REG_26 | BW | CR | SF | Comment | air-time (~15 bytes)
|
||||
* | CONFIG | REG_1D | REG_1E | REG_26 | BW | CR | SF | Comment | air-time (15 bytes)
|
||||
* |------------------|--------|--------|--------|-------|-----|------|------------------------------------------------
|
||||
* | BW125CR45SF128 | 0x72 | 0x74 | 0x04 | 125 | 4/5 | 128 | Default, medium range | 50ms
|
||||
* | BW500CR45SF128 | 0x92 | 0x74 | 0x04 | 500 | 4/5 | 128 | Fast, short range | 15ms
|
||||
* | BW31_25CR48SF512 | 0x48 | 0x94 | 0x04 | 31.25 | 4/8 | 512 | Slow, long range | 900ms
|
||||
* | BW125CR48SF4096 | 0x78 | 0xC4 | 0x0C | 125 | 4/8 | 4096 | Slow, long range | 1500ms
|
||||
*
|
||||
* See here for air-time calculation: https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc/edit#gid=0
|
||||
* See here for air-time calculation: https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc
|
||||
*
|
||||
* @brief API declaration for RFM95
|
||||
*
|
||||
@@ -189,7 +189,9 @@ extern HardwareSPI SPI; //!< SPI
|
||||
#define RFM95_internalToSNR(__value) ((int8_t)(__value / 4)) //!< Convert internal SNR to SNR
|
||||
|
||||
#define RFM95_MIN_POWER_LEVEL_DBM ((rfm95_powerLevel_t)5u) //!< min. power level
|
||||
#if !defined(RFM95_MAX_POWER_LEVEL_DBM)
|
||||
#if defined(MY_RFM95_MAX_POWER_LEVEL_DBM)
|
||||
#define RFM95_MAX_POWER_LEVEL_DBM MY_RFM95_MAX_POWER_LEVEL_DBM //!< MY_RFM95_MAX_POWER_LEVEL_DBM
|
||||
#else
|
||||
#define RFM95_MAX_POWER_LEVEL_DBM ((rfm95_powerLevel_t)23u) //!< max. power level
|
||||
#endif
|
||||
/**
|
||||
@@ -298,10 +300,10 @@ typedef struct {
|
||||
|
||||
/**
|
||||
* @brief Initialise the driver transport hardware and software
|
||||
* @param frequency
|
||||
* @param frequencyHz Transmitter frequency in Hz
|
||||
* @return True if initialisation succeeded
|
||||
*/
|
||||
LOCAL bool RFM95_initialise(const float frequency);
|
||||
LOCAL bool RFM95_initialise(const uint32_t frequencyHz);
|
||||
/**
|
||||
* @brief Set the driver/node address
|
||||
* @param addr
|
||||
|
||||
Reference in New Issue
Block a user