File tree Expand file tree Collapse file tree 9 files changed +84
-18
lines changed Expand file tree Collapse file tree 9 files changed +84
-18
lines changed Original file line number Diff line number Diff line change 2
2
//!
3
3
//! The pulse with modulation (PWM) module enables the generation of pulse width modulated signals on GPIO.
4
4
5
- use core:: cell:: RefCell ;
6
5
use core:: sync:: atomic:: { compiler_fence, Ordering } ;
6
+ use core:: { cell:: RefCell , ops:: Deref } ;
7
7
8
8
#[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
9
9
use crate :: {
@@ -973,7 +973,7 @@ pub enum Error {
973
973
BufferTooLong ,
974
974
}
975
975
976
- pub trait Instance : private :: Sealed { }
976
+ pub trait Instance : Deref < Target = crate :: pac :: pwm0 :: RegisterBlock > + sealed :: Sealed { }
977
977
978
978
impl Instance for PWM0 { }
979
979
@@ -986,8 +986,8 @@ impl Instance for PWM2 {}
986
986
#[ cfg( not( any( feature = "52810" , feature = "52811" , feature = "52832" ) ) ) ]
987
987
impl Instance for PWM3 { }
988
988
989
- mod private {
990
- pub trait Sealed : core :: ops :: Deref < Target = crate :: pac :: pwm0 :: RegisterBlock > { }
989
+ mod sealed {
990
+ pub trait Sealed { }
991
991
992
992
impl Sealed for crate :: pwm:: PWM0 { }
993
993
Original file line number Diff line number Diff line change @@ -219,17 +219,22 @@ pub enum Error {
219
219
}
220
220
221
221
/// Implemented by all RTC instances.
222
- pub trait Instance : Deref < Target = rtc0:: RegisterBlock > {
222
+ pub trait Instance : Deref < Target = rtc0:: RegisterBlock > + sealed :: Sealed {
223
223
/// The interrupt associated with this RTC instance.
224
224
const INTERRUPT : Interrupt ;
225
225
}
226
226
227
+ mod sealed {
228
+ pub trait Sealed { }
229
+ }
230
+
227
231
macro_rules! impl_instance {
228
232
( $( $name: ident, ) * ) => {
229
233
$(
230
234
impl Instance for $name {
231
235
const INTERRUPT : Interrupt = Interrupt :: $name;
232
236
}
237
+ impl sealed:: Sealed for $name { }
233
238
) *
234
239
}
235
240
}
Original file line number Diff line number Diff line change @@ -128,8 +128,14 @@ pub enum Error {
128
128
}
129
129
130
130
/// Trait implemented by all SPI peripheral instances.
131
- pub trait Instance : Deref < Target = spi0:: RegisterBlock > { }
131
+ pub trait Instance : Deref < Target = spi0:: RegisterBlock > + sealed :: Sealed { }
132
132
133
+ mod sealed {
134
+ pub trait Sealed { }
135
+ }
136
+
137
+ impl sealed:: Sealed for SPI0 { }
133
138
impl Instance for SPI0 { }
134
139
140
+ impl sealed:: Sealed for SPI1 { }
135
141
impl Instance for SPI1 { }
Original file line number Diff line number Diff line change @@ -394,8 +394,13 @@ pub enum Error {
394
394
}
395
395
396
396
/// Implemented by all SPIM instances.
397
- pub trait Instance : Deref < Target = spim0:: RegisterBlock > { }
397
+ pub trait Instance : Deref < Target = spim0:: RegisterBlock > + sealed :: Sealed { }
398
398
399
+ mod sealed {
400
+ pub trait Sealed { }
401
+ }
402
+
403
+ impl sealed:: Sealed for SPIM0 { }
399
404
impl Instance for SPIM0 { }
400
405
401
406
#[ cfg( any(
@@ -404,10 +409,22 @@ impl Instance for SPIM0 {}
404
409
feature = "52840" ,
405
410
feature = "52811"
406
411
) ) ]
407
- impl Instance for SPIM1 { }
412
+ mod _spim1 {
413
+ use super :: * ;
414
+ impl Instance for SPIM1 { }
415
+ impl sealed:: Sealed for SPIM1 { }
416
+ }
408
417
409
418
#[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
410
- impl Instance for SPIM2 { }
419
+ mod _spim2 {
420
+ use super :: * ;
421
+ impl Instance for SPIM2 { }
422
+ impl sealed:: Sealed for SPIM2 { }
423
+ }
411
424
412
425
#[ cfg( any( feature = "52833" , feature = "52840" ) ) ]
413
- impl Instance for SPIM3 { }
426
+ mod _spim3 {
427
+ use super :: * ;
428
+ impl Instance for SPIM3 { }
429
+ impl sealed:: Sealed for SPIM3 { }
430
+ }
Original file line number Diff line number Diff line change @@ -296,8 +296,14 @@ pub enum Error {
296
296
}
297
297
298
298
/// Implemented by all TWIM instances.
299
- pub trait Instance : Deref < Target = twi0:: RegisterBlock > { }
299
+ pub trait Instance : Deref < Target = twi0:: RegisterBlock > + sealed :: Sealed { }
300
300
301
+ mod sealed {
302
+ pub trait Sealed { }
303
+ }
304
+
305
+ impl sealed:: Sealed for TWI0 { }
301
306
impl Instance for TWI0 { }
302
307
308
+ impl sealed:: Sealed for TWI1 { }
303
309
impl Instance for TWI1 { }
Original file line number Diff line number Diff line change @@ -447,9 +447,18 @@ pub enum Error {
447
447
}
448
448
449
449
/// Implemented by all TWIM instances
450
- pub trait Instance : Deref < Target = twim0:: RegisterBlock > { }
450
+ pub trait Instance : Deref < Target = twim0:: RegisterBlock > + sealed :: Sealed { }
451
451
452
+ mod sealed {
453
+ pub trait Sealed { }
454
+ }
455
+
456
+ impl sealed:: Sealed for TWIM0 { }
452
457
impl Instance for TWIM0 { }
453
458
454
459
#[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
455
- impl Instance for TWIM1 { }
460
+ mod _twim1 {
461
+ use super :: * ;
462
+ impl sealed:: Sealed for TWIM1 { }
463
+ impl Instance for TWIM1 { }
464
+ }
Original file line number Diff line number Diff line change @@ -314,9 +314,18 @@ pub enum TwiEvent {
314
314
}
315
315
316
316
/// Implemented by all TWIS instances
317
- pub trait Instance : Deref < Target = twis0:: RegisterBlock > { }
317
+ pub trait Instance : Deref < Target = twis0:: RegisterBlock > + sealed :: Sealed { }
318
318
319
+ mod sealed {
320
+ pub trait Sealed { }
321
+ }
322
+
323
+ impl sealed:: Sealed for TWIS0 { }
319
324
impl Instance for TWIS0 { }
320
325
321
326
#[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
322
- impl Instance for TWIS1 { }
327
+ mod _twis1 {
328
+ use super :: * ;
329
+ impl sealed:: Sealed for TWIS1 { }
330
+ impl Instance for TWIS1 { }
331
+ }
Original file line number Diff line number Diff line change @@ -142,6 +142,11 @@ pub struct Pins {
142
142
pub rts : Option < Pin < Output < PushPull > > > ,
143
143
}
144
144
145
- pub trait Instance : Deref < Target = uart0:: RegisterBlock > { }
145
+ pub trait Instance : Deref < Target = uart0:: RegisterBlock > + sealed :: Sealed { }
146
146
147
+ mod sealed {
148
+ pub trait Sealed { }
149
+ }
150
+
151
+ impl sealed:: Sealed for UART0 { }
147
152
impl Instance for UART0 { }
Original file line number Diff line number Diff line change @@ -368,9 +368,18 @@ pub enum Error {
368
368
BufferNotInRAM ,
369
369
}
370
370
371
- pub trait Instance : Deref < Target = uarte0:: RegisterBlock > { }
371
+ pub trait Instance : Deref < Target = uarte0:: RegisterBlock > + sealed :: Sealed { }
372
372
373
+ mod sealed {
374
+ pub trait Sealed { }
375
+ }
376
+
377
+ impl sealed:: Sealed for UARTE0 { }
373
378
impl Instance for UARTE0 { }
374
379
375
380
#[ cfg( any( feature = "52833" , feature = "52840" , feature = "9160" ) ) ]
376
- impl Instance for UARTE1 { }
381
+ mod _uarte1 {
382
+ use super :: * ;
383
+ impl sealed:: Sealed for UARTE1 { }
384
+ impl Instance for UARTE1 { }
385
+ }
You can’t perform that action at this time.
0 commit comments