Start adding 16-pin Sparkfun GPIO expander
This commit is contained in:
parent
5b39efb79d
commit
532ca8915f
29
src/main.rs
29
src/main.rs
@ -15,6 +15,7 @@ use esp_hal::{
|
||||
clock::CpuClock,
|
||||
delay::Delay,
|
||||
gpio::{Level, Output, OutputConfig},
|
||||
i2c::{self, master::I2c},
|
||||
interrupt::software::SoftwareInterruptControl,
|
||||
main,
|
||||
spi::master::{Config, Spi},
|
||||
@ -126,6 +127,34 @@ fn main() -> ! {
|
||||
.with_rx(peripherals.GPIO7)
|
||||
.with_tx(peripherals.GPIO8);
|
||||
|
||||
let mut i2c = I2c::new(
|
||||
peripherals.I2C0,
|
||||
i2c::master::Config::default().with_frequency(Rate::from_khz(400)),
|
||||
)
|
||||
.unwrap()
|
||||
.with_scl(peripherals.GPIO20)
|
||||
.with_sda(peripherals.GPIO22);
|
||||
|
||||
let mut i2c_rst = Output::new(peripherals.GPIO15, Level::High, OutputConfig::default());
|
||||
|
||||
let test_delay = Delay::new();
|
||||
|
||||
i2c_rst.set_low();
|
||||
test_delay.delay_millis(1000);
|
||||
i2c_rst.set_high();
|
||||
|
||||
log::info!("I2C reset");
|
||||
|
||||
let REG_INTERRUPT_MASK_A = 0x13;
|
||||
let default_address = 0x3e;
|
||||
|
||||
let write_buf = [REG_INTERRUPT_MASK_A];
|
||||
let mut read_buf = [0, 0];
|
||||
i2c.write_read(default_address, &write_buf, &mut read_buf)
|
||||
.unwrap();
|
||||
|
||||
log::info!("Read: {:?}", read_buf);
|
||||
|
||||
let mut at_commands = ATCommands::new(sim_rst, sim_pwr_key, uart);
|
||||
|
||||
let font_renderer = FontRenderer::create(30);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user