1 #if !defined(_RADIOLIB_HAL_H)
2 #define _RADIOLIB_HAL_H
9 #define RADIOLIB_EEPROM_TABLE_VERSION (0x0002)
12 enum RADIOLIB_EEPROM_PARAMS {
13 RADIOLIB_EEPROM_TABLE_VERSION_ID,
14 RADIOLIB_EEPROM_LORAWAN_CLASS_ID,
15 RADIOLIB_EEPROM_LORAWAN_MODE_ID,
16 RADIOLIB_EEPROM_LORAWAN_CHECKSUM_ID,
17 RADIOLIB_EEPROM_LORAWAN_VERSION_ID,
18 RADIOLIB_EEPROM_LORAWAN_LAST_TIME_ID,
19 RADIOLIB_EEPROM_LORAWAN_DEV_ADDR_ID,
20 RADIOLIB_EEPROM_LORAWAN_APP_S_KEY_ID,
21 RADIOLIB_EEPROM_LORAWAN_FNWK_SINT_KEY_ID,
22 RADIOLIB_EEPROM_LORAWAN_SNWK_SINT_KEY_ID,
23 RADIOLIB_EEPROM_LORAWAN_NWK_SENC_KEY_ID,
24 RADIOLIB_EEPROM_LORAWAN_DEV_NONCE_ID,
25 RADIOLIB_EEPROM_LORAWAN_JOIN_NONCE_ID,
26 RADIOLIB_EEPROM_LORAWAN_HOME_NET_ID,
27 RADIOLIB_EEPROM_LORAWAN_A_FCNT_DOWN_ID,
28 RADIOLIB_EEPROM_LORAWAN_N_FCNT_DOWN_ID,
29 RADIOLIB_EEPROM_LORAWAN_CONF_FCNT_UP_ID,
30 RADIOLIB_EEPROM_LORAWAN_CONF_FCNT_DOWN_ID,
31 RADIOLIB_EEPROM_LORAWAN_ADR_FCNT_ID,
32 RADIOLIB_EEPROM_LORAWAN_RJ_COUNT0_ID,
33 RADIOLIB_EEPROM_LORAWAN_RJ_COUNT1_ID,
34 RADIOLIB_EEPROM_LORAWAN_FCNT_UP_ID,
35 RADIOLIB_EEPROM_LORAWAN_LINK_ADR_ID,
36 RADIOLIB_EEPROM_LORAWAN_DUTY_CYCLE_ID,
37 RADIOLIB_EEPROM_LORAWAN_RX_PARAM_SETUP_ID,
38 RADIOLIB_EEPROM_LORAWAN_RX_TIMING_SETUP_ID,
39 RADIOLIB_EEPROM_LORAWAN_TX_PARAM_SETUP_ID,
40 RADIOLIB_EEPROM_LORAWAN_ADR_PARAM_SETUP_ID,
41 RADIOLIB_EEPROM_LORAWAN_REJOIN_PARAM_SETUP_ID,
42 RADIOLIB_EEPROM_LORAWAN_BEACON_FREQ_ID,
43 RADIOLIB_EEPROM_LORAWAN_PING_SLOT_CHANNEL_ID,
44 RADIOLIB_EEPROM_LORAWAN_PERIODICITY_ID,
45 RADIOLIB_EEPROM_LORAWAN_NUM_ADR_MASKS_ID,
46 RADIOLIB_EEPROM_LORAWAN_MAC_QUEUE_UL_ID,
47 RADIOLIB_EEPROM_LORAWAN_UL_CHANNELS_ID,
48 RADIOLIB_EEPROM_LORAWAN_DL_CHANNELS_ID
51 static const uint32_t RadioLibPersistentParamTable[] = {
140 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);
150 virtual void pinMode(uint32_t pin, uint32_t mode) = 0;
175 virtual void attachInterrupt(uint32_t interruptNum,
void (*interruptCb)(
void), uint32_t mode) = 0;
189 virtual void delay(
unsigned long ms) = 0;
220 virtual long pulseIn(uint32_t pin, uint32_t state,
unsigned long timeout) = 0;
238 virtual void spiTransfer(uint8_t* out,
size_t len, uint8_t* in) = 0;
273 virtual void tone(uint32_t pin,
unsigned int frequency,
unsigned long duration = 0);
279 virtual void noTone(uint32_t pin);
284 virtual void yield();
Hardware abstraction library base interface.
Definition: Hal.h:95
const uint32_t GpioInterruptFalling
Value to be used as the "falling" GPIO level change direction.
Definition: Hal.h:129
virtual uint32_t digitalRead(uint32_t pin)=0
Digital read method. Must be implemented by the platform-specific hardware abstraction!
const uint32_t GpioModeOutput
Value to be used as the "output" GPIO direction.
Definition: Hal.h:109
virtual void yield()
Yield method, called from long loops in multi-threaded environment (to prevent blocking other threads...
Definition: Hal.cpp:29
T getPersistentParameter(uint32_t id)
Method to get arbitrary parameter from persistent storage. This method DOES NOT perform any endiannes...
Definition: Hal.cpp:73
void setPersistentParameter(uint32_t id, T val, uint32_t offset=0)
Method to set arbitrary parameter to persistent storage. This method DOES NOT perform any endianness ...
Definition: Hal.cpp:63
virtual unsigned long millis()=0
Get number of milliseconds since start. Must be implemented by the platform-specific hardware abstrac...
const uint32_t GpioModeInput
Value to be used as the "input" GPIO direction.
Definition: Hal.h:104
virtual void detachInterrupt(uint32_t interruptNum)=0
Method to detach function from an external interrupt. Must be implemented by the platform-specific ha...
virtual uint32_t pinToInterrupt(uint32_t pin)
Function to convert from pin number to interrupt number.
Definition: Hal.cpp:33
virtual long pulseIn(uint32_t pin, uint32_t state, unsigned long timeout)=0
Measure the length of incoming digital pulse in microseconds. Must be implemented by the platform-spe...
const uint32_t GpioLevelLow
Value to be used as the "low" GPIO level.
Definition: Hal.h:114
const uint32_t GpioLevelHigh
Value to be used as the "high" GPIO level.
Definition: Hal.h:119
virtual void spiEnd()=0
SPI termination method.
virtual void init()
Module initialization method. This will be called by all radio modules at the beginning of startup....
Definition: Hal.cpp:11
virtual void readPersistentStorage(uint32_t addr, uint8_t *buff, size_t len)
Method to read from persistent storage (e.g. EEPROM).
Definition: Hal.cpp:37
virtual void digitalWrite(uint32_t pin, uint32_t value)=0
Digital write method. Must be implemented by the platform-specific hardware abstraction!
virtual void spiEndTransaction()=0
Method to end SPI transaction.
virtual void noTone(uint32_t pin)
Method to stop producing a tone.
Definition: Hal.cpp:25
const uint32_t GpioInterruptRising
Value to be used as the "rising" GPIO level change direction.
Definition: Hal.h:124
virtual void delay(unsigned long ms)=0
Blocking wait function. Must be implemented by the platform-specific hardware abstraction!
virtual void writePersistentStorage(uint32_t addr, uint8_t *buff, size_t len)
Method to write to persistent storage (e.g. EEPROM).
Definition: Hal.cpp:44
virtual void spiBegin()=0
SPI initialization method.
virtual void term()
Module termination method. This will be called by all radio modules when the destructor is called....
Definition: Hal.cpp:15
virtual void tone(uint32_t pin, unsigned int frequency, unsigned long duration=0)
Method to produce a square-wave with 50% duty cycle ("tone") of a given frequency at some pin.
Definition: Hal.cpp:19
virtual void spiBeginTransaction()=0
Method to start SPI transaction.
void wipePersistentStorage()
Method to wipe the persistent storage by writing to 0. Will write at most RADIOLIB_HAL_PERSISTENT_STO...
Definition: Hal.cpp:51
virtual void delayMicroseconds(unsigned long us)=0
Blocking microsecond wait function. Must be implemented by the platform-specific hardware abstraction...
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)
Default constructor.
Definition: Hal.cpp:3
uint32_t getPersistentAddr(uint32_t id)
Method to convert from persistent parameter ID to its physical address.
Definition: Hal.cpp:58
virtual void spiTransfer(uint8_t *out, size_t len, uint8_t *in)=0
Method to transfer buffer over SPI.
virtual unsigned long micros()=0
Get number of microseconds since start. Must be implemented by the platform-specific hardware abstrac...
virtual void pinMode(uint32_t pin, uint32_t mode)=0
GPIO pin mode (input/output/...) configuration method. Must be implemented by the platform-specific h...
virtual void attachInterrupt(uint32_t interruptNum, void(*interruptCb)(void), uint32_t mode)=0
Method to attach function to an external interrupt. Must be implemented by the platform-specific hard...