kopia lustrzana https://github.com/jgromes/RadioLib
[MOD] Added flag to distinguish DIO and GPIO pins
rodzic
88e11fa0a2
commit
334b5fd499
|
@ -129,7 +129,7 @@
|
|||
* Platform-specific configuration.
|
||||
*
|
||||
* RADIOLIB_PLATFORM - platform name, used in debugging to quickly check the correct platform is detected.
|
||||
* RADIOLIB_NC - alias for unused pin, usually the largest possible value of uint8_t.
|
||||
* RADIOLIB_NC - alias for unused pin, usually the largest possible value of uint32_t.
|
||||
* RADIOLIB_DEFAULT_SPI - default SPIClass instance to use.
|
||||
* RADIOLIB_NONVOLATILE - macro to place variable into program storage (usually Flash).
|
||||
* RADIOLIB_NONVOLATILE_READ_BYTE - function/macro to read variables saved in program storage (usually Flash).
|
||||
|
@ -422,7 +422,7 @@
|
|||
// generic non-Arduino platform
|
||||
#define RADIOLIB_PLATFORM "Generic"
|
||||
|
||||
#define RADIOLIB_NC (0xFF)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_NONVOLATILE
|
||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) (*((uint8_t *)(void *)(addr)))
|
||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) (*((uint32_t *)(void *)(addr)))
|
||||
|
|
|
@ -489,15 +489,17 @@ void Module::setRfSwitchPins(uint32_t rxEn, uint32_t txEn) {
|
|||
void Module::setRfSwitchTable(const uint32_t (&pins)[RFSWITCH_MAX_PINS], const RfSwitchMode_t table[]) {
|
||||
memcpy(this->rfSwitchPins, pins, sizeof(this->rfSwitchPins));
|
||||
this->rfSwitchTable = table;
|
||||
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++)
|
||||
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++) {
|
||||
this->hal->pinMode(pins[i], this->hal->GpioModeOutput);
|
||||
}
|
||||
}
|
||||
|
||||
const Module::RfSwitchMode_t *Module::findRfSwitchMode(uint8_t mode) const {
|
||||
const RfSwitchMode_t *row = this->rfSwitchTable;
|
||||
while (row && row->mode != MODE_END_OF_TABLE) {
|
||||
if (row->mode == mode)
|
||||
while(row && row->mode != MODE_END_OF_TABLE) {
|
||||
if(row->mode == mode) {
|
||||
return row;
|
||||
}
|
||||
++row;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -514,8 +516,9 @@ void Module::setRfSwitchState(uint8_t mode) {
|
|||
const uint32_t *value = &row->values[0];
|
||||
for(size_t i = 0; i < RFSWITCH_MAX_PINS; i++) {
|
||||
uint32_t pin = this->rfSwitchPins[i];
|
||||
if (pin != RADIOLIB_NC)
|
||||
if(!(pin & RFSWITCH_PIN_FLAG)) {
|
||||
this->hal->digitalWrite(pin, *value);
|
||||
}
|
||||
++value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
*/
|
||||
#define END_OF_MODE_TABLE { Module::MODE_END_OF_TABLE, {} }
|
||||
|
||||
/*!
|
||||
\def RFSWITCH_PIN_FLAG Bit flag used to mark unused pins in RF switch pin map. This can be either
|
||||
unconnected pin marked with RADIOLIB_NC, or a pin controlled by the radio (e.g. DIOx pins on LR11x0),
|
||||
as opposed to an MCU-controlled GPIO pin.
|
||||
*/
|
||||
#define RFSWITCH_PIN_FLAG (0x01UL << 31)
|
||||
|
||||
/*!
|
||||
\defgroup module_spi_command_pos Position of commands in Module::spiConfig command array.
|
||||
\{
|
||||
|
|
Ładowanie…
Reference in New Issue