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

interrupt in button_pio

Altera_Forum
Honored Contributor II
1,607 Views

HI, 

 

Does anyone know how to get button_pio to run a function based on interrupt. 

 

E.g. Press a button, it generates an interrupt so that cpu can read the status and do something. 

 

I am currently using polling which is a waste of cpu resources. 

 

Any pointers or code that would help. Thanks.
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
694 Views

\com.microtronix.nios2linux.kernel_1.4.0\linux-2.6.x\drivers\char\altera_pio_button.c 

 

you can find a lot about pio buttons in the forum.
0 Kudos
Altera_Forum
Honored Contributor II
694 Views

Hi, 

 

I have looked at the example as suggested, but just couldn't understand it. 

 

It looks like it's a driver. 

 

I am just trying to write an application is based on pio interrupt. Anyone has some simple example application that allow me to that ? 

 

Thanks.
0 Kudos
Altera_Forum
Honored Contributor II
694 Views

You cannot use interrupts under uClinux in a userapplication. Interrupts can only handled in kernel drivers.

0 Kudos
Altera_Forum
Honored Contributor II
694 Views

 

--- Quote Start ---  

originally posted by albertyong88@Nov 15 2006, 05:14 PM 

hi, 

 

i have looked at the example as suggested, but just couldn't understand it. 

 

it looks like it's a driver. 

 

i am just trying to write an application is based on pio interrupt. anyone has some simple example application that allow me to that ? 

 

thanks. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=19440) 

--- quote end ---  

 

--- Quote End ---  

 

You need to read the book "linux device driver 3rd ed" . 

seperate device driver from your application improve your program.
0 Kudos
Altera_Forum
Honored Contributor II
694 Views

Hi, 

 

What I have done now is included the altera_pio_button.c into the source tree locally, and change Makefile and Kconfig accordingly, and then compile by doing 

 

make; make linux image; 

 

All seems to be fine, but when I look at /proc/interrupts, there is no list of pio_buttons nor is there /dev/btn 

 

Any ideas what went wrong ?
0 Kudos
Altera_Forum
Honored Contributor II
694 Views

 

--- Quote Start ---  

originally posted by albertyong88@Nov 15 2006, 11:44 PM 

hi, 

 

what i have done now is included the altera_pio_button.c into the source tree locally, and change makefile and kconfig accordingly, and then compile by doing 

 

make; make linux image; 

 

all seems to be fine, but when i look at /proc/interrupts, there is no list of pio_buttons nor is there /dev/btn 

 

any ideas what went wrong ? 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=19452) 

--- quote end ---  

 

--- Quote End ---  

 

you need to open and read the char dev /dev/btn. 

eg, cat /dev/btn 

 

The nios2 patches (ver17) to uClinux-dist are updated to include button and lcd drivers now.
0 Kudos
Altera_Forum
Honored Contributor II
694 Views

Sorry, did this twice.

0 Kudos
Altera_Forum
Honored Contributor II
694 Views

Hi Hippo, 

 

I got the new kernel patches, and included in my new built. 

 

However, it booted up, there was nothing indicating the driver is loaded. 

 

I am attaching the boot screen 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

Uncompressing Linux... Ok, booting the kernel. 

Linux version 2.6.17-uc1 (uclinux@colinux) (gcc version 3.4.6)# 29 PREEMPT Tue N 

ov 21 10:20:08 EST 2006 

 

 

uClinux/Nios II 

Altera Nios II support © 2004 Microtronix Datacom Ltd. 

Built 1 zonelists 

Kernel command line: 

PID hash table entries: 256 (order: 8, 1024 bytes) 

Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) 

Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) 

Memory available: 30312k/32768k RAM, 0k/0k ROM (1475k kernel code, 663k data) 

Mount-cache hash table entries: 512 

NET: Registered protocol family 16 

NET: Registered protocol family 2 

IP route cache hash table entries: 1024 (order: 0, 4096 bytes) 

TCP established hash table entries: 1024 (order: 0, 4096 bytes) 

TCP bind hash table entries: 1024 (order: 0, 4096 bytes) 

TCP: Hash tables configured (established 1024 bind 1024) 

TCP reno registered 

io scheduler noop registered 

io scheduler deadline registered (default) 

You have init Device 250 

Serial: JTAG UART driver $Revision: 1.1 $ 

ttyJ0 at MMIO 0x822208b0 (irq = 1) is a jtag_uart 

smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <nico@cam.org

eth0: SMC91C11xFD (rev 1) at 82210300 IRQ 6 [nowait] 

eth0: Ethernet addr: 00:07:ed:0f:06:92 

i2c /dev entries driver 

i2c-oc: i2c Opencores adapter driver 

Opencores i2c algorithm module 

TCP bic registered 

NET: Registered protocol family 1 

NET: Registered protocol family 17 

Freeing unused kernel memory: 532k freed (0x4182000 - 0x4206000) 

Shell invoked to run file: /etc/rc 

Command: hostname uClinux 

Command: mount -t proc proc /proc 

Command: mount -t sysfs sysfs /sys 

Command: mount -t usbfs none /proc/bus/usb 

mount: Mounting none on /proc/bus/usb failed: No such file or directory 

Command: mkdir /var/tmp 

Command: mkdir /var/log 

Command: mkdir /var/run 

Command: mkdir /var/lock 

Command: mkdir /var/empty 

Command: ifconfig lo 127.0.0.1 

Command: route add -net 127.0.0.0 netmask 255.0.0.0 lo 

Command: ifconfig eth0 192.168.50.63eth0: link down 

 

Command: cat /etc/motd 

Welcome to 

          ____ _  _ 

        /  __| ||_| 

    _  _| |  | | _ ____  _  _  _  _ 

  | | | | |  | || |  _ \| | | |\ \/ / 

  | |_| | |__| || | | | | |_| |/     

  |  ___\____|_||_|_| |_|\____|\_/\_/ 

  | | 

  |_| 

 

For further information check: 

http://www.uclinux.org/ (http://www.uclinux.org/

 

Command: inetd & 

[18] 

Command: mkdir /nios2bin 

Command: mount -t nfs -n -o nolock,rsize=1024,wsize=1024 192.168.50.62:/home/ucl 

inux/nios2bin /nios2bin 

eth0: link up, 100Mbps, full-duplex, lpa 0x45E1 

Command: boa & 

[21] 

Command: 

Execution Finished, Exiting 

 

Sash command shell (version 1.1.1) 

/>[/b] 

--- Quote End ---  

 

 

Also, I added 

nod /dev/btn 666 0 0 c 62 0 

in romfs_list 

 

After booting, check /dev dir, btn seems to be there. 

 

When I did cat /proc/devices, I get  

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

/> cat /proc/devices 

Character devices: 

  1 mem 

  2 pty 

  3 ttyp 

  5 /dev/tty 

  5 /dev/console 

10 misc 

89 i2c 

232 ttyJ 

240 iodata 

241 iodir 

250 LCD_PIO[/b] 

--- Quote End ---  

 

 

And when I did cat /proc/interrupts, I get 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

  :          0  spurious 

  0:      15431 L timer 

  1:        24  jtag_uart 

  2:        30  pio_button 

  6:        602 L eth0 

  7:          1  Opencores I2C[/b] 

--- Quote End ---  

 

 

I also read the aritcle in icwin by Wyouken.  

http://www.icwin.net/source/pdf/nios2_linu...nux_nios2_3.pdf (http://www.icwin.net/source/pdf/nios2_linux/run_uclinux_nios2_3.pdf

 

So, it seems that the driver is NOT loaded. Can you help ?
0 Kudos
Reply