SHOW:
|
|
- or go back to the newest paste.
1 | #include "uio-irq.h" // https://pastebin.com/w42Ti0Hz | |
2 | ||
3 | - | // for level-triggered interrupts: |
3 | + | // blocking, for level-triggered interrupts: |
4 | int fd = open( path, O_RDWR | O_CLOEXEC ); | |
5 | setup_irq(); | |
6 | loop { | |
7 | uio_irqenable( fd ); | |
8 | uio_wfi( fd ); | |
9 | handle_irq(); | |
10 | } | |
11 | ||
12 | - | // for edge-triggered interrupts: |
12 | + | // blocking, for edge-triggered interrupts: |
13 | int fd = open( path, O_RDWR | O_CLOEXEC ); | |
14 | setup_irq(); | |
15 | loop { | |
16 | uio_irqenable( fd ); | |
17 | handle_irq(); | |
18 | uio_wfi( fd ); | |
19 | } | |
20 | ||
21 | ||
22 | // non-blocking, for level-triggered interrupts: | |
23 | int fd = open( path, O_RDWR | O_CLOEXEC | O_NONBLOCK ); | |
24 | setup_irq(); | |
25 | uio_irqenable( fd ); | |
26 | when fd readable { | |
27 | uio_wfi( fd ); | |
28 | handle_irq(); | |
29 | uio_irqenable( fd ); | |
30 | } | |
31 | ||
32 | // non-blocking, for edge-triggered interrupts: | |
33 | int fd = open( path, O_RDWR | O_CLOEXEC | O_NONBLOCK ); | |
34 | setup_irq(); | |
35 | uio_irqenable( fd ); | |
36 | handle_irq(); | |
37 | when fd readable { | |
38 | uio_wfi( fd ); | |
39 | uio_irqenable( fd ); | |
40 | handle_irq(); | |
41 | } |