29 | | * '''ICU_MASK''' : ADDRESS![2:0] = 0x4 |
30 | | Each bit i of this 32 bits register enables the corresponding |
31 | | '''p_irq_in[i]''' input interrupt, when this bit is one. |
32 | | This register can be read or written.A write request of a zero gives resets this register. |
33 | | This register is write-only. |
| 25 | * `ICU_INT`: ADDRESS![4:0] = 0x0 |
| 26 | Each bit in this register reflects the state of the corresponding interrupt line. |
| 27 | This is read-only. |
| 28 | |
| 29 | * `ICU_MASK`: ADDRESS![4:0] = 0x4 |
| 30 | Each bit in this register reflects the state of the enable for the corresponding interrupt line. |
| 31 | This is read-only. |
| 32 | |
| 33 | * `ICU_MASK_SET`: ADDRESS![4:0] = 0x8 |
| 34 | Each bit set in the written word will be set in the ICU MASK. (ICU_MASK = ICU_MASK | written_data). |
| 35 | This is write-only. |
| 36 | |
| 37 | * `ICU_MASK_CLEAR`: ADDRESS![4:0] = 0xc |
| 38 | Each bit set in the written word will be reset in the ICU MASK. (ICU_MASK = ICU_MASK & ~written_data). |
| 39 | This is write-only. |
| 40 | |
| 41 | * `ICU_IT_VECTOR`: ADDRESS![4:0] = 0x10 |
| 42 | This register gives the number of the highest-priority active interrupt. |
| 43 | If no interrupt is active, (-1) is returned. |
| 44 | This is read-only. |
| 45 | |
| 46 | = Component usage = |
| 47 | |
| 48 | For extensibility issues, you should access your ICU using globally-defined offsets. |
| 49 | |
| 50 | You should include file source:trunk/soclib/include/soclib/icu.h from your software, it |
| 51 | defines `ICU_INT`, `ICU_MASK`, `ICU_MASK_SET`, `ICU_MASK_CLEAR`, `ICU_IT_VECTOR`. |
| 52 | |
| 53 | Sample code: |
| 54 | {{{ |
| 55 | #include "soclib/icu.h" |
| 56 | |
| 57 | static const volatile void* timer_address = 0xc0000000; |
| 58 | |
| 59 | static icu_test(const size_t icu_no) |
| 60 | { |
| 61 | volatile int *icu = ((int*)icu_address) + timer_no*ICU_SPAN; |
| 62 | |
| 63 | // Getting / setting interrupt mask |
| 64 | uint32_t current_interrupt_mask = icu[ICU_MASK]; |
| 65 | |
| 66 | // Enabling IRQ #5 |
| 67 | icu[ICU_MASK_SET] = 0x20; |
| 68 | // Disabling IRQ #0 |
| 69 | icu[ICU_MASK_CLEAR] = 0x1; |
| 70 | |
| 71 | // When interrupt is raised, you may do: |
| 72 | int irq_to_serve = icu[ICU_IT_VECTOR]; |
| 73 | // This should be equivalent to (see man 3 ffs) |
| 74 | int irq_to_serve = ffs(icu[ICU_IT_VECTOR] & icu[ICU_MASK]); |
| 75 | } |
| 76 | }}} |
| 77 | |
| 78 | (add -I/path/to/soclib/include to your compilation command-line) |