@@ -26,37 +26,38 @@ bool perimanSetPinBus(uint8_t pin, peripheral_bus_type_t type, void * bus){
26
26
return false;
27
27
}
28
28
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 );
30
30
return false;
31
31
}
32
32
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 );
34
34
return false;
35
35
}
36
36
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 );
38
38
return false;
39
- }
39
+ }
40
40
otype = pins [pin ].type ;
41
41
obus = pins [pin ].bus ;
42
42
if (type == otype && bus == obus ){
43
43
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 );
45
45
}
46
46
return true;
47
47
}
48
48
if (obus != NULL ){
49
49
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 );
51
51
return false;
52
52
}
53
53
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 );
55
55
return false;
56
56
}
57
57
}
58
58
pins [pin ].type = type ;
59
59
pins [pin ].bus = bus ;
60
+ log_v ("Pin %u successfully set to type %u with bus %p" , pin , (unsigned int )type , bus );
60
61
return true;
61
62
}
62
63
@@ -66,7 +67,7 @@ void * perimanGetPinBus(uint8_t pin, peripheral_bus_type_t type){
66
67
return NULL ;
67
68
}
68
69
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 );
70
71
return NULL ;
71
72
}
72
73
if (pins [pin ].type == type ){
@@ -89,10 +90,11 @@ bool perimanSetBusDeinit(peripheral_bus_type_t type, peripheral_bus_deinit_cb_t
89
90
return false;
90
91
}
91
92
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 );
93
94
return false;
94
95
}
95
96
deinit_functions [type ] = cb ;
97
+ log_v ("Deinit function for type %u successfully set to %p" , (unsigned int )type , cb );
96
98
return true;
97
99
}
98
100
0 commit comments