From d853267112101ed0c4a73ce19a126de7d134725b Mon Sep 17 00:00:00 2001 From: cclngit <38783129+cclngit@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:18:16 +0200 Subject: [PATCH] ---------- --- Firmware/MTR_Charger_X5S/.DS_Store | Bin 6148 -> 6148 bytes Firmware/MTR_Charger_X5S/lib/MTR_STUSB4500 | 1 - Firmware/MTR_Charger_X5S/platformio.ini | 3 ++ Firmware/MTR_Charger_X5S/src/main.cpp | 47 ++++++++++++++++----- 4 files changed, 40 insertions(+), 11 deletions(-) delete mode 160000 Firmware/MTR_Charger_X5S/lib/MTR_STUSB4500 diff --git a/Firmware/MTR_Charger_X5S/.DS_Store b/Firmware/MTR_Charger_X5S/.DS_Store index d1687f16d6aa7f95355bf949439f11c9759c12f9..221f1f90a964882f55527fc1fc391541d9acbb54 100644 GIT binary patch delta 37 tcmZoMXfc@J&&WJ6U^gT4WFE#FoGHc0IZ65XIgFccF-oy*X6N|J4*=$%3_Jh; delta 32 ocmZoMXfc@J&&V_}VE1GL5thmPj8`{*XB1$Y*dV-_o#QV*0JKmF?EnA( diff --git a/Firmware/MTR_Charger_X5S/lib/MTR_STUSB4500 b/Firmware/MTR_Charger_X5S/lib/MTR_STUSB4500 deleted file mode 160000 index c1c55be..0000000 --- a/Firmware/MTR_Charger_X5S/lib/MTR_STUSB4500 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c1c55be1ff57884c6cf6477a289f7a3ee15a267f diff --git a/Firmware/MTR_Charger_X5S/platformio.ini b/Firmware/MTR_Charger_X5S/platformio.ini index 824ceec..2eb9657 100644 --- a/Firmware/MTR_Charger_X5S/platformio.ini +++ b/Firmware/MTR_Charger_X5S/platformio.ini @@ -12,3 +12,6 @@ platform = raspberrypi board = pico framework = arduino + +lib_deps = + https://github.com/MoreThanRobotsFR/MTR_STUSB4500#main diff --git a/Firmware/MTR_Charger_X5S/src/main.cpp b/Firmware/MTR_Charger_X5S/src/main.cpp index cb9fbba..8390c3c 100644 --- a/Firmware/MTR_Charger_X5S/src/main.cpp +++ b/Firmware/MTR_Charger_X5S/src/main.cpp @@ -1,18 +1,45 @@ -#include +#include +#include -// put function declarations here: -int myFunction(int, int); +// Create an instance of the STUSB4500 class +MTR_STUSB4500 stusb4500; void setup() { - // put your setup code here, to run once: - int result = myFunction(2, 3); + // Initialize the STUSB4500 device + stusb4500.init(); + + // Set the number of sink PDOs to 1 + stusb4500.setPdoNumber(1); + + // Set the voltage value for SNK_PDO1 to 5V + // can't be set, because is hardcoded to 5V + + // Set the current value for SNK_PDO1 to 1A + stusb4500.setISinkPdo1(1000); + } void loop() { - // put your main code here, to run repeatedly: -} + // Get the alert status from the STUSB4500 + uint8_t alertStatus; + if (stusb4500.getAlertStatus(alertStatus)) { + Serial.print("Alert status: 0x"); + Serial.println(alertStatus, HEX); + } + + // Get the port status from the STUSB4500 + uint8_t portStatus; + if (stusb4500.getPortStatus(portStatus)) { + Serial.print("Port status: 0x"); + Serial.println(portStatus, HEX); + } + + // Get the device ID from the STUSB4500 + uint8_t deviceID; + if (stusb4500.getDeviceID(deviceID)) { + Serial.print("Device ID: 0x"); + Serial.println(deviceID, HEX); + } -// put function definitions here: -int myFunction(int x, int y) { - return x + y; + delay(1000); // Wait for 1 second } \ No newline at end of file