diff options
| author | Dion Dokter <[email protected]> | 2024-06-14 16:55:05 +0200 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2024-06-14 16:55:05 +0200 |
| commit | f758c4b3910e8cb4d09c284db245e66de8cb5e5e (patch) | |
| tree | 095ac0d4fe20d6205f2dd531569f383e8c72d566 /examples/stm32u0/src | |
| parent | 74739997bd70d3c23b5c58d25aa5c9ba4db55f35 (diff) | |
Start implementing lcd
Diffstat (limited to 'examples/stm32u0/src')
| -rw-r--r-- | examples/stm32u0/src/bin/lcd.rs | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/examples/stm32u0/src/bin/lcd.rs b/examples/stm32u0/src/bin/lcd.rs new file mode 100644 index 000000000..8612c3dfc --- /dev/null +++ b/examples/stm32u0/src/bin/lcd.rs | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_stm32::lcd::{Bias, Config, Duty, Lcd, VoltageSource}; | ||
| 7 | use {defmt_rtt as _, panic_probe as _}; | ||
| 8 | |||
| 9 | #[embassy_executor::main] | ||
| 10 | async fn main(_spawner: Spawner) { | ||
| 11 | let mut config = embassy_stm32::Config::default(); | ||
| 12 | // The RTC clock = the LCD clock and must be running | ||
| 13 | { | ||
| 14 | use embassy_stm32::rcc::*; | ||
| 15 | config.rcc.sys = Sysclk::PLL1_R; | ||
| 16 | config.rcc.hsi = true; | ||
| 17 | config.rcc.pll = Some(Pll { | ||
| 18 | source: PllSource::HSI, // 16 MHz | ||
| 19 | prediv: PllPreDiv::DIV1, | ||
| 20 | mul: PllMul::MUL7, // 16 * 7 = 112 MHz | ||
| 21 | divp: None, | ||
| 22 | divq: None, | ||
| 23 | divr: Some(PllRDiv::DIV2), // 112 / 2 = 56 MHz | ||
| 24 | }); | ||
| 25 | config.rcc.ls = LsConfig::default(); | ||
| 26 | } | ||
| 27 | |||
| 28 | let p = embassy_stm32::init(config); | ||
| 29 | info!("Hello World!"); | ||
| 30 | |||
| 31 | let mut config = Config::default(); | ||
| 32 | config.bias = Bias::Third; | ||
| 33 | config.duty = Duty::Quarter; | ||
| 34 | |||
| 35 | let mut lcd = Lcd::new( | ||
| 36 | p.LCD, | ||
| 37 | config, | ||
| 38 | [ | ||
| 39 | p.PC4.into(), | ||
| 40 | p.PC5.into(), | ||
| 41 | p.PB1.into(), | ||
| 42 | p.PE7.into(), | ||
| 43 | p.PE8.into(), | ||
| 44 | p.PE9.into(), | ||
| 45 | p.PB11.into(), | ||
| 46 | p.PB14.into(), | ||
| 47 | p.PB15.into(), | ||
| 48 | p.PD8.into(), | ||
| 49 | p.PD9.into(), | ||
| 50 | p.PD12.into(), | ||
| 51 | p.PB9.into(), | ||
| 52 | p.PA10.into(), | ||
| 53 | p.PA9.into(), | ||
| 54 | p.PA8.into(), | ||
| 55 | p.PD13.into(), | ||
| 56 | p.PC6.into(), | ||
| 57 | p.PC8.into(), | ||
| 58 | p.PC9.into(), | ||
| 59 | p.PC10.into(), | ||
| 60 | p.PD0.into(), | ||
| 61 | p.PD1.into(), | ||
| 62 | p.PD3.into(), | ||
| 63 | p.PD4.into(), | ||
| 64 | p.PD5.into(), | ||
| 65 | p.PD6.into(), | ||
| 66 | p.PC11.into(), | ||
| 67 | ], | ||
| 68 | ); | ||
| 69 | |||
| 70 | loop { | ||
| 71 | defmt::info!("Writing frame"); | ||
| 72 | lcd.write_frame(&[0xAAAAAAAA; 16]); | ||
| 73 | defmt::info!("Writing frame"); | ||
| 74 | lcd.write_frame(&[!0xAAAAAAAA; 16]); | ||
| 75 | } | ||
| 76 | } | ||
