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

Reading and writing pio(nios) in uclinux

Altera_Forum
Honored Contributor II
1,486 Views

hi, 

I have uclinux on nios,  

the memory is sdram, 

but now i do not know how to read or write the pio(built in sopc) in uclinux. 

can anybody help me?:) 

thanks a lot! 

 

 

 

my regards, 

wangyipin
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
436 Views

I'm not sure how it works in the latest versions of uClinux, but in the (old) version I use the build system generates a nios2_system.h header file from my .ptf that defines all my PIO addresses as a "np_pio" struct. It automatically names them na_<pio name>. You can then write/read to them directly from your application (assuming you aren't using an MMU). So, e.g., if you have a PIO named my_pio in SOPC builder then you can read/write it as follows: 

 

#include "nios2_system.h" ... // Reads the PIO value. int currvalue = na_my_pio->np_piodata; // Writes a new value. na_my_pio->np_piodata = newvalue; ...  

 

See the definition of the np_pio struct for info on more advanced features (e.g., bidirectional data, edge detection).
0 Kudos
Altera_Forum
Honored Contributor II
436 Views

thanks Tristan, 

i will try, and i know the header file is the point
0 Kudos
Altera_Forum
Honored Contributor II
436 Views

 

--- Quote Start ---  

 

but now i do not know how to read or write the pio(built in sopc) in uclinux. 

--- Quote End ---  

In a device driver or in a user land program ? 

Using NIOS with our without MMU ?  

 

-Michael
0 Kudos
Altera_Forum
Honored Contributor II
436 Views

In a user program without MMU. 

What's the easiest way? 

 

 

 

 

 

--- Quote Start ---  

In a device driver or in a user land program ? 

Using NIOS with our without MMU ?  

 

-Michael 

--- Quote End ---  

0 Kudos
Reply