2023-04-11 02:51:29 +00:00
|
|
|
#include "ArduinoHal.h"
|
|
|
|
|
|
|
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
|
|
|
|
2023-04-22 16:53:30 +00:00
|
|
|
ArduinoHal::ArduinoHal(): RadioLibHal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), spi(&RADIOLIB_DEFAULT_SPI), initInterface(true) {}
|
2023-04-11 02:51:29 +00:00
|
|
|
|
2023-04-22 16:53:30 +00:00
|
|
|
ArduinoHal::ArduinoHal(SPIClass& spi, SPISettings spiSettings): RadioLibHal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), spi(&spi), spiSettings(spiSettings) {}
|
2023-04-11 02:51:29 +00:00
|
|
|
|
|
|
|
void ArduinoHal::init() {
|
2023-04-22 16:53:30 +00:00
|
|
|
if(initInterface) {
|
2023-04-11 02:51:29 +00:00
|
|
|
spiBegin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArduinoHal::term() {
|
2023-04-22 16:53:30 +00:00
|
|
|
if(initInterface) {
|
2023-04-11 02:51:29 +00:00
|
|
|
spiEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
void inline ArduinoHal::pinMode(uint32_t pin, uint32_t mode) {
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
2023-04-11 02:51:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
::pinMode(pin, RADIOLIB_ARDUINOHAL_PIN_MODE_CAST mode);
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
void inline ArduinoHal::digitalWrite(uint32_t pin, uint32_t value) {
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
2023-04-11 02:51:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
::digitalWrite(pin, RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST value);
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
uint32_t inline ArduinoHal::digitalRead(uint32_t pin) {
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
2023-04-11 02:51:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
return(::digitalRead(pin));
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
void inline ArduinoHal::attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) {
|
2023-04-22 16:08:08 +00:00
|
|
|
if(interruptNum == RADIOLIB_NC) {
|
2023-04-11 02:51:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
::attachInterrupt(interruptNum, interruptCb, RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST mode);
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
void inline ArduinoHal::detachInterrupt(uint32_t interruptNum) {
|
2023-04-22 16:08:08 +00:00
|
|
|
if(interruptNum == RADIOLIB_NC) {
|
2023-04-11 02:51:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
::detachInterrupt(interruptNum);
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2024-04-25 19:50:58 +00:00
|
|
|
void inline ArduinoHal::delay(RadioLibTime_t ms) {
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
|
2023-04-11 02:51:29 +00:00
|
|
|
::delay(ms);
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#else
|
|
|
|
::delay(ms * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS));
|
|
|
|
#endif
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2024-04-25 19:50:58 +00:00
|
|
|
void inline ArduinoHal::delayMicroseconds(RadioLibTime_t us) {
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
|
2023-04-11 02:51:29 +00:00
|
|
|
::delayMicroseconds(us);
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#else
|
|
|
|
::delayMicroseconds(us * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS));
|
|
|
|
#endif
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2024-04-25 19:50:58 +00:00
|
|
|
RadioLibTime_t inline ArduinoHal::millis() {
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
|
2023-04-22 16:08:08 +00:00
|
|
|
return(::millis());
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#else
|
|
|
|
return(::millis() * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS));
|
|
|
|
#endif
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2024-04-25 19:50:58 +00:00
|
|
|
RadioLibTime_t inline ArduinoHal::micros() {
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#if !defined(RADIOLIB_CLOCK_DRIFT_MS)
|
2023-04-22 16:08:08 +00:00
|
|
|
return(::micros());
|
[LoRaWAN] Rework bands, official Rx windows, support ADR, confirm frames, improve EEPROM handling, support clock drift (#867)
* [LoRaWAN] rework bands, add ADR, partial MAC support
Known problem: terribly bad at receiving downlinks
Mask-list bands (e.g. US915) untested, likely a few bugs
* [LoRaWAN] Change Rx windows from CAD to RxSingle
* [LoRaWAN] improve persistence, better Rx windows, wear leveling, confirmed frames
* [LoRaWAN] Module-independent (OTAA) Rx windows, fix confirming downlinks
* [LoRaWAN] Implement SX127x support, fix MAC uplinking, support clock drift
* [ArduinoHal] fix clock drift calculation
* [LoRaWAN] Improve band & ADR logic, allow setting ADR, DR, subband, update examples
* [LoRaWAN] Fix EU868 coding rate, improve example
* [LoRaWAN] fix unused channel index
* [LoRaWAN] fix merge issue (deleted line)
* [LoRaWAN] fix CSMA calling now incorrect function
* [LoRaWAN] fix include logic
* [LoRaWAN] fix warnings, remove duplicate function
* [LoRaWAN] improve examples, add unified sendReceive, bugfixes, add FSK
* [LoRaWAN] improve examples
* [LoRaWAN] add new keywords, add debug guard
* [SX127x] Updated startReceive interface to be more in line with SX126x
* [SX127x] Added public method to convert from bytes to symbols
* [LoRaWAN] Update start receive for SX127x
* Added note about LoRaWAN beta
* [SX127x] Fixed potential float overflow
---------
Co-authored-by: jgromes <jan.gromes@gmail.com>
2023-11-12 13:02:39 +00:00
|
|
|
#else
|
|
|
|
return(::micros() * 1000 / (1000 + RADIOLIB_CLOCK_DRIFT_MS));
|
|
|
|
#endif
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2024-04-25 19:50:58 +00:00
|
|
|
long inline ArduinoHal::pulseIn(uint32_t pin, uint32_t state, RadioLibTime_t timeout) {
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
2023-04-11 02:51:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
return(::pulseIn(pin, state, timeout));
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-11 02:51:29 +00:00
|
|
|
void inline ArduinoHal::spiBegin() {
|
2023-04-22 16:53:30 +00:00
|
|
|
spi->begin();
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-11 02:51:29 +00:00
|
|
|
void inline ArduinoHal::spiBeginTransaction() {
|
2023-04-22 16:53:30 +00:00
|
|
|
spi->beginTransaction(spiSettings);
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-06-26 17:36:45 +00:00
|
|
|
void ArduinoHal::spiTransfer(uint8_t* out, size_t len, uint8_t* in) {
|
|
|
|
for(size_t i = 0; i < len; i++) {
|
|
|
|
in[i] = spi->transfer(out[i]);
|
|
|
|
}
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-11 02:51:29 +00:00
|
|
|
void inline ArduinoHal::spiEndTransaction() {
|
2023-04-22 16:53:30 +00:00
|
|
|
spi->endTransaction();
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-11 02:51:29 +00:00
|
|
|
void inline ArduinoHal::spiEnd() {
|
2023-04-22 16:53:30 +00:00
|
|
|
spi->end();
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2024-04-25 19:50:58 +00:00
|
|
|
void inline ArduinoHal::tone(uint32_t pin, unsigned int frequency, RadioLibTime_t duration) {
|
2023-04-11 02:51:29 +00:00
|
|
|
#if !defined(RADIOLIB_TONE_UNSUPPORTED)
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
::tone(pin, frequency, duration);
|
2023-08-29 19:57:51 +00:00
|
|
|
#elif defined(RADIOLIB_ESP32)
|
2023-04-22 16:08:08 +00:00
|
|
|
// ESP32 tone() emulation
|
|
|
|
(void)duration;
|
2023-04-22 16:53:30 +00:00
|
|
|
if(prev == -1) {
|
2023-10-28 19:54:31 +00:00
|
|
|
#if !defined(ESP_IDF_VERSION) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0))
|
2023-04-22 16:08:08 +00:00
|
|
|
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
|
2023-10-28 19:54:31 +00:00
|
|
|
#endif
|
2023-04-22 16:08:08 +00:00
|
|
|
}
|
2023-04-22 16:53:30 +00:00
|
|
|
if(prev != frequency) {
|
2023-10-28 19:54:31 +00:00
|
|
|
#if !defined(ESP_IDF_VERSION) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0))
|
2023-04-22 16:08:08 +00:00
|
|
|
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, frequency);
|
2023-10-28 19:54:31 +00:00
|
|
|
#else
|
2023-10-28 17:41:51 +00:00
|
|
|
ledcWriteTone(pin, frequency);
|
2023-10-28 19:54:31 +00:00
|
|
|
#endif
|
2023-04-22 16:08:08 +00:00
|
|
|
}
|
2023-04-22 16:53:30 +00:00
|
|
|
prev = frequency;
|
2023-04-11 02:51:29 +00:00
|
|
|
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
2023-04-22 16:08:08 +00:00
|
|
|
// better tone for mbed OS boards
|
|
|
|
(void)duration;
|
|
|
|
if(!pwmPin) {
|
|
|
|
pwmPin = new mbed::PwmOut(digitalPinToPinName(pin));
|
|
|
|
}
|
|
|
|
pwmPin->period(1.0 / frequency);
|
|
|
|
pwmPin->write(0.5);
|
2023-11-18 15:56:45 +00:00
|
|
|
#else
|
|
|
|
(void)pin;
|
|
|
|
(void)frequency;
|
|
|
|
(void)duration;
|
2023-04-11 02:51:29 +00:00
|
|
|
#endif
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
void inline ArduinoHal::noTone(uint32_t pin) {
|
2023-04-11 02:51:29 +00:00
|
|
|
#if !defined(RADIOLIB_TONE_UNSUPPORTED) and defined(ARDUINO_ARCH_STM32)
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
::noTone(pin, false);
|
2023-04-11 02:51:29 +00:00
|
|
|
#elif !defined(RADIOLIB_TONE_UNSUPPORTED)
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
::noTone(pin);
|
2023-08-29 19:57:51 +00:00
|
|
|
#elif defined(RADIOLIB_ESP32)
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// ESP32 tone() emulation
|
2023-10-28 19:54:31 +00:00
|
|
|
#if !defined(ESP_IDF_VERSION) || (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0))
|
2023-04-22 16:08:08 +00:00
|
|
|
ledcDetachPin(pin);
|
|
|
|
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
|
2023-10-28 19:54:31 +00:00
|
|
|
#else
|
2023-10-28 17:41:51 +00:00
|
|
|
ledcDetach(pin);
|
|
|
|
ledcWrite(pin, 0);
|
2023-10-28 19:54:31 +00:00
|
|
|
#endif
|
2023-04-22 16:53:30 +00:00
|
|
|
prev = -1;
|
2023-04-11 02:51:29 +00:00
|
|
|
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
2023-04-22 16:08:08 +00:00
|
|
|
if(pin == RADIOLIB_NC) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// better tone for mbed OS boards
|
|
|
|
(void)pin;
|
|
|
|
pwmPin->suspend();
|
2023-11-18 15:56:45 +00:00
|
|
|
#else
|
|
|
|
(void)pin;
|
2023-04-11 02:51:29 +00:00
|
|
|
#endif
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-11 02:51:29 +00:00
|
|
|
void inline ArduinoHal::yield() {
|
|
|
|
#if !defined(RADIOLIB_YIELD_UNSUPPORTED)
|
|
|
|
::yield();
|
|
|
|
#endif
|
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-16 19:39:00 +00:00
|
|
|
uint32_t inline ArduinoHal::pinToInterrupt(uint32_t pin) {
|
2023-04-22 16:08:08 +00:00
|
|
|
return(digitalPinToInterrupt(pin));
|
2023-04-11 02:51:29 +00:00
|
|
|
}
|
2023-04-22 16:08:08 +00:00
|
|
|
|
2023-04-11 02:51:29 +00:00
|
|
|
#endif
|