Skip to content

Commit

Permalink
capsules: i2c_master: Relay Nak to userspace
Browse files Browse the repository at this point in the history
If we get a Nak we should relay that information to userspace so that it
is aware.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
alistair23 committed Jan 4, 2024
1 parent 69df3ab commit 1c5a3be
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions capsules/core/src/i2c_master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a, I: i2c::I2CMaster<'a>> SyscallDriver for I2CMasterDriver<'a, I> {
}

impl<'a, I: i2c::I2CMaster<'a>> i2c::I2CHwMasterClient for I2CMasterDriver<'a, I> {
fn command_complete(&self, buffer: &'static mut [u8], _status: Result<(), i2c::Error>) {
fn command_complete(&self, buffer: &'static mut [u8], status: Result<(), i2c::Error>) {
self.tx.take().map(|tx| {
self.apps.enter(tx.processid, |_, kernel_data| {
if let Some(read_len) = tx.read_len.take() {
Expand All @@ -205,7 +205,16 @@ impl<'a, I: i2c::I2CMaster<'a>> i2c::I2CHwMasterClient for I2CMasterDriver<'a, I
}

// signal to driver that tx complete
kernel_data.schedule_upcall(0, (0, 0, 0)).ok();
kernel_data
.schedule_upcall(
0,
(
kernel::errorcode::into_statuscode(status.map_err(|e| e.into())),
0,
0,
),
)
.ok();
})
});

Expand Down

0 comments on commit 1c5a3be

Please sign in to comment.