PCA9547 Support/Autodetect #87

Merged
sb10q merged 1 commits from mwojcik/zynq-rs:pca9547_support into master 2024-08-17 17:37:18 +08:00

View File

@ -6,6 +6,8 @@ use super::slcr;
use super::time::Microseconds; use super::time::Microseconds;
use embedded_hal::timer::CountDown; use embedded_hal::timer::CountDown;
use libregister::{RegisterR, RegisterRW, RegisterW}; use libregister::{RegisterR, RegisterRW, RegisterW};
#[cfg(feature = "target_kasli_soc")]
use log::info;
pub enum I2cMultiplexer { pub enum I2cMultiplexer {
PCA9548 = 0, PCA9548 = 0,
@ -163,8 +165,8 @@ impl I2c {
let config = self.read(false)?; let config = self.read(false)?;
let pca = match config { let pca = match config {
0x00 => I2cMultiplexer::PCA9548, 0x00 => { info!("PCA9548 detected"); I2cMultiplexer::PCA9548 },
0x08 => I2cMultiplexer::PCA9547, 0x08 => { info!("PCA9547 detected"); I2cMultiplexer::PCA9547 },
Outdated
Review

I suggest logging which chip was detected to help troubleshooting possible problems.

I suggest logging which chip was detected to help troubleshooting possible problems.
_ => { return Err("Unknown response for PCA954X autodetect")}, _ => { return Err("Unknown response for PCA954X autodetect")},
}; };
self.stop()?; self.stop()?;