Skip to content

Commit 572b311

Browse files
committed
Fixed formatting to match existing style + Hardwire comments
1 parent 61b212d commit 572b311

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

STM32F1/cores/maple/libmaple/i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ void _i2c_irq_handler(i2c_dev *dev) {
349349
*/
350350
if (msg->length > 1) {
351351
i2c_write(dev, msg->data[msg->xferred++]);
352-
} else if (msg->length == 0){ /* We're just sending an address */
352+
} else if (msg->length == 0) { /* We're just sending an address */
353353
i2c_stop_condition(dev);
354354
/*
355355
* Turn off event interrupts to keep BTF from firing until

STM32F1/libraries/Wire/HardWire.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@
4141
uint8 HardWire::process() {
4242
int8 res = i2c_master_xfer(sel_hard, &itc_msg, 1, 0);
4343
if (res == I2C_ERROR_PROTOCOL) {
44-
if (sel_hard->error_flags & I2C_SR1_AF)
44+
if (sel_hard->error_flags & I2C_SR1_AF) { /* NACK */
4545
res = (sel_hard->error_flags & I2C_SR1_ADDR ? ENACKADDR :
46-
ENACKTRNS);
47-
else if (sel_hard->error_flags & I2C_SR1_OVR) res = EDATA;
48-
else res = EOTHER;
46+
ENACKTRNS);
47+
} else if (sel_hard->error_flags & I2C_SR1_OVR) { /* Over/Underrun */
48+
res = EDATA;
49+
} else { /* Bus or Arbitration error */
50+
res = EOTHER;
51+
}
4952
i2c_disable(sel_hard);
5053
i2c_master_enable(sel_hard, (I2C_BUS_RESET | dev_flags));
5154
}

0 commit comments

Comments
 (0)