@@ -26,37 +26,38 @@ bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){
2626 return false;
2727 }
2828 if (type >= ESP32_BUS_TYPE_MAX ){
29- log_e ("Invalid type: %u" , (unsigned int )type );
29+ log_e ("Invalid type: %u when setting pin %u " , (unsigned int )type , pin );
3030 return false;
3131 }
3232 if (type > ESP32_BUS_TYPE_GPIO && bus == NULL ){
33- log_e ("Bus is NULL" );
33+ log_e ("Bus is NULL for pin %u with type %u" , pin , ( unsigned int ) type );
3434 return false;
3535 }
3636 if (type == ESP32_BUS_TYPE_INIT && bus != NULL ){
37- log_e ("Can't set a Bus to INIT Type" );
37+ log_e ("Can't set a Bus to INIT Type (pin %u)" , pin );
3838 return false;
39- }
39+ }
4040 otype = pins [pin ].type ;
4141 obus = pins [pin ].bus ;
4242 if (type == otype && bus == obus ){
4343 if (type != ESP32_BUS_TYPE_INIT ) {
44- log_i ("Bus already set" );
44+ log_i ("Pin %u already has type %u with bus %p" , pin , ( unsigned int ) type , bus );
4545 }
4646 return true;
4747 }
4848 if (obus != NULL ){
4949 if (deinit_functions [otype ] == NULL ){
50- log_e ("Bus does not have deinit function set" );
50+ log_e ("No deinit function for type %u (pin %u)" , ( unsigned int ) otype , pin );
5151 return false;
5252 }
5353 if (!deinit_functions [otype ](obus )){
54- log_e ("Previous bus failed to deinit" );
54+ log_e ("Deinit function for previous bus type %u failed (pin %u)" , ( unsigned int ) otype , pin );
5555 return false;
5656 }
5757 }
5858 pins [pin ].type = type ;
5959 pins [pin ].bus = bus ;
60+ log_v ("Pin %u successfully set to type %u with bus %p" , pin , (unsigned int )type , bus );
6061 return true;
6162}
6263
@@ -66,7 +67,7 @@ void * perimanGetPinBus(uint8_t pin, peripheral_bus_type_t type){
6667 return NULL ;
6768 }
6869 if (type >= ESP32_BUS_TYPE_MAX || type == ESP32_BUS_TYPE_INIT ){
69- log_e ("Invalid type: %u " , (unsigned int )type );
70+ log_e ("Invalid type (%u) for pin %u " , (unsigned int )type , pin );
7071 return NULL ;
7172 }
7273 if (pins [pin ].type == type ){
@@ -89,10 +90,11 @@ bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t
8990 return false;
9091 }
9192 if (cb == NULL ){
92- log_e ("Callback is NULL" );
93+ log_e ("Callback is NULL when setting deinit function for type %u" , ( unsigned int ) type );
9394 return false;
9495 }
9596 deinit_functions [type ] = cb ;
97+ log_v ("Deinit function for type %u successfully set to %p" , (unsigned int )type , cb );
9698 return true;
9799}
98100
0 commit comments