Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preliminary Othernet Dreamcatcher Support #4933

Merged
merged 15 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// -----------------------------------------------------------------------------
#define FT6336U_ADDR 0x48

// -----------------------------------------------------------------------------
// BIAS-T Generator
// -----------------------------------------------------------------------------
#define TPS65233_ADDR 0x60

// convert 24-bit color to 16-bit (56K)
#define COLOR565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3))

Expand Down
3 changes: 2 additions & 1 deletion src/detect/ScanI2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class ScanI2C
FT6336U,
STK8BAXX,
ICM20948,
MAX30102
MAX30102,
TPS65233
} DeviceType;

// typedef uint8_t DeviceAddress;
Expand Down
3 changes: 3 additions & 0 deletions src/detect/ScanI2CTwoWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
SCAN_SIMPLE_CASE(NAU7802_ADDR, NAU7802, "NAU7802 based scale found\n");
SCAN_SIMPLE_CASE(FT6336U_ADDR, FT6336U, "FT6336U touchscreen found\n");
SCAN_SIMPLE_CASE(MAX1704X_ADDR, MAX17048, "MAX17048 lipo fuel gauge found\n");
#ifdef HAS_TPS65233
SCAN_SIMPLE_CASE(TPS65233_ADDR, TPS65233, "TPS65233 BIAS-T found\n");
caveman99 marked this conversation as resolved.
Show resolved Hide resolved
#endif
SCAN_SIMPLE_CASE(MLX90614_ADDR_DEF, MLX90614, "MLX90614 IR temp sensor found\n");

case ICM20948_ADDR: // same as BMX160_ADDR
Expand Down
20 changes: 20 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ void setup()
digitalWrite(VEXT_ENABLE, VEXT_ON_VALUE); // turn on the display power
#endif

#if defined(BIAS_T_ENABLE)
caveman99 marked this conversation as resolved.
Show resolved Hide resolved
pinMode(BIAS_T_ENABLE, OUTPUT);
digitalWrite(BIAS_T_ENABLE, BIAS_T_VALUE); // turn on 5V for GPS Antenna
#endif

#if defined(VTFT_CTRL)
pinMode(VTFT_CTRL, OUTPUT);
digitalWrite(VTFT_CTRL, LOW);
Expand Down Expand Up @@ -538,6 +543,21 @@ void setup()
rgb_found = i2cScanner->find(ScanI2C::DeviceType::NCP5623);
#endif

#ifdef HAS_TPS65233
// TPS65233 is a power management IC for satellite modems, used in the Dreamcatcher
// We are switching it off here since we don't use an LNB.
if (i2cScanner->exists(ScanI2C::DeviceType::TPS65233)) {
Wire.beginTransmission(TPS65233_ADDR);
Wire.write(0); // Register 0
Wire.write(128); // Turn off the LNB power, keep I2C Control enabled
Wire.endTransmission();
Wire.beginTransmission(TPS65233_ADDR);
Wire.write(1); // Register 1
Wire.write(0); // Turn off Tone Generator 22kHz
Wire.endTransmission();
}
#endif

#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
auto acc_info = i2cScanner->firstAccelerometer();
accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found;
Expand Down
12 changes: 12 additions & 0 deletions src/mesh/LR11x0Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ template <typename T> bool LR11x0Interface<T>::init()

limitPower();

#ifdef LR11X0_RF_SWITCH_SUBGHZ
pinMode(LR11X0_RF_SWITCH_SUBGHZ, OUTPUT);
digitalWrite(LR11X0_RF_SWITCH_SUBGHZ, getFreq() < 1e9 ? HIGH : LOW);
LOG_DEBUG("Setting RF0 switch to %s\n", getFreq() < 1e9 ? "SubGHz" : "2.4GHz");
#endif

#ifdef LR11X0_RF_SWITCH_2_4GHZ
pinMode(LR11X0_RF_SWITCH_2_4GHZ, OUTPUT);
digitalWrite(LR11X0_RF_SWITCH_2_4GHZ, getFreq() < 1e9 ? LOW : HIGH);
LOG_DEBUG("Setting RF1 switch to %s\n", getFreq() < 1e9 ? "SubGHz" : "2.4GHz");
#endif

int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage);
// \todo Display actual typename of the adapter, not just `LR11x0`
LOG_INFO("LR11x0 init result %d\n", res);
Expand Down
27 changes: 27 additions & 0 deletions variants/dreamcatcher/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[env:dreamcatcher] ; 2301, latest revision
extends = esp32s3_base
board = esp32s3box
caveman99 marked this conversation as resolved.
Show resolved Hide resolved
board_level = extra

build_flags =
${esp32s3_base.build_flags}
-D PRIVATE_HW
-D OTHERNET_DC_REV=2301
-I variants/dreamcatcher
-DARDUINO_USB_CDC_ON_BOOT=1

lib_deps = ${esp32s3_base.lib_deps}
earlephilhower/ESP8266Audio@^1.9.7
earlephilhower/ESP8266SAM@^1.0.1

[env:dreamcatcher-2206]
extends = esp32s3_base
board = esp32s3box
board_level = extra

build_flags =
${esp32s3_base.build_flags}
-D PRIVATE_HW
-D OTHERNET_DC_REV=2206
-I variants/dreamcatcher
-DARDUINO_USB_CDC_ON_BOOT=1
17 changes: 17 additions & 0 deletions variants/dreamcatcher/rfswitch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "RadioLib.h"

