-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Enforces more consistency into Peripheral Manager #8188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,10 +33,16 @@ bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){ | |
log_e("Bus is NULL"); | ||
return false; | ||
} | ||
if (type == ESP32_BUS_TYPE_INIT && bus != NULL){ | ||
log_e("Can't set a Bus to INIT Type"); | ||
return false; | ||
} | ||
otype = pins[pin].type; | ||
obus = pins[pin].bus; | ||
if(type == otype && bus == obus){ | ||
log_i("Bus already set"); | ||
if (type != ESP32_BUS_TYPE_INIT) { | ||
log_i("Bus already set"); | ||
} | ||
return true; | ||
} | ||
if(obus != NULL){ | ||
|
@@ -59,7 +65,7 @@ void * perimanGetPinBus(uint8_t pin, peripheral_bus_type_t type){ | |
log_e("Invalid pin: %u", pin); | ||
return NULL; | ||
} | ||
if(type >= ESP32_BUS_TYPE_MAX){ | ||
if(type >= ESP32_BUS_TYPE_MAX || type == ESP32_BUS_TYPE_INIT){ | ||
log_e("Invalid type: %u", (unsigned int)type); | ||
return NULL; | ||
} | ||
|
@@ -78,7 +84,7 @@ peripheral_bus_type_t perimanGetPinBusType(uint8_t pin){ | |
} | ||
|
||
bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t cb){ | ||
if(type >= ESP32_BUS_TYPE_MAX){ | ||
if(type >= ESP32_BUS_TYPE_MAX || type == ESP32_BUS_TYPE_INIT){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here as previous comment from @me-no-dev, we will never call perimanSetBusDeinit with INIT type. This check is not that necessary :) but of course is not breaking anything and can be there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the code clear about it. As commented below.
|
||
log_e("Invalid type: %u", (unsigned int)type); | ||
return false; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not an invalid call per say. It will always return NULL. No need to print an error really and remember that peripheral manager is internal API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the code clear about it. As commented below.