Merge branch 'bunnie-dev' into main

This commit is contained in:
bunnie 2022-04-06 13:38:55 +08:00
commit f6131693ab

View file

@ -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::<I2cTransaction, _>().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) {
}