I'm not using the drivers for these devices, so I leave them out of the kernel compile. I could never get the button device /dev/btn to work.
What I do instead is just directly read and write the ports. So I have
# include "nios2_system.h"
VUINT16 *button_address = (VUINT16*) na_button_pio;
VUINT16 *led_7seg_address = (VUINT16*) na_seven_seg_pio;
VUINT8 *led_address = (VUINT8*) na_led_pio;
and then just read and write to these ports.
For the buttons:
int get_button_press(void) {
int button_value = ~*button_address;
if (button_value & 0x08)
return 1;
else if (button_value & 0x04)
return 2;
else if (button_value & 0x02)
return 3;
else if (button_value & 0x01)
return 4;
else
return 0;
}
For the leds just read and write values. I can share my digit code and alphabetic characters for the seven segment display if you want.
Cheers,
Josh