Add HD44780 example (#60)

* Added HD44780 lcd example

* Formatting lcd_display.rs

* Formatting Cargo.toml

* Fixed import formatting issue

* Fixed line with spaces
This commit is contained in:
Marcuss2 2021-07-23 10:37:36 +02:00 committed by GitHub
parent f310d92b64
commit a02c8131ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 1 deletions

View file

@ -21,6 +21,7 @@ paste = "1.0"
cortex-m-rt = "0.6.14"
panic-halt = "0.2.0"
rp2040-boot2 = { git = "https://github.com/rp-rs/rp2040-boot2-rs", branch="main" }
hd44780-driver = "0.4.0"
[features]
rt = ["rp2040-pac/rt"]
rt = ["rp2040-pac/rt"]

View file

@ -0,0 +1,52 @@
#![no_std]
#![no_main]
use cortex_m_rt::entry;
use hal::pac;
use hal::sio::Sio;
use hd44780_driver as hd44780;
use panic_halt as _;
use rp2040_hal as hal;
#[link_section = ".boot2"]
#[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER;
#[entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let core = pac::CorePeripherals::take().unwrap();
// AHL bus speed default
let mut delay_provider = cortex_m::delay::Delay::new(core.SYST, 12_000_000);
let sio = Sio::new(pac.SIO);
let pins = hal::gpio::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let lcd = hd44780::HD44780::new_4bit(
pins.gpio16.into_push_pull_output(), // Register Select
pins.gpio17.into_push_pull_output(), // Enable
pins.gpio18.into_push_pull_output(), // d4
pins.gpio19.into_push_pull_output(), // d5
pins.gpio20.into_push_pull_output(), // d6
pins.gpio21.into_push_pull_output(), // d7
&mut delay_provider,
);
let mut lcd = lcd.unwrap();
lcd.reset(&mut delay_provider).unwrap();
lcd.clear(&mut delay_provider).unwrap();
lcd.write_str("rp-hal on", &mut delay_provider).unwrap();
lcd.set_cursor_pos(40, &mut delay_provider).unwrap();
lcd.set_cursor_visibility(hd44780::Cursor::Visible, &mut delay_provider)
.unwrap();
lcd.write_str("HD44780!", &mut delay_provider).unwrap();
loop {}
}