Implements all common low-level SPI methods to control the LoRa chip. The base class SX127x contains private instance of this class.
More...
#include <Module.h>
|
| Module (int cs=LORALIB_DEFAULT_SPI_CS, int int0=2, int int1=3, SPIClass &spi=SPI) |
| Default constructor. Called internally when creating new LoRa instance. More...
|
|
void | init (uint8_t interface, uint8_t gpio) |
| Initialization method. Called internally when connecting to the LoRa chip and should not be called explicitly from Arduino code. More...
|
|
void | term () |
| Termination method. Called internally when required LoRa chip is not found and should not be called explicitly from Arduino code.
|
|
int16_t | SPIgetRegValue (uint8_t reg, uint8_t msb=7, uint8_t lsb=0) |
| SPI read method that automatically masks unused bits. This method is the preferred SPI read mechanism. More...
|
|
int16_t | SPIsetRegValue (uint8_t reg, uint8_t value, uint8_t msb=7, uint8_t lsb=0, uint8_t checkInterval=2) |
| Overwrite-safe SPI write method with verification. This method is the preferred SPI write mechanism. More...
|
|
void | SPIreadRegisterBurst (uint8_t reg, uint8_t numBytes, uint8_t *inBytes) |
| SPI burst read method. More...
|
|
uint8_t | SPIreadRegister (uint8_t reg) |
| SPI basic read method. Use of this method is reserved for special cases, SPIgetRegValue should be used instead. More...
|
|
void | SPIwriteRegisterBurst (uint8_t reg, uint8_t *data, uint8_t numBytes) |
| SPI burst write method. More...
|
|
void | SPIwriteRegister (uint8_t reg, uint8_t data) |
| SPI basic write method. Use of this method is reserved for special cases, SPIsetRegValue should be used instead. More...
|
|
void | SPItransfer (uint8_t cmd, uint8_t reg, uint8_t *dataOut, uint8_t *dataIn, uint8_t numBytes) |
| SPI single transfer method. More...
|
|
int | getInt0 () const |
| Access method to get the pin number of interrupt/GPIO 0. More...
|
|
int | getInt1 () const |
| Access method to get the pin number of interrupt/GPIO 1. More...
|
|
Implements all common low-level SPI methods to control the LoRa chip. The base class SX127x contains private instance of this class.
Module::Module |
( |
int |
cs = LORALIB_DEFAULT_SPI_CS , |
|
|
int |
int0 = 2 , |
|
|
int |
int1 = 3 , |
|
|
SPIClass & |
spi = SPI |
|
) |
| |
Default constructor. Called internally when creating new LoRa instance.
- Parameters
-
cs | Arduino pin that will be used as chip select signal for SPI. Defaults to 4 on ESP32/ESP8266 boards, or to 10 on other architectures. |
int0 | Arduino pin that will be used as interrupt/GPIO 0. Connect to SX127x/RFM9x pin DIO0. Does not need to be connected to Arduino interrupt pin, unless Arduino sketch is using interrupt-driven transmit/receive methods. |
int1 | Arduino pin that will be used as interrupt/GPIO 1. Connect to SX127x/RFM9x pin DIO1. Does not need to be connected to Arduino interrupt pin, unless Arduino sketch is using interrupt-driven transmit/receive methods. |
spi | SPIClass instance that will be used for SPI bus control. This can be hardware SPI or some software SPI driver. |
int Module::getInt0 |
( |
| ) |
const |
|
inline |
Access method to get the pin number of interrupt/GPIO 0.
- Returns
- Pin number of interrupt/GPIO 0 configured in the constructor.
int Module::getInt1 |
( |
| ) |
const |
|
inline |
Access method to get the pin number of interrupt/GPIO 1.
- Returns
- Pin number of interrupt/GPIO 1 configured in the constructor.
void Module::init |
( |
uint8_t |
interface, |
|
|
uint8_t |
gpio |
|
) |
| |
Initialization method. Called internally when connecting to the LoRa chip and should not be called explicitly from Arduino code.
- Parameters
-
interface | Module interface that should be used. Required for RadioLib compatibility, will always be set to USE_SPI. |
gpio | Determines which interrupt/GPIO should be used. Required for RadioLib compatibility, will always be set to INT_BOTH. |
int16_t Module::SPIgetRegValue |
( |
uint8_t |
reg, |
|
|
uint8_t |
msb = 7 , |
|
|
uint8_t |
lsb = 0 |
|
) |
| |
SPI read method that automatically masks unused bits. This method is the preferred SPI read mechanism.
- Parameters
-
reg | Address of SPI register to read. |
msb | Most significant bit of the register variable. Bits above this one will be masked out. |
lsb | Least significant bit of the register variable. Bits below this one will be masked out. |
- Returns
- Masked register value or status code.
uint8_t Module::SPIreadRegister |
( |
uint8_t |
reg | ) |
|
SPI basic read method. Use of this method is reserved for special cases, SPIgetRegValue should be used instead.
- Parameters
-
reg | Address of SPI register to read. |
- Returns
- Value that was read from register.
void Module::SPIreadRegisterBurst |
( |
uint8_t |
reg, |
|
|
uint8_t |
numBytes, |
|
|
uint8_t * |
inBytes |
|
) |
| |
SPI burst read method.
- Parameters
-
reg | Address of SPI register to read. |
numBytes | Number of bytes that will be read. |
inBytes | Pointer to array that will hold the read data. |
int16_t Module::SPIsetRegValue |
( |
uint8_t |
reg, |
|
|
uint8_t |
value, |
|
|
uint8_t |
msb = 7 , |
|
|
uint8_t |
lsb = 0 , |
|
|
uint8_t |
checkInterval = 2 |
|
) |
| |
Overwrite-safe SPI write method with verification. This method is the preferred SPI write mechanism.
- Parameters
-
reg | Address of SPI register to write. |
value | Single byte value that will be written to the SPI register. |
msb | Most significant bit of the register variable. Bits above this one will not be affected by the write operation. |
lsb | Least significant bit of the register variable. Bits below this one will not be affected by the write operation. |
checkInterval | Number of milliseconds between register writing and verification reading. Some registers need up to 10ms to process the change. |
- Returns
- Status Codes
void Module::SPItransfer |
( |
uint8_t |
cmd, |
|
|
uint8_t |
reg, |
|
|
uint8_t * |
dataOut, |
|
|
uint8_t * |
dataIn, |
|
|
uint8_t |
numBytes |
|
) |
| |
SPI single transfer method.
- Parameters
-
cmd | SPI access command (read/write/burst/...). |
reg | Address of SPI register to transfer to/from. |
dataOut | Data that will be transfered from master to slave. |
dataIn | Data that was transfered from slave to master. |
numBytes | Number of bytes to transfer. |
void Module::SPIwriteRegister |
( |
uint8_t |
reg, |
|
|
uint8_t |
data |
|
) |
| |
SPI basic write method. Use of this method is reserved for special cases, SPIsetRegValue should be used instead.
- Parameters
-
reg | Address of SPI register to write. |
data | Value that will be written to the register. |
void Module::SPIwriteRegisterBurst |
( |
uint8_t |
reg, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
numBytes |
|
) |
| |
SPI burst write method.
- Parameters
-
reg | Address of SPI register to write. |
data | Pointer to array that holds the data that will be written. |
numBytes | Number of bytes that will be written. |
The documentation for this class was generated from the following files: