Skip to content

Commit 1c3a24d

Browse files
ppannutoalistair23
authored andcommitted
tock: namespace hal as belonging to radiolib
Externally, `TockHal()` is ambiguous and overloaded. This renames the main class to `TockRadioLibHal()` to avoid conflicts with other hardware a Tock application might interface with. It also updates constants with similar namespacing.
1 parent fe52311 commit 1c3a24d

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/hal/Tock/libtockHal.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
SOFTWARE.
2525
*/
2626

27-
#ifndef TOCK_HAL_H
28-
#define TOCK_HAL_H
27+
#ifndef TOCK_RADIOLIB_HAL_H
28+
#define TOCK_RADIOLIB_HAL_H
2929

3030
// include RadioLib
3131
#include <RadioLib.h>
@@ -38,20 +38,20 @@
3838
#include "libtock-sync/services/alarm.h"
3939
#include "libtock/kernel/read_only_state.h"
4040

41-
#define RADIO_BUSY 1
42-
#define RADIO_DIO_1 2
43-
#define RADIO_DIO_3 3
44-
#define RADIO_RESET 4
41+
#define RADIOLIB_RADIO_BUSY 1
42+
#define RADIOLIB_RADIO_DIO_1 2
43+
#define RADIOLIB_RADIO_DIO_3 3
44+
#define RADIOLIB_RADIO_RESET 4
4545
// Skip the chips select as Tock handles this for us
46-
#define RADIO_NSS RADIOLIB_NC
46+
#define RADIOLIB_RADIO_NSS RADIOLIB_NC
4747

4848
// define Arduino-style macros
49-
#define PIN_LOW (0x0)
50-
#define PIN_HIGH (0x1)
51-
#define PIN_INPUT (0x01)
52-
#define PIN_OUTPUT (0x03)
53-
#define PIN_RISING (0x01)
54-
#define PIN_FALLING (0x02)
49+
#define TOCK_RADIOLIB_PIN_LOW (0x0)
50+
#define TOCK_RADIOLIB_PIN_HIGH (0x1)
51+
#define TOCK_RADIOLIB_PIN_INPUT (0x01)
52+
#define TOCK_RADIOLIB_PIN_OUTPUT (0x03)
53+
#define TOCK_RADIOLIB_PIN_RISING (0x01)
54+
#define TOCK_RADIOLIB_PIN_FALLING (0x02)
5555

5656
typedef void (*gpioIrqFn)(void);
5757

@@ -83,11 +83,11 @@ static void lora_phy_gpio_Callback (int gpioPin,
8383
}
8484
}
8585

86-
class TockHal : public RadioLibHal {
86+
class TockRadioLibHal : public RadioLibHal {
8787
public:
8888
// default constructor - initializes the base HAL and any needed private members
89-
TockHal()
90-
: RadioLibHal(PIN_INPUT, PIN_OUTPUT, PIN_LOW, PIN_HIGH, PIN_RISING, PIN_FALLING) {
89+
TockRadioLibHal()
90+
: RadioLibHal(TOCK_RADIOLIB_PIN_INPUT, TOCK_RADIOLIB_PIN_OUTPUT, TOCK_RADIOLIB_PIN_LOW, TOCK_RADIOLIB_PIN_HIGH, TOCK_RADIOLIB_PIN_RISING, TOCK_RADIOLIB_PIN_FALLING) {
9191
}
9292

9393
void init() override {
@@ -103,9 +103,9 @@ class TockHal : public RadioLibHal {
103103
return;
104104
}
105105

106-
if (mode == PIN_OUTPUT) {
106+
if (mode == TOCK_RADIOLIB_PIN_OUTPUT) {
107107
libtock_lora_phy_gpio_enable_output(pin);
108-
} else if (mode == PIN_INPUT) {
108+
} else if (mode == TOCK_RADIOLIB_PIN_INPUT) {
109109
libtock_lora_phy_gpio_enable_input(pin, libtock_pull_down);
110110
}
111111
}

0 commit comments

Comments
 (0)