[HAL] Use compact Doxygen and stop using reserved format
This commit is contained in:
parent
9749083573
commit
7a99aa0ef4
3 changed files with 17 additions and 51 deletions
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||||
|
|
||||||
ArduinoHal::ArduinoHal(): RadioLibHal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), _spi(&RADIOLIB_DEFAULT_SPI), _initInterface(true) {}
|
ArduinoHal::ArduinoHal(): RadioLibHal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), spi(&RADIOLIB_DEFAULT_SPI), initInterface(true) {}
|
||||||
|
|
||||||
ArduinoHal::ArduinoHal(SPIClass& spi, SPISettings spiSettings): RadioLibHal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), _spi(&spi), _spiSettings(spiSettings) {}
|
ArduinoHal::ArduinoHal(SPIClass& spi, SPISettings spiSettings): RadioLibHal(INPUT, OUTPUT, LOW, HIGH, RISING, FALLING), spi(&spi), spiSettings(spiSettings) {}
|
||||||
|
|
||||||
void ArduinoHal::init() {
|
void ArduinoHal::init() {
|
||||||
if(_initInterface) {
|
if(initInterface) {
|
||||||
spiBegin();
|
spiBegin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArduinoHal::term() {
|
void ArduinoHal::term() {
|
||||||
if(_initInterface) {
|
if(initInterface) {
|
||||||
spiEnd();
|
spiEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,23 +77,23 @@ long inline ArduinoHal::pulseIn(uint32_t pin, uint32_t state, unsigned long time
|
||||||
}
|
}
|
||||||
|
|
||||||
void inline ArduinoHal::spiBegin() {
|
void inline ArduinoHal::spiBegin() {
|
||||||
_spi->begin();
|
spi->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void inline ArduinoHal::spiBeginTransaction() {
|
void inline ArduinoHal::spiBeginTransaction() {
|
||||||
_spi->beginTransaction(_spiSettings);
|
spi->beginTransaction(spiSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t inline ArduinoHal::spiTransfer(uint8_t b) {
|
uint8_t inline ArduinoHal::spiTransfer(uint8_t b) {
|
||||||
return(_spi->transfer(b));
|
return(spi->transfer(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
void inline ArduinoHal::spiEndTransaction() {
|
void inline ArduinoHal::spiEndTransaction() {
|
||||||
_spi->endTransaction();
|
spi->endTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void inline ArduinoHal::spiEnd() {
|
void inline ArduinoHal::spiEnd() {
|
||||||
_spi->end();
|
spi->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void inline ArduinoHal::tone(uint32_t pin, unsigned int frequency, unsigned long duration) {
|
void inline ArduinoHal::tone(uint32_t pin, unsigned int frequency, unsigned long duration) {
|
||||||
|
@ -105,13 +105,13 @@ void inline ArduinoHal::tone(uint32_t pin, unsigned int frequency, unsigned long
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
// ESP32 tone() emulation
|
// ESP32 tone() emulation
|
||||||
(void)duration;
|
(void)duration;
|
||||||
if(_prev == -1) {
|
if(prev == -1) {
|
||||||
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
|
ledcAttachPin(pin, RADIOLIB_TONE_ESP32_CHANNEL);
|
||||||
}
|
}
|
||||||
if(_prev != frequency) {
|
if(prev != frequency) {
|
||||||
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, frequency);
|
ledcWriteTone(RADIOLIB_TONE_ESP32_CHANNEL, frequency);
|
||||||
}
|
}
|
||||||
_prev = frequency;
|
prev = frequency;
|
||||||
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
// better tone for mbed OS boards
|
// better tone for mbed OS boards
|
||||||
(void)duration;
|
(void)duration;
|
||||||
|
@ -141,7 +141,7 @@ void inline ArduinoHal::noTone(uint32_t pin) {
|
||||||
// ESP32 tone() emulation
|
// ESP32 tone() emulation
|
||||||
ledcDetachPin(pin);
|
ledcDetachPin(pin);
|
||||||
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
|
ledcWrite(RADIOLIB_TONE_ESP32_CHANNEL, 0);
|
||||||
_prev = -1;
|
prev = -1;
|
||||||
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
#elif defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
if(pin == RADIOLIB_NC) {
|
if(pin == RADIOLIB_NC) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ArduinoHal
|
\class ArduinoHal
|
||||||
|
|
||||||
\brief Arduino default hardware abstraction library implementation.
|
\brief Arduino default hardware abstraction library implementation.
|
||||||
This class can be extended to support other Arduino platform or change behaviour of the default implementation.
|
This class can be extended to support other Arduino platform or change behaviour of the default implementation.
|
||||||
*/
|
*/
|
||||||
|
@ -30,9 +29,7 @@ class ArduinoHal : public RadioLibHal {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Arduino Hal constructor. Will not attempt SPI interface initialization.
|
\brief Arduino Hal constructor. Will not attempt SPI interface initialization.
|
||||||
|
|
||||||
\param spi SPI interface to be used, can also use software SPI implementations.
|
\param spi SPI interface to be used, can also use software SPI implementations.
|
||||||
|
|
||||||
\param spiSettings SPI interface settings.
|
\param spiSettings SPI interface settings.
|
||||||
*/
|
*/
|
||||||
ArduinoHal(SPIClass& spi, SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS);
|
ArduinoHal(SPIClass& spi, SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS);
|
||||||
|
@ -65,16 +62,16 @@ class ArduinoHal : public RadioLibHal {
|
||||||
#if !defined(RADIOLIB_GODMODE)
|
#if !defined(RADIOLIB_GODMODE)
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
SPIClass* _spi = NULL;
|
SPIClass* spi = NULL;
|
||||||
SPISettings _spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS;
|
SPISettings spiSettings = RADIOLIB_DEFAULT_SPI_SETTINGS;
|
||||||
bool _initInterface = false;
|
bool initInterface = false;
|
||||||
|
|
||||||
#if defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
#if defined(RADIOLIB_MBED_TONE_OVERRIDE)
|
||||||
mbed::PwmOut *pwmPin = NULL;
|
mbed::PwmOut *pwmPin = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
int32_t _prev = -1;
|
int32_t prev = -1;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
31
src/Hal.h
31
src/Hal.h
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Hal
|
\class Hal
|
||||||
|
|
||||||
\brief Hardware abstraction library base interface.
|
\brief Hardware abstraction library base interface.
|
||||||
*/
|
*/
|
||||||
class RadioLibHal {
|
class RadioLibHal {
|
||||||
|
@ -47,17 +46,11 @@ class RadioLibHal {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default constructor.
|
\brief Default constructor.
|
||||||
|
|
||||||
\param input Value to be used as the "input" GPIO direction.
|
\param input Value to be used as the "input" GPIO direction.
|
||||||
|
|
||||||
\param output Value to be used as the "output" GPIO direction.
|
\param output Value to be used as the "output" GPIO direction.
|
||||||
|
|
||||||
\param low Value to be used as the "low" GPIO level.
|
\param low Value to be used as the "low" GPIO level.
|
||||||
|
|
||||||
\param high Value to be used as the "high" GPIO level.
|
\param high Value to be used as the "high" GPIO level.
|
||||||
|
|
||||||
\param rising Value to be used as the "rising" GPIO level change direction.
|
\param rising Value to be used as the "rising" GPIO level change direction.
|
||||||
|
|
||||||
\param falling Value to be used as the "falling" GPIO level change direction.
|
\param falling Value to be used as the "falling" GPIO level change direction.
|
||||||
*/
|
*/
|
||||||
RadioLibHal(const uint32_t input, const uint32_t output, const uint32_t low, const uint32_t high, const uint32_t rising, const uint32_t falling);
|
RadioLibHal(const uint32_t input, const uint32_t output, const uint32_t low, const uint32_t high, const uint32_t rising, const uint32_t falling);
|
||||||
|
@ -67,9 +60,7 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief GPIO pin mode (input/output/...) configuration method.
|
\brief GPIO pin mode (input/output/...) configuration method.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param pin Pin to be changed (platform-specific).
|
\param pin Pin to be changed (platform-specific).
|
||||||
|
|
||||||
\param mode Mode to be set (platform-specific).
|
\param mode Mode to be set (platform-specific).
|
||||||
*/
|
*/
|
||||||
virtual void pinMode(uint32_t pin, uint32_t mode) = 0;
|
virtual void pinMode(uint32_t pin, uint32_t mode) = 0;
|
||||||
|
@ -77,9 +68,7 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Digital write method.
|
\brief Digital write method.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param pin Pin to be changed (platform-specific).
|
\param pin Pin to be changed (platform-specific).
|
||||||
|
|
||||||
\param value Value to set (platform-specific).
|
\param value Value to set (platform-specific).
|
||||||
*/
|
*/
|
||||||
virtual void digitalWrite(uint32_t pin, uint32_t value) = 0;
|
virtual void digitalWrite(uint32_t pin, uint32_t value) = 0;
|
||||||
|
@ -87,9 +76,7 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Digital read method.
|
\brief Digital read method.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param pin Pin to be changed (platform-specific).
|
\param pin Pin to be changed (platform-specific).
|
||||||
|
|
||||||
\returns Value read on the pin (platform-specific).
|
\returns Value read on the pin (platform-specific).
|
||||||
*/
|
*/
|
||||||
virtual uint32_t digitalRead(uint32_t pin) = 0;
|
virtual uint32_t digitalRead(uint32_t pin) = 0;
|
||||||
|
@ -97,11 +84,8 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Method to attach function to an external interrupt.
|
\brief Method to attach function to an external interrupt.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param interruptNum Interrupt number to attach to (platform-specific).
|
\param interruptNum Interrupt number to attach to (platform-specific).
|
||||||
|
|
||||||
\param interruptCb Interrupt service routine to execute.
|
\param interruptCb Interrupt service routine to execute.
|
||||||
|
|
||||||
\param mode Rising/falling mode (platform-specific).
|
\param mode Rising/falling mode (platform-specific).
|
||||||
*/
|
*/
|
||||||
virtual void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) = 0;
|
virtual void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) = 0;
|
||||||
|
@ -109,7 +93,6 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Method to detach function from an external interrupt.
|
\brief Method to detach function from an external interrupt.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param interruptNum Interrupt number to detach from (platform-specific).
|
\param interruptNum Interrupt number to detach from (platform-specific).
|
||||||
*/
|
*/
|
||||||
virtual void detachInterrupt(uint32_t interruptNum) = 0;
|
virtual void detachInterrupt(uint32_t interruptNum) = 0;
|
||||||
|
@ -117,7 +100,6 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Blocking wait function.
|
\brief Blocking wait function.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param ms Number of milliseconds to wait.
|
\param ms Number of milliseconds to wait.
|
||||||
*/
|
*/
|
||||||
virtual void delay(unsigned long ms) = 0;
|
virtual void delay(unsigned long ms) = 0;
|
||||||
|
@ -125,7 +107,6 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Blocking microsecond wait function.
|
\brief Blocking microsecond wait function.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param us Number of microseconds to wait.
|
\param us Number of microseconds to wait.
|
||||||
*/
|
*/
|
||||||
virtual void delayMicroseconds(unsigned long us) = 0;
|
virtual void delayMicroseconds(unsigned long us) = 0;
|
||||||
|
@ -133,7 +114,6 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Get number of milliseconds since start.
|
\brief Get number of milliseconds since start.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\returns Number of milliseconds since start.
|
\returns Number of milliseconds since start.
|
||||||
*/
|
*/
|
||||||
virtual unsigned long millis() = 0;
|
virtual unsigned long millis() = 0;
|
||||||
|
@ -141,7 +121,6 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Get number of microseconds since start.
|
\brief Get number of microseconds since start.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\returns Number of microseconds since start.
|
\returns Number of microseconds since start.
|
||||||
*/
|
*/
|
||||||
virtual unsigned long micros() = 0;
|
virtual unsigned long micros() = 0;
|
||||||
|
@ -149,13 +128,9 @@ class RadioLibHal {
|
||||||
/*!
|
/*!
|
||||||
\brief Measure the length of incoming digital pulse in microseconds.
|
\brief Measure the length of incoming digital pulse in microseconds.
|
||||||
Must be implemented by the platform-specific hardware abstraction!
|
Must be implemented by the platform-specific hardware abstraction!
|
||||||
|
|
||||||
\param pin Pin to measure on (platform-specific).
|
\param pin Pin to measure on (platform-specific).
|
||||||
|
|
||||||
\param state Pin level to monitor (platform-specific).
|
\param state Pin level to monitor (platform-specific).
|
||||||
|
|
||||||
\param timeout Timeout in microseconds.
|
\param timeout Timeout in microseconds.
|
||||||
|
|
||||||
\returns Pulse length in microseconds, or 0 if the pulse did not start before timeout.
|
\returns Pulse length in microseconds, or 0 if the pulse did not start before timeout.
|
||||||
*/
|
*/
|
||||||
virtual long pulseIn(uint32_t pin, uint32_t state, unsigned long timeout) = 0;
|
virtual long pulseIn(uint32_t pin, uint32_t state, unsigned long timeout) = 0;
|
||||||
|
@ -172,9 +147,7 @@ class RadioLibHal {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Method to transfer one byte over SPI.
|
\brief Method to transfer one byte over SPI.
|
||||||
|
|
||||||
\param b Byte to send.
|
\param b Byte to send.
|
||||||
|
|
||||||
\returns Received byte.
|
\returns Received byte.
|
||||||
*/
|
*/
|
||||||
virtual uint8_t spiTransfer(uint8_t b) = 0;
|
virtual uint8_t spiTransfer(uint8_t b) = 0;
|
||||||
|
@ -208,18 +181,14 @@ class RadioLibHal {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Method to produce a square-wave with 50% duty cycle ("tone") of a given frequency at some pin.
|
\brief Method to produce a square-wave with 50% duty cycle ("tone") of a given frequency at some pin.
|
||||||
|
|
||||||
\param pin Pin to be used as the output.
|
\param pin Pin to be used as the output.
|
||||||
|
|
||||||
\param frequency Frequency of the square wave.
|
\param frequency Frequency of the square wave.
|
||||||
|
|
||||||
\param duration Duration of the tone in ms. When set to 0, the tone will be infinite.
|
\param duration Duration of the tone in ms. When set to 0, the tone will be infinite.
|
||||||
*/
|
*/
|
||||||
virtual void tone(uint32_t pin, unsigned int frequency, unsigned long duration = 0);
|
virtual void tone(uint32_t pin, unsigned int frequency, unsigned long duration = 0);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Method to stop producing a tone.
|
\brief Method to stop producing a tone.
|
||||||
|
|
||||||
\param pin Pin which is currently producing the tone.
|
\param pin Pin which is currently producing the tone.
|
||||||
*/
|
*/
|
||||||
virtual void noTone(uint32_t pin);
|
virtual void noTone(uint32_t pin);
|
||||||
|
|
Loading…
Add table
Reference in a new issue