Bug in SPI_MasterTransferGetCount() fsl_spi.c from SDK_2.2_FRDM-KL25Z

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in SPI_MasterTransferGetCount() fsl_spi.c from SDK_2.2_FRDM-KL25Z

274 Views
Q_man
NXP Employee
NXP Employee

Hi,

I'm using the SPI_MasterTransfereGetCount() function to detect when a none-blocking transfer is completed:

  

/* transfere a block of data */
SPI_MasterTransferNonBlocking(BCC_SPI_SPI_BASE, &spi_master_handle, &xfer);   

/* Wait until transfer is finished. */   
while ( (kStatus_NoTransferInProgress != SPI_MasterTransferGetCount(BCC_SPI_SPI_BASE, &spi_master_handle, &count)) && (timeout > 0U))    
{   
     timeout--;    
}‍‍‍‍‍

Debugging the problem I found that the following line is incorrect:

status_t SPI_MasterTransferGetCount(SPI_Type *base, spi_master_handle_t *handle, size_t *count)
{
    assert(handle);
    status_t status = kStatus_Success;

//    if (handle->state != kStatus_SPI_Busy)    /* wrong */
    if (handle->state != kSPI_Busy)    /* correct */
    {
        status = kStatus_NoTransferInProgress;    
    }
    else    
    {        /* Return remaing bytes in different cases */        
        if (handle->rxData)
        {
            *count = handle->transferSize - handle->rxRemainingBytes;
        }
        else
        {
            *count = handle->transferSize - handle->txRemainingBytes;
        }
    }
    return status;
}‍‍‍‍‍‍‍‍‍
0 Kudos
1 Reply

140 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Wolfgang:

Thanks for your feedback and I will issue a internal ticket to software team.

Regards

Daniel

0 Kudos