match on mode
This commit is contained in:
parent
0dd00c94aa
commit
990d83d424
@ -100,24 +100,29 @@ impl<'d, T: Instance> Spim<'d, T> {
|
|||||||
// Configure mode.
|
// Configure mode.
|
||||||
let mode = config.mode;
|
let mode = config.mode;
|
||||||
r.config.write(|w| {
|
r.config.write(|w| {
|
||||||
// Can't match on `mode` due to embedded-hal, see https://github.com/rust-embedded/embedded-hal/pull/126
|
match mode {
|
||||||
if mode == MODE_0 {
|
MODE_0 => {
|
||||||
w.order().msb_first();
|
w.order().msb_first();
|
||||||
w.cpol().active_high();
|
w.cpol().active_high();
|
||||||
w.cpha().leading();
|
w.cpha().leading();
|
||||||
} else if mode == MODE_1 {
|
}
|
||||||
w.order().msb_first();
|
MODE_1 => {
|
||||||
w.cpol().active_high();
|
w.order().msb_first();
|
||||||
w.cpha().trailing();
|
w.cpol().active_high();
|
||||||
} else if mode == MODE_2 {
|
w.cpha().trailing();
|
||||||
w.order().msb_first();
|
}
|
||||||
w.cpol().active_low();
|
MODE_2 => {
|
||||||
w.cpha().leading();
|
w.order().msb_first();
|
||||||
} else {
|
w.cpol().active_low();
|
||||||
w.order().msb_first();
|
w.cpha().leading();
|
||||||
w.cpol().active_low();
|
}
|
||||||
w.cpha().trailing();
|
MODE_3 => {
|
||||||
|
w.order().msb_first();
|
||||||
|
w.cpol().active_low();
|
||||||
|
w.cpha().trailing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w
|
w
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user