Module capsules_extra::hd44780

source ·
Expand description

SyscallDriver for the HD44780 LCD screen.

The LCD must be connected as shown here, because the pins of the LCD are already defined in the kernel, and modifying them means re-compiling the kernel with the modifications.

This capsule takes an alarm, an array of pins and one buffer initialized to 0.

This capsule uses the TextScreen capsule and implements the TextScreen trait, through which it can receive commands (specific driver commands or write commands) and call specific callbacks (write_complete() or command_complete()).

§According to the HD44780 datasheet, there must be a delay between certain operations on the device. Since there cannot be a delay while running on kernel mode, the alarm is the best way to implement those delays. To remember the state before and after each delay, the program will be a big state-machine that goes through the possible states defined in the LCDStatus enum. Also, after every command completed, a callback will be called to the text_screen capsule, in order for this capsule to be able to receive new commands. If a command is sent while this capsule is busy, it will return a “BUSY” code. Usage

let lcd = components::hd44780::HD44780Component::new(mux_alarm).finalize(
    components::hd44780_component_helper!(
        stm32f429zi::tim2::Tim2,
        // rs pin
        gpio_ports.pins[5][13].as_ref().unwrap(),
        // en pin
        gpio_ports.pins[4][11].as_ref().unwrap(),
        // data 4 pin
        gpio_ports.pins[5][14].as_ref().unwrap(),
        // data 5 pin
        gpio_ports.pins[4][13].as_ref().unwrap(),
        // data 6 pin
        gpio_ports.pins[5][15].as_ref().unwrap(),
        // data 7 pin
        gpio_ports.pins[6][14].as_ref().unwrap()
    )
);

let text_screen = components::text_screen::TextScreenComponent::new(board_kernel, lcd)
                .finalize(components::screen_buffer_size!(64));

Author: Teona Severin teona.severin9@gmail.com

Structs§

Constants§