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.

using SPI with DMAC on AM3517

Other Parts Discussed in Thread: AM3517

Hi folks,

I am looking to setup an SPI interface between am3517 and an Atmel uC. I would like to use SPI with DMA request. How do i go about doing this? is it possible to do this from userspace or would i have to write a module? i am very confused. Any guidance would be helpful.

  • Please provide more details about the software you are using.

    Best regards,
    Miroslav

  • I am using AM3517 with TI SDK v05.07, Linux Kernel version 2.6.37. I have written example user space codes to run spi with spidev. 

    1) I would like to set up an SPI line with baud rate greater than 4M and service interrupts when I receive some data with spi on the dma receive channel from slave and based on certain states I would like to transfer 300 bytes of data as one block in one write cycle

    I read online that interrupts can be serviced only from kernel module / device drivers. How do i go about setting up interrupts for spi receive event on DMA? I know how to write simple hello world kernel modules and cross compile them for the kernel.

    2) Does the spidev automatically call omap2_mcspi.c which contains DMA requests and causes  DMA to be  automatically invoked when the size of my transfer exceeds a defined threshold or is that done by /drivers/spi/spi.c?

    Please find below code fragments on my implementation of read +write using spidev in user space

    ***********************my class SPI.ccp fragment***************************

    int Spi::spiWriteRead( unsigned char *data, int length){

    struct spi_ioc_transfer spi[length];
    int i = 0;
    int retVal = -1;

    // one spi transfer for each byte

    for (i = 0 ; i < length ; i++){

    spi[i].tx_buf = (unsigned long)(data + i); // transmit from "data"
    spi[i].rx_buf = (unsigned long)(data + i) ; // receive into "data"
    spi[i].len = sizeof(*(data + i)) ;
    spi[i].delay_usecs = 0 ;
    spi[i].speed_hz = this->speed ;
    spi[i].bits_per_word = this->bitsPerWord ;
    spi[i].cs_change = 0;
    }

    retVal = ioctl (this->spifd, SPI_IOC_MESSAGE(length), &spi) ;

    if(retVal < 0){
    perror("Problem transmitting spi data..ioctl");
    exit(1);
    }

    return retVal;

    }

    ***************************main.cpp*************************

    #include "Spi.h"

    using namespace std;

    int main(void)
    {
    Spi spi("/dev/spidev1.0", SPI_MODE_0, 5000000, 8);
    //Spi spi;
    int i = 6;
    unsigned char data[1];
    int rx_data=0;
    while(i > 0)
    {
    data[0] = 1;
    //data[1] = 'A';
    //data[2] = 0;

    spi.spiWriteRead(data, sizeof(data) );
    rx_data = (int)data[0];
    cout<<"the received data is:"<<rx_data<<endl;

    i--;
    }
    return 0;
    }

    Thanks alot for your help!