@@ -32,6 +32,7 @@ pub trait FlashAlgorithm: Sized + 'static {
32
32
fn new ( address : u32 , clock : u32 , function : Function ) -> Result < Self , ErrorCode > ;
33
33
34
34
/// Erase entire chip. Will only be called after [`FlashAlgorithm::new()`] with [`Function::Erase`].
35
+ #[ cfg( feature = "erase-chip" ) ]
35
36
fn erase_all ( & mut self ) -> Result < ( ) , ErrorCode > ;
36
37
37
38
/// Erase sector. Will only be called after [`FlashAlgorithm::new()`] with [`Function::Erase`].
@@ -110,18 +111,6 @@ macro_rules! algorithm {
110
111
}
111
112
#[ no_mangle]
112
113
#[ link_section = ".entry" ]
113
- pub unsafe extern "C" fn EraseChip ( ) -> u32 {
114
- if !_IS_INIT {
115
- return 1 ;
116
- }
117
- let this = & mut * _ALGO_INSTANCE. as_mut_ptr( ) ;
118
- match <$type as FlashAlgorithm >:: erase_all( this) {
119
- Ok ( ( ) ) => 0 ,
120
- Err ( e) => e. get( ) ,
121
- }
122
- }
123
- #[ no_mangle]
124
- #[ link_section = ".entry" ]
125
114
pub unsafe extern "C" fn EraseSector ( addr: u32 ) -> u32 {
126
115
if !_IS_INIT {
127
116
return 1 ;
@@ -145,6 +134,7 @@ macro_rules! algorithm {
145
134
Err ( e) => e. get( ) ,
146
135
}
147
136
}
137
+ $crate:: erase_chip!( $type) ;
148
138
149
139
#[ allow( non_upper_case_globals) ]
150
140
#[ no_mangle]
@@ -210,6 +200,32 @@ macro_rules! algorithm {
210
200
} ;
211
201
}
212
202
203
+ #[ doc( hidden) ]
204
+ #[ macro_export]
205
+ #[ cfg( not( feature = "erase-chip" ) ) ]
206
+ macro_rules! erase_chip {
207
+ ( $type: ty) => { }
208
+ }
209
+ #[ doc( hidden) ]
210
+ #[ macro_export]
211
+ #[ cfg( feature = "erase-chip" ) ]
212
+ macro_rules! erase_chip {
213
+ ( $type: ty) => {
214
+ #[ no_mangle]
215
+ #[ link_section = ".entry" ]
216
+ pub unsafe extern "C" fn EraseChip ( ) -> u32 {
217
+ if !_IS_INIT {
218
+ return 1 ;
219
+ }
220
+ let this = & mut * _ALGO_INSTANCE. as_mut_ptr( ) ;
221
+ match <$type as FlashAlgorithm >:: erase_all( this) {
222
+ Ok ( ( ) ) => 0 ,
223
+ Err ( e) => e. get( ) ,
224
+ }
225
+ }
226
+ }
227
+ }
228
+
213
229
#[ doc( hidden) ]
214
230
#[ macro_export]
215
231
macro_rules! count {
0 commit comments