浏览代码

Only clear FIFOs when bus is idle

main
PaulStoffregen 5 年前
父节点
当前提交
6c9fec1699
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. +4
    -2
      WireIMXRT.cpp

+ 4
- 2
WireIMXRT.cpp 查看文件

@@ -132,7 +132,8 @@ uint8_t TwoWire::endTransmission(uint8_t sendStop)
//printf("m=%x\n", status);

// 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->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);
@@ -232,7 +233,8 @@ uint8_t TwoWire::requestFrom(uint8_t address, uint8_t length, uint8_t sendStop)
//printf("MSR=%lX, MCR:%lx, MFSR=%lX\n", status, port->MCR, port->MFSR);

// 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->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);

正在加载...
取消
保存