Skip to content

Commit a411163

Browse files
committed
System: Add gpioExpanderSwitchesRead and gpioExpanderDisplay routines
1 parent 66c47b6 commit a411163

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Firmware/RTK_Everywhere/System.ino

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,3 +1277,63 @@ void gpioExpanderConnectGNSSToESP32()
12771277
if (online.gpioExpanderSwitches == true)
12781278
gpioExpanderSwitches->digitalWrite(gpioExpanderSwitch_S5, LOW);
12791279
}
1280+
1281+
// Read the switches value from the GPIO expander
1282+
int gpioExpanderSwitchesRead()
1283+
{
1284+
uint8_t data;
1285+
1286+
if (gpioExpanderSwitches->getInputRegister(&data) == PCA95XX_ERROR_SUCCESS)
1287+
return data;
1288+
systemPrintf("GPIO expander read failure!\r\n");
1289+
return -1;
1290+
}
1291+
1292+
void gpioExpanderDisplay()
1293+
{
1294+
int data;
1295+
1296+
data = gpioExpanderSwitchesRead();
1297+
if (data < 0)
1298+
return;
1299+
if (productVariant == RTK_POSTCARD)
1300+
{
1301+
systemPrintf("GPIO Expander: 0x%02x", data);
1302+
if (data & 0x80) systemPrintf(", IO7");
1303+
if (data & 0x40) systemPrintf(", IO6");
1304+
if (data & 0x20) systemPrintf(", Card Detect");
1305+
if (data & 0x10) systemPrintf(", Center");
1306+
if (data & 0x08) systemPrintf(", Left");
1307+
if (data & 0x04) systemPrintf(", Right");
1308+
if (data & 0x02) systemPrintf(", Down");
1309+
if (data & 0x01) systemPrintf(", Up");
1310+
systemPrintln();
1311+
}
1312+
else if (productVariant == RTK_FACET_FP)
1313+
{
1314+
// ttyACM0 -> GNSS USB UART
1315+
//
1316+
// GNSS UART 1 -> SW5 (1) -> ttyACM1
1317+
// '->(0) -> ESP32 UART 1
1318+
//
1319+
// .->(1) -> GNSS UART 4
1320+
// ESP32 UART 0 -> SW1 (1) -> SW2 (0) -> RS232
1321+
// '->(0) ------------> ttyACM2
1322+
//
1323+
1324+
systemPrintf("GPIO Expander: 0x%02x\r\n", data);
1325+
systemPrintf(" GNSS UART 1 -> %s\r\n", (data & 0x80) ? "ttyASM1" :"ESP32 UART 1");
1326+
if (data & 0x40) systemPrintf(" LoRa BOOT\r\n");
1327+
systemPrintf(" GNSS: %s\r\n", (data & 0x20) ? "Run" : "Reset");
1328+
systemPrintf(" LoRa: %s\r\n", (data & 0x10) ? "Enable" : "Disable");
1329+
systemPrintf(" GNSS UART 2 -> %s\r\n", (data & 0x08) ? "LoRa UART 0" : "JST TTL Serial");
1330+
systemPrintf(" ESP32 UART 2 -> %s\r\n", (data & 0x04) ? "LoRa UART 2" : "GNSS UART 3");
1331+
switch (data & 3)
1332+
{
1333+
case 2:
1334+
case 0: systemPrintf(" ESP32 UART 0 -> ttyASM2\r\n"); break;
1335+
case 1: systemPrintf(" ESP32 UART 0 -> Serial Connector\r\n"); break;
1336+
case 3: systemPrintf(" ESP32 UART 0 -> GNSS UART 4\r\n"); break;
1337+
}
1338+
}
1339+
}

0 commit comments

Comments
 (0)