pub struct FsmcLcd<PINS> { /* private fields */ }
Expand description

An FMC or FSMC configured as an LCD interface

Implementations

Configures the FSMC/FMC to interface with an LCD using the provided pins

The same timings will be used for all connected LCDs.

The return type includes an FsmcLcd and either an Lcd or a tuple of up to four Lcds, depending on the pins given.

The returned FsmcLcd can be used later to release the FSMC and pins for other uses, or it can be ignored.

Return type examples
One enable/chip select pin

If you pass an LcdPins object with the enable field containing a single ChipSelect1 object with a pin, this function will return an FsmcLcd and an Lcd<SubBank1>.

Multiple enable/chip select pins

If you pass an LcdPins object with the enable field containing a tuple of 2-4 ChipSelectX objects, this function will return an FsmcLcd and a tuple of Lcd<_> objects. Each Lcd is associated with one chip select pin, and can be controlled independently.

Examples

The stm32f4xx-hal repository has a st7789-lcd example that draws graphics on an LCD and runs on the STM32F412G-DISCO board.

Up to four LCDs can be controlled separately using four chip select pins

let lcd_pins = LcdPins {
    data: (
        gpiod.pd14.into_alternate_af12(),
        gpiod.pd15.into_alternate_af12(),
        gpiod.pd0.into_alternate_af12(),
        gpiod.pd1.into_alternate_af12(),
        gpioe.pe7.into_alternate_af12(),
        gpioe.pe8.into_alternate_af12(),
        gpioe.pe9.into_alternate_af12(),
        gpioe.pe10.into_alternate_af12(),
        gpioe.pe11.into_alternate_af12(),
        gpioe.pe12.into_alternate_af12(),
        gpioe.pe13.into_alternate_af12(),
        gpioe.pe14.into_alternate_af12(),
        gpioe.pe15.into_alternate_af12(),
        gpiod.pd8.into_alternate_af12(),
        gpiod.pd9.into_alternate_af12(),
        gpiod.pd10.into_alternate_af12(),
    ),
    // Four address pins, one for each LCD
    // All of them will have the same output
    address: (
        gpiof.pf0.into_alternate_af12(),
        gpioe.pe2.into_alternate_af12(),
        gpioe.pe3.into_alternate_af12(),
        gpiof.pf14.into_alternate_af12(),
    ),
    read_enable: gpiod.pd4.into_alternate_af12(),
    write_enable: gpiod.pd5.into_alternate_af12(),
    // Four chip select pins, one for each LCD, controlled independently
    chip_select: (
        ChipSelect1(gpiod.pd7.into_alternate_af12()),
        ChipSelect2(gpiog.pg9.into_alternate_af12()),
        ChipSelect3(gpiog.pg10.into_alternate_af12()),
        ChipSelect4(gpiog.pg12.into_alternate_af12()),
    ),
};

let (_fsmc, mut lcds) = FsmcLcd::new(dp.FSMC, lcd_pins, &Timing::default(), &Timing::default());
// lcds is a tuple of four `Lcd` objects. Each one can be accessed independently.
// This is just a basic example of some things that can be done.
lcds.0.write_command(37);
lcds.1.write_command(38);
lcds.2.write_command(39);
lcds.3.write_command(40);

Reunites this FsmcLcd and all its associated LCDs, and returns the FSMC and pins for other uses

This function also resets and disables the FSMC.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.