Split reset for primary and secondary displays
This commit is contained in:
+14
-2
@@ -28,7 +28,7 @@ use embedded_hal_bus::i2c::AtomicDevice;
|
|||||||
use embedded_hal_bus::util::AtomicCell;
|
use embedded_hal_bus::util::AtomicCell;
|
||||||
use esp_hal::Blocking;
|
use esp_hal::Blocking;
|
||||||
use esp_hal::clock::CpuClock;
|
use esp_hal::clock::CpuClock;
|
||||||
use esp_hal::gpio::{Input, InputConfig, Pull};
|
use esp_hal::gpio::{Input, InputConfig, Level, Output, OutputConfig, Pull};
|
||||||
use esp_hal::i2c::master::{Config as I2cConfig, I2c};
|
use esp_hal::i2c::master::{Config as I2cConfig, I2c};
|
||||||
use esp_hal::timer::timg::TimerGroup;
|
use esp_hal::timer::timg::TimerGroup;
|
||||||
use log::error;
|
use log::error;
|
||||||
@@ -72,10 +72,22 @@ async fn main(spawner: Spawner) {
|
|||||||
peripherals.GPIO37, // miso
|
peripherals.GPIO37, // miso
|
||||||
peripherals.GPIO11, // primary cs
|
peripherals.GPIO11, // primary cs
|
||||||
peripherals.GPIO13, // oled cs
|
peripherals.GPIO13, // oled cs
|
||||||
peripherals.GPIO10, // shared reset
|
peripherals.GPIO10, // primary reset
|
||||||
|
peripherals.GPIO47, // secondary reset
|
||||||
peripherals.GPIO12, // shared dc
|
peripherals.GPIO12, // shared dc
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
let _secondary_oled_cs_2 = Output::new(
|
||||||
|
peripherals.GPIO14,
|
||||||
|
Level::High,
|
||||||
|
OutputConfig::default(),
|
||||||
|
);
|
||||||
|
let _secondary_oled_cs_3 = Output::new(
|
||||||
|
peripherals.GPIO21,
|
||||||
|
Level::High,
|
||||||
|
OutputConfig::default(),
|
||||||
|
);
|
||||||
|
|
||||||
let config = I2cConfig::default().with_frequency(esp_hal::time::Rate::from_khz(400));
|
let config = I2cConfig::default().with_frequency(esp_hal::time::Rate::from_khz(400));
|
||||||
let i2c = match I2c::new(peripherals.I2C0, config) {
|
let i2c = match I2c::new(peripherals.I2C0, config) {
|
||||||
Ok(bus) => bus
|
Ok(bus) => bus
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use crate::display::primary_lcd::{PrimaryLcdDisplay, init_primary_lcd_on_bus};
|
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||||
use embedded_hal::digital::ErrorType;
|
use embedded_hal::digital::ErrorType;
|
||||||
@@ -12,6 +11,7 @@ use esp_hal::spi::master::{Config as SpiConfig, Spi};
|
|||||||
use esp_hal::time::Rate;
|
use esp_hal::time::Rate;
|
||||||
|
|
||||||
use crate::display::secondary_oled::{SecondaryOledDisplay, init_secondary_oled_on_bus};
|
use crate::display::secondary_oled::{SecondaryOledDisplay, init_secondary_oled_on_bus};
|
||||||
|
use crate::display::primary_lcd::{PrimaryLcdDisplay, init_primary_lcd_on_bus};
|
||||||
|
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
use embassy_sync::blocking_mutex::Mutex as BlockingMutex;
|
use embassy_sync::blocking_mutex::Mutex as BlockingMutex;
|
||||||
@@ -52,14 +52,15 @@ pub type DualPrimaryDisplay<'a> =
|
|||||||
pub type DualSecondaryDisplay<'a> =
|
pub type DualSecondaryDisplay<'a> =
|
||||||
SecondaryOledDisplay<'a, DisplaySpiBus, SharedPin<'a, Output<'a>>, SharedPin<'a, Output<'a>>>;
|
SecondaryOledDisplay<'a, DisplaySpiBus, SharedPin<'a, Output<'a>>, SharedPin<'a, Output<'a>>>;
|
||||||
|
|
||||||
pub fn init_dual_displays<SPI, SCK, MOSI, MISO, CS1, CS2, RES, DC>(
|
pub fn init_dual_displays<SPI, SCK, MOSI, MISO, CS1, CS2, RES1, RES2, DC>(
|
||||||
spi_peripheral: SPI,
|
spi_peripheral: SPI,
|
||||||
sck: SCK,
|
sck: SCK,
|
||||||
mosi: MOSI,
|
mosi: MOSI,
|
||||||
miso: MISO,
|
miso: MISO,
|
||||||
cs_primary: CS1,
|
cs_primary: CS1,
|
||||||
cs_secondary: CS2,
|
cs_secondary: CS2,
|
||||||
reset_pin: RES,
|
reset_primary: RES1,
|
||||||
|
reset_secondary: RES2,
|
||||||
dc_pin: DC,
|
dc_pin: DC,
|
||||||
) -> (DualPrimaryDisplay<'static>, DualSecondaryDisplay<'static>)
|
) -> (DualPrimaryDisplay<'static>, DualSecondaryDisplay<'static>)
|
||||||
where
|
where
|
||||||
@@ -69,7 +70,8 @@ where
|
|||||||
MISO: PeripheralInput<'static>,
|
MISO: PeripheralInput<'static>,
|
||||||
CS1: OutputPin + 'static,
|
CS1: OutputPin + 'static,
|
||||||
CS2: OutputPin + 'static,
|
CS2: OutputPin + 'static,
|
||||||
RES: OutputPin + 'static,
|
RES1: OutputPin + 'static,
|
||||||
|
RES2: OutputPin + 'static,
|
||||||
DC: OutputPin + 'static,
|
DC: OutputPin + 'static,
|
||||||
{
|
{
|
||||||
let spi = Spi::new(
|
let spi = Spi::new(
|
||||||
@@ -84,15 +86,17 @@ where
|
|||||||
.with_miso(miso);
|
.with_miso(miso);
|
||||||
|
|
||||||
let bus_static: &'static AtomicCell<_> = Box::leak(Box::new(AtomicCell::new(spi)));
|
let bus_static: &'static AtomicCell<_> = Box::leak(Box::new(AtomicCell::new(spi)));
|
||||||
let reset_static =
|
let reset_primary_static =
|
||||||
SharedPin::pre_wrap(Output::new(reset_pin, Level::High, OutputConfig::default()));
|
SharedPin::pre_wrap(Output::new(reset_primary, Level::High, OutputConfig::default()));
|
||||||
|
let reset_secondary_static =
|
||||||
|
SharedPin::pre_wrap(Output::new(reset_secondary, Level::High, OutputConfig::default()));
|
||||||
let dc_static = SharedPin::pre_wrap(Output::new(dc_pin, Level::High, OutputConfig::default()));
|
let dc_static = SharedPin::pre_wrap(Output::new(dc_pin, Level::High, OutputConfig::default()));
|
||||||
let mut delay = Delay::new();
|
let mut delay = Delay::new();
|
||||||
|
|
||||||
let primary = init_primary_lcd_on_bus(
|
let primary = init_primary_lcd_on_bus(
|
||||||
bus_static,
|
bus_static,
|
||||||
cs_primary,
|
cs_primary,
|
||||||
SharedPin::new(reset_static),
|
SharedPin::new(reset_primary_static),
|
||||||
SharedPin::new(dc_static),
|
SharedPin::new(dc_static),
|
||||||
&mut delay,
|
&mut delay,
|
||||||
);
|
);
|
||||||
@@ -100,7 +104,7 @@ where
|
|||||||
let secondary = init_secondary_oled_on_bus(
|
let secondary = init_secondary_oled_on_bus(
|
||||||
bus_static,
|
bus_static,
|
||||||
cs_secondary,
|
cs_secondary,
|
||||||
SharedPin::new(reset_static),
|
SharedPin::new(reset_secondary_static),
|
||||||
SharedPin::new(dc_static),
|
SharedPin::new(dc_static),
|
||||||
&mut delay,
|
&mut delay,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user