Build a color test pattern.

This commit is contained in:
Savanni D'Gerinel 2023-11-14 08:04:31 -05:00
parent c46ab1b389
commit 6d14cdbe2a
1 changed files with 91 additions and 13 deletions

View File

@ -120,49 +120,127 @@ fn main() -> ! {
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz()); 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 spi = Spi::<_, _, _, 8>::new(pac.SPI1, (spi_sdo, spi_clk));
let mut spi = spi.init( let mut spi = spi.init(
&mut pac.RESETS, &mut pac.RESETS,
clocks.peripheral_clock.freq(), clocks.peripheral_clock.freq(),
1.MHz(), 1.MHz(),
embedded_hal::spi::MODE_0, embedded_hal::spi::MODE_1,
); );
*/ */
let mut led_pin = pins.led.into_push_pull_output(); let mut led_pin = pins.led.into_push_pull_output();
let mut blue_pin = pins.gpio3.into_push_pull_output(); let mut blue_pin = pins.gpio3.into_push_pull_output();
led_pin.set_high().unwrap(); 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_clk.set_low();
spi_sdo.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 { loop {
send( send(
&mut spi_sdo, &mut spi_sdo,
&mut spi_clk, &mut spi_clk,
&mut delay, &mut delay,
&[ bits_1,
0xe1, 0x80, 0x00, 0x00,
0xe1, 0x00, 0x80, 0x00,
0xe1, 0x00, 0x00, 0x80,
],
); );
spi_clk.set_low(); spi_clk.set_low();
spi_sdo.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(&[ spi.write(bits_1);
0, 0, 0, 0, 0xf0, 0x80, 0x0, 0x0, 0xe1, 0x0, 0x80, 0x0, 0xe1, 0x0, 0x0, 0x80, 0xff, delay.delay_ms(500);
0xff, 0xff, 0xff, spi.write(bits_2);
]); delay.delay_ms(500);
spi.write(bits_3);
delay.delay_ms(500);
*/ */
/*
led_pin.set_high().unwrap(); led_pin.set_high().unwrap();
blue_pin.set_low().unwrap(); blue_pin.set_low().unwrap();
delay.delay_ms(500); delay.delay_ms(500);
led_pin.set_low().unwrap(); led_pin.set_low().unwrap();
blue_pin.set_high().unwrap(); blue_pin.set_high().unwrap();
delay.delay_ms(500); delay.delay_ms(500);
*/
} }
} }