6 //--------------------------------------------------------------------------
7 // Static data used by HAL
9 extern uint32_t hal_interrupt_handlers[HAL_ISR_COUNT];
10 extern uint32_t hal_interrupt_data[HAL_ISR_COUNT];
12 //--------------------------------------------------------------------------
14 // The #define is used to test whether this routine exists, and to allow
15 // code outside the HAL to call it.
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
21 //--------------------------------------------------------------------------
22 // Vector translation.
24 #ifndef HAL_TRANSLATE_VECTOR
25 #define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
26 (_index_) = (_vector_)
29 //--------------------------------------------------------------------------
30 // Interrupt and VSR attachment macros
32 #define HAL_INTERRUPT_IN_USE( _vector_, _state_) \
35 HAL_TRANSLATE_VECTOR ((_vector_), _index_); \
37 if( hal_interrupt_handlers[_index_] == (uint32_t)hal_default_isr ) \
43 #define HAL_INTERRUPT_ATTACH( _vector_, _isr_, _data_) \
45 if( hal_interrupt_handlers[_vector_] == (uint32_t)hal_default_isr ) \
47 hal_interrupt_handlers[_vector_] = (uint32_t)_isr_; \
48 hal_interrupt_data[_vector_] = (uint32_t) _data_; \
52 #define HAL_INTERRUPT_DETACH( _vector_, _isr_ ) \
54 if( hal_interrupt_handlers[_vector_] == (uint32_t)_isr_ ) \
56 hal_interrupt_handlers[_vector_] = (uint32_t)hal_default_isr; \
57 hal_interrupt_data[_vector_] = 0; \
62 //--------------------------------------------------------------------------
63 // Interrupt controller access
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);
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_ )
82 #endif /* HAL_DEFAULT_ISR */