Skip to content

Commit 14160d3

Browse files
committed
Add constants for various 'SPI mode numbers'
1 parent f91fc4b commit 14160d3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/spi.rs

+24
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,27 @@ pub struct Mode {
5252
/// Clock phase
5353
pub phase: Phase,
5454
}
55+
56+
/// Helper for CPOL = 0, CPHA = 0
57+
pub const MODE_0: Mode = Mode {
58+
polarity: Polarity::IdleLow,
59+
phase: Phase::CaptureOnFirstTransition,
60+
};
61+
62+
/// Helper for CPOL = 0, CPHA = 1
63+
pub const MODE_1: Mode = Mode {
64+
polarity: Polarity::IdleLow,
65+
phase: Phase::CaptureOnSecondTransition,
66+
};
67+
68+
/// Helper for CPOL = 1, CPHA = 0
69+
pub const MODE_2: Mode = Mode {
70+
polarity: Polarity::IdleHigh,
71+
phase: Phase::CaptureOnFirstTransition,
72+
};
73+
74+
/// Helper for CPOL = 1, CPHA = 1
75+
pub const MODE_3: Mode = Mode {
76+
polarity: Polarity::IdleHigh,
77+
phase: Phase::CaptureOnSecondTransition,
78+
};

0 commit comments

Comments
 (0)