[beagleboard] SPI with DMA
Hi Folks, I have recently decided to learn embedded linux development and I am currently working on a project to use the SPI on Beagle Bone to transfer 64+bytes of data as one block in one write cycle to an Atmel SAM 32 bit uC. I would like to use DMA with the SPI and I have read online that this is not possible from user space with spidev. I came across omap2_mcspi.c driver and I noticed that this has dma functions in it. I would like to enable two DMA channels(tx and rx) to provide and receive data from the respective registers on the SPI. Could someone guide as to how I am to go about using omap2_mcspi? Would i need to make a module? Thanks! -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[beagleboard] Re: SPI with DMA
I'm using BeagleBone with AM3517 and Linux kernel version: 2.6.37 On Tuesday, August 19, 2014 5:00:24 PM UTC+1, Siddarth Sharma wrote: > > Hi Folks, > > I have recently decided to learn embedded linux development and I am > currently working on a project to use the SPI on Beagle Bone to transfer > 64+bytes of data as one block in one write cycle to an Atmel SAM 32 bit uC. > I would like to use DMA with the SPI and I have read online that this is > not possible from user space with spidev. I came across omap2_mcspi.c > driver and I noticed that this has dma functions in it. I would like to > enable two DMA channels(tx and rx) to provide and receive data from the > respective registers on the SPI. Could someone guide as to how I am to go > about using omap2_mcspi? Would i need to make a module? > > Thanks! > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beagleboard] Re: SPI with DMA
Sorry, its the AM335x On Tue, Aug 19, 2014 at 5:04 PM, Robert Nelson wrote: > On Tue, Aug 19, 2014 at 11:02 AM, Siddarth Sharma > wrote: > > I'm using BeagleBone with AM3517 and Linux kernel version: 2.6.37 > > are you sure? > > Regards, > > -- > Robert Nelson > http://www.rcn-ee.com/ > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to a topic in the > Google Groups "BeagleBoard" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/beagleboard/ZtfEPoACcXE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > beagleboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [beagleboard] Re: SPI with DMA
Hi John, Attached is my user space code to transmit 1 byte of data stored in buffer - data using spidev. Would this then call dma controller automatically if i increase the size of my buffer data to 64 bytes? Also, I want to setup a interrupt handler that gets called when data is received or transmitted by the dma. How do i do this? Thanks! On Tue, Aug 19, 2014 at 5:19 PM, John Syn wrote: > > From: Siddarth Sharma > Reply-To: "beagleboard@googlegroups.com" > Date: Tuesday, August 19, 2014 at 9:02 AM > To: "beagleboard@googlegroups.com" > Subject: [beagleboard] Re: SPI with DMA > > I'm using BeagleBone with AM3517 and Linux kernel version: 2.6.37 > > BeagleBone use AM3359 or AM3358 processors. When using the mcspi driver, > DMA is automatically invoked when the size of your transfer exceeds a > defined threshold which you will find in the mcspi driver. If you want to > see how this is done, look at examples of SPI drivers in the /drivers/iio > or /drivers/staging/iio folder. BTW, you don’t invoke the mcspi driver > functions directly. Instead you use the generic linux SPI functions which > in turn call the mcspi functions. Read the /Documentation/spi docs. > > Regards, > John > > > > On Tuesday, August 19, 2014 5:00:24 PM UTC+1, Siddarth Sharma wrote: >> >> Hi Folks, >> >> I have recently decided to learn embedded linux development and I am >> currently working on a project to use the SPI on Beagle Bone to transfer >> 64+bytes of data as one block in one write cycle to an Atmel SAM 32 bit uC. >> I would like to use DMA with the SPI and I have read online that this is >> not possible from user space with spidev. I came across omap2_mcspi.c >> driver and I noticed that this has dma functions in it. I would like to >> enable two DMA channels(tx and rx) to provide and receive data from the >> respective registers on the SPI. Could someone guide as to how I am to go >> about using omap2_mcspi? Would i need to make a module? >> >> Thanks! >> > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to the Google Groups > "BeagleBoard" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to beagleboard+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > For more options, visit http://beagleboard.org/discuss > --- > You received this message because you are subscribed to a topic in the > Google Groups "BeagleBoard" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/beagleboard/ZtfEPoACcXE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > beagleboard+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. /* * main.cpp * * Created on: 4 Aug 2014 * Author: siddharth */ #include "Spi.h" using namespace std; int main(void) { Spi spi("/dev/spidev1.0", SPI_MODE_0, 500, 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:"</* * Spi.cpp * * Created on: 4 Aug 2014 * Author: siddharth */ #include "Spi.h" #include using namespace std; int Spi::spiOpen(std::string devspi){ int statusVal = -1; this->spifd = open(devspi.c_str(), O_RDWR); if(this->spifd < 0){ perror("could not open SPI device"); exit(1); } statusVal = ioctl (this->spifd, SPI_IOC_WR_MODE, &(this->mode)); if(statusVal < 0){ perror("Could not set SPIMode (WR)...ioctl fail"); exit(1); } statusVal = ioctl (this->spifd, SPI_IOC_RD_MODE, &(this->mode)); if(statusVal < 0) { perror("Could not set SPIMode (RD)...ioctl fail"); exit(1); } statusVal = ioctl (this->spifd, SPI_IOC_WR_BITS_PER_WORD, &(this->bitsPerWord)); if(statusVal < 0) { perror("Could not set SPI bitsPerWord (WR)...ioctl fail"); exit(1); } statusVal = ioctl (this->spifd, SPI_IOC_RD_BITS_PER_WORD, &(t
[beagleboard] detecting interrupt on GPIO in kernel module
I am toggling the input into a GPIO line on my BeagleBone from high to low every 500 ms using an Atmel uC. I have registered a handler for this in my Linux Kernel Module, but the handler is not being called for some reason. My module code is - #define GPIO 54 #define GPIO_INT_NAME "gpio_int" #define GPIO_HIGH gpio_get_value(GPIO) #define GPIO_LOW (gpio_get_value(GPIO) == 0) short int irq_any_gpio= 0; int count =0; enum { falling, rising } type; static irqreturn_t r_irq_handler(int irq, void *dev_id) { count++; printk(KERN_DEBUG "interrupt received (irq: %d)\n", irq); if (irq == gpio_to_irq(GPIO)) { type = GPIO_LOW ? falling : rising; if(type == falling) { printk("gpio pin is low\n"); } else printk("gpio pin is high\n"); } return IRQ_HANDLED; } void r_int_config(void) { if (gpio_request(GPIO, GPIO_INT_NAME )) { printk("GPIO request failure: %s\n", GPIO_INT_NAME ); return; } if ( (irq_any_gpio = gpio_to_irq(GPIO)) < 0 ) { printk("GPIO to IRQ mapping failure %s\n",GPIO_INT_NAME ); return; } printk(KERN_NOTICE "Mapped int %d\n", irq_any_gpio); if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) { printk("Irq Request failure\n"); return; } return; } void r_int_release(void) { free_irq(gpio_to_irq(GPIO), NULL); gpio_free(GPIO);; return; } int init_module(void) { printk("<1>Hello World\n"); r_int_config(); return 0; } On calling insmod interrupt_test.ko, i get the following message [ 76.594543] Hello World [ 76.597137] Mapped int 214 But now when I start toggling the input into this gpio pin, the interrupt handler doesn't get called and the message - "interrupt received" is not being displayed. How do I solve this ? What's causing the problem? -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[beagleboard] Re: detecting interrupt on GPIO in kernel module
Does the problem have something to do with dev id paramter in the interrupt handler? On Tuesday, August 26, 2014 3:08:01 PM UTC+1, Siddarth Sharma wrote: > > I am toggling the input into a GPIO line on my BeagleBone from high to low > every 500 ms using an Atmel uC. I have registered a handler for this in my > Linux Kernel Module, but the handler is not being called for some reason. > > My module code is - > > #define GPIO 54 > #define GPIO_INT_NAME "gpio_int" > > #define GPIO_HIGH gpio_get_value(GPIO) > #define GPIO_LOW (gpio_get_value(GPIO) == 0) > short int irq_any_gpio= 0; > int count =0; > > enum { falling, rising } type; > static irqreturn_t r_irq_handler(int irq, void *dev_id) > { > count++; > printk(KERN_DEBUG "interrupt received (irq: %d)\n", irq); > if (irq == gpio_to_irq(GPIO)) > { > > type = GPIO_LOW ? falling : rising; > > if(type == falling) > { > printk("gpio pin is low\n"); > } > else > printk("gpio pin is high\n"); > > } > > return IRQ_HANDLED; > } > > > void r_int_config(void) { > >if (gpio_request(GPIO, GPIO_INT_NAME )) >{ > printk("GPIO request failure: %s\n", GPIO_INT_NAME ); > return; >} > >if ( (irq_any_gpio = gpio_to_irq(GPIO)) < 0 ) { > printk("GPIO to IRQ mapping failure %s\n",GPIO_INT_NAME ); > return; >} > >printk(KERN_NOTICE "Mapped int %d\n", irq_any_gpio); > >if (request_irq(irq_any_gpio,(irq_handler_t ) r_irq_handler, > IRQF_TRIGGER_HIGH, GPIO_INT_NAME, NULL)) >{ > printk("Irq Request failure\n"); > return; >} > >return; > } > > void r_int_release(void) { > >free_irq(gpio_to_irq(GPIO), NULL); > gpio_free(GPIO);; >return; > } > > int init_module(void) > { > printk("<1>Hello World\n"); > r_int_config(); > return 0; > } > > On calling insmod interrupt_test.ko, i get the following message > > [ 76.594543] Hello World > > [ 76.597137] Mapped int 214 > > But now when I start toggling the input into this gpio pin, the interrupt > handler doesn't get called and the message - "interrupt received" is not > being displayed. > > How do I solve this ? What's causing the problem? > -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.