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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

452 次查看
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 项奖励
1 回复

318 次查看
danielchen
NXP TechSupport
NXP TechSupport

Hi Wolfgang:

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

Regards

Daniel

0 项奖励