// RF Switch Matrix SubG RFO_HP_LF / RFO_LP_LF / RFI_[NP]_LF0
// DIO5 -> RFSW0_V1
// DIO6 -> RFSW1_V2
// DIO7 -> ANT_CTRL_ON + ESP_IO9/LR_GPS_ANT_DC_EN -> RFI_GPS (Bias-T GPS)

static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6, RADIOLIB_LR11X0_DIO7, RADIOLIB_NC,
RADIOLIB_NC};

static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6 DIO7
{LR11x0::MODE_STBY, {LOW, LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW, LOW}},
{LR11x0::MODE_TX, {LOW, HIGH, LOW}}, {LR11x0::MODE_TX_HP, {LOW, HIGH, LOW}},
{LR11x0::MODE_TX_HF, {LOW, LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW, HIGH}},
{LR11x0::MODE_WIFI, {LOW, LOW, LOW}}, END_OF_MODE_TABLE,
};
109 changes: 109 additions & 0 deletions variants/dreamcatcher/variant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#undef I2C_SDA
#undef I2C_SCL
#define I2C_SDA 16 // I2C pins for this board
#define I2C_SCL 17

#define I2C_SDA1 45
caveman99 marked this conversation as resolved.
Show resolved Hide resolved
#define I2C_SCL1 46

#define LED_PIN 6
#define LED_STATE_ON 1
#define BUTTON_PIN 0

#define HAS_TPS65233

// V1 of SubG Switch SMA 0 or F Selector 1
// #define RF_SW_SUBG1 8
// V2 of SubG Switch SMA 1 or F Selector 0
// #define RF_SW_SUBG2 5

#define RESET_OLED 8 // Emulate RF_SW_SUBG1, Use F Connector
#define VTFT_CTRL 5 // Emulate RF_SW_SUBG2, for SMA swap the pin values

#if OTHERNET_DC_REV == 2206
#define USE_LR1120

#define SPI_MISO 37
#define SPI_MOSI 39
#define SPI_SCK 38
#define SDCARD_CS 40

#define PIN_BUZZER 48

// These can either be used for GPS or a serial link. Define through Protobufs
// #define GPS_RX_PIN 10
// #define GPS_TX_PIN 21

#define PIN_POWER_EN 7 // RF section power supply enable
#define PERIPHERAL_WARMUP_MS 1000 // wait for TPS chip to initialize
#define TPS_EXTM 45 // connected, but not used
#define BIAS_T_ENABLE 9 // needs to be low
#define BIAS_T_VALUE 0
#else // 2301
#define USE_LR1121
#define SPI_MISO 10
#define SPI_MOSI 39
#define SPI_SCK 38

#define SDCARD_CS 40

// This is only informational, we always use SD cards in 1 bit mode
#define SPI_DATA1 15
#define SPI_DATA2 18

// These can either be used for GPS or a serial link. Define through Protobufs
// #define GPS_RX_PIN 36
// #define GPS_TX_PIN 37

// dac / amp instead of buzzer
#define HAS_I2S
#define DAC_I2S_BCK 21
#define DAC_I2S_WS 9
#define DAC_I2S_DOUT 48

#define BIAS_T_ENABLE 7 // needs to be low
#define BIAS_T_VALUE 0
#define BIAS_T_SUBGHZ 2 // also needs to be low, we hijack SENSOR_POWER_CTRL_PIN to emulate this
#define SENSOR_POWER_CTRL_PIN BIAS_T_SUBGHZ
#define SENSOR_POWER_ON 0
#endif

#define HAS_SDCARD // Have SPI interface SD card slot
#define SDCARD_USE_SPI1

#define LORA_RESET 3
#define LORA_SCK 12
#define LORA_MISO 13
#define LORA_MOSI 11
#define LORA_CS 14
#define LORA_DIO9 4
#define LORA_DIO2 47

#define LR1120_IRQ_PIN LORA_DIO9
#define LR1120_NRESET_PIN LORA_RESET
#define LR1120_BUSY_PIN LORA_DIO2
#define LR1120_SPI_NSS_PIN LORA_CS
#define LR1120_SPI_SCK_PIN LORA_SCK
#define LR1120_SPI_MOSI_PIN LORA_MOSI
#define LR1120_SPI_MISO_PIN LORA_MISO

#define LR1121_IRQ_PIN LORA_DIO9
#define LR1121_NRESET_PIN LORA_RESET
#define LR1121_BUSY_PIN LORA_DIO2
#define LR1121_SPI_NSS_PIN LORA_CS
#define LR1121_SPI_SCK_PIN LORA_SCK
#define LR1121_SPI_MOSI_PIN LORA_MOSI
#define LR1121_SPI_MISO_PIN LORA_MISO

#define LR11X0_DIO3_TCXO_VOLTAGE 1.8
#define LR11X0_DIO_AS_RF_SWITCH

// This board needs external switching between sub-GHz and 2.4G circuits

// V1 of RF1 selector SubG 1 or 2.4GHz 0
// #define RF_SW_SMA1 42
// V2 of RF1 Selector SubG 0 or 2.4GHz 1
// #define RF_SW_SMA2 41

#define LR11X0_RF_SWITCH_SUBGHZ 42
#define LR11X0_RF_SWITCH_2_4GHZ 41
Loading