Forum Discussion
Altera_Forum
Honored Contributor
9 years agoHi,
--- Quote Start --- Besides, I found this in a reference but I'm still not very sure how to use it to access IO ports.
To access IO ports, we can define them as memory pointer access (uncached). Nios2-Linux does
not lock access to the memory like normal Linux distros, so it is not a problem :
(*(volatile unsigned *)(port)) //for read, replace port with the hardware address
(*(volatile unsigned *)(port))=(d) //for write, replace port with the hardware address
To maintain the IORD and IOWR standard, which is used in Nios II systems, these macros can be
defined at the beginning of the source code to ease portability :
# define IORD(address,offset) (*(volatile unsigned *)(((address)|0x80000000)+4*(offset)))
# define IOWR(address,offset,value) (*(volatile unsigned *)(((address)|0x80000000)+4*(offset)))=(value) --- Quote End --- Maybe, this code is a sample for uClinux. To access your IO ports, you need to make a kernel driver. --- Quote Start --- May I know is there any reference that can help me to understand more in programming DE2-115 in linux system? like some sample coding to display some words in LCD,or control the LEDs and so on. Because I find it hard to find a good reference for that. --- Quote End --- It is a little bit difficult for a beginner to write kernel drivers...But I recommend you to find a existing driver which has similar behavior what you want. Kazu