Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a1dd0bb

Browse files
authoredMar 16, 2023
Fixes Deinit functions
1 parent ccedb0b commit a1dd0bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎cores/esp32/esp32-hal-periman.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){
2929
log_e("Invalid type: %u", (unsigned int)type);
3030
return false;
3131
}
32-
if(type > ESP32_BUS_TYPE_GPIO && bus == NULL){
32+
if(type >= ESP32_BUS_TYPE_GPIO && bus == NULL){
3333
log_e("Bus is NULL");
3434
return false;
3535
}
@@ -39,7 +39,7 @@ bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){
3939
log_i("Bus already set");
4040
return true;
4141
}
42-
if(obus != NULL){
42+
if(obus != NULL && type > ESP32_BUS_TYPE_INIT){
4343
if(deinit_functions[otype] == NULL){
4444
log_e("Bus does not have deinit function set");
4545
return false;

1 commit comments

Comments
 (1)

SuGlider commented on Mar 16, 2023

@SuGlider
CollaboratorAuthor

Fix in Line 32: Adds GPIO Peripheral as the one that must have a valid bus pointer.
Fix in Line 42: When a deinit() function of a peripheral calls perimanSetPinBus(pin, ESP32_BUS_TYPE_INIT, NULL); to free the pin in the Peripheral Manager table, it will end up calling it self again in an infinite loop.

Please sign in to comment.