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 | |
| parent | 74739997bd70d3c23b5c58d25aa5c9ba4db55f35 (diff) | |
Start implementing lcd
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32u0/.cargo/config.toml | 2 | ||||
| -rw-r--r-- | examples/stm32u0/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/stm32u0/src/bin/lcd.rs | 76 |
3 files changed, 78 insertions, 2 deletions
diff --git a/examples/stm32u0/.cargo/config.toml b/examples/stm32u0/.cargo/config.toml index 688347084..06eed6c8f 100644 --- a/examples/stm32u0/.cargo/config.toml +++ b/examples/stm32u0/.cargo/config.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 2 | # replace stm32u083rctx with your chip as listed in `probe-rs chip list` | 2 | # replace stm32u083rctx with your chip as listed in `probe-rs chip list` |
| 3 | runner = "probe-rs run --chip stm32u083rctx" | 3 | runner = "probe-rs run --chip stm32u083rctx --catch-hardfault" |
| 4 | 4 | ||
| 5 | [build] | 5 | [build] |
| 6 | target = "thumbv6m-none-eabi" | 6 | target = "thumbv6m-none-eabi" |
diff --git a/examples/stm32u0/Cargo.toml b/examples/stm32u0/Cargo.toml index afeb4dc34..6c310b0f6 100644 --- a/examples/stm32u0/Cargo.toml +++ b/examples/stm32u0/Cargo.toml | |||
| @@ -6,7 +6,7 @@ license = "MIT OR Apache-2.0" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | # Change stm32u083rc to your chip name, if necessary. | 8 | # Change stm32u083rc to your chip name, if necessary. |
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32u083rc", "memory-x", "unstable-pac", "exti", "chrono"] } | 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = [ "defmt", "time-driver-any", "stm32u083mc", "memory-x", "unstable-pac", "exti", "chrono"] } |
| 10 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 12 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
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 | } | ||
