@@ -90,6 +90,7 @@ NRF52Bluetooth *nrf52Bluetooth = nullptr;
90
90
#include " linux/LinuxHardwareI2C.h"
91
91
#include " mesh/raspihttp/PiWebServer.h"
92
92
#include " platform/portduino/PortduinoGlue.h"
93
+ #include " platform/portduino/USBHal.h"
93
94
#include < fstream>
94
95
#include < iostream>
95
96
#include < string>
@@ -213,6 +214,9 @@ static OSThread *powerFSMthread;
213
214
static OSThread *ambientLightingThread;
214
215
215
216
RadioInterface *rIf = NULL ;
217
+ #ifdef ARCH_PORTDUINO
218
+ RadioLibHal *RadioLibHAL = NULL ;
219
+ #endif
216
220
217
221
/* *
218
222
* Some platforms (nrf52) might provide an alterate version that suppresses calling delay from sleep.
@@ -237,6 +241,17 @@ void printInfo()
237
241
#ifndef PIO_UNIT_TESTING
238
242
void setup ()
239
243
{
244
+ #if defined(T_DECK)
245
+ // GPIO10 manages all peripheral power supplies
246
+ // Turn on peripheral power immediately after MUC starts.
247
+ // If some boards are turned on late, ESP32 will reset due to low voltage.
248
+ // ESP32-C3(Keyboard) , MAX98357A(Audio Power Amplifier) ,
249
+ // TF Card , Display backlight(AW9364DNR) , AN48841B(Trackball) , ES7210(Decoder)
250
+ pinMode (KB_POWERON, OUTPUT);
251
+ digitalWrite (KB_POWERON, HIGH);
252
+ delay (100 );
253
+ #endif
254
+
240
255
concurrency::hasBeenSetup = true ;
241
256
#if ARCH_PORTDUINO
242
257
SPISettings spiSettings (settingsMap[spiSpeed], MSBFIRST, SPI_MODE0);
@@ -409,15 +424,6 @@ void setup()
409
424
digitalWrite (AQ_SET_PIN, HIGH);
410
425
#endif
411
426
412
- #if defined(T_DECK)
413
- // enable keyboard
414
- pinMode (KB_POWERON, OUTPUT);
415
- digitalWrite (KB_POWERON, HIGH);
416
- // There needs to be a delay after power on, give LILYGO-KEYBOARD some startup time
417
- // otherwise keyboard and touch screen will not work
418
- delay (200 );
419
- #endif
420
-
421
427
// Currently only the tbeam has a PMU
422
428
// PMU initialization needs to be placed before i2c scanning
423
429
power = new Power ();
@@ -573,6 +579,7 @@ void setup()
573
579
scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::BMP_3XX, meshtastic_TelemetrySensorType_BMP3XX);
574
580
scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::BMP_085, meshtastic_TelemetrySensorType_BMP085);
575
581
scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::INA260, meshtastic_TelemetrySensorType_INA260);
582
+ scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::INA226, meshtastic_TelemetrySensorType_INA226);
576
583
scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::INA219, meshtastic_TelemetrySensorType_INA219);
577
584
scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::INA3221, meshtastic_TelemetrySensorType_INA3221);
578
585
scannerToSensorsMap (i2cScanner, ScanI2C::DeviceType::MAX17048, meshtastic_TelemetrySensorType_MAX17048);
@@ -703,12 +710,16 @@ void setup()
703
710
pinMode (LORA_CS, OUTPUT);
704
711
digitalWrite (LORA_CS, HIGH);
705
712
SPI1.begin (false );
706
- #else // HW_SPI1_DEVICE
713
+ #else // HW_SPI1_DEVICE
707
714
SPI.setSCK (LORA_SCK);
708
715
SPI.setTX (LORA_MOSI);
709
716
SPI.setRX (LORA_MISO);
710
717
SPI.begin (false );
711
- #endif // HW_SPI1_DEVICE
718
+ #endif // HW_SPI1_DEVICE
719
+ #elif ARCH_PORTDUINO
720
+ if (settingsStrings[spidev] != " ch341" ) {
721
+ SPI.begin ();
722
+ }
712
723
#elif !defined(ARCH_ESP32) // ARCH_RP2040
713
724
SPI.begin ();
714
725
#else
@@ -814,8 +825,11 @@ void setup()
814
825
if (settingsMap[use_sx1262]) {
815
826
if (!rIf) {
816
827
LOG_DEBUG (" Activate sx1262 radio on SPI port %s" , settingsStrings[spidev].c_str ());
817
- LockingArduinoHal *RadioLibHAL =
818
- new LockingArduinoHal (SPI, spiSettings, (settingsMap[ch341Quirk] ? settingsMap[busy] : RADIOLIB_NC));
828
+ if (settingsStrings[spidev] == " ch341" ) {
829
+ RadioLibHAL = ch341Hal;
830
+ } else {
831
+ RadioLibHAL = new LockingArduinoHal (SPI, spiSettings);
832
+ }
819
833
rIf = new SX1262Interface ((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
820
834
settingsMap[busy]);
821
835
if (!rIf->init ()) {
@@ -829,8 +843,7 @@ void setup()
829
843
} else if (settingsMap[use_rf95]) {
830
844
if (!rIf) {
831
845
LOG_DEBUG (" Activate rf95 radio on SPI port %s" , settingsStrings[spidev].c_str ());
832
- LockingArduinoHal *RadioLibHAL =
833
- new LockingArduinoHal (SPI, spiSettings, (settingsMap[ch341Quirk] ? settingsMap[busy] : RADIOLIB_NC));
846
+ RadioLibHAL = new LockingArduinoHal (SPI, spiSettings);
834
847
rIf = new RF95Interface ((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
835
848
settingsMap[busy]);
836
849
if (!rIf->init ()) {
@@ -845,7 +858,7 @@ void setup()
845
858
} else if (settingsMap[use_sx1280]) {
846
859
if (!rIf) {
847
860
LOG_DEBUG (" Activate sx1280 radio on SPI port %s" , settingsStrings[spidev].c_str ());
848
- LockingArduinoHal * RadioLibHAL = new LockingArduinoHal (SPI, spiSettings);
861
+ RadioLibHAL = new LockingArduinoHal (SPI, spiSettings);
849
862
rIf = new SX1280Interface ((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
850
863
settingsMap[busy]);
851
864
if (!rIf->init ()) {
@@ -905,7 +918,7 @@ void setup()
905
918
} else if (settingsMap[use_sx1268]) {
906
919
if (!rIf) {
907
920
LOG_DEBUG (" Activate sx1268 radio on SPI port %s" , settingsStrings[spidev].c_str ());
908
- LockingArduinoHal * RadioLibHAL = new LockingArduinoHal (SPI, spiSettings);
921
+ RadioLibHAL = new LockingArduinoHal (SPI, spiSettings);
909
922
rIf = new SX1268Interface ((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
910
923
settingsMap[busy]);
911
924
if (!rIf->init ()) {
@@ -1262,4 +1275,4 @@ void loop()
1262
1275
mainDelay.delay (delayMsec);
1263
1276
}
1264
1277
}
1265
- #endif
1278
+ #endif
0 commit comments