AnsweredAssumed Answered

MQX: How SPI driver Tx/Rx questions

Question asked by Hui Shao on Mar 27, 2015
Latest reply on Apr 1, 2015 by Hui Shao

Hi-

 

I just upgraded my SPI driver to MQX4.1.1 from legacy SPI driver from MQX3.8.

 

When I debugging through the failure when calling function fread() in my application, I noticed that function _dspi_tx_rx() inside spi_dspi.c:

 

data = dspi_info_ptr->DUMMY_PATTERN;

...

    else
    {
        rx_len = tx_len = len;

        /* Optimized loop for single byte frames */
        while (rx_len)
        {
            if (tx_len) {
                if ((dspi_ptr->SR & DSPI_SR_TFFF_MASK) && ((rx_len-tx_len)<DSPI_FIFO_DEPTH))
                {
                    if (txbuf)
                        data = *txbuf++;
                    dspi_ptr->PUSHR = DSPI_PUSHR_TXDATA(data);
                    dspi_ptr->SR = DSPI_SR_TFFF_MASK;
                    tx_len--;

...

 

The data above is supposed to hold the dummy pattern to be sent out when fread() is called. However, it is never used in this function. Can someone tell me why and how to make dummy pattern work? Actually fread() will call _io_spi_read_write(fd_ptr, NULL, data_ptr, n); in which Tx buffer is set to NULL and in this function:

 

if ((wrbuf == NULL) && (dev_data->FLAGS & SPI_FLAG_FULL_DUPLEX))
{
wrbuf = rdbuf;
}

 

wrbuf is made share same buffer with rdbuf. Seems like half-duplex in MQX3.8 is not supported anymore (by _dspi_polled_rx())?.

 

In addition, no matter what value I set to DSPI_FIFO_DEPTH, I can't get ISR to run. The code in _dspi_tx_rx() simply works in polling mode. How can I enable interrupt mode?


Thanks!


Hui

Outcomes