Skip to content

Commit

Permalink
Add last_abort_reason
Browse files Browse the repository at this point in the history
Fixes #1049
  • Loading branch information
peterharperuk committed Sep 25, 2024
1 parent d08f36c commit aa786a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rp2_common/hardware_i2c/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ static int i2c_write_blocking_internal(i2c_inst_t *i2c, uint8_t addr, const uint

// nostop means we are now at the end of a *message* but not the end of a *transfer*
i2c->restart_on_next = nostop;
i2c->last_abort_reason = abort_reason;
return rval;
}

Expand Down Expand Up @@ -278,7 +279,7 @@ static int i2c_read_blocking_internal(i2c_inst_t *i2c, uint8_t addr, uint8_t *ds

bool abort = false;
bool timeout = false;
uint32_t abort_reason;
uint32_t abort_reason = 0;
int byte_ctr;
int ilen = (int)len;
for (byte_ctr = 0; byte_ctr < ilen; ++byte_ctr) {
Expand Down Expand Up @@ -329,6 +330,7 @@ static int i2c_read_blocking_internal(i2c_inst_t *i2c, uint8_t addr, uint8_t *ds
}

i2c->restart_on_next = nostop;
i2c->last_abort_reason = abort_reason;
return rval;
}

Expand Down
1 change: 1 addition & 0 deletions src/rp2_common/hardware_i2c/include/hardware/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ void i2c_set_slave_mode(i2c_inst_t *i2c, bool slave, uint8_t addr);
struct i2c_inst {
i2c_hw_t *hw;
bool restart_on_next;
uint32_t last_abort_reason;
};

/**
Expand Down

0 comments on commit aa786a1

Please sign in to comment.