Forum Discussion
Altera_Forum
Honored Contributor
20 years agobuttons and leds
Hello all and hippo, Can anyone out there help me with buttons and leds ? I am running uclinux on cyclone ii 2c35 nios ii dev board. I have 8 leds, 2 7-segment leds, 4 buttons and 16x...
Altera_Forum
Honored Contributor
20 years ago --- Quote Start --- originally posted by jmarshall@Aug 16 2006, 02:01 PM 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
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=17645)
--- quote end ---
--- Quote End --- hi all, i would like to c the code oso. thx for sharing! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif