]> git.tnoah.ca Git - lora-radio.git/commitdiff
Fixed board and modem import structure
authorMark Qvist <mark@unsigned.io>
Fri, 9 Feb 2024 14:29:54 +0000 (15:29 +0100)
committerMark Qvist <mark@unsigned.io>
Fri, 9 Feb 2024 14:29:54 +0000 (15:29 +0100)
Boards.h [new file with mode: 0644]
Config.h
LoRa.cpp
Makefile

diff --git a/Boards.h b/Boards.h
new file mode 100644 (file)
index 0000000..751a373
--- /dev/null
+++ b/Boards.h
@@ -0,0 +1,55 @@
+// Copyright (C) 2024, Mark Qvist
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+#import "Modem.h"
+
+#ifndef BOARDS_H
+  #define BOARDS_H
+  
+    #define PLATFORM_AVR   0x90
+    #define PLATFORM_ESP32 0x80
+    #define PLATFORM_NRF52 0x70
+
+    #define MCU_1284P 0x91
+    #define MCU_2560  0x92
+    #define MCU_ESP32 0x81
+    #define MCU_NRF52 0x71
+
+    #define BOARD_RNODE         0x31
+    #define BOARD_HMBRW         0x32
+    #define BOARD_TBEAM         0x33
+    #define BOARD_HUZZAH32      0x34
+    #define BOARD_GENERIC_ESP32 0x35
+    #define BOARD_LORA32_V2_0   0x36
+    #define BOARD_LORA32_V2_1   0x37
+    #define BOARD_LORA32_V1_0   0x39
+    #define BOARD_HELTEC32_V2   0x38
+    #define BOARD_RNODE_NG_20   0x40
+    #define BOARD_RNODE_NG_21   0x41
+    #define BOARD_RNODE_NG_22   0x42
+    #define BOARD_GENERIC_NRF52 0x50
+    #define BOARD_RAK4630       0x51
+
+    #if BOARD_MODEL == BOARD_RAK4630
+      #define MODEM SX1262
+    #elif BOARD_MODEL == BOARD_RNODE_NG_22
+      #define MODEM SX1262
+    #elif BOARD_MODEL == BOARD_GENERIC_NRF52
+      #define MODEM SX1262
+    #else
+      #define MODEM SX1276
+    #endif
+
+#endif
\ No newline at end of file
index 17bcccd367e5056264d81cc8cb46692ec281dde0..bee7efbc792860956eccf425b417ec4471b934ac 100644 (file)
--- a/Config.h
+++ b/Config.h
@@ -14,6 +14,7 @@
 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 #include "ROM.h"
+#include "Boards.h"
 #include "Modem.h"
 
 #ifndef CONFIG_H
        #define MAJ_VERS  0x01
        #define MIN_VERS  0x46
 
-       #define PLATFORM_AVR   0x90
-  #define PLATFORM_ESP32 0x80
-    #define PLATFORM_NRF52 0x70
-
-       #define MCU_1284P 0x91
-       #define MCU_2560  0x92
-       #define MCU_ESP32 0x81
-       #define MCU_NRF52 0x71
-
-       #define BOARD_RNODE         0x31
-       #define BOARD_HMBRW         0x32
-       #define BOARD_TBEAM         0x33
-       #define BOARD_HUZZAH32      0x34
-       #define BOARD_GENERIC_ESP32 0x35
-       #define BOARD_LORA32_V2_0   0x36
-       #define BOARD_LORA32_V2_1   0x37
-       #define BOARD_LORA32_V1_0   0x39
-       #define BOARD_HELTEC32_V2   0x38
-       #define BOARD_RNODE_NG_20   0x40
-       #define BOARD_RNODE_NG_21   0x41
-       #define BOARD_RNODE_NG_22   0x42
-       #define BOARD_GENERIC_NRF52 0x50
-       #define BOARD_RAK4630       0x51
-
        #define MODE_HOST 0x11
        #define MODE_TNC  0x12
 
                        #define HAS_NP true
                        #define HAS_SD false
             #define HAS_EEPROM true
