@@ -11,6 +11,7 @@ macro_rules! peripheral_target_address {
11
11
} ;
12
12
}
13
13
macro_rules! peripheral_target_instance {
14
+ // PAC target
14
15
( ( $peripheral: ty, $register: ident, $size: ty,
15
16
$dir: ty $( , $mux: expr) * ) ) => {
16
17
unsafe impl TargetAddress <$dir> for $peripheral {
@@ -26,8 +27,59 @@ macro_rules! peripheral_target_instance {
26
27
}
27
28
} ;
28
29
29
- ( ( SPI : $peripheral: ty, $rxreg: ident, $txreg: ident, [ $( $size: ty) ,+] , $rxmux: expr, $txmux: expr) ) => {
30
- // Access via PAC peripheral structures implies u8 sizing, as the sizing is unknown.
30
+ // PAC target where register is within a channel
31
+ ( ( $peripheral: ty, $channel: ident. $register: ident, $size: ty,
32
+ $dir: ty $( , $mux: expr) * ) ) => {
33
+ unsafe impl TargetAddress <$dir> for $peripheral {
34
+ #[ inline( always) ]
35
+ fn address( & self ) -> usize {
36
+ & self . $channel. $register as * const _ as usize
37
+ }
38
+
39
+ type MemSize = $size;
40
+ $(
41
+ const REQUEST_LINE : Option <u8 > = Some ( $mux as u8 ) ;
42
+ ) *
43
+ }
44
+ } ;
45
+
46
+ // PAC and HAL targets, generic
47
+ ( ( HAL : $hal: ident<$peripheral: ty>, $register: ident, $size: ty,
48
+ $dir: ty $( , $mux: expr) * ) ) => {
49
+
50
+ // PAC implementation
51
+ unsafe impl TargetAddress <$dir> for $peripheral {
52
+ #[ inline( always) ]
53
+ fn address( & self ) -> usize {
54
+ & self . $register as * const _ as usize
55
+ }
56
+
57
+ type MemSize = $size;
58
+ $(
59
+ const REQUEST_LINE : Option <u8 > = Some ( $mux as u8 ) ;
60
+ ) *
61
+ }
62
+
63
+ // HAL implementation
64
+ unsafe impl TargetAddress <$dir> for $hal<$peripheral> {
65
+ #[ inline( always) ]
66
+ fn address( & self ) -> usize {
67
+ & self . inner( ) . $register as * const _ as usize
68
+ }
69
+
70
+ type MemSize = $size;
71
+ $(
72
+ const REQUEST_LINE : Option <u8 > = Some ( $mux as u8 ) ;
73
+ ) *
74
+ }
75
+ } ;
76
+
77
+ // PAC and HAL targets for SPI peripheral
78
+ ( ( SPI : $peripheral: ty, $rxreg: ident, $txreg: ident, [ $( $size: ty) ,+] ,
79
+ $rxmux: expr, $txmux: expr) ) => {
80
+
81
+ // Access via PAC peripheral structures implies u8 sizing, as the sizing
82
+ // is unknown.
31
83
unsafe impl TargetAddress <M2P > for $peripheral {
32
84
#[ inline( always) ]
33
85
fn address( & self ) -> usize {
@@ -76,6 +128,7 @@ macro_rules! peripheral_target_instance {
76
128
) +
77
129
} ;
78
130
131
+ // PAC and HAL targets for Serial Peripherals
79
132
( ( SERIAL : $peripheral: ty, $rxreg: ident, $txreg: ident, $rxmux: expr, $txmux: expr) ) => {
80
133
unsafe impl TargetAddress <M2P > for $peripheral {
81
134
#[ inline( always) ]
@@ -151,37 +204,4 @@ macro_rules! peripheral_target_instance {
151
204
const TRBUFF : bool = true ;
152
205
}
153
206
} ;
154
-
155
- ( ( INNER : $peripheral: ty, $register: ident $( ( $TRBUFF: ident) ) * , $size: ty,
156
- $dir: ty $( , $mux: expr) * ) ) => {
157
- unsafe impl TargetAddress <$dir> for $peripheral {
158
- #[ inline( always) ]
159
- fn address( & self ) -> usize {
160
- & self . inner( ) . $register as * const _ as usize
161
- }
162
-
163
- type MemSize = $size;
164
- $(
165
- const REQUEST_LINE : Option <u8 > = Some ( $mux as u8 ) ;
166
- ) *
167
- $(
168
- const $TRBUFF: bool = true ;
169
- ) *
170
- }
171
- } ;
172
-
173
- ( ( $peripheral: ty, $channel: ident. $register: ident, $size: ty,
174
- $dir: ty $( , $mux: expr) * ) ) => {
175
- unsafe impl TargetAddress <$dir> for $peripheral {
176
- #[ inline( always) ]
177
- fn address( & self ) -> usize {
178
- & self . $channel. $register as * const _ as usize
179
- }
180
-
181
- type MemSize = $size;
182
- $(
183
- const REQUEST_LINE : Option <u8 > = Some ( $mux as u8 ) ;
184
- ) *
185
- }
186
- } ;
187
207
}
0 commit comments