mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2024-10-01 03:15:39 -04:00
Factor out board config detection
This commit is contained in:
parent
498b1f12e9
commit
e67b38c005
23
Config.h
23
Config.h
@ -1,20 +1,13 @@
|
||||
#include "ROM.h"
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define MAJ_VERS 0x01
|
||||
#define MIN_VERS 0x1B
|
||||
|
||||
#define PLATFORM_AVR 0x90
|
||||
#define PLATFORM_ESP32 0x80
|
||||
#define PLATFORM_LINUX 0x70
|
||||
|
||||
#define MCU_1284P 0x91
|
||||
#define MCU_2560 0x92
|
||||
#define MCU_ESP32 0x81
|
||||
#define MCU_LINUX 0x71
|
||||
|
||||
#define BOARD_RNODE 0x31
|
||||
#define BOARD_HMBRW 0x32
|
||||
#define BOARD_TBEAM 0x33
|
||||
@ -24,24 +17,25 @@
|
||||
#define BOARD_LORA32_V2_1 0x37
|
||||
#define BOARD_SPIDEV 0x38
|
||||
|
||||
#define LIBRARY_ARDUINO 0x1
|
||||
#define LIBRARY_C 0x2
|
||||
|
||||
#define MODE_HOST 0x11
|
||||
#define MODE_TNC 0x12
|
||||
|
||||
#if defined(__AVR_ATmega1284P__)
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define MCU_VARIANT MCU_1284P
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
#elif defined(__AVR_ATmega2560__)
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define MCU_VARIANT MCU_2560
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
#elif defined(ESP32)
|
||||
#define PLATFORM PLATFORM_ESP32
|
||||
#define MCU_VARIANT MCU_ESP32
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
#elif defined(__unix__)
|
||||
#define PLATFORM PLATFORM_LINUX
|
||||
#define MCU_VARIANT MCU_LINUX
|
||||
#define LIBRARY_TYPE LIBRARY_C
|
||||
#else
|
||||
#error "The firmware cannot be compiled for the selected MCU variant"
|
||||
#endif
|
||||
@ -63,7 +57,6 @@
|
||||
const int pin_led_tx = 13;
|
||||
|
||||
#define BOARD_MODEL BOARD_RNODE
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
|
||||
#define CONFIG_UART_BUFFER_SIZE 6144
|
||||
#define CONFIG_QUEUE_SIZE 6144
|
||||
@ -80,7 +73,6 @@
|
||||
const int pin_led_tx = 13;
|
||||
|
||||
#define BOARD_MODEL BOARD_HMBRW
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
|
||||
#define CONFIG_UART_BUFFER_SIZE 768
|
||||
#define CONFIG_QUEUE_SIZE 5120
|
||||
@ -142,8 +134,6 @@
|
||||
#error An unsupported board was selected. Cannot compile RNode firmware.
|
||||
#endif
|
||||
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
|
||||
#define CONFIG_UART_BUFFER_SIZE 6144
|
||||
#define CONFIG_QUEUE_SIZE 6144
|
||||
#define CONFIG_QUEUE_MAX_LENGTH 200
|
||||
@ -162,7 +152,6 @@
|
||||
const int pin_led_tx = -1;
|
||||
|
||||
#define BOARD_MODEL BOARD_SPIDEV
|
||||
#define LIBRARY_TYPE LIBRARY_C
|
||||
|
||||
#define CONFIG_UART_BUFFER_SIZE 6144
|
||||
#define CONFIG_QUEUE_SIZE 6144
|
||||
|
18
LoRa.cpp
18
LoRa.cpp
@ -6,24 +6,6 @@
|
||||
|
||||
#include "LoRa.h"
|
||||
|
||||
#define MCU_1284P 0x91
|
||||
#define MCU_2560 0x92
|
||||
#define MCU_ESP32 0x81
|
||||
#if defined(__AVR_ATmega1284P__)
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define MCU_VARIANT MCU_1284P
|
||||
#elif defined(__AVR_ATmega2560__)
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define MCU_VARIANT MCU_2560
|
||||
#elif defined(ESP32)
|
||||
#define PLATFORM PLATFORM_ESP32
|
||||
#define MCU_VARIANT MCU_ESP32
|
||||
#endif
|
||||
|
||||
#ifndef MCU_VARIANT
|
||||
#error No MCU variant defined, cannot compile
|
||||
#endif
|
||||
|
||||
#if MCU_VARIANT == MCU_ESP32
|
||||
#include "soc/rtc_wdt.h"
|
||||
#define ISR_VECT IRAM_ATTR
|
||||
|
8
LoRa.h
8
LoRa.h
@ -7,8 +7,16 @@
|
||||
#ifndef LORA_H
|
||||
#define LORA_H
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#if LIBRARY_TYPE == LIBRARY_ARDUINO
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#elif LIBRARY_TYPE == LIBRARY_C
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include "ArduinoOnLinux/Stream.h"
|
||||
#endif
|
||||
|
||||
#define LORA_DEFAULT_SS_PIN 10
|
||||
#define LORA_DEFAULT_RESET_PIN 9
|
||||
|
2
MD5.cpp
2
MD5.cpp
@ -1,7 +1,7 @@
|
||||
#include "MD5.h"
|
||||
|
||||
#if LIBRARY_TYPE == LIBRARY_ARDUINO
|
||||
#include "Arduino.h"
|
||||
#include <Arduino.h>
|
||||
#elif LIBRARY_TYPE == LIBRARY_C
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
5
Makefile
5
Makefile
@ -145,6 +145,9 @@ clean:
|
||||
rm -Rf bin
|
||||
rm -Rf obj
|
||||
|
||||
obj/MD5.o: MD5.cpp MD5.h Config.h ROM.h prep-linux
|
||||
obj/MD5.o: MD5.cpp MD5.h Config.h ROM.h Platform.h prep-linux
|
||||
$(CC) -c -o $@ $<
|
||||
|
||||
obj/LoRa.o: LoRa.cpp LoRa.h Platform.h prep-linux
|
||||
$(CC) -c -o $@ $<
|
||||
|
||||
|
42
Platform.h
Normal file
42
Platform.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
// Determine the platform, MCU, and C library we are building for.
|
||||
|
||||
#define PLATFORM_AVR 0x90
|
||||
#define PLATFORM_ESP32 0x80
|
||||
#define PLATFORM_LINUX 0x70
|
||||
|
||||
#define MCU_1284P 0x91
|
||||
#define MCU_2560 0x92
|
||||
#define MCU_ESP32 0x81
|
||||
#define MCU_LINUX 0x71
|
||||
|
||||
#define LIBRARY_ARDUINO 0x1
|
||||
#define LIBRARY_C 0x2
|
||||
|
||||
#if defined(__AVR_ATmega1284P__)
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define MCU_VARIANT MCU_1284P
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
#elif defined(__AVR_ATmega2560__)
|
||||
#define PLATFORM PLATFORM_AVR
|
||||
#define MCU_VARIANT MCU_2560
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
#elif defined(ESP32)
|
||||
#define PLATFORM PLATFORM_ESP32
|
||||
#define MCU_VARIANT MCU_ESP32
|
||||
#define LIBRARY_TYPE LIBRARY_ARDUINO
|
||||
#elif defined(__unix__)
|
||||
#define PLATFORM PLATFORM_LINUX
|
||||
#define MCU_VARIANT MCU_LINUX
|
||||
#define LIBRARY_TYPE LIBRARY_C
|
||||
#else
|
||||
#error "The firmware cannot be compiled for the selected MCU variant"
|
||||
#endif
|
||||
|
||||
#ifndef MCU_VARIANT
|
||||
#error No MCU variant defined, cannot compile
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user