File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ pub(crate) unsafe fn blocking_write(start_address: u32, buf: &[u8; WRITE_SIZE])
51
51
wait_ready_blocking ( )
52
52
}
53
53
54
+ /// Fix for incorrect register field width in STM32G4 category metadata
55
+ #[ cfg( flash_g4c4) ]
56
+ #[ inline( always) ]
57
+ pub fn set_pnb_c4 ( cr : & mut stm32_metapac:: flash:: regs:: Cr , val : u8 ) {
58
+ cr. 0 = ( cr. 0 & !( 0xff << 3usize ) ) | ( ( ( val as u32 ) & 0xff ) << 3usize ) ;
59
+ }
60
+
54
61
pub ( crate ) unsafe fn blocking_erase_sector ( sector : & FlashSector ) -> Result < ( ) , Error > {
55
62
let idx = ( sector. start - super :: FLASH_BASE as u32 ) / super :: BANK1_REGION . erase_size as u32 ;
56
63
wait_busy ( ) ;
@@ -63,7 +70,10 @@ pub(crate) unsafe fn blocking_erase_sector(sector: &FlashSector) -> Result<(), E
63
70
w. set_bker ( sector. bank == crate :: flash:: FlashBank :: Bank2 ) ;
64
71
#[ cfg( flash_g0x0) ]
65
72
w. set_pnb ( idx as u16 ) ;
66
- #[ cfg( not( flash_g0x0) ) ]
73
+ #[ cfg( flash_g4c4) ]
74
+ set_pnb_c4 ( w, idx as u8 ) ;
75
+ // otherwise
76
+ #[ cfg( not( any( flash_g0x0, flash_g4c4) ) ) ]
67
77
w. set_pnb ( idx as u8 ) ;
68
78
w. set_strt ( true ) ;
69
79
} ) ;
You can’t perform that action at this time.
0 commit comments