-                       #define MODEM_MISO 3
-                       #define MODEM_MOSI 6
-                       #define MODEM_CLK 5
                        const int pin_cs = 7;
                        const int pin_reset = 8;
                        const int pin_dio = 33;
index 3a9667c10e26bc5786a269e969aae308b8264f2e..3637a08c8fe7a71bcafad558f831780d76a85da8 100644 (file)
--- a/LoRa.cpp
+++ b/LoRa.cpp
@@ -4,6 +4,7 @@
 // Modifications and additions copyright 2023 by Mark Qvist
 // Obviously still under the MIT license.
 
+#include "Boards.h"
 #include "LoRa.h"
 #include "Modem.h"
 
   #define ISR_VECT
 #endif
 
+#if BOARD_MODEL == BOARD_RNODE_NG_22
+  #define MODEM_MISO 3
+  #define MODEM_MOSI 6
+  #define MODEM_CLK  5
+#endif
+
 #if MODEM == SX1262
     #define OP_FIFO_WRITE            0x0E
     #define OP_FIFO_READ             0x1E
index 82f1c74ab628038df001df6f717efc9fa8ecb22d..effaa0a2adfb39883e7c5f632ac034c3231e3c9e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -55,55 +55,55 @@ upload-spiffs:
        python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin
 
 firmware:
-       arduino-cli compile --fqbn unsignedio:avr:rnode --build-property "compiler.cpp.extra_flags=\"-DMODEM=0x01\""
+       arduino-cli compile --fqbn unsignedio:avr:rnode
 
 firmware-mega2560:
-       arduino-cli compile --fqbn arduino:avr:mega --build-property "compiler.cpp.extra_flags=\"-DMODEM=0x01\""
+       arduino-cli compile --fqbn arduino:avr:mega
 
 firmware-tbeam:
-       arduino-cli compile --fqbn esp32:esp32:t-beam -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x33\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:t-beam -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x33\""
 
 firmware-lora32_v10:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x39\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x39\""
 
 firmware-lora32_v10_extled:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x39\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x39\" \"-DEXTERNAL_LEDS=true\""
 
 firmware-lora32_v20:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x36\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x36\" \"-DEXTERNAL_LEDS=true\""
 
 firmware-lora32_v21:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DMODEM=0x01\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DMODEM=0x01\""
 
 firmware-lora32_v21_extled:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DEXTERNAL_LEDS=true\""
 
 firmware-lora32_v21_tcxo:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DENABLE_TCXO=true\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x37\" \"-DENABLE_TCXO=true\""
 
 firmware-heltec32_v2:
-       arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\""
 
 firmware-heltec32_v2_extled:
-       arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DEXTERNAL_LEDS=true\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V2 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x38\" \"-DEXTERNAL_LEDS=true\""
 
 firmware-rnode_ng_20:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x40\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x40\""
 
 firmware-rnode_ng_21:
-       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x41\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:ttgo-lora32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x41\""
 
 firmware-rnode_ng_22:
-       arduino-cli compile --fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x42\" \"-DMODEM=0x03\""
+       arduino-cli compile --fqbn "esp32:esp32:esp32s3:CDCOnBoot=cdc" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x42\""
 
 firmware-featheresp32:
-       arduino-cli compile --fqbn esp32:esp32:featheresp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x34\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:featheresp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x34\""
 
 firmware-genericesp32:
-       arduino-cli compile --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x35\" \"-DMODEM=0x01\""
+       arduino-cli compile --fqbn esp32:esp32:esp32 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x35\""
 
 firmware-rak4630:
-       arduino-cli compile --fqbn rakwireless:nrf52:WisCoreRAK4631Board -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x51\" \"-DMODEM=0x03\""
+       arduino-cli compile --fqbn rakwireless:nrf52:WisCoreRAK4631Board -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x51\""
 
 upload:
        arduino-cli upload -p /dev/ttyUSB0 --fqbn unsignedio:avr:rnode