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

accessing hardware - a smart start?

Altera_Forum
Honored Contributor II
962 Views

Hello everyone. 

 

I am using the DE2 2C35 Board with uClinux NOMMU an DE2_NET.sof and ptf. 

 

I would like to ask for a smart way to start developing own software. 

 

I would like to begin to control the LEDs. 

 

I am trying to port the example "Board Diagnostics" Project from Nios2 EDS into Linux. 

 

But how to start? 

 

I see: 

 

led = 0xff; 

IOWR_ALTERA_AVALON_PIO_DATA(LED_PIO_BASE, led); 

printf( "\nAll LEDs should now be on.\n" ); 

 

I searched for the defines and found: 

// altera_avalon_pio_regs.h# define IORD_ALTERA_AVALON_PIO_DATA(base) IORD(base, 0)# define IOWR_ALTERA_AVALON_PIO_DATA(base, data) IOWR(base, 0, data) 

 

// io.h# define IORD(BASE, REGNUM)  

__builtin_ldwio (__IO_CALC_ADDRESS_NATIVE ((BASE), (REGNUM)))# define IOWR(BASE, REGNUM, DATA)  

__builtin_stwio (__IO_CALC_ADDRESS_NATIVE ((BASE), (REGNUM)), (DATA)) 

 

 

But i am not quiet sure i this is the correct way. 

 

 

Any ideas? Are there examples somewhere how to access the hardware from uclinux?
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
295 Views

The correct way is to use the GPIO Kernel driver provided with the uClinux distribution: 

http://www.nioswiki.com/gpio 

 

There are several article on accessing hardware in the Wiki. Generally hardware should be accessed via device drivers. With NoMMU it's possible to access hardware directly from user mode, for MMU this should be possible in some cases with "uio", but doing a device driver is more clean and more portable. 

 

-Michael
0 Kudos
Reply