From e9f1f940a2cad5256669e1cb8ef9d5fbede272d2 Mon Sep 17 00:00:00 2001
From: jgromes <jan.gromes@gmail.com>
Date: Sat, 13 Mar 2021 19:57:44 +0100
Subject: [PATCH] [SX128x] Added low-level access macro

---
 src/modules/SX128x/SX1280.h |  2 +-
 src/modules/SX128x/SX1281.h |  2 +-
 src/modules/SX128x/SX1282.h |  2 +-
 src/modules/SX128x/SX128x.h | 26 +++++++++++++++++---------
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/modules/SX128x/SX1280.h b/src/modules/SX128x/SX1280.h
index 3cd3184a..f72d125a 100644
--- a/src/modules/SX128x/SX1280.h
+++ b/src/modules/SX128x/SX1280.h
@@ -52,7 +52,7 @@ class SX1280: public SX1281 {
     */
     float getRangingResult();
 
-#ifndef RADIOLIB_GODMODE
+#if !defined(RADIOLIB_GODMODE)
   private:
 #endif
 
diff --git a/src/modules/SX128x/SX1281.h b/src/modules/SX128x/SX1281.h
index 67a0a323..4482e3c5 100644
--- a/src/modules/SX128x/SX1281.h
+++ b/src/modules/SX128x/SX1281.h
@@ -22,7 +22,7 @@ class SX1281: public SX128x {
     */
     SX1281(Module* mod);
 
-#ifndef RADIOLIB_GODMODE
+#if !defined(RADIOLIB_GODMODE)
   private:
 #endif
 
diff --git a/src/modules/SX128x/SX1282.h b/src/modules/SX128x/SX1282.h
index f6cbdbd7..71feb29a 100644
--- a/src/modules/SX128x/SX1282.h
+++ b/src/modules/SX128x/SX1282.h
@@ -23,7 +23,7 @@ class SX1282: public SX1280 {
     */
     SX1282(Module* mod);
 
-#ifndef RADIOLIB_GODMODE
+#if !defined(RADIOLIB_GODMODE)
   private:
 #endif
 
diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h
index 5763e527..d1cc8216 100644
--- a/src/modules/SX128x/SX128x.h
+++ b/src/modules/SX128x/SX128x.h
@@ -760,11 +760,15 @@ class SX128x: public PhysicalLayer {
    */
     uint8_t random();
 
-#ifndef RADIOLIB_GODMODE
+#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
   protected:
 #endif
     Module* _mod;
 
+#if !defined(RADIOLIB_GODMODE)
+  protected:
+#endif
+
     // cached LoRa parameters
     float _bwKhz = 0;
     uint8_t _bw = 0, _sf = 0, _cr = 0;
@@ -795,7 +799,18 @@ class SX128x: public PhysicalLayer {
 
     int16_t setHeaderType(uint8_t headerType, size_t len = 0xFF);
 
-#ifndef RADIOLIB_GODMODE
+#if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
+  private:
+#endif
+
+    // common low-level SPI interface
+    int16_t SPIwriteCommand(uint8_t cmd, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
+    int16_t SPIwriteCommand(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
+    int16_t SPIreadCommand(uint8_t cmd, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
+    int16_t SPIreadCommand(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
+    int16_t SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes, bool waitForBusy, uint32_t timeout = 5000);
+
+#if !defined(RADIOLIB_GODMODE)
   private:
 #endif
     // common parameters
@@ -814,13 +829,6 @@ class SX128x: public PhysicalLayer {
     uint8_t _connectionState = 0, _crcBLE = 0, _bleTestPayload = 0;
 
     int16_t config(uint8_t modem);
-
-    // common low-level SPI interface
-    int16_t SPIwriteCommand(uint8_t cmd, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
-    int16_t SPIwriteCommand(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
-    int16_t SPIreadCommand(uint8_t cmd, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
-    int16_t SPIreadCommand(uint8_t* cmd, uint8_t cmdLen, uint8_t* data, uint8_t numBytes, bool waitForBusy = true);
-    int16_t SPItransfer(uint8_t* cmd, uint8_t cmdLen, bool write, uint8_t* dataOut, uint8_t* dataIn, uint8_t numBytes, bool waitForBusy, uint32_t timeout = 5000);
 };
 
 #endif