@@ -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,19 @@ 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
+ feature = "_core-cm7" ,
44
+ not( feature = "_core-cm4" )
45
+ ) ) ]
41
46
const fn current ( ) -> CoreId {
42
47
CoreId :: Core0
43
48
}
44
49
45
- #[ cfg( feature = "_core-cm4" ) ]
50
+ #[ cfg( any(
51
+ all( not( stm32wl) , feature = "_core-cm4" ) ,
52
+ all( stm32wl, feature = "_core-cm0p" )
53
+ ) ) ]
46
54
const fn current ( ) -> CoreId {
47
55
CoreId :: Core1
48
56
}
@@ -86,7 +94,10 @@ impl<'d> HardwareSemaphore<'d> {
86
94
reg. procid ( ) == process_id,
87
95
) {
88
96
( true , true , true ) => Ok ( ( ) ) ,
89
- _ => Err ( HsemLockFailed ) ,
97
+ v => {
98
+ error ! ( "{}: {}" , v, CoreId :: current( ) as u8 ) ;
99
+ Err ( HsemLockFailed )
100
+ }
90
101
}
91
102
}
92
103
@@ -97,9 +108,12 @@ impl<'d> HardwareSemaphore<'d> {
97
108
pub fn one_step_lock ( & mut self , sem_id : u8 ) -> Result < ( ) , HsemLockFailed > {
98
109
let reg = HSEM . rlr ( sem_id as usize ) . read ( ) ;
99
110
100
- match ( reg. lock ( ) , reg. coreid ( ) == CoreId :: current ( ) as u8 , reg. procid ( ) ) {
111
+ match ( reg. lock ( ) , reg. coreid ( ) == CoreId :: current ( ) as u8 , reg. procid ( ) ) {
101
112
( _, true , 0 ) => Ok ( ( ) ) ,
102
- _ => Err ( HsemLockFailed ) ,
113
+ v => {
114
+ error ! ( "{}: Current: {} Actual: {}" , v, CoreId :: current( ) as u8 , reg. coreid( ) ) ;
115
+ Err ( HsemLockFailed )
116
+ }
103
117
}
104
118
}
105
119
0 commit comments