Compare commits
2 Commits
168ba6eb40
...
6d14cdbe2a
Author | SHA1 | Date |
---|---|---|
Savanni D'Gerinel | 6d14cdbe2a | |
Savanni D'Gerinel | c46ab1b389 |
|
@ -29,8 +29,8 @@ fn send_byte<I, J, P>(
|
|||
J: PinId,
|
||||
P: PullType,
|
||||
{
|
||||
(0..7).for_each(|bit| {
|
||||
if byte & (1 << (7 - bit)) > 0 {
|
||||
(0..8).for_each(|bit| {
|
||||
if byte & (1 << (8 - bit)) > 0 {
|
||||
data.set_high();
|
||||
} else {
|
||||
data.set_low();
|
||||
|
@ -120,46 +120,127 @@ fn main() -> ! {
|
|||
|
||||
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz());
|
||||
|
||||
let mut spi_clk = pins.gpio10.into_push_pull_output();
|
||||
let mut spi_sdo = pins.gpio11.into_push_pull_output();
|
||||
|
||||
/*
|
||||
let mut spi_clk = pins.gpio10.into_function();
|
||||
let mut spi_sdo = pins.gpio11.into_function();
|
||||
let spi = Spi::<_, _, _, 8>::new(pac.SPI1, (spi_sdo, spi_clk));
|
||||
let mut spi = spi.init(
|
||||
&mut pac.RESETS,
|
||||
clocks.peripheral_clock.freq(),
|
||||
1.MHz(),
|
||||
embedded_hal::spi::MODE_0,
|
||||
embedded_hal::spi::MODE_1,
|
||||
);
|
||||
*/
|
||||
|
||||
let mut led_pin = pins.led.into_push_pull_output();
|
||||
let mut blue_pin = pins.gpio3.into_push_pull_output();
|
||||
led_pin.set_high().unwrap();
|
||||
delay.delay_ms(500);
|
||||
led_pin.set_low().unwrap();
|
||||
|
||||
let mut spi_clk = pins.gpio10.into_push_pull_output();
|
||||
let mut spi_sdo = pins.gpio11.into_push_pull_output();
|
||||
spi_clk.set_low();
|
||||
spi_sdo.set_low();
|
||||
|
||||
let bits_1 = &[
|
||||
0, 0, 0, 0,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
];
|
||||
let bits_2 = &[
|
||||
0, 0, 0, 0,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
];
|
||||
let bits_3 = &[
|
||||
0, 0, 0, 0,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xe1, 0x00, 0x00, 0x80,
|
||||
0xe1, 0x80, 0x00, 0x00,
|
||||
0xe1, 0x00, 0x80, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
];
|
||||
|
||||
let a = 15 / 2;
|
||||
|
||||
loop {
|
||||
send(
|
||||
&mut spi_sdo,
|
||||
&mut spi_clk,
|
||||
&mut delay,
|
||||
&[
|
||||
0, 0, 0, 0, 0xf0, 0x80, 0x0, 0x0, 0xe1, 0x0, 0x80, 0x0, 0xe1, 0x0, 0x0, 0x80, 0xff,
|
||||
0xff, 0xff, 0xff,
|
||||
],
|
||||
bits_1,
|
||||
);
|
||||
spi_clk.set_low();
|
||||
spi_sdo.set_low();
|
||||
delay.delay_ms(500);
|
||||
|
||||
send(
|
||||
&mut spi_sdo,
|
||||
&mut spi_clk,
|
||||
&mut delay,
|
||||
bits_2,
|
||||
);
|
||||
spi_clk.set_low();
|
||||
spi_sdo.set_low();
|
||||
delay.delay_ms(500);
|
||||
|
||||
send(
|
||||
&mut spi_sdo,
|
||||
&mut spi_clk,
|
||||
&mut delay,
|
||||
bits_3,
|
||||
);
|
||||
spi_clk.set_low();
|
||||
spi_sdo.set_low();
|
||||
delay.delay_ms(500);
|
||||
|
||||
/*
|
||||
spi.write(&[
|
||||
0, 0, 0, 0, 0xf0, 0x80, 0x0, 0x0, 0xe1, 0x0, 0x80, 0x0, 0xe1, 0x0, 0x0, 0x80, 0xff,
|
||||
0xff, 0xff, 0xff,
|
||||
]);
|
||||
spi.write(bits_1);
|
||||
delay.delay_ms(500);
|
||||
spi.write(bits_2);
|
||||
delay.delay_ms(500);
|
||||
spi.write(bits_3);
|
||||
delay.delay_ms(500);
|
||||
*/
|
||||
|
||||
/*
|
||||
led_pin.set_high().unwrap();
|
||||
blue_pin.set_low().unwrap();
|
||||
delay.delay_ms(500);
|
||||
led_pin.set_low().unwrap();
|
||||
blue_pin.set_high().unwrap();
|
||||
delay.delay_ms(500);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue