Browse Source

Only clear FIFOs when bus is idle

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

+ 4
- 2
WireIMXRT.cpp View File

//printf("m=%x\n", status); //printf("m=%x\n", status);


// Wonder if MFSR we should maybe clear it? // Wonder if MFSR we should maybe clear it?
if ( port->MFSR & 0x7) {
if ((port->MFSR & 0x7) &&
((port->MSR & (LPI2C_MSR_BBF|LPI2C_MSR_MBF)) != (LPI2C_MSR_BBF|LPI2C_MSR_MBF))) {
port->MCR = LPI2C_MCR_MEN | LPI2C_MCR_RTF; // clear the FIFO port->MCR = LPI2C_MCR_MEN | LPI2C_MCR_RTF; // clear the FIFO
port->MSR = LPI2C_MSR_PLTF | LPI2C_MSR_ALF | LPI2C_MSR_NDF | LPI2C_MSR_SDF | LPI2C_MSR_FEF; // clear flags port->MSR = LPI2C_MSR_PLTF | LPI2C_MSR_ALF | LPI2C_MSR_NDF | LPI2C_MSR_SDF | LPI2C_MSR_FEF; // clear flags
//printf("Clear TX Fifo %lx %lx\n", port->MSR, port->MFSR); //printf("Clear TX Fifo %lx %lx\n", port->MSR, port->MFSR);
//printf("MSR=%lX, MCR:%lx, MFSR=%lX\n", status, port->MCR, port->MFSR); //printf("MSR=%lX, MCR:%lx, MFSR=%lX\n", status, port->MCR, port->MFSR);


// Wonder if MFSR we should maybe clear it? // Wonder if MFSR we should maybe clear it?
if ( port->MFSR & 0x7) {
if ((port->MFSR & 0x7) &&
((port->MSR & (LPI2C_MSR_BBF|LPI2C_MSR_MBF)) != (LPI2C_MSR_BBF|LPI2C_MSR_MBF))) {
port->MCR = LPI2C_MCR_MEN | LPI2C_MCR_RTF; // clear the FIFO port->MCR = LPI2C_MCR_MEN | LPI2C_MCR_RTF; // clear the FIFO
port->MSR = LPI2C_MSR_PLTF | LPI2C_MSR_ALF | LPI2C_MSR_NDF | LPI2C_MSR_SDF | LPI2C_MSR_FEF; // clear flags port->MSR = LPI2C_MSR_PLTF | LPI2C_MSR_ALF | LPI2C_MSR_NDF | LPI2C_MSR_SDF | LPI2C_MSR_FEF; // clear flags
//printf("Clear TX Fifo %lx %lx\n", port->MSR, port->MFSR); //printf("Clear TX Fifo %lx %lx\n", port->MSR, port->MFSR);

Loading…
Cancel
Save