Struct stm32f4xx_hal::fsmc_lcd::FsmcLcd
source · [−]pub struct FsmcLcd<PINS> { /* private fields */ }
Expand description
An FMC or FSMC configured as an LCD interface
Implementations
sourceimpl<PINS> FsmcLcd<PINS> where
PINS: Pins,
impl<PINS> FsmcLcd<PINS> where
PINS: Pins,
sourcepub fn new(
fsmc: FSMC,
pins: PINS,
read_timing: &Timing,
write_timing: &Timing
) -> (Self, PINS::Lcds)
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 Lcd
s,
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);
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more