From 1b25f4c11d68e45ab5c83443cf7402af57848f62 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 6 Apr 2022 13:38:44 +0800 Subject: [PATCH] fix hosted mode --- services/llio/src/i2c/hosted.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/services/llio/src/i2c/hosted.rs b/services/llio/src/i2c/hosted.rs index 3e5e28fbc..8ac8da341 100644 --- a/services/llio/src/i2c/hosted.rs +++ b/services/llio/src/i2c/hosted.rs @@ -10,8 +10,23 @@ impl I2cStateMachine { } pub fn suspend(&mut self) {} pub fn resume(&mut self) {} - pub fn initiate(&mut self, _transaction: I2cTransaction) -> I2cStatus { - I2cStatus::ResponseInProgress + pub fn initiate(&mut self, mut msg: xous::MessageEnvelope) { + let mut buffer = unsafe { xous_ipc::Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) }; + let transaction = buffer.to_original::().unwrap(); + let response = if transaction.rxbuf.is_some() { + I2cResult { + rxbuf: [0u8; I2C_MAX_LEN], + rxlen: transaction.rxbuf.unwrap().len() as u32, + status: I2cStatus::ResponseReadOk, + } + } else { + I2cResult { + rxbuf: [0u8; I2C_MAX_LEN], + rxlen: 0, + status: I2cStatus::ResponseWriteOk, + } + }; + buffer.replace(response).unwrap(); } pub fn report_write_done(&mut self) { }