Skip to content

Commit b69f375

Browse files
committed
Add USB Type and valid pin check to periman
1 parent cbe9eaf commit b69f375

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: cores/esp32/esp32-hal-periman.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,6 @@ bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t
9696
return true;
9797
}
9898

99-
99+
bool perimanPinIsValid(uint8_t pin){
100+
return !(GPIO_NOT_VALID(pin));
101+
}

Diff for: cores/esp32/esp32-hal-periman.h

+6
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ typedef enum {
5454
#endif
5555
#if SOC_TOUCH_SENSOR_SUPPORTED
5656
ESP32_BUS_TYPE_TOUCH, // IO is used as TOUCH pin
57+
#endif
58+
#if SOC_USB_SERIAL_JTAG_SUPPORTED || SOC_USB_OTG_SUPPORTED
59+
ESP32_BUS_TYPE_USB, // IO is used as USB pin
5760
#endif
5861
ESP32_BUS_TYPE_MAX
5962
} peripheral_bus_type_t;
@@ -72,6 +75,9 @@ peripheral_bus_type_t perimanGetPinBusType(uint8_t pin);
7275
// Sets the peripheral destructor callback. Used to destroy bus when pin is assigned another function
7376
bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t cb);
7477

78+
// Check if given pin is a valid GPIO number
79+
bool perimanPinIsValid(uint8_t pin);
80+
7581
#ifdef __cplusplus
7682
}
7783
#endif

0 commit comments

Comments
 (0)