You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Use `CanOpts::default()` to get 250kbps at 32mhz system clock
32
32
pubstructCanOpts{
33
-
pubbrp:u16,
34
-
pubsjw:u8,
35
-
pubts1:u8,
36
-
pubts2:u8,
37
-
publbkm:LBKM_A,
33
+
brp:u16,
34
+
sjw:u8,
35
+
ts1:u8,
36
+
ts2:u8,
37
+
lbkm:LBKM_A,
38
38
}
39
39
40
40
implCanOpts{
41
+
/// Create new `CanOpts` using the default settings from `CanOpts::default()` to get 250kbps at 32mhz system clock.
41
42
pubfnnew() -> CanOpts{
42
43
CanOpts::default()
43
44
}
44
45
46
+
/// Set the Baud Rate Prescaler. See http://www.bittiming.can-wiki.info/#bxCAN for generating the timing parameters for different baud rates and clocks.
45
47
pubfnbrp(mutself,brp:u16) -> Self{
46
48
self.brp = brp;
47
49
self
48
50
}
49
51
52
+
/// Set the Resynchronisation Jump Width. See http://www.bittiming.can-wiki.info/#bxCAN for generating the timing parameters for different baud rates and clocks.
50
53
pubfnsjw(mutself,sjw:u8) -> Self{
51
54
self.sjw = sjw;
52
55
self
53
56
}
54
57
58
+
/// Set Time Segment One. See http://www.bittiming.can-wiki.info/#bxCAN for generating the timing parameters for different baud rates and clocks.
55
59
pubfnts1(mutself,ts1:u8) -> Self{
56
60
self.ts1 = ts1;
57
61
self
58
62
}
59
63
64
+
/// Set Time Segment Two. See http://www.bittiming.can-wiki.info/#bxCAN for generating the timing parameters for different baud rates and clocks.
60
65
pubfnts2(mutself,ts2:u8) -> Self{
61
66
self.ts2 = ts2;
62
67
self
63
68
}
64
69
70
+
/// Enable or disable loopback mode on the CAN device. This is useful for debugging.
65
71
pubfnlbkm(mutself,lbkm:LBKM_A) -> Self{
66
72
self.lbkm = lbkm;
67
73
self
@@ -308,6 +314,7 @@ impl CanFilterData {
308
314
}
309
315
310
316
implCan{
317
+
/// Initialize the CAN peripheral using the options specified by `opts`.
311
318
pubfnnew_with_opts(
312
319
can: stm32::CAN,
313
320
rx: gpioa::PA11<AF9>,
@@ -619,7 +626,7 @@ impl CanFrame {
619
626
///
620
627
/// # Panics
621
628
///
622
-
/// This function will panic if `dlc` is not inside the vliad range `0..=8`.
629
+
/// This function will panic if `dlc` is not inside the valid range `0..=8`.
623
630
pubfnnew_remote(id:CanId,dlc:usize) -> CanFrame{
624
631
assert!((0..=8).contains(&dlc));
625
632
@@ -630,7 +637,13 @@ impl CanFrame {
630
637
}
631
638
}
632
639
640
+
/// Length of the frame data
633
641
pubfnlen(&self) -> usize{
634
642
self.dlc
635
643
}
644
+
645
+
/// Is this frame empty. This usually indicates a remote frame.
0 commit comments