Skip to content

Commit

Permalink
nxp_driver: Update the fsl_lpi2c.* files.
Browse files Browse the repository at this point in the history
Updated for MIMXRT1011, -1015, -1021, -1052, -1062, -1064 and .-1176
Tested with MIMXRT1011, -1021, -1052, -1062 and -1176
Lacking boards for testing MIMXRT1015 and -1064. But at least
the build is fine.
  • Loading branch information
robert-hh committed Jan 14, 2022
1 parent a180582 commit fa5a554
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 42 deletions.
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1011/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1015/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1021/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1052/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1062/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1064/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down
24 changes: 18 additions & 6 deletions sdk/devices/MIMXRT1176/drivers/fsl_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,21 +1065,33 @@ static status_t LPI2C_RunTransferStateMachine(LPI2C_Type *base, lpi2c_master_han

/* Check for errors. */
status = LPI2C_MasterGetStatusFlags(base);

/* Get fifo counts. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);

/* Get pointer to private data. */
xfer = &handle->transfer;

/* For the last byte, nack flag is expected.
Do not check and clear kLPI2C_MasterNackDetectFlag for the last byte,
in case FIFO is emptied when stop command has not been sent. */
if (handle->remainingBytes == 0U)
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
/* When data size is not zero which means it is not only one byte of address is sent, and */
/* when the txfifo is empty, or have one byte which is the stop command, then the nack status can be ignored. */
if ((xfer->dataSize != 0U) &&
((txCount == 0U) || ((txCount == 1U) && (handle->state == (uint8_t)kWaitForCompletionState) &&
((xfer->flags & (uint32_t)kLPI2C_TransferNoStopFlag) == 0U))))
{
status &= ~(uint32_t)kLPI2C_MasterNackDetectFlag;
}
}

result = LPI2C_MasterCheckAndClearError(base, status);

if (kStatus_Success == result)
{
/* Get pointer to private data. */
xfer = &handle->transfer;

/* Get fifo counts and compute room in tx fifo. */
LPI2C_MasterGetFifoCounts(base, &rxCount, &txCount);
/* Compute room in tx fifo */
txCount = txFifoSize - txCount;

while (!state_complete)
Expand Down

0 comments on commit fa5a554

Please sign in to comment.