Forum Discussion
4 Replies
- Altera_Forum
Honored Contributor
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:
See the definition of the np_pio struct for info on more advanced features (e.g., bidirectional data, edge detection).#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; ... - Altera_Forum
Honored Contributor
thanks Tristan,
i will try, and i know the header file is the point - Altera_Forum
Honored Contributor
--- 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 - Altera_Forum
Honored Contributor
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 ---