Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Access to the PIO in eCos

Altera_Forum
Honored Contributor II
972 Views

Hi. What is the best way to access the PIO in eCos. I would like access to led_pio and button_pio. I would have been nice to be able to make a program similar to count_binary, but I don't know how to get the interrupt in eCos, and we'll be using switches in our prosject so I think it's enough to just pull it.  

 

It's not possible to access the altera_avalon_pio_regs.h file from eCos is it? So it's not possible to write and read directly to and from the PIOs. 

 

I thought it could be nice to access the led_pio and button_pio as /dev/led_pio and /dev/button_pio and thus threat them as files in eCos. But I'm not sure how to do this. I have begone a little, as you can see from this package: altera_avalon_pio.zip (http://hovedprosjekter.hig.no/v2005/elektro/adc/ecos/altera_avalon_pio.zip). I think I got the basic functions right, but I'm not entierly sure how to make the devtab. And I'm not sure how to handle initialisation properly when the PIO can be without IRQ. If any of you could take a look and give me some advice, I'd be very happy. 

 

I wonder why there's no driver for the PIO in the eCos package. Is it so obvious and simple that they didn't think to include it or is it so difficult that they didn't bother to make it? 

 

Ole
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
252 Views

You can access the PIO regs file by just adding the following include paths to your compiler flags: 

 

-I'$(SOPC_KIT_NIOS2)'/components/altera_avalon_pio/inc -I$(PREFIX)/include/cyg/hal 

 

As far as how to connect to an interrupt, you seem to have answered your own question in the code you posted. You connect by making calls to the three functions: cyg_drv_interrupt_create(), cyg_drv_interrupt_attach(), and cyg_drv_interrupt_unmask(). Details on how to use these functions can be found in the eCos documentation. 

 

Whether you do this in a similar manner to the count_pio example, or write a full blown driver is up to you (although I might be inclined to go for the former). If you do want to create a DEVTAB entry, then take a look at: packages/devs/touch/arm/ipaq/current/src/ipaq_ts.c for a simple example (that's the IPAQ touch screen driver). 

 

Finally, in the spirit of open source development, if you do come up with anything that you’d like to make available to others, or maybe even see in the next release – please post it to this forum http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
0 Kudos
Reply