Forum Discussion
Altera_Forum
Honored Contributor
15 years agoI'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).