Polishing code (#803)

This commit is contained in:
Olivier
2017-04-02 20:03:59 +02:00
committed by Embedded Innovation
parent f84960dc28
commit 818f887926
21 changed files with 393 additions and 443 deletions
+3 -3
View File
@@ -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
}
+7 -5
View File
@@ -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