[HAL] Formatting cleanup, added doxygen comments
This commit is contained in:
parent
37bb8af768
commit
09c3ac4f6b
8 changed files with 274 additions and 63 deletions
|
@ -12,7 +12,6 @@
|
|||
#endif
|
||||
|
||||
#include "Hal.h"
|
||||
//#include <stdint.h>
|
||||
|
||||
#include <SPI.h>
|
||||
|
||||
|
|
115
src/BuildOpt.h
115
src/BuildOpt.h
|
@ -42,6 +42,20 @@
|
|||
//#define RADIOLIB_TONE_UNSUPPORTED
|
||||
//#define RADIOLIB_YIELD_UNSUPPORTED
|
||||
|
||||
// in addition, the following macros may be defined if the Arduino core differs from the defaults
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
||||
|
||||
// you might also have to define these if the Arduino core has some uncommon pin mode/status types
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
|
||||
|
||||
// some of RadioLib drivers may be excluded, to prevent collisions with platforms (or to speed up build process)
|
||||
// the following is a complete list of all possible exclusion macros, uncomment any of them to disable that driver
|
||||
// NOTE: Some of the exclusion macros are dependent on each other. For example, it is not possible to exclude RF69
|
||||
|
@ -65,107 +79,118 @@
|
|||
//#define RADIOLIB_EXCLUDE_RTTY
|
||||
//#define RADIOLIB_EXCLUDE_SSTV
|
||||
//#define RADIOLIB_EXCLUDE_DIRECT_RECEIVE
|
||||
|
||||
#elif defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR))
|
||||
// Arduino AVR boards (except for megaAVR) - Uno, Mega etc.
|
||||
#define RADIOLIB_PLATFORM "Arduino AVR"
|
||||
|
||||
#elif defined(ESP8266)
|
||||
// ESP8266 boards
|
||||
#define RADIOLIB_PLATFORM "ESP8266"
|
||||
|
||||
#elif defined(ESP32)
|
||||
// ESP32 boards
|
||||
#define RADIOLIB_PLATFORM "ESP32"
|
||||
|
||||
// ESP32 doesn't support tone(), but it can be emulated via LED control peripheral
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
#define RADIOLIB_TONE_ESP32_CHANNEL (1)
|
||||
|
||||
#elif defined(ARDUINO_ARCH_STM32)
|
||||
// official STM32 Arduino core (https://github.com/stm32duino/Arduino_Core_STM32)
|
||||
#define RADIOLIB_PLATFORM "Arduino STM32 (official)"
|
||||
|
||||
#elif defined(SAMD_SERIES)
|
||||
// Adafruit SAMD boards (M0 and M4)
|
||||
#define RADIOLIB_PLATFORM "Adafruit SAMD"
|
||||
|
||||
#elif defined(ARDUINO_ARCH_SAMD)
|
||||
// Arduino SAMD (Zero, MKR, etc.)
|
||||
#define RADIOLIB_PLATFORM "Arduino SAMD"
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
#elif defined(__SAM3X8E__)
|
||||
// Arduino Due
|
||||
#define RADIOLIB_PLATFORM "Arduino Due"
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
|
||||
#elif (defined(NRF52832_XXAA) || defined(NRF52840_XXAA)) && !defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
// Adafruit nRF52 boards
|
||||
#define RADIOLIB_PLATFORM "Adafruit nRF52"
|
||||
|
||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||
// Intel Curie
|
||||
#define RADIOLIB_PLATFORM "Intel Curie"
|
||||
|
||||
#elif defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(PORTDUINO)
|
||||
// Arduino megaAVR boards - Uno Wifi Rev.2, Nano Every
|
||||
#define RADIOLIB_PLATFORM "Arduino megaAVR"
|
||||
|
||||
#elif defined(ARDUINO_ARCH_APOLLO3)
|
||||
// Sparkfun Apollo3 boards
|
||||
#define RADIOLIB_PLATFORM "Sparkfun Apollo3"
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (Arduino_PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (Arduino_PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
#elif defined(ARDUINO_ARDUINO_NANO33BLE)
|
||||
// Arduino Nano 33 BLE
|
||||
#define RADIOLIB_PLATFORM "Arduino Nano 33 BLE"
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
|
||||
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
#define RADIOLIB_MBED_TONE_OVERRIDE
|
||||
|
||||
#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
|
||||
// Arduino Portenta H7
|
||||
#define RADIOLIB_PLATFORM "Portenta H7"
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
|
||||
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
#define RADIOLIB_MBED_TONE_OVERRIDE
|
||||
|
||||
#elif defined(__STM32F4__) || defined(__STM32F1__)
|
||||
// Arduino STM32 core by Roger Clark (https://github.com/rogerclarkmelbourne/Arduino_STM32)
|
||||
#define RADIOLIB_PLATFORM "STM32duino (unofficial)"
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (WiringPinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (ExtIntTriggerMode)
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (WiringPinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (ExtIntTriggerMode)
|
||||
#elif defined(ARDUINO_ARCH_MEGAAVR)
|
||||
// MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX)
|
||||
#define RADIOLIB_PLATFORM "MegaCoreX"
|
||||
|
||||
#elif defined(ARDUINO_ARCH_MBED_RP2040)
|
||||
// Raspberry Pi Pico (official mbed core)
|
||||
#define RADIOLIB_PLATFORM "Raspberry Pi Pico"
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
|
||||
// Arduino mbed OS boards have a really bad tone implementation which will crash after a couple seconds
|
||||
#define RADIOLIB_TONE_UNSUPPORTED
|
||||
#define RADIOLIB_MBED_TONE_OVERRIDE
|
||||
|
||||
#elif defined(ARDUINO_ARCH_RP2040)
|
||||
// Raspberry Pi Pico (unofficial core)
|
||||
#define RADIOLIB_PLATFORM "Raspberry Pi Pico (unofficial)"
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PinMode)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST (PinStatus)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (PinStatus)
|
||||
#elif defined(__ASR6501__) || defined(ARDUINO_ARCH_ASR650X) || defined(DARDUINO_ARCH_ASR6601)
|
||||
// CubeCell
|
||||
#define RADIOLIB_PLATFORM "CubeCell"
|
||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(1000000, MSBFIRST, SPI_MODE0) // see issue #709
|
||||
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PINMODE)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (IrqModes)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST (PINMODE)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST (IrqModes)
|
||||
|
||||
// provide an easy access to the on-board module
|
||||
#include "board-config.h"
|
||||
|
@ -188,6 +213,7 @@
|
|||
#if defined(yield)
|
||||
#undef yield
|
||||
#endif
|
||||
|
||||
#elif defined(RASPI)
|
||||
// RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino)
|
||||
#define RADIOLIB_PLATFORM "RasPiArduino"
|
||||
|
@ -211,46 +237,60 @@
|
|||
#undef micros
|
||||
inline unsigned long micros() { return((unsigned long)(STCV)); };
|
||||
#endif
|
||||
|
||||
#elif defined(TEENSYDUINO)
|
||||
// Teensy
|
||||
#define RADIOLIB_PLATFORM "Teensy"
|
||||
|
||||
#else
|
||||
// other Arduino platforms not covered by the above list - this may or may not work
|
||||
#define RADIOLIB_PLATFORM "Unknown Arduino"
|
||||
#define RADIOLIB_UNKNOWN_PLATFORM
|
||||
|
||||
#endif
|
||||
|
||||
// set the default values for all macros
|
||||
// these will be applied if they were not defined above
|
||||
#if !defined(RADIOLIB_NC)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#define RADIOLIB_NC (0xFFFFFFFF)
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_DEFAULT_SPI)
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#define RADIOLIB_DEFAULT_SPI SPI
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_DEFAULT_SPI_SETTINGS)
|
||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
||||
#define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0)
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_NONVOLATILE)
|
||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
||||
#define RADIOLIB_NONVOLATILE PROGMEM
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_NONVOLATILE_READ_BYTE)
|
||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr)
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_NONVOLATILE_READ_DWORD)
|
||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
||||
#define RADIOLIB_NONVOLATILE_READ_DWORD(addr) pgm_read_dword(addr)
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_TYPE_ALIAS)
|
||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
||||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_ARDUINOHAL_PIN_MODE_CAST)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_MODE_CAST
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST)
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
|
||||
#define RADIOLIB_ARDUINOHAL_PIN_STATUS_CAST
|
||||
#endif
|
||||
|
||||
#if !defined(RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST)
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
|
||||
#define RADIOLIB_ARDUINOHAL_INTERRUPT_MODE_CAST
|
||||
#endif
|
||||
|
||||
#else
|
||||
// generic non-Arduino platform
|
||||
#define RADIOLIB_PLATFORM "Generic"
|
||||
|
@ -262,7 +302,7 @@
|
|||
#define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type;
|
||||
|
||||
#if !defined(RADIOLIB_DEBUG_PORT)
|
||||
#define RADIOLIB_DEBUG_PORT stdout
|
||||
#define RADIOLIB_DEBUG_PORT stdout
|
||||
#endif
|
||||
|
||||
#define DEC 10
|
||||
|
@ -374,7 +414,6 @@
|
|||
#define RADIOLIB_STATIC_ARRAY_SIZE (256)
|
||||
#endif
|
||||
|
||||
|
||||
// This only compiles on STM32 boards with SUBGHZ module, but also
|
||||
// include when generating docs
|
||||
#if (!defined(ARDUINO_ARCH_STM32) || !defined(SUBGHZSPI_BASE)) && !defined(DOXYGEN)
|
||||
|
|
28
src/Hal.cpp
28
src/Hal.cpp
|
@ -1,7 +1,6 @@
|
|||
#include <stdint.h>
|
||||
#include "Hal.h"
|
||||
|
||||
Hal::Hal(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::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)
|
||||
: GpioModeInput(input),
|
||||
GpioModeOutput(output),
|
||||
GpioLevelLow(low),
|
||||
|
@ -9,17 +8,28 @@ Hal::Hal(const uint32_t input, const uint32_t output, const uint32_t low, const
|
|||
GpioInterruptRising(rising),
|
||||
GpioInterruptFalling(falling) {}
|
||||
|
||||
void Hal::init(){};
|
||||
void Hal::term(){};
|
||||
void Hal::tone(uint32_t pin, unsigned int frequency, unsigned long duration){
|
||||
void RadioLibHal::init() {
|
||||
|
||||
}
|
||||
|
||||
void RadioLibHal::term() {
|
||||
|
||||
}
|
||||
|
||||
void RadioLibHal::tone(uint32_t pin, unsigned int frequency, unsigned long duration) {
|
||||
(void)pin;
|
||||
(void)frequency;
|
||||
(void)duration;
|
||||
};
|
||||
void Hal::noTone(uint32_t pin){
|
||||
|
||||
void RadioLibHal::noTone(uint32_t pin) {
|
||||
(void)pin;
|
||||
};
|
||||
void Hal::yield(){};
|
||||
uint32_t Hal::pinToInterrupt(uint32_t pin) {
|
||||
return pin;
|
||||
|
||||
void RadioLibHal::yield() {
|
||||
|
||||
};
|
||||
|
||||
uint32_t RadioLibHal::pinToInterrupt(uint32_t pin) {
|
||||
return(pin);
|
||||
};
|
||||
|
|
176
src/Hal.h
176
src/Hal.h
|
@ -1,46 +1,208 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#if !defined(_RADIOLIB_HAL_H)
|
||||
#define _RADIOLIB_HAL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*!
|
||||
\class Hal
|
||||
|
||||
\brief Hardware abstraction library base interface.
|
||||
*/
|
||||
class Hal {
|
||||
class RadioLibHal {
|
||||
public:
|
||||
|
||||
// values for pin modes, levels and change directions
|
||||
// these tell RadioLib how are different logic states represented on a given platform
|
||||
|
||||
/*!
|
||||
\brief Value to be used as the "input" GPIO direction.
|
||||
*/
|
||||
const uint32_t GpioModeInput;
|
||||
|
||||
/*!
|
||||
\brief Value to be used as the "output" GPIO direction.
|
||||
*/
|
||||
const uint32_t GpioModeOutput;
|
||||
|
||||
/*!
|
||||
\brief Value to be used as the "low" GPIO level.
|
||||
*/
|
||||
const uint32_t GpioLevelLow;
|
||||
|
||||
/*!
|
||||
\brief Value to be used as the "high" GPIO level.
|
||||
*/
|
||||
const uint32_t GpioLevelHigh;
|
||||
|
||||
/*!
|
||||
\brief Value to be used as the "rising" GPIO level change direction.
|
||||
*/
|
||||
const uint32_t GpioInterruptRising;
|
||||
|
||||
/*!
|
||||
\brief Value to be used as the "falling" GPIO level change direction.
|
||||
*/
|
||||
const uint32_t GpioInterruptFalling;
|
||||
|
||||
Hal(const uint32_t input, const uint32_t output, const uint32_t low, const uint32_t high, const uint32_t rising, const uint32_t falling);
|
||||
/*!
|
||||
\brief Default constructor.
|
||||
\param input Value to be used as the "input" 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 high Value to be used as the "high" GPIO level.
|
||||
\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.
|
||||
*/
|
||||
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);
|
||||
|
||||
virtual void init();
|
||||
virtual void term();
|
||||
// pure virtual methods - these must be implemented by the hardware abstraction for RadioLib to function
|
||||
|
||||
/*!
|
||||
\brief GPIO pin mode (input/output/...) configuration method.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param pin Pin to be changed (platform-specific).
|
||||
\param mode Mode to be set (platform-specific).
|
||||
*/
|
||||
virtual void pinMode(uint32_t pin, uint32_t mode) = 0;
|
||||
|
||||
/*!
|
||||
\brief Digital write method.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param pin Pin to be changed (platform-specific).
|
||||
\param value Value to set (platform-specific).
|
||||
*/
|
||||
virtual void digitalWrite(uint32_t pin, uint32_t value) = 0;
|
||||
|
||||
/*!
|
||||
\brief Digital read method.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param pin Pin to be changed (platform-specific).
|
||||
\returns Value read on the pin (platform-specific).
|
||||
*/
|
||||
virtual uint32_t digitalRead(uint32_t pin) = 0;
|
||||
|
||||
/*!
|
||||
\brief Method to attach function to an external interrupt.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param interruptNum Interrupt number to attach to (platform-specific).
|
||||
\param interruptCb Interrupt service routine to execute.
|
||||
\param mode Rising/falling mode (platform-specific).
|
||||
*/
|
||||
virtual void attachInterrupt(uint32_t interruptNum, void (*interruptCb)(void), uint32_t mode) = 0;
|
||||
|
||||
/*!
|
||||
\brief Method to detach function from an external interrupt.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param interruptNum Interrupt number to detach from (platform-specific).
|
||||
*/
|
||||
virtual void detachInterrupt(uint32_t interruptNum) = 0;
|
||||
|
||||
/*!
|
||||
\brief Blocking wait function.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param ms Number of milliseconds to wait.
|
||||
*/
|
||||
virtual void delay(unsigned long ms) = 0;
|
||||
|
||||
/*!
|
||||
\brief Blocking microsecond wait function.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param us Number of microseconds to wait.
|
||||
*/
|
||||
virtual void delayMicroseconds(unsigned long us) = 0;
|
||||
|
||||
/*!
|
||||
\brief Get number of milliseconds since start.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\returns Number of milliseconds since start.
|
||||
*/
|
||||
virtual unsigned long millis() = 0;
|
||||
|
||||
/*!
|
||||
\brief Get number of microseconds since start.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\returns Number of microseconds since start.
|
||||
*/
|
||||
virtual unsigned long micros() = 0;
|
||||
|
||||
/*!
|
||||
\brief Measure the length of incoming digital pulse in microseconds.
|
||||
Must be implemented by the platform-specific hardware abstraction!
|
||||
\param pin Pin to measure on (platform-specific).
|
||||
\param state Pin level to monitor (platform-specific).
|
||||
\param timeout Timeout in microseconds.
|
||||
\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;
|
||||
|
||||
/*!
|
||||
\brief SPI initialization method.
|
||||
*/
|
||||
virtual void spiBegin() = 0;
|
||||
|
||||
/*!
|
||||
\brief Method to start SPI transaction.
|
||||
*/
|
||||
virtual void spiBeginTransaction() = 0;
|
||||
|
||||
/*!
|
||||
\brief Method to transfer one byte over SPI.
|
||||
\param b Byte to send.
|
||||
\returns Received byte.
|
||||
*/
|
||||
virtual uint8_t spiTransfer(uint8_t b) = 0;
|
||||
|
||||
/*!
|
||||
\brief Method to end SPI transaction.
|
||||
*/
|
||||
virtual void spiEndTransaction() = 0;
|
||||
|
||||
/*!
|
||||
\brief SPI termination method.
|
||||
*/
|
||||
virtual void spiEnd() = 0;
|
||||
|
||||
// virtual methods - these may or may not exists on a given platform
|
||||
// they exist in this implementation, but do nothing
|
||||
|
||||
/*!
|
||||
\brief Module initialization method.
|
||||
This will be called by all radio modules at the beginning of startup.
|
||||
Can be used to e.g., initalize SPI interface.
|
||||
*/
|
||||
virtual void init();
|
||||
|
||||
/*!
|
||||
\brief Module termination method.
|
||||
This will be called by all radio modules when the desctructor is called.
|
||||
Can be used to e.g., stop SPI interface.
|
||||
*/
|
||||
virtual void term();
|
||||
|
||||
/*!
|
||||
\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 frequency Frequency of the square wave.
|
||||
\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);
|
||||
|
||||
/*!
|
||||
\brief Method to stop producing a tone.
|
||||
\param pin Pin which is currently producing the tone.
|
||||
*/
|
||||
virtual void noTone(uint32_t pin);
|
||||
|
||||
/*!
|
||||
\brief Yield method, called from long loops in multi-threaded environment (to prevent blocking other threads).
|
||||
*/
|
||||
virtual void yield();
|
||||
|
||||
/*!
|
||||
\brief Function to convert from pin number to interrupt number.
|
||||
\param pin Pin to convert from.
|
||||
\returns The interrupt number of a given pin.
|
||||
*/
|
||||
virtual uint32_t pinToInterrupt(uint32_t pin);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
#define __STDC_FORMAT_MACROS
|
||||
#include "Module.h"
|
||||
|
||||
// the following is probably only needed on non-Arduino builds
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "Module.h"
|
||||
|
||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||
#include "ArduinoHal.h"
|
||||
Module::Module(uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||
this->hal = new ArduinoHal;
|
||||
this->hal = new ArduinoHal();
|
||||
}
|
||||
|
||||
Module::Module(uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio, SPIClass& spi, SPISettings spiSettings) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||
|
@ -15,7 +16,7 @@ Module::Module(uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio, SPIClass&
|
|||
}
|
||||
#endif
|
||||
|
||||
Module::Module(Hal *hal, uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||
Module::Module(RadioLibHal *hal, uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio) : _cs(cs), _irq(irq), _rst(rst), _gpio(gpio) {
|
||||
this->hal = hal;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class Module {
|
|||
|
||||
\param gpio Pin to be used as additional interrupt/GPIO.
|
||||
*/
|
||||
Module(Hal *hal, uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio = RADIOLIB_NC);
|
||||
Module(RadioLibHal *hal, uint32_t cs, uint32_t irq, uint32_t rst, uint32_t gpio = RADIOLIB_NC);
|
||||
|
||||
/*!
|
||||
\brief Copy constructor.
|
||||
|
@ -132,7 +132,7 @@ class Module {
|
|||
|
||||
// public member variables
|
||||
|
||||
Hal* hal = NULL;
|
||||
RadioLibHal* hal = NULL;
|
||||
|
||||
/*!
|
||||
\brief Basic SPI read command. Defaults to 0x00.
|
||||
|
|
|
@ -6,7 +6,7 @@ ExternalRadio::ExternalRadio() : PhysicalLayer(1, 0) {
|
|||
}
|
||||
#endif
|
||||
|
||||
ExternalRadio::ExternalRadio(Hal *hal) : PhysicalLayer(1, 0) {
|
||||
ExternalRadio::ExternalRadio(RadioLibHal *hal) : PhysicalLayer(1, 0) {
|
||||
mod = new Module(hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class ExternalRadio: public PhysicalLayer {
|
|||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||
ExternalRadio();
|
||||
#endif
|
||||
ExternalRadio(Hal *hal);
|
||||
ExternalRadio(RadioLibHal *hal);
|
||||
|
||||
Module* getMod();
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue