reset the i2c machine every new transaction

This commit is contained in:
bunnie 2021-06-25 03:41:42 +08:00
parent f7874aab94
commit 6825e2e7e8
3 changed files with 4 additions and 4 deletions

View file

@ -553,7 +553,7 @@ fn imef_cb(s: String::<4000>) {
#[xous::xous_main]
fn xmain() -> ! {
log_server::init_wait().unwrap();
log::set_max_level(log::LevelFilter::Debug);
log::set_max_level(log::LevelFilter::Info);
info!("my PID is {}", xous::process::id());
let xns = xous_names::XousNames::new().unwrap();

View file

@ -157,8 +157,8 @@ impl I2cStateMachine {
self.state = I2cState::Idle;
self.index = 0;
// reset the block - this resest just the state machine and not the prescaler or interrupt enable configs
self.i2c_csr.wfo(utra::i2c::CORE_RESET_RESET, 1);
}
self.i2c_csr.wfo(utra::i2c::CORE_RESET_RESET, 1);
self.error = false;
self.timestamp = now;
self.transaction = transaction.clone();

View file

@ -552,10 +552,10 @@ fn i2c_thread(sid0: usize, sid1: usize, sid2: usize, sid3: usize) {
let sr_cid = xous::connect(i2c_sid).expect("couldn't create suspend callback connection");
let mut susres = susres::Susres::new(&xns, I2cOpcode::SuspendResume as u32, sr_cid).expect("couldn't create suspend/resume object");
log::trace!("starting main loop");
log::trace!("starting i2c main loop");
loop {
let mut msg = xous::receive_message(i2c_sid).unwrap();
log::trace!("Message: {:?}", msg);
log::trace!("i2c message: {:?}", msg);
match FromPrimitive::from_usize(msg.body.id()) {
Some(I2cOpcode::SuspendResume) => xous::msg_scalar_unpack!(msg, token, _, _, _, {
i2c.suspend();