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++
12745 Discussions

How can i handle the pio in uclinux?

Altera_Forum
Honored Contributor II
1,280 Views

I have upload the kernal and filesystem to flash,and the kernal runs very well.Then i build the example 'hello world',it runs very well too. 

 

Now i want to handle the PIO in uclinux,like 'hello led' in nios IDE,i make an application project ,but i can't use the API that ALTERA have provided, like IOWR_ALTERA_AVALON_PIO_DATA(LED_BASE, led).How can i do with it. 

 

On the other hand,can any one tell me where can i download the nios-elf-tools(cross compile tool)in the linux. 

 

Thanks.
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
590 Views

you can best use the inl outl or inb outb macro's in linux for accessing the GPIO. 

 

for the crosscompiler you can look for marc&#39;s one but I believe hissite is down at the moment http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif
0 Kudos
Altera_Forum
Honored Contributor II
590 Views

 

--- Quote Start ---  

originally posted by wgoossens@Dec 14 2005, 06:41 PM 

you can best use the inl outl or inb outb macro&#39;s in linux for accessing the gpio. 

 

for the crosscompiler you can look for marc&#39;s one but i believe hissite is down at the moment http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/sad.gif  

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11537) 

--- quote end ---  

 

--- Quote End ---  

 

 

Thanks! 

 

Can you tell me more about inl outl .....
0 Kudos
Altera_Forum
Honored Contributor II
590 Views

try:# man inl 

or# man outl 

.... 

 

 

it basicaly reads a long (inl) or a byte (inb) from the port you pass as an argument or writes a long (outl) or a byte (outb). 

for example: 

 

outb(inb(GPIO1),GPIO2); 

 

where GPIO1 and GPIO2 are defined as base-addresses of your GPIO components. 

 

reads a byte from the base address of one GPIO and outputs this no a second GPIO.
0 Kudos
Altera_Forum
Honored Contributor II
590 Views

In the header file...../bin/eclipse/plugins/com.microtronix.nios2linux.kernel_1.4.0/linux-2.6.x/include/asm-nios2nommu/io.h 

There are # define writew(b,addr)  

({  

__asm__ __volatile__(  

"sthio %0, 0(%1)"  

: : "r"(http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/cool.gif , "r" (addr));  

}) 

and other application like this.But in my Application Project,when i use writew or other application that has defined in the io.h,there are error undefined reference to `writew&#39;,I have include the header file like this# <asm/io.h>.Can anyone tell me why. 

 

 

Thanks. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif
0 Kudos
Altera_Forum
Honored Contributor II
590 Views

> there are error undefined reference to `writew&#39;,I have include the header file like 

> this# <asm/io.h>.Can anyone tell me why. 

 

__KERNEL__ must be defined. If you define this for an application, you&#39;ll likely pull in 

other definitions that will cause compile-time problems. I recommend you copy the 

macros you need into a header file in your application source tree. It&#39;ll probably save 

you some headaches. 

 

Regards, 

--Scott
0 Kudos
Reply