Browse Source

endTransmission to only report success when all commands processed from fifo

main
PaulStoffregen 6 years ago
parent
commit
1c236b07a4
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      WireIMXRT.cpp

+ 7
- 2
WireIMXRT.cpp View File

//printf("NACK, f=%d, i=%d\n", port->MFSR & 0x07, i); //printf("NACK, f=%d, i=%d\n", port->MFSR & 0x07, i);
// TODO: check that hardware really sends stop automatically // TODO: check that hardware really sends stop automatically
port->MCR = LPI2C_MCR_MEN | LPI2C_MCR_RTF; // clear the FIFO port->MCR = LPI2C_MCR_MEN | LPI2C_MCR_RTF; // clear the FIFO
// TODO: is always sending a stop the right way to recover?
port->MTDR = LPI2C_MTDR_CMD_STOP;
return 2; // NACK for address return 2; // NACK for address
//return 3; // NACK for data TODO: how to discern addr from data? //return 3; // NACK for data TODO: how to discern addr from data?
} }


if (sendStop) { if (sendStop) {
if (status & LPI2C_MSR_SDF) { if (status & LPI2C_MSR_SDF) {
//printf("stop sent, msr=%x\n", status);
return 0;
// master automatically sends stop condition on some
// types of errors, so this flag only means success
// when all comments in fifo have been fully used
uint32_t fifo = port->MFSR & 0x07;
if (fifo == 0) return 0;
} }
} else { } else {
uint32_t fifo_used = port->MFSR & 0x07; // pg 2914 uint32_t fifo_used = port->MFSR & 0x07; // pg 2914

Loading…
Cancel
Save