diff --git a/Cargo.toml b/Cargo.toml index ab8517b..78f20ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ft6x06" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Shantanu Gaikwad"] categories = ["embedded", "no-std", "hardware-support"] diff --git a/src/lib.rs b/src/lib.rs index 4803c46..9417ab1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,8 @@ use heapless::Vec; use crate::constant::*; use core::marker::PhantomData; use embedded_hal as hal; -use hal::blocking::{delay::DelayMs, i2c}; +use hal::blocking::{delay::{DelayMs, DelayUs}, i2c}; +use hal::digital::v2::OutputPin; use rtt_target::rprintln; #[derive(Copy, Clone, Debug)] @@ -185,6 +186,27 @@ pub struct Ft6X06 { addr: u8, } +/// Perform a long hard reset, the FT66206 needs at least 5mS ... +// +// - On the STM32F413 the touchscreen shares the reset GPIO pin w/ the LCD. +// - The ST7789 driver uses a fast (10uS) reset. +// - The touchscreen controller needs 5mS: +// https://www.displayfuture.com/Display/datasheet/controller/FT6206.pdf +pub fn long_hard_reset<'a, RST, DELAY>( + rst: &'a mut RST, + delay: &'a mut DELAY, +) -> Result<(), &'a str> +where + RST: OutputPin, + DELAY: DelayUs, +{ + rst.set_low().map_err(|_| "rst.set_low failed")?; + delay.delay_us(10_000); + rst.set_high().map_err(|_| "rst.set_high failed")?; + + Ok(()) +} + impl Ft6X06 where I2C: i2c::WriteRead + i2c::Write,