@@ -87,6 +87,7 @@ pub unsafe trait Instance: message_ram::Instance {
87
87
88
88
/// Indicates if an Receive Overflow has occurred
89
89
#[ derive( Clone , Copy , Debug ) ]
90
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
90
91
pub enum ReceiveErrorOverflow {
91
92
/// No overflow has occurred
92
93
Normal ( u8 ) ,
@@ -97,6 +98,7 @@ pub enum ReceiveErrorOverflow {
97
98
///Error Counters
98
99
#[ derive( Clone , Copy , Debug ) ]
99
100
#[ non_exhaustive]
101
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
100
102
pub struct ErrorCounters {
101
103
/// General CAN error counter
102
104
pub can_errors : u8 ,
@@ -116,6 +118,7 @@ enum LoopbackMode {
116
118
117
119
/// Bus Activity
118
120
#[ derive( Clone , Copy , Debug ) ]
121
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
119
122
pub enum Activity {
120
123
/// Node is Synchronizing
121
124
Synchronizing = 0b00 ,
@@ -141,6 +144,7 @@ impl TryFrom<u8> for Activity {
141
144
142
145
/// Indicates the type of the last error which occurred on the CAN bus
143
146
#[ derive( Clone , Copy , Debug ) ]
147
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
144
148
pub enum LastErrorCode {
145
149
/// There has been no error since last read
146
150
NoError = 0b000 ,
@@ -179,6 +183,7 @@ impl TryFrom<u8> for LastErrorCode {
179
183
/// Some status indications regarding the FDCAN protocl
180
184
#[ derive( Clone , Copy , Debug ) ]
181
185
#[ non_exhaustive]
186
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
182
187
pub struct ProtocolStatus {
183
188
/// Type of current activity
184
189
pub activity : Activity ,
@@ -200,13 +205,16 @@ pub trait Transmit {}
200
205
pub trait Receive { }
201
206
202
207
/// Allows for the FdCan Instance to be released or to enter ConfigMode
208
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
203
209
pub struct PoweredDownMode ;
204
210
/// Allows for the configuration for the Instance
211
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
205
212
pub struct ConfigMode ;
206
213
/// This mode can be used for a “Hot Selftest”, meaning the FDCAN can be tested without
207
214
/// affecting a running CAN system connected to the FDCAN_TX and FDCAN_RX pins. In this
208
215
/// mode, FDCAN_RX pin is disconnected from the FDCAN and FDCAN_TX pin is held
209
216
/// recessive.
217
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
210
218
pub struct InternalLoopbackMode ;
211
219
impl Transmit for InternalLoopbackMode { }
212
220
impl Receive for InternalLoopbackMode { }
@@ -216,10 +224,12 @@ impl Receive for InternalLoopbackMode {}
216
224
/// feedback from its transmit output to its receive input. The actual value of the FDCAN_RX
217
225
/// input pin is disregarded by the FDCAN. The transmitted messages can be monitored at the
218
226
/// FDCAN_TX transmit pin.
227
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
219
228
pub struct ExternalLoopbackMode ;
220
229
impl Transmit for ExternalLoopbackMode { }
221
230
impl Receive for ExternalLoopbackMode { }
222
231
/// The normal use of the FdCan instance after configurations
232
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
223
233
pub struct NormalOperationMode ;
224
234
impl Transmit for NormalOperationMode { }
225
235
impl Receive for NormalOperationMode { }
@@ -229,6 +239,7 @@ impl Receive for NormalOperationMode {}
229
239
/// send dominant bits, instead it waits for the occurrence of bus idle condition to resynchronize
230
240
/// itself to the CAN communication. The error counters for transmit and receive are frozen while
231
241
/// error logging (can_errors) is active. TODO: automatically enter in this mode?
242
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
232
243
pub struct RestrictedOperationMode ;
233
244
impl Receive for RestrictedOperationMode { }
234
245
/// In Bus monitoring mode (for more details refer to ISO11898-1, 10.12 Bus monitoring),
@@ -239,14 +250,17 @@ impl Receive for RestrictedOperationMode {}
239
250
/// state. In Bus monitoring mode the TXBRP register is held in reset state. The Bus monitoring
240
251
/// mode can be used to analyze the traffic on a CAN bus without affecting it by the transmission
241
252
/// of dominant bits.
253
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
242
254
pub struct BusMonitoringMode ;
243
255
impl Receive for BusMonitoringMode { }
244
256
/// Test mode must be used for production tests or self test only. The software control for
245
257
/// FDCAN_TX pin interferes with all CAN protocol functions. It is not recommended to use test
246
258
/// modes for application.
259
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
247
260
pub struct TestMode ;
248
261
249
262
/// Interface to a FdCAN peripheral.
263
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
250
264
pub struct FdCan < I : Instance , MODE > {
251
265
control : FdCanControl < I , MODE > ,
252
266
}
@@ -1120,6 +1134,7 @@ where
1120
1134
/// FdCanControl Struct
1121
1135
/// Used to house some information during an FdCan split.
1122
1136
/// and can be used for some generic information retrieval during operation.
1137
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
1123
1138
pub struct FdCanControl < I , MODE >
1124
1139
where
1125
1140
I : Instance ,
@@ -1185,6 +1200,7 @@ where
1185
1200
}
1186
1201
1187
1202
/// Interface to the CAN transmitter part.
1203
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
1188
1204
pub struct Tx < I , MODE > {
1189
1205
_can : PhantomData < I > ,
1190
1206
_mode : PhantomData < MODE > ,
@@ -1460,6 +1476,7 @@ impl FifoNr for Fifo1 {
1460
1476
/// Notes whether an overrun has occurred.
1461
1477
/// Since both arms contain T, this can be 'unwrap'ed without causing a panic.
1462
1478
#[ derive( Clone , Copy , Debug ) ]
1479
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
1463
1480
pub enum ReceiveOverrun < T > {
1464
1481
/// No overrun has occured
1465
1482
NoOverrun ( T ) ,
@@ -1479,6 +1496,7 @@ impl<T> ReceiveOverrun<T> {
1479
1496
}
1480
1497
1481
1498
/// Interface to the CAN receiver part.
1499
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
1482
1500
pub struct Rx < I , MODE , FIFONR >
1483
1501
where
1484
1502
FIFONR : FifoNr ,
@@ -1618,6 +1636,7 @@ where
1618
1636
/// These are used for the transmit queue
1619
1637
/// and the two Receive FIFOs
1620
1638
#[ derive( Debug , Copy , Clone , Ord , PartialOrd , Eq , PartialEq ) ]
1639
+ #[ cfg_attr( feature = "defmt-03" , derive( defmt:: Format ) ) ]
1621
1640
pub enum Mailbox {
1622
1641
/// Transmit mailbox 0
1623
1642
_0 = 0 ,
0 commit comments