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

An FMC or FSMC configured as an LCD interface

Implementations§

source§

impl<PINS> FsmcLcd<PINS>
where PINS: Pins,

source

pub fn new( fsmc: FSMC, pins: PINS, read_timing: &Timing, write_timing: &Timing ) -> (Self, PINS::Lcds)

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(),
        gpiod.pd15.into(),
        gpiod.pd0.into(),
        gpiod.pd1.into(),
        gpioe.pe7.into(),
        gpioe.pe8.into(),
        gpioe.pe9.into(),
        gpioe.pe10.into(),
        gpioe.pe11.into(),
        gpioe.pe12.into(),
        gpioe.pe13.into(),
        gpioe.pe14.into(),
        gpioe.pe15.into(),
        gpiod.pd8.into(),
        gpiod.pd9.into(),
        gpiod.pd10.into(),
    ),
    // Four address pins, one for each LCD
    // All of them will have the same output
    address: (
        gpiof.pf0.into(),
        gpioe.pe2.into(),
        gpioe.pe3.into(),
        gpiof.pf14.into(),
    ),
    read_enable: gpiod.pd4.into(),
    write_enable: gpiod.pd5.into(),
    // Four chip select pins, one for each LCD, controlled independently
    chip_select: (
        ChipSelect1::from(gpiod.pd7),
        ChipSelect2::from(gpiog.pg9),
        ChipSelect3::from(gpiog.pg10),
        ChipSelect4::from(gpiog.pg12),
    ),
};

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);
source

pub fn release(self, _lcds: PINS::Lcds) -> (FSMC, PINS)

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§

§

impl<PINS> RefUnwindSafe for FsmcLcd<PINS>
where PINS: RefUnwindSafe,

§

impl<PINS> Send for FsmcLcd<PINS>
where PINS: Send,

§

impl<PINS> !Sync for FsmcLcd<PINS>

§

impl<PINS> Unpin for FsmcLcd<PINS>
where PINS: Unpin,

§

impl<PINS> UnwindSafe for FsmcLcd<PINS>
where PINS: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.