generated from MoreThanRobotsFR/MoreThanRobots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
40 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
Submodule MTR_STUSB4500
deleted from
c1c55b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,45 @@ | ||
#include <Arduino.h> | ||
#include <Wire.h> | ||
#include <MTR_STUSB4500.h> | ||
|
||
// 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 | ||
} |