This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5728: SPI burst read issue

Part Number: AM5728

Tool/software: Linux

Hi,

I am trying to read 188 bytes of data with bits_per_word=32 from FPGA board. But i am getting first 32 bits repeatedly upto 188 bytes. Moreover my chip select is getting high after reading first 32 bits. Actually my chip select should remain low until we read all 188 bytes of data. Please suggest a solution to remain my chip select as low & to read all 188 bytes of data.

My SPI burst read function is below,

cs = 0x08

addr = 0x01

len=188 bytes

 data_buf = buffer to which data is to be read.

ics_int32_t ics_mars_wvs_spi_burst_read(ics_int8_t cs, ics_uint32_t addr , ics_uint32_t len , ics_uint32_t *data_buf)
{
        ics_uint32_t header,i,read_dat[len];
        ics_uint8_t ret,ret1;
        struct spi_device *spi;

        /*Spi Header*/
        spi = (struct spi_device *)ptr;

        /*Spi Header*/
        header = (1 << 31)/*R/W*/ | (1 << 30)/*B/N*/ | (5 << 26)/*WF ID*/ | (cs << 21) /*CS*/ | (addr << 11) /* address*/ |((len & 0x3FF)<<1);  

        printk(KERN_ALERT "SPI READ LEN : %d\n",len);

        ret = spi_write(spi,&header, 4);
        if(ret)
        {
                printk(KERN_ALERT "SPI write error\n");
        }

        ret1 = spi_read(spi,(void *)read_dat, sizeof(read_dat));

        for(i=0; i < len ; i++)
        {
                printk(KERN_ALERT "SPI READ rx_buff DATA : %X\n",read_dat[i]);
                *(data_buf+i) = read_dat[i];
                printk(KERN_ALERT "SPI data to umac: %X\n",*(data_buf+i));
        }
        if(ret1)
        {
                printk(KERN_ALERT "SPI read error\n");
        }

       return 1;
}

Thanks,

Swapna G

  • Which version of the SDK are you using?

    Steve K.
  • SDK version is 02.00.01.07.

    My burst read function is implemented in spidev.c.

    Thanks,

    Swapna. G

  • Hi Sir,
    Please do help for the SPI burst read issue.

    Thanks
    swapna. G
  • That SDK is rather old. Can you try with the latest SDK?

    Steve K.
  • Hi,

    As we working on this version for customer requirement. So please suggest solution for SPI Burst read for our SDK version (02.00.01.07).

    here is the code, please let me know the problem in my code.

    SPI clk = 10MHz

    SPI mode =0

    bits per word = 32

    My SPI burst read function is below,

    lmac_mem = 0x08

    addr = 0x01

    len=188 bytes

     data_buf = buffer to which data is to be read.

    ics_int32_t ics_mars_wvs_spi_burst_read(ics_int8_t lmac_mem, ics_uint32_t addr , ics_uint32_t len , ics_uint32_t *data_buf)
    {
            ics_uint32_t header,i,read_dat[len];
            ics_uint8_t ret,ret1;
            struct spi_device *spi;

            /*Spi Header*/
            spi = (struct spi_device *)ptr;

            /*Spi Header*/
            header = (1 << 31)/*R/W*/ | (1 << 30)/*B/N*/ | (5 << 26)/*WF ID*/ | (lmac_mem << 21) /*lmac_mem*/ | (addr << 11) /* address*/ |((len & 0x3FF)<<1);  

            printk(KERN_ALERT "SPI READ LEN : %d\n",len);

            ret = spi_write(spi,&header, 4);
            if(ret)
            {
                    printk(KERN_ALERT "SPI write error\n");
            }

            ret1 = spi_read(spi,(void *)&read_dat, sizeof(read_dat));

            for(i=0; i < len ; i++)
            {
                    printk(KERN_ALERT "SPI READ rx_buff DATA : %X\n",read_dat[i]);
                    *(data_buf+i) = read_dat[i];
                    printk(KERN_ALERT "SPI data to umac: %X\n",*(data_buf+i));
            }
            if(ret1)
            {
                    printk(KERN_ALERT "SPI read error\n");
            }

           return 1;
    }

    Thanks,

    Swapna. G

  • Are you still having problems? The code looks like it should work.

    Steve K.
  • Hi Steve,

    Ya facing same issue regarding burst read.

    Thanks,

    Swapna

  • Where are you calling ics_mars_wvs_spi_burst_read?

    Steve K.
  • Hi Steve,

    We are calling ics_mars_wvs_spi_burst_read function in our UMAC driver as shown below,

    void ics_getrxReg_burst(unsigned int offset, unsigned int len, unsigned int * buf)
    {
    len = len >> 2;
    ics_mars_wvs_spi_burst_read(0x08, offset, len, buf); //////////// len=42 , buf = buffer to which data to be filled
    }

    ics_void ics_wlan_print_rxdata(ics_wlan_rx_status_info_t *st)
    {
    ics_uint32 mpdu[1000];
    ics_uint32 data, k, length;

    length = st->len;
    length = ((length+3)>>2)<<2;

    ics_getrxReg_burst(st->addr/4, (length + sizeof(ics_wlan_rx_frame_info_t)) , (unsigned int *)mpdu);
    }

    And moreover, my SPI burst WRITE, SPI single WRITE, SPI single READ are working fine.
    My problem is with only SPI burst READ.

    Thanks,
    Swapna. G
  • Do you still see the issue?

    Steve K.