Change SBC to Jetson Orin
This commit is contained in:
@@ -32,7 +32,7 @@ public class GPIO {
|
||||
* @param pin GPIO pin number
|
||||
* @return true if the pin is already exported
|
||||
*/
|
||||
public static boolean GpioPinExists(@NotNull RaspberryPi5BPins pin){
|
||||
public static boolean GpioPinExists(@NotNull JetsonOrinPins pin){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber);
|
||||
return pinPath.toFile().isDirectory();
|
||||
}
|
||||
@@ -42,7 +42,7 @@ public class GPIO {
|
||||
* @param pin GPIO pin number
|
||||
* @return true if the pin is successfully exported
|
||||
*/
|
||||
public static boolean ExportPin(@NotNull RaspberryPi5BPins pin){
|
||||
public static boolean ExportPin(@NotNull JetsonOrinPins pin){
|
||||
try{
|
||||
if (Files.isWritable(gpioExportPath)){
|
||||
Files.write(gpioExportPath, String.valueOf(pin.gpionumber).getBytes());
|
||||
@@ -55,12 +55,13 @@ public class GPIO {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unexport the pin
|
||||
* @param pin GPIO pin number
|
||||
* @return true if the pin is successfully unexported
|
||||
*/
|
||||
public static boolean UnexportPin(@NotNull RaspberryPi5BPins pin){
|
||||
public static boolean UnexportPin(@NotNull JetsonOrinPins pin){
|
||||
if (Files.isWritable(gpioUnexportPath)){
|
||||
try{
|
||||
Files.write(gpioUnexportPath, String.valueOf(pin.gpionumber).getBytes());
|
||||
@@ -80,7 +81,7 @@ public class GPIO {
|
||||
* @return "in" if the pin is input, "out" if the pin is output, "unknown" if the direction is unknown
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static String GetPinDirection(@NotNull RaspberryPi5BPins pin){
|
||||
public static String GetPinDirection(@NotNull JetsonOrinPins pin){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("direction");
|
||||
if (pinPath.toFile().isFile()){
|
||||
if (Files.isReadable(pinPath)){
|
||||
@@ -100,7 +101,7 @@ public class GPIO {
|
||||
* @param direction "in" for input, "out" for output
|
||||
* @return true if the direction is successfully set
|
||||
*/
|
||||
public static boolean SetPinDirection(@NotNull RaspberryPi5BPins pin, String direction){
|
||||
public static boolean SetPinDirection(@NotNull JetsonOrinPins pin, String direction){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("direction");
|
||||
if (pinPath.toFile().isFile()){
|
||||
if (Files.isWritable(pinPath)){
|
||||
@@ -126,7 +127,7 @@ public class GPIO {
|
||||
* @return true if the value is successfully set
|
||||
*/
|
||||
@SuppressWarnings("UnusedReturnValue")
|
||||
public static boolean SetValue(@NotNull RaspberryPi5BPins pin, boolean isON){
|
||||
public static boolean SetValue(@NotNull JetsonOrinPins pin, boolean isON){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("value");
|
||||
if (pinPath.toFile().isFile()){
|
||||
if (Files.isWritable(pinPath)){
|
||||
@@ -148,7 +149,7 @@ public class GPIO {
|
||||
* @return "1" if the pin value is 1, "0" if the pin value is 0, "unknown" if the value is unknown
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public static String GetValue(@NotNull RaspberryPi5BPins pin){
|
||||
public static String GetValue(@NotNull JetsonOrinPins pin){
|
||||
Path pinPath = gpioPath.resolve("gpio"+pin.gpionumber).resolve("value");
|
||||
if (pinPath.toFile().isFile()){
|
||||
if (Files.isReadable(pinPath)){
|
||||
|
||||
38
src/main/java/SBC/JetsonOrinPins.java
Normal file
38
src/main/java/SBC/JetsonOrinPins.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package SBC;
|
||||
|
||||
/**
|
||||
* Source : <a href="https://jetsonhacks.com/nvidia-jetson-agx-orin-gpio-header-pinout/">...</a>
|
||||
*/
|
||||
public enum JetsonOrinPins {
|
||||
Pin07(7,"MCLK05",106),
|
||||
Pin11(11,"UART1_RTS",112),
|
||||
Pin12(12,"I2S2_CLK",50),
|
||||
Pin13(13,"GPIO32",108),
|
||||
Pin15(15,"GPIO27",85),
|
||||
Pin16(16,"GPIO8",9),
|
||||
Pin18(18,"GPIO35",43),
|
||||
Pin19(19,"SPI1_MOSI",135),
|
||||
Pin21(21,"SPI1_MISO",134),
|
||||
Pin22(22,"GPIO17",96),
|
||||
Pin23(23,"SPI1_SCK",133),
|
||||
Pin24(24,"SPI1_CS0",136),
|
||||
Pin25(25,"SPI1_CS1",137),
|
||||
Pin29(29,"CAN0_RX",1),
|
||||
Pin31(31,"CAN0_TX",0),
|
||||
Pin32(32,"GPIO9",8),
|
||||
Pin33(33,"CAN1_TX",2),
|
||||
Pin35(35,"I2S_FS",53),
|
||||
Pin36(36,"UART1_CTS",113),
|
||||
Pin37(37,"CAN1_RX",3),
|
||||
Pin38(38,"I2S_SDIN",52),
|
||||
Pin40(40,"I2S_SDOUT",51);
|
||||
public final int pin;
|
||||
public final String name;
|
||||
public final int gpionumber;
|
||||
|
||||
JetsonOrinPins(int pin, String name, int gpionumber){
|
||||
this.pin = pin;
|
||||
this.name = name;
|
||||
this.gpionumber = gpionumber;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package SBC;
|
||||
|
||||
public enum RaspberryPi5BPins {
|
||||
Pin03(3,"GPIO2/SDA", 573),
|
||||
Pin05(5,"GPIO3/SCL", 574),
|
||||
Pin07(7,"GPIO4/GPCLK0", 575),
|
||||
Pin08(8,"GPIO14/TXD", 585),
|
||||
Pin10(10,"GPIO15/RXD", 586),
|
||||
Pin11(11,"GPIO17", 588),
|
||||
Pin12(12,"GPIO18/PCMCLK", 589),
|
||||
Pin13(13,"GPIO27", 598),
|
||||
Pin15(15,"GPIO22", 593),
|
||||
Pin16(16,"GPIO23", 594),
|
||||
Pin18(18,"GPIO24", 595),
|
||||
Pin19(19,"GPIO10/MOSI", 581),
|
||||
Pin21(21,"GPIO9/MISO", 580),
|
||||
Pin22(22,"GPIO25", 596),
|
||||
Pin23(23,"GPIO11/SCLK", 582),
|
||||
Pin24(24,"GPIO8/CE0", 579),
|
||||
Pin26(26,"GPIO7/CE1", 578),
|
||||
Pin27(27,"GPIO0/IDSD", 587),
|
||||
Pin28(28,"GPIO1/IDSC", 587),
|
||||
Pin29(29,"GPIO5", 576),
|
||||
Pin31(31,"GPIO6", 577),
|
||||
Pin32(32,"GPIO12/PWM0", 583),
|
||||
Pin33(33,"GPIO13/PWM1", 584),
|
||||
Pin35(35,"GPIO19/PCMFS", 590),
|
||||
Pin36(36,"GPIO16", 587),
|
||||
Pin37(37,"GPIO26", 597),
|
||||
Pin38(38,"GPIO20/PCMDIN", 591),
|
||||
Pin40(40,"GPIO21/PCMDOUT", 592);
|
||||
|
||||
public final int pin;
|
||||
public final String name;
|
||||
public final int gpionumber;
|
||||
|
||||
RaspberryPi5BPins(int pin, String name, int gpionumber){
|
||||
this.pin = pin;
|
||||
this.name = name;
|
||||
this.gpionumber = gpionumber;
|
||||
}
|
||||
}
|
||||
@@ -37,11 +37,11 @@ public class Main {
|
||||
private static NetworkTransmitReceiveInfo[] previousNetworkInfo;
|
||||
private static final Map<String, String> networkTX = new HashMap<>();
|
||||
private static final Map<String, String> networkRX = new HashMap<>();
|
||||
private static RaspberryPi5BPins AmplifierPower = null;
|
||||
private static RaspberryPi5BPins LedWeb = null;
|
||||
private static RaspberryPi5BPins LedIpCamera = null;
|
||||
private static RaspberryPi5BPins LedPanTilt = null;
|
||||
private static RaspberryPi5BPins Max485Direction = null;
|
||||
private static JetsonOrinPins AmplifierPower = null;
|
||||
private static JetsonOrinPins LedWeb = null;
|
||||
private static JetsonOrinPins LedIpCamera = null;
|
||||
private static JetsonOrinPins LedPanTilt = null;
|
||||
private static JetsonOrinPins Max485Direction = null;
|
||||
|
||||
private static ExecutorService gpioExecutor = null;
|
||||
|
||||
@@ -89,17 +89,17 @@ public class Main {
|
||||
private static void init_gpio(){
|
||||
if (GPIO.HaveGPIO()){
|
||||
gpioExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
||||
AmplifierPower = InitializePin(RaspberryPi5BPins.Pin13, true);
|
||||
LedWeb = InitializePin(RaspberryPi5BPins.Pin15, true);
|
||||
LedIpCamera = InitializePin(RaspberryPi5BPins.Pin19, true);
|
||||
LedPanTilt = InitializePin(RaspberryPi5BPins.Pin21, true);
|
||||
Max485Direction = InitializePin(RaspberryPi5BPins.Pin23, true);
|
||||
AmplifierPower = InitializePin(JetsonOrinPins.Pin13, true);
|
||||
LedWeb = InitializePin(JetsonOrinPins.Pin15, true);
|
||||
LedIpCamera = InitializePin(JetsonOrinPins.Pin19, true);
|
||||
LedPanTilt = InitializePin(JetsonOrinPins.Pin21, true);
|
||||
Max485Direction = InitializePin(JetsonOrinPins.Pin23, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
private static RaspberryPi5BPins InitializePin(RaspberryPi5BPins pin, boolean isOutput){
|
||||
private static JetsonOrinPins InitializePin(JetsonOrinPins pin, boolean isOutput){
|
||||
boolean exported = false;
|
||||
if (GPIO.GpioPinExists(pin)){
|
||||
exported = true;
|
||||
@@ -135,7 +135,7 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private static void Blink(RaspberryPi5BPins pin){
|
||||
private static void Blink(JetsonOrinPins pin){
|
||||
if (pin!=null){
|
||||
if (gpioExecutor!=null){
|
||||
gpioExecutor.submit(()->{
|
||||
|
||||
Reference in New Issue
Block a user