File tree Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,7 @@ version = "0.3.1"
12
12
[dependencies ]
13
13
aligned = " 0.1.1"
14
14
bare-metal = " 0.1.0"
15
- volatile-register = " 0.2.0"
15
+ volatile-register = " 0.2.0"
16
+
17
+ [features ]
18
+ cm7-r0p1 = []
Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ set -euxo pipefail
2
2
3
3
main () {
4
4
case $TARGET in
5
+ thumbv7em-none-eabi* )
6
+ xargo check --target $TARGET --features cm7-r0p1
7
+ xargo check --target $TARGET
8
+ ;;
5
9
thumbv* -none-eabi* )
6
10
xargo check --target $TARGET
7
11
;;
Original file line number Diff line number Diff line change @@ -18,11 +18,22 @@ pub fn read() -> u8 {
18
18
}
19
19
20
20
/// Writes to the CPU register
21
+ ///
22
+ /// **IMPORTANT** If you are using a Cortex-M7 device with revision r0p1 you MUST enable the
23
+ /// `cm7-r0p1` Cargo feature or this function WILL misbehave.
24
+ #[ cfg_attr( not( target_arch = "arm" ) , allow( unused_variables) ) ]
21
25
#[ inline]
22
- pub unsafe fn write ( _basepri : u8 ) {
26
+ pub unsafe fn write ( basepri : u8 ) {
23
27
match ( ) {
24
28
#[ cfg( target_arch = "arm" ) ]
25
- ( ) => asm ! ( "msr BASEPRI, $0" :: "r" ( _basepri) : "memory" : "volatile" ) ,
29
+ ( ) => match ( ) {
30
+ #[ cfg( not( feature = "cm7-r0p1" ) ) ]
31
+ ( ) => asm ! ( "msr BASEPRI, $0" :: "r" ( basepri) : "memory" : "volatile" ) ,
32
+ #[ cfg( feature = "cm7-r0p1" ) ]
33
+ ( ) => asm ! ( "cpsid i
34
+ msr BASEPRI, $0
35
+ cpsie i" :: "r" ( basepri) : "memory" : "volatile" ) ,
36
+ } ,
26
37
#[ cfg( not( target_arch = "arm" ) ) ]
27
38
( ) => unimplemented ! ( ) ,
28
39
}
Original file line number Diff line number Diff line change 4
4
///
5
5
/// - `basepri != 0` AND `basepri::read() == 0`, OR
6
6
/// - `basepri != 0` AND `basepri < basepri::read()`
7
+ ///
8
+ /// **IMPORTANT** If you are using a Cortex-M7 device with revision r0p1 you MUST enable the
9
+ /// `cm7-r0p1` Cargo feature or this function WILL misbehave.
10
+ #[ cfg_attr( not( target_arch = "arm" ) , allow( unused_variables) ) ]
7
11
#[ inline]
8
- pub fn write ( _basepri : u8 ) {
12
+ pub fn write ( basepri : u8 ) {
9
13
match ( ) {
10
14
#[ cfg( target_arch = "arm" ) ]
11
15
( ) => unsafe {
12
- asm ! ( "msr BASEPRI_MAX, $0" :: "r" ( _basepri) : "memory" : "volatile" ) ;
16
+ match ( ) {
17
+ #[ cfg( not( feature = "cm7-r0p1" ) ) ]
18
+ ( ) => asm ! ( "msr BASEPRI_MAX, $0" :: "r" ( basepri) : "memory" : "volatile" ) ,
19
+ #[ cfg( feature = "cm7-r0p1" ) ]
20
+ ( ) => asm ! ( "cpsid i
21
+ msr BASEPRI_MAX, $0
22
+ cpsie i" :: "r" ( basepri) : "memory" : "volatile" ) ,
23
+ }
13
24
} ,
14
25
#[ cfg( not( target_arch = "arm" ) ) ]
15
26
( ) => unimplemented ! ( ) ,
You can’t perform that action at this time.
0 commit comments