]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/arch/arm/generic/defines/hal_intr.h
Included ARM LPC21xx related code from uLan project. The snapshot date is 2008-07-05
[lincan.git] / embedded / arch / arm / generic / defines / hal_intr.h
1 #ifndef HAL_INTR_H
2 #define HAL_INTR_H
3
4 #include <hal_ints.h>
5
6 //--------------------------------------------------------------------------
7 // Static data used by HAL
8 // ISR tables
9 extern uint32_t hal_interrupt_handlers[HAL_ISR_COUNT];
10 extern uint32_t hal_interrupt_data[HAL_ISR_COUNT];
11
12 //--------------------------------------------------------------------------
13 // Default ISR
14 // The #define is used to test whether this routine exists, and to allow
15 // code outside the HAL to call it.
16  
17 typedef void (*hal_isr)(int vector, uint32_t data); //function ptr
18 extern uint32_t hal_default_isr(int vector, uint32_t data);
19 #define HAL_DEFAULT_ISR hal_default_isr
20
21 //--------------------------------------------------------------------------
22 // Vector translation.
23
24 #ifndef HAL_TRANSLATE_VECTOR
25 #define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
26     (_index_) = (_vector_)
27 #endif
28
29 //--------------------------------------------------------------------------
30 // Interrupt and VSR attachment macros
31
32 #define HAL_INTERRUPT_IN_USE( _vector_, _state_)                          \
33     {                                                                     \
34     uint32_t _index_;                                                     \
35     HAL_TRANSLATE_VECTOR ((_vector_), _index_);                           \
36                                                                           \
37     if( hal_interrupt_handlers[_index_] == (uint32_t)hal_default_isr ) \
38         (_state_) = 0;                                                    \
39     else                                                                  \
40         (_state_) = 1;                                                    \
41     }
42
43 #define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_)                     \
44     {                                                                      \
45     if( hal_interrupt_handlers[_vector_] == (uint32_t)hal_default_isr ) \
46     {                                                                      \
47         hal_interrupt_handlers[_vector_] = (uint32_t)_isr_;             \
48         hal_interrupt_data[_vector_] = (uint32_t) _data_;                  \
49     }                                                                      \
50     }
51
52 #define HAL_INTERRUPT_DETACH( _vector_, _isr_ )                            \
53     {                                                                      \
54     if( hal_interrupt_handlers[_vector_] == (uint32_t)_isr_ )           \
55     {                                                                      \
56         hal_interrupt_handlers[_vector_] = (uint32_t)hal_default_isr;   \
57         hal_interrupt_data[_vector_] = 0;                                  \
58     }                                                                      \
59     }
60
61
62 //--------------------------------------------------------------------------
63 // Interrupt controller access
64
65 extern void hal_interrupt_mask(int);
66 extern void hal_interrupt_unmask(int);
67 extern void hal_interrupt_acknowledge(int);
68 extern void hal_interrupt_configure(int, int, int);
69 extern void hal_interrupt_set_level(int, int);
70
71 #define HAL_INTERRUPT_MASK( _vector_ )                     \
72     hal_interrupt_mask( _vector_ ) 
73 #define HAL_INTERRUPT_UNMASK( _vector_ )                   \
74     hal_interrupt_unmask( _vector_ )
75 #define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ )              \
76     hal_interrupt_acknowledge( _vector_ )
77 #define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ ) \
78     hal_interrupt_configure( _vector_, _level_, _up_ )
79 #define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )       \
80     hal_interrupt_set_level( _vector_, _level_ )
81
82 #endif /* HAL_DEFAULT_ISR */