@@ -11,6 +11,7 @@ pub struct HsemLockFailed;
11
11
///
12
12
/// On some chips, the Reference Manual calls this value MASTERID instead of COREID.
13
13
#[ repr( u8 ) ]
14
+ #[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
14
15
pub enum CoreId {
15
16
#[ cfg( any( stm32h7a3, stm32h7b3, stm32h7b0) ) ]
16
17
/// Cortex-M7, core 1. MASTERID = 1
@@ -37,12 +38,15 @@ pub enum CoreId {
37
38
}
38
39
39
40
impl CoreId {
40
- #[ cfg( any( feature = "_core-cm7" , not( feature = "_core-cm4" ) ) ) ]
41
+ #[ cfg( any(
42
+ all( stm32wl, feature = "_core-cm4" ) ,
43
+ all( not( stm32wl) , any( feature = "_core-cm7" , not( feature = "_core-cm4" ) ) ) ,
44
+ ) ) ]
41
45
const fn current ( ) -> CoreId {
42
46
CoreId :: Core0
43
47
}
44
48
45
- #[ cfg( feature = "_core-cm4" ) ]
49
+ #[ cfg( any ( all ( not ( stm32wl ) , feature = "_core-cm4" ) , all ( stm32wl , feature = "_core-cm0p" ) ) ) ]
46
50
const fn current ( ) -> CoreId {
47
51
CoreId :: Core1
48
52
}
@@ -86,7 +90,10 @@ impl<'d> HardwareSemaphore<'d> {
86
90
reg. procid ( ) == process_id,
87
91
) {
88
92
( true , true , true ) => Ok ( ( ) ) ,
89
- _ => Err ( HsemLockFailed ) ,
93
+ v => {
94
+ error ! ( "{}: {}" , v, CoreId :: current( ) as u8 ) ;
95
+ Err ( HsemLockFailed )
96
+ }
90
97
}
91
98
}
92
99
@@ -99,7 +106,10 @@ impl<'d> HardwareSemaphore<'d> {
99
106
100
107
match ( reg. lock ( ) , reg. coreid ( ) == CoreId :: current ( ) as u8 , reg. procid ( ) ) {
101
108
( _, true , 0 ) => Ok ( ( ) ) ,
102
- _ => Err ( HsemLockFailed ) ,
109
+ v => {
110
+ error ! ( "{}: Current: {} Actual: {}" , v, CoreId :: current( ) as u8 , reg. coreid( ) ) ;
111
+ Err ( HsemLockFailed )
112
+ }
103
113
}
104
114
}
105
115
0 commit comments