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) { }