Skip to content

Commit 7103ce8

Browse files
authored
feat(perimgr): add function to retrieve detaching CB
1 parent 6d93baa commit 7103ce8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cores/esp32/esp32-hal-periman.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ typedef struct ATTR_PACKED {
1616
int8_t bus_channel;
1717
} peripheral_pin_item_t;
1818

19-
static peripheral_bus_deinit_cb_t deinit_functions[ESP32_BUS_TYPE_MAX];
19+
static peripheral_bus_deinit_cb_t deinit_functions[ESP32_BUS_TYPE_MAX] = { NULL };
2020
static peripheral_pin_item_t pins[SOC_GPIO_PIN_COUNT];
2121

2222
#define GPIO_NOT_VALID(p) ((p >= SOC_GPIO_PIN_COUNT) || ((SOC_GPIO_VALID_GPIO_MASK & (1ULL << p)) == 0))
@@ -236,6 +236,14 @@ bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t
236236
return true;
237237
}
238238

239+
peripheral_bus_deinit_cb_t perimanSetBusDeinit(peripheral_bus_type_t type) {
240+
if (type >= ESP32_BUS_TYPE_MAX || type == ESP32_BUS_TYPE_INIT) {
241+
log_e("Invalid type: %s (%u)", perimanGetTypeName(type), (unsigned int)type);
242+
return NULL;
243+
}
244+
return deinit_functions[type];
245+
}
246+
239247
bool perimanPinIsValid(uint8_t pin) {
240248
return !(GPIO_NOT_VALID(pin));
241249
}

0 commit comments

Comments
 (0)