Skip to content

Commit a6efa0c

Browse files
committed
fsmc pins
1 parent 9edc558 commit a6efa0c

File tree

6 files changed

+294
-344
lines changed

6 files changed

+294
-344
lines changed

examples/display-touch.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use cortex_m;
1818
use cortex_m_rt::entry;
1919
use rtt_target::{rprintln, rtt_init_print};
2020
use stm32f4xx_hal::{
21-
fsmc_lcd::{FsmcLcd, LcdPins, Timing},
21+
fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing},
2222
gpio::Speed,
2323
pac,
2424
prelude::*,
@@ -67,33 +67,20 @@ fn main() -> ! {
6767

6868
// Pins connected to the LCD on the board
6969
use stm32f4xx_hal::gpio::alt::fsmc as alt;
70-
let lcd_pins = LcdPins {
71-
data: (
72-
gpiod.pd14.into(),
73-
gpiod.pd15.into(),
74-
gpiod.pd0.into(),
75-
gpiod.pd1.into(),
76-
gpioe.pe7.into(),
77-
gpioe.pe8.into(),
78-
gpioe.pe9.into(),
79-
gpioe.pe10.into(),
80-
gpioe.pe11.into(),
81-
gpioe.pe12.into(),
82-
gpioe.pe13.into(),
83-
gpioe.pe14.into(),
84-
gpioe.pe15.into(),
85-
gpiod.pd8.into(),
86-
gpiod.pd9.into(),
87-
gpiod.pd10.into(),
70+
let lcd_pins = LcdPins::new(
71+
DataPins16::new(
72+
gpiod.pd14, gpiod.pd15, gpiod.pd0, gpiod.pd1, gpioe.pe7, gpioe.pe8, gpioe.pe9,
73+
gpioe.pe10, gpioe.pe11, gpioe.pe12, gpioe.pe13, gpioe.pe14, gpioe.pe15, gpiod.pd8,
74+
gpiod.pd9, gpiod.pd10,
8875
),
89-
address: alt::Address::from(gpiof.pf0),
90-
read_enable: gpiod.pd4.into(),
91-
write_enable: gpiod.pd5.into(),
76+
alt::Address::from(gpiof.pf0),
77+
gpiod.pd4,
78+
gpiod.pd5,
9279
#[cfg(feature = "stm32f413")]
93-
chip_select: alt::ChipSelect3::from(gpiog.pg10),
80+
alt::ChipSelect3::from(gpiog.pg10),
9481
#[cfg(feature = "stm32f412")]
95-
chip_select: alt::ChipSelect1::from(gpiod.pd7),
96-
};
82+
alt::ChipSelect1::from(gpiod.pd7),
83+
);
9784

9885
// Enable backlight
9986
#[cfg(feature = "stm32f413")]

examples/f413disco-lcd-ferris.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rtt_target::{self, rtt_init_print};
1616
use stm32f4xx_hal as hal;
1717

1818
use crate::hal::{
19-
fsmc_lcd::{FsmcLcd, LcdPins, Timing},
19+
fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing},
2020
gpio::Speed,
2121
pac::{CorePeripherals, Peripherals},
2222
prelude::*,
@@ -710,30 +710,17 @@ fn main() -> ! {
710710

711711
// Define the pins we need for our 16bit parallel bus
712712
use stm32f4xx_hal::gpio::alt::fsmc as alt;
713-
let lcd_pins = LcdPins {
714-
data: (
715-
gpiod.pd14.into(),
716-
gpiod.pd15.into(),
717-
gpiod.pd0.into(),
718-
gpiod.pd1.into(),
719-
gpioe.pe7.into(),
720-
gpioe.pe8.into(),
721-
gpioe.pe9.into(),
722-
gpioe.pe10.into(),
723-
gpioe.pe11.into(),
724-
gpioe.pe12.into(),
725-
gpioe.pe13.into(),
726-
gpioe.pe14.into(),
727-
gpioe.pe15.into(),
728-
gpiod.pd8.into(),
729-
gpiod.pd9.into(),
730-
gpiod.pd10.into(),
713+
let lcd_pins = LcdPins::new(
714+
DataPins16::new(
715+
gpiod.pd14, gpiod.pd15, gpiod.pd0, gpiod.pd1, gpioe.pe7, gpioe.pe8, gpioe.pe9,
716+
gpioe.pe10, gpioe.pe11, gpioe.pe12, gpioe.pe13, gpioe.pe14, gpioe.pe15, gpiod.pd8,
717+
gpiod.pd9, gpiod.pd10,
731718
),
732-
address: alt::Address::from(gpiof.pf0),
733-
read_enable: gpiod.pd4.into(),
734-
write_enable: gpiod.pd5.into(),
735-
chip_select: alt::ChipSelect3::from(gpiog.pg10),
736-
};
719+
alt::Address::from(gpiof.pf0),
720+
gpiod.pd4,
721+
gpiod.pd5,
722+
alt::ChipSelect3::from(gpiog.pg10),
723+
);
737724

738725
// Setup the RESET pin
739726
let rst = gpiob.pb13.into_push_pull_output().speed(Speed::VeryHigh);

examples/st7789-lcd.rs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use embedded_graphics::prelude::*;
3030

3131
use embedded_graphics::primitives::{Circle, PrimitiveStyle};
3232
use st7789::ST7789;
33-
use stm32f4xx_hal::fsmc_lcd::{FsmcLcd, LcdPins, Timing};
33+
use stm32f4xx_hal::fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing};
3434
use stm32f4xx_hal::pac::{CorePeripherals, Peripherals};
3535
use stm32f4xx_hal::prelude::*;
3636

@@ -51,30 +51,17 @@ fn main() -> ! {
5151

5252
// Pins connected to the LCD on the 32F412GDISCOVERY board
5353
use stm32f4xx_hal::gpio::alt::fsmc as alt;
54-
let lcd_pins = LcdPins {
55-
data: (
56-
gpiod.pd14.into(),
57-
gpiod.pd15.into(),
58-
gpiod.pd0.into(),
59-
gpiod.pd1.into(),
60-
gpioe.pe7.into(),
61-
gpioe.pe8.into(),
62-
gpioe.pe9.into(),
63-
gpioe.pe10.into(),
64-
gpioe.pe11.into(),
65-
gpioe.pe12.into(),
66-
gpioe.pe13.into(),
67-
gpioe.pe14.into(),
68-
gpioe.pe15.into(),
69-
gpiod.pd8.into(),
70-
gpiod.pd9.into(),
71-
gpiod.pd10.into(),
54+
let lcd_pins = LcdPins::new(
55+
DataPins16::new(
56+
gpiod.pd14, gpiod.pd15, gpiod.pd0, gpiod.pd1, gpioe.pe7, gpioe.pe8, gpioe.pe9,
57+
gpioe.pe10, gpioe.pe11, gpioe.pe12, gpioe.pe13, gpioe.pe14, gpioe.pe15, gpiod.pd8,
58+
gpiod.pd9, gpiod.pd10,
7259
),
73-
address: alt::Address::from(gpiof.pf0),
74-
read_enable: gpiod.pd4.into(),
75-
write_enable: gpiod.pd5.into(),
76-
chip_select: alt::ChipSelect1::from(gpiod.pd7),
77-
};
60+
alt::Address::from(gpiof.pf0),
61+
gpiod.pd4,
62+
gpiod.pd5,
63+
alt::ChipSelect1::from(gpiod.pd7),
64+
);
7865
let lcd_reset = gpiod.pd11.into_push_pull_output();
7966
let backlight_control = gpiof.pf5.into_push_pull_output();
8067

src/fsmc_lcd/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ mod timing;
6565

6666
use core::marker::PhantomData;
6767

68-
pub use self::pins::{AddressPins, ChipSelectPins, DataPins, LcdPins, Pins};
68+
pub use self::pins::{AddressPins, ChipSelectPins, DataPins, DataPins16, LcdPins, Pins};
6969
pub use self::timing::{AccessMode, Timing};
7070

7171
use crate::rcc::{Enable, Reset};
@@ -390,6 +390,13 @@ pub struct Lcd<S> {
390390
/// S determines the chip select signal to use, and the addresses used with that signal.
391391
_sub_bank: PhantomData<S>,
392392
}
393+
impl<S> Lcd<S> {
394+
fn new() -> Self {
395+
Self {
396+
_sub_bank: PhantomData,
397+
}
398+
}
399+
}
393400

394401
impl<S> Lcd<S>
395402
where

0 commit comments

Comments
 (0)