mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-24 18:23:08 +00:00
Move Custom95 in with the rest of the RH code, to be ready to refactor
This commit is contained in:
parent
fd17193d5e
commit
5904d66111
@ -40,13 +40,12 @@
|
||||
/// significant 4 bits are reserved for applications.
|
||||
class RHGenericDriver
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/// \brief Defines different operating modes for the transport hardware
|
||||
///
|
||||
/// These are the different values that can be adopted by the _mode variable and
|
||||
/// returned by the mode() member function,
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
RHModeInitialising = 0, ///< Transport is initialising. Initial default value until init() is called..
|
||||
RHModeSleep, ///< Transport hardware is in low power sleep mode (if supported)
|
||||
RHModeIdle, ///< Transport is idle.
|
||||
@ -72,30 +71,6 @@ public:
|
||||
/// \return true if a new, complete, error-free uncollected message is available to be retreived by recv().
|
||||
virtual bool available() = 0;
|
||||
|
||||
/// Turns the receiver on if it not already on.
|
||||
/// If there is a valid message available, copy it to buf and return true
|
||||
/// else return false.
|
||||
/// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted).
|
||||
/// You should be sure to call this function frequently enough to not miss any messages
|
||||
/// It is recommended that you call it in your main loop.
|
||||
/// \param[in] buf Location to copy the received message
|
||||
/// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
|
||||
/// \return true if a valid message was copied to buf
|
||||
virtual bool recv(uint8_t* buf, uint8_t* len) = 0;
|
||||
|
||||
/// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
|
||||
/// Then optionally waits for Channel Activity Detection (CAD)
|
||||
/// to show the channnel is clear (if the radio supports CAD) by calling waitCAD().
|
||||
/// Then loads a message into the transmitter and starts the transmitter. Note that a message length
|
||||
/// of 0 is NOT permitted. If the message is too long for the underlying radio technology, send() will
|
||||
/// return false and will not send the message.
|
||||
/// \param[in] data Array of data to be sent
|
||||
/// \param[in] len Number of bytes of data to send (> 0)
|
||||
/// specify the maximum time in ms to wait. If 0 (the default) do not wait for CAD before transmitting.
|
||||
/// \return true if the message length was valid and it was correctly queued for transmit. Return false
|
||||
/// if CAD was requested and the CAD timeout timed out before clear channel was detected.
|
||||
virtual bool send(const uint8_t* data, uint8_t len) = 0;
|
||||
|
||||
/// Returns the maximum message length
|
||||
/// available in this Driver.
|
||||
/// \return The maximum legal message length
|
||||
@ -228,7 +203,7 @@ public:
|
||||
/// \param[in] prompt string to preface the print
|
||||
/// \param[in] buf Location of the buffer to print
|
||||
/// \param[in] len Length of the buffer in octets.
|
||||
static void printBuffer(const char* prompt, const uint8_t* buf, uint8_t len);
|
||||
static void printBuffer(const char *prompt, const uint8_t *buf, uint8_t len);
|
||||
|
||||
/// Returns the count of the number of bad received packets (ie packets with bad lengths, checksum etc)
|
||||
/// which were rejected and not delivered to the application.
|
||||
@ -247,8 +222,7 @@ public:
|
||||
/// \return The number of packets successfully transmitted
|
||||
virtual uint16_t txGood();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
/// The current transport operating mode
|
||||
volatile RHMode _mode;
|
||||
|
||||
@ -300,8 +274,7 @@ protected:
|
||||
/// Channel activity timeout in ms
|
||||
unsigned int _cad_timeout;
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -13,8 +13,7 @@ uint8_t RH_RF95::_interruptCount = 0; // Index into _deviceForInterrupt for next
|
||||
|
||||
// These are indexed by the values of ModemConfigChoice
|
||||
// Stored in flash (program) memory to save SRAM
|
||||
PROGMEM static const RH_RF95::ModemConfig MODEM_CONFIG_TABLE[] =
|
||||
{
|
||||
PROGMEM static const RH_RF95::ModemConfig MODEM_CONFIG_TABLE[] = {
|
||||
// 1d, 1e, 26
|
||||
{0x72, 0x74, 0x04}, // Bw125Cr45Sf128 (the chip default), AGC enabled
|
||||
{0x92, 0x74, 0x04}, // Bw500Cr45Sf128, AGC enabled
|
||||
@ -24,8 +23,7 @@ PROGMEM static const RH_RF95::ModemConfig MODEM_CONFIG_TABLE[] =
|
||||
};
|
||||
|
||||
RH_RF95::RH_RF95(uint8_t slaveSelectPin, uint8_t interruptPin, RHGenericSPI &spi)
|
||||
: RHSPIDriver(slaveSelectPin, spi),
|
||||
_rxBufValid(0)
|
||||
: RHSPIDriver(slaveSelectPin, spi), _rxBufValid(0)
|
||||
{
|
||||
_interruptPin = interruptPin;
|
||||
_myInterruptIndex = 0xff; // Not allocated yet
|
||||
@ -54,16 +52,15 @@ bool RH_RF95::init()
|
||||
// On all other platforms, its innocuous, belt and braces
|
||||
pinMode(_interruptPin, INPUT);
|
||||
|
||||
bool isWakeFromDeepSleep = false; // true if we think we are waking from deep sleep AND the rf95 seems to have a valid configuration
|
||||
bool isWakeFromDeepSleep =
|
||||
false; // true if we think we are waking from deep sleep AND the rf95 seems to have a valid configuration
|
||||
|
||||
if (!isWakeFromDeepSleep)
|
||||
{
|
||||
if (!isWakeFromDeepSleep) {
|
||||
// Set sleep mode, so we can also set LORA mode:
|
||||
spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE);
|
||||
delay(10); // Wait for sleep mode to take over from say, CAD
|
||||
// Check we are in sleep mode, with LORA set
|
||||
if (spiRead(RH_RF95_REG_01_OP_MODE) != (RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE))
|
||||
{
|
||||
if (spiRead(RH_RF95_REG_01_OP_MODE) != (RH_RF95_MODE_SLEEP | RH_RF95_LONG_RANGE_MODE)) {
|
||||
// Serial.println(spiRead(RH_RF95_REG_01_OP_MODE), HEX);
|
||||
return false; // No device present?
|
||||
}
|
||||
@ -93,16 +90,15 @@ bool RH_RF95::init()
|
||||
setTxPower(13);
|
||||
|
||||
Serial.printf("IRQ flag mask 0x%x\n", spiRead(RH_RF95_REG_11_IRQ_FLAGS_MASK));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// FIXME
|
||||
// restore mode base off reading RS95 registers
|
||||
|
||||
// Only let CPU enter deep sleep if RF95 is sitting waiting on a receive or is in idle or sleep.
|
||||
}
|
||||
|
||||
// geeksville: we do this last, because if there is an interrupt pending from during the deep sleep, this attach will cause it to be taken.
|
||||
// geeksville: we do this last, because if there is an interrupt pending from during the deep sleep, this attach will cause it
|
||||
// to be taken.
|
||||
|
||||
// Set up interrupt handler
|
||||
// Since there are a limited number of interrupt glue functions isr*() available,
|
||||
@ -110,8 +106,7 @@ bool RH_RF95::init()
|
||||
// ON some devices, notably most Arduinos, the interrupt pin passed in is actuallt the
|
||||
// interrupt number. You have to figure out the interruptnumber-to-interruptpin mapping
|
||||
// yourself based on knwledge of what Arduino board you are running on.
|
||||
if (_myInterruptIndex == 0xff)
|
||||
{
|
||||
if (_myInterruptIndex == 0xff) {
|
||||
// First run, no interrupt allocated yet
|
||||
if (_interruptCount <= RH_RF95_NUM_INTERRUPTS)
|
||||
_myInterruptIndex = _interruptCount++;
|
||||
@ -144,12 +139,10 @@ bool RH_RF95::isReceiving()
|
||||
// 0x0b == Look for header info valid, signal synchronized or signal detected
|
||||
uint8_t reg = spiRead(RH_RF95_REG_18_MODEM_STAT) & 0x1f;
|
||||
// Serial.printf("reg %x\n", reg);
|
||||
return _mode == RHModeRx && (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED |
|
||||
RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
||||
return _mode == RHModeRx && (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
||||
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
|
||||
}
|
||||
|
||||
|
||||
// C++ level interrupt handler for this instance
|
||||
// LORA is unusual in that it has several interrupt lines, and not a single, combined one.
|
||||
// On MiniWirelessLoRa, only one of the several interrupt lines (DI0) from the RFM95 is usefuly
|
||||
@ -172,21 +165,17 @@ void RH_RF95::handleInterrupt()
|
||||
clearRxBuf();
|
||||
}
|
||||
|
||||
if ((irq_flags & RH_RF95_RX_DONE) && !haveRxError)
|
||||
{
|
||||
if ((irq_flags & RH_RF95_RX_DONE) && !haveRxError) {
|
||||
// Read the RegHopChannel register to check if CRC presence is signalled
|
||||
// in the header. If not it might be a stray (noise) packet.*
|
||||
uint8_t crc_present = spiRead(RH_RF95_REG_1C_HOP_CHANNEL) & RH_RF95_RX_PAYLOAD_CRC_IS_ON;
|
||||
|
||||
spiWrite(RH_RF95_REG_12_IRQ_FLAGS, 0xff); // Clear all IRQ flags, required before reading fifo (according to datasheet)
|
||||
|
||||
if (!crc_present)
|
||||
{
|
||||
if (!crc_present) {
|
||||
_rxBad++;
|
||||
clearRxBuf();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Have received a packet
|
||||
uint8_t len = spiRead(RH_RF95_REG_13_RX_NB_BYTES);
|
||||
|
||||
@ -220,21 +209,18 @@ void RH_RF95::handleInterrupt()
|
||||
}
|
||||
}
|
||||
|
||||
if (irq_flags & RH_RF95_TX_DONE)
|
||||
{
|
||||
if (irq_flags & RH_RF95_TX_DONE) {
|
||||
_txGood++;
|
||||
setModeIdle();
|
||||
}
|
||||
|
||||
if (_mode == RHModeCad && (irq_flags & RH_RF95_CAD_DONE))
|
||||
{
|
||||
if (_mode == RHModeCad && (irq_flags & RH_RF95_CAD_DONE)) {
|
||||
_cad = irq_flags & RH_RF95_CAD_DETECTED;
|
||||
setModeIdle();
|
||||
}
|
||||
|
||||
// ack all interrupts, note - we did this already in the RX_DONE case above, and we don't want to do it twice
|
||||
if (!(irq_flags & RH_RF95_RX_DONE))
|
||||
{
|
||||
if (!(irq_flags & RH_RF95_RX_DONE)) {
|
||||
// Sigh: on some processors, for some unknown reason, doing this only once does not actually
|
||||
// clear the radio's interrupt flag. So we do it twice. Why?
|
||||
// kevinh: turn this off until root cause is known, because it can cause missed interrupts!
|
||||
@ -272,10 +258,7 @@ void RH_RF95::validateRxBuf()
|
||||
_rxHeaderFrom = _buf[1];
|
||||
_rxHeaderId = _buf[2];
|
||||
_rxHeaderFlags = _buf[3];
|
||||
if (_promiscuous ||
|
||||
_rxHeaderTo == _thisAddress ||
|
||||
_rxHeaderTo == RH_BROADCAST_ADDRESS)
|
||||
{
|
||||
if (_promiscuous || _rxHeaderTo == _thisAddress || _rxHeaderTo == RH_BROADCAST_ADDRESS) {
|
||||
_rxGood++;
|
||||
_rxBufValid = true;
|
||||
}
|
||||
@ -297,23 +280,6 @@ void RH_RF95::clearRxBuf()
|
||||
ATOMIC_BLOCK_END;
|
||||
}
|
||||
|
||||
bool RH_RF95::recv(uint8_t *buf, uint8_t *len)
|
||||
{
|
||||
if (!available())
|
||||
return false;
|
||||
if (buf && len)
|
||||
{
|
||||
ATOMIC_BLOCK_START;
|
||||
// Skip the 4 headers that are at the beginning of the rxBuf
|
||||
if (*len > _bufLen - RH_RF95_HEADER_LEN)
|
||||
*len = _bufLen - RH_RF95_HEADER_LEN;
|
||||
memcpy(buf, _buf + RH_RF95_HEADER_LEN, *len);
|
||||
ATOMIC_BLOCK_END;
|
||||
}
|
||||
clearRxBuf(); // This message accepted and cleared
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RH_RF95::send(const uint8_t *data, uint8_t len)
|
||||
{
|
||||
if (len > RH_RF95_MAX_MESSAGE_LEN)
|
||||
@ -344,11 +310,12 @@ bool RH_RF95::send(const uint8_t *data, uint8_t len)
|
||||
bool RH_RF95::printRegisters()
|
||||
{
|
||||
#ifdef RH_HAVE_SERIAL
|
||||
uint8_t registers[] = {0x01, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x014, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27};
|
||||
uint8_t registers[] = {0x01, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
|
||||
0x11, 0x12, 0x13, 0x014, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
|
||||
0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27};
|
||||
|
||||
uint8_t i;
|
||||
for (i = 0; i < sizeof(registers); i++)
|
||||
{
|
||||
for (i = 0; i < sizeof(registers); i++) {
|
||||
Serial.print(registers[i], HEX);
|
||||
Serial.print(": ");
|
||||
Serial.println(spiRead(registers[i]), HEX);
|
||||
@ -376,8 +343,7 @@ bool RH_RF95::setFrequency(float centre)
|
||||
|
||||
void RH_RF95::setModeIdle()
|
||||
{
|
||||
if (_mode != RHModeIdle)
|
||||
{
|
||||
if (_mode != RHModeIdle) {
|
||||
spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_STDBY);
|
||||
_mode = RHModeIdle;
|
||||
}
|
||||
@ -385,8 +351,7 @@ void RH_RF95::setModeIdle()
|
||||
|
||||
bool RH_RF95::sleep()
|
||||
{
|
||||
if (_mode != RHModeSleep)
|
||||
{
|
||||
if (_mode != RHModeSleep) {
|
||||
spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_SLEEP);
|
||||
_mode = RHModeSleep;
|
||||
}
|
||||
@ -395,8 +360,7 @@ bool RH_RF95::sleep()
|
||||
|
||||
void RH_RF95::setModeRx()
|
||||
{
|
||||
if (_mode != RHModeRx)
|
||||
{
|
||||
if (_mode != RHModeRx) {
|
||||
spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_RXCONTINUOUS);
|
||||
spiWrite(RH_RF95_REG_40_DIO_MAPPING1, 0x00); // Interrupt on RxDone
|
||||
_mode = RHModeRx;
|
||||
@ -405,8 +369,7 @@ void RH_RF95::setModeRx()
|
||||
|
||||
void RH_RF95::setModeTx()
|
||||
{
|
||||
if (_mode != RHModeTx)
|
||||
{
|
||||
if (_mode != RHModeTx) {
|
||||
spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_TX);
|
||||
spiWrite(RH_RF95_REG_40_DIO_MAPPING1, 0x40); // Interrupt on TxDone
|
||||
_mode = RHModeTx;
|
||||
@ -417,16 +380,13 @@ void RH_RF95::setTxPower(int8_t power, bool useRFO)
|
||||
{
|
||||
// Sigh, different behaviours depending on whther the module use PA_BOOST or the RFO pin
|
||||
// for the transmitter output
|
||||
if (useRFO)
|
||||
{
|
||||
if (useRFO) {
|
||||
if (power > 14)
|
||||
power = 14;
|
||||
if (power < -1)
|
||||
power = -1;
|
||||
spiWrite(RH_RF95_REG_09_PA_CONFIG, RH_RF95_MAX_POWER | (power + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (power > 23)
|
||||
power = 23;
|
||||
if (power < 5)
|
||||
@ -435,13 +395,10 @@ void RH_RF95::setTxPower(int8_t power, bool useRFO)
|
||||
// For RH_RF95_PA_DAC_ENABLE, manual says '+20dBm on PA_BOOST when OutputPower=0xf'
|
||||
// RH_RF95_PA_DAC_ENABLE actually adds about 3dBm to all power levels. We will us it
|
||||
// for 21, 22 and 23dBm
|
||||
if (power > 20)
|
||||
{
|
||||
if (power > 20) {
|
||||
spiWrite(RH_RF95_REG_4D_PA_DAC, RH_RF95_PA_DAC_ENABLE);
|
||||
power -= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
spiWrite(RH_RF95_REG_4D_PA_DAC, RH_RF95_PA_DAC_DISABLE);
|
||||
}
|
||||
|
||||
@ -486,8 +443,7 @@ void RH_RF95::setPreambleLength(uint16_t bytes)
|
||||
bool RH_RF95::isChannelActive()
|
||||
{
|
||||
// Set mode RHModeCad
|
||||
if (_mode != RHModeCad)
|
||||
{
|
||||
if (_mode != RHModeCad) {
|
||||
spiWrite(RH_RF95_REG_01_OP_MODE, RH_RF95_MODE_CAD);
|
||||
spiWrite(RH_RF95_REG_40_DIO_MAPPING1, 0x80); // Interrupt on CadDone
|
||||
_mode = RHModeCad;
|
||||
@ -501,8 +457,7 @@ bool RH_RF95::isChannelActive()
|
||||
|
||||
void RH_RF95::enableTCXO()
|
||||
{
|
||||
while ((spiRead(RH_RF95_REG_4B_TCXO) & RH_RF95_TCXO_TCXO_INPUT_ON) != RH_RF95_TCXO_TCXO_INPUT_ON)
|
||||
{
|
||||
while ((spiRead(RH_RF95_REG_4B_TCXO) & RH_RF95_TCXO_TCXO_INPUT_ON) != RH_RF95_TCXO_TCXO_INPUT_ON) {
|
||||
sleep();
|
||||
spiWrite(RH_RF95_REG_4B_TCXO, (spiRead(RH_RF95_REG_4B_TCXO) | RH_RF95_TCXO_TCXO_INPUT_ON));
|
||||
}
|
||||
@ -577,7 +532,7 @@ void RH_RF95::setSpreadingFactor(uint8_t sf)
|
||||
|
||||
void RH_RF95::setSignalBandwidth(long sbw)
|
||||
{
|
||||
uint8_t bw; //register bit pattern
|
||||
uint8_t bw; // register bit pattern
|
||||
|
||||
if (sbw <= 7800)
|
||||
bw = RH_RF95_BW_7_8KHZ;
|
||||
@ -629,7 +584,8 @@ void RH_RF95::setLowDatarate()
|
||||
// Semtech modem design guide AN1200.13 says
|
||||
// "To avoid issues surrounding drift of the crystal reference oscillator due to either temperature change
|
||||
// or motion,the low data rate optimization bit is used. Specifically for 125 kHz bandwidth and SF = 11 and 12,
|
||||
// this adds a small overhead to increase robustness to reference frequency variations over the timescale of the LoRa packet."
|
||||
// this adds a small overhead to increase robustness to reference frequency variations over the timescale of the LoRa
|
||||
// packet."
|
||||
|
||||
// read current value for BW and SF
|
||||
uint8_t BW = spiRead(RH_RF95_REG_1D_MODEM_CONFIG1) >> 4; // bw is in bits 7..4
|
||||
|
@ -33,7 +33,7 @@
|
||||
// Can be pre-defined to a smaller size (to save SRAM) prior to including this header
|
||||
// Here we allow for 1 byte message length, 4 bytes headers, user data and 2 bytes of FCS
|
||||
#ifndef RH_RF95_MAX_MESSAGE_LEN
|
||||
#define RH_RF95_MAX_MESSAGE_LEN (RH_RF95_MAX_PAYLOAD_LEN - RH_RF95_HEADER_LEN)
|
||||
#define RH_RF95_MAX_MESSAGE_LEN (RH_RF95_MAX_PAYLOAD_LEN - RH_RF95_HEADER_LEN)
|
||||
#endif
|
||||
|
||||
// The crystal oscillator frequency of the module
|
||||
@ -42,7 +42,6 @@
|
||||
// The Frequency Synthesizer step = RH_RF95_FXOSC / 2^^19
|
||||
#define RH_RF95_FSTEP (RH_RF95_FXOSC / 524288)
|
||||
|
||||
|
||||
// Register names (LoRa Mode, from table 85)
|
||||
#define RH_RF95_REG_00_FIFO 0x00
|
||||
#define RH_RF95_REG_01_OP_MODE 0x01
|
||||
@ -267,7 +266,8 @@
|
||||
/// an Arduino compatible board, which include an on-board RFM95/96 LoRa Radio (Semtech SX1276), external antenna,
|
||||
/// run on 2xAAA batteries and support low power operations. RF95 examples work without modification.
|
||||
/// Use Arduino Board Manager to install the Talk2 code support. Upload the code with an FTDI adapter set to 5V.
|
||||
/// - heltec / TTGO ESP32 LoRa OLED https://www.aliexpress.com/item/Internet-Development-Board-SX1278-ESP32-WIFI-chip-0-96-inch-OLED-Bluetooth-WIFI-Lora-Kit-32/32824535649.html
|
||||
/// - heltec / TTGO ESP32 LoRa OLED
|
||||
/// https://www.aliexpress.com/item/Internet-Development-Board-SX1278-ESP32-WIFI-chip-0-96-inch-OLED-Bluetooth-WIFI-Lora-Kit-32/32824535649.html
|
||||
///
|
||||
/// \par Overview
|
||||
///
|
||||
@ -563,7 +563,7 @@
|
||||
/// You would not expect to get anywhere near these powers to air with a simple 1/4 wavelength wire antenna.
|
||||
class RH_RF95 : public RHSPIDriver
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/// \brief Defines register values for a set of modem configuration registers
|
||||
///
|
||||
/// Defines register values for a set of modem configuration registers
|
||||
@ -571,8 +571,7 @@ public:
|
||||
/// ModemConfigChoice suit your need setModemRegisters() writes the
|
||||
/// register values from this structure to the appropriate registers
|
||||
/// to set the desired spreading factor, coding rate and bandwidth
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t reg_1d; ///< Value for register RH_RF95_REG_1D_MODEM_CONFIG1
|
||||
uint8_t reg_1e; ///< Value for register RH_RF95_REG_1E_MODEM_CONFIG2
|
||||
uint8_t reg_26; ///< Value for register RH_RF95_REG_26_MODEM_CONFIG3
|
||||
@ -591,8 +590,7 @@ public:
|
||||
/// Caution: for some slow rates nad with ReliableDatagrams youi may need to increase the reply timeout
|
||||
/// with manager.setTimeout() to
|
||||
/// deal with the long transmission times.
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
Bw125Cr45Sf128 = 0, ///< Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Default medium range
|
||||
Bw500Cr45Sf128, ///< Bw = 500 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on. Fast+short range
|
||||
Bw31_25Cr48Sf512, ///< Bw = 31.25 kHz, Cr = 4/8, Sf = 512chips/symbol, CRC on. Slow+long range
|
||||
@ -618,7 +616,7 @@ public:
|
||||
/// On other boards, any digital pin may be used.
|
||||
/// \param[in] spi Pointer to the SPI interface object to use.
|
||||
/// Defaults to the standard Arduino hardware SPI interface
|
||||
RH_RF95(uint8_t slaveSelectPin = SS, uint8_t interruptPin = 2, RHGenericSPI& spi = hardware_spi);
|
||||
RH_RF95(uint8_t slaveSelectPin = SS, uint8_t interruptPin = 2, RHGenericSPI &spi = hardware_spi);
|
||||
|
||||
/// Initialise the Driver transport hardware and software.
|
||||
/// Make sure the Driver is properly configured before calling init().
|
||||
@ -641,7 +639,7 @@ public:
|
||||
/// spreading factor etc. You can use this to configure the modem with custom configurations if none of the
|
||||
/// canned configurations in ModemConfigChoice suit you.
|
||||
/// \param[in] config A ModemConfig structure containing values for the modem configuration registers.
|
||||
void setModemRegisters(const ModemConfig* config);
|
||||
void setModemRegisters(const ModemConfig *config);
|
||||
|
||||
/// Select one of the predefined modem configurations. If you need a modem configuration not provided
|
||||
/// here, use setModemRegisters() with your own ModemConfig.
|
||||
@ -659,29 +657,6 @@ public:
|
||||
/// \return true if a new, complete, error-free uncollected message is available to be retreived by recv()
|
||||
virtual bool available();
|
||||
|
||||
/// Turns the receiver on if it not already on.
|
||||
/// If there is a valid message available, copy it to buf and return true
|
||||
/// else return false.
|
||||
/// If a message is copied, *len is set to the length (Caution, 0 length messages are permitted).
|
||||
/// You should be sure to call this function frequently enough to not miss any messages
|
||||
/// It is recommended that you call it in your main loop.
|
||||
/// \param[in] buf Location to copy the received message
|
||||
/// \param[in,out] len Pointer to available space in buf. Set to the actual number of octets copied.
|
||||
/// \return true if a valid message was copied to buf
|
||||
virtual bool recv(uint8_t* buf, uint8_t* len);
|
||||
|
||||
/// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
|
||||
/// Then optionally waits for Channel Activity Detection (CAD)
|
||||
/// to show the channnel is clear (if the radio supports CAD) by calling waitCAD().
|
||||
/// Then loads a message into the transmitter and starts the transmitter. Note that a message length
|
||||
/// of 0 is permitted.
|
||||
/// \param[in] data Array of data to be sent
|
||||
/// \param[in] len Number of bytes of data to send
|
||||
/// specify the maximum time in ms to wait. If 0 (the default) do not wait for CAD before transmitting.
|
||||
/// \return true if the message length was valid and it was correctly queued for transmit. Return false
|
||||
/// if CAD was requested and the CAD timeout timed out before clear channel was detected.
|
||||
virtual bool send(const uint8_t* data, uint8_t len);
|
||||
|
||||
/// Sets the length of the preamble
|
||||
/// in bytes.
|
||||
/// Caution: this should be set to the same
|
||||
@ -831,7 +806,7 @@ public:
|
||||
/// Return true if we are currently receiving a packet
|
||||
bool isReceiving();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/// This is a low level function to handle the interrupts for one instance of RH_RF95.
|
||||
/// Called automatically by isr*()
|
||||
/// Should not need to be called by user code.
|
||||
@ -843,7 +818,19 @@ protected:
|
||||
/// Clear our local receive buffer
|
||||
void clearRxBuf();
|
||||
|
||||
private:
|
||||
/// Waits until any previous transmit packet is finished being transmitted with waitPacketSent().
|
||||
/// Then optionally waits for Channel Activity Detection (CAD)
|
||||
/// to show the channnel is clear (if the radio supports CAD) by calling waitCAD().
|
||||
/// Then loads a message into the transmitter and starts the transmitter. Note that a message length
|
||||
/// of 0 is permitted.
|
||||
/// \param[in] data Array of data to be sent
|
||||
/// \param[in] len Number of bytes of data to send
|
||||
/// specify the maximum time in ms to wait. If 0 (the default) do not wait for CAD before transmitting.
|
||||
/// \return true if the message length was valid and it was correctly queued for transmit. Return false
|
||||
/// if CAD was requested and the CAD timeout timed out before clear channel was detected.
|
||||
virtual bool send(const uint8_t *data, uint8_t len);
|
||||
|
||||
private:
|
||||
/// Low level interrupt service routine for device connected to interrupt 0
|
||||
static void isr0();
|
||||
|
||||
@ -854,7 +841,7 @@ private:
|
||||
static void isr2();
|
||||
|
||||
/// Array of instances connected to interrupts 0 and 1
|
||||
static RH_RF95* _deviceForInterrupt[];
|
||||
static RH_RF95 *_deviceForInterrupt[];
|
||||
|
||||
/// Index of next interrupt number to use in _deviceForInterrupt
|
||||
static uint8_t _interruptCount;
|
||||
@ -872,7 +859,7 @@ private:
|
||||
// Last measured SNR, dB
|
||||
int8_t _lastSNR;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/// Number of octets in the buffer
|
||||
volatile uint8_t _bufLen;
|
||||
|
||||
@ -891,4 +878,3 @@ protected:
|
||||
/// @example rf95_reliable_datagram_server.pde
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user