no-OS
irq.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef IRQ_H_
41 #define IRQ_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdint.h>
48 
49 /******************************************************************************/
50 /*************************** Types Declarations *******************************/
51 /******************************************************************************/
52 
64 };
65 
72 };
73 
79 struct irq_platform_ops ;
80 
87  uint32_t irq_ctrl_id;
91  void *extra;
92 };
93 
98 struct irq_ctrl_desc {
100  uint32_t irq_ctrl_id;
104  void *extra;
105 };
106 
118  void (*callback)(void *ctx, uint32_t event, void *extra);
120  void *ctx;
122  void *config;
123 };
124 
132  int32_t (*init)(struct irq_ctrl_desc **desc,
133  const struct irq_init_param *param);
135  int32_t (*register_callback)(struct irq_ctrl_desc *desc, uint32_t irq_id,
136  struct callback_desc *callback_desc);
138  int32_t (*unregister)(struct irq_ctrl_desc *desc, uint32_t irq_id);
140  int32_t (*global_enable)(struct irq_ctrl_desc *desc);
142  int32_t (*global_disable)(struct irq_ctrl_desc *desc);
144  int32_t (*trigger_level_set)(struct irq_ctrl_desc *desc, uint32_t irq_id,
145  enum irq_trig_level trig);
147  int32_t (*enable)(struct irq_ctrl_desc *desc, uint32_t irq_id);
149  int32_t (*disable)(struct irq_ctrl_desc *desc, uint32_t irq_id);
151  int32_t (*remove)(struct irq_ctrl_desc *desc);
152 };
153 
154 /******************************************************************************/
155 /************************ Functions Declarations ******************************/
156 /******************************************************************************/
157 
158 /* Initialize a interrupt controller peripheral. */
159 int32_t irq_ctrl_init(struct irq_ctrl_desc **desc,
160  const struct irq_init_param *param);
161 
162 /* Free the resources allocated by irq_ctrl_init(). */
163 int32_t irq_ctrl_remove(struct irq_ctrl_desc *desc);
164 
165 /* Register a callback to handle the irq events */
166 int32_t irq_register_callback(struct irq_ctrl_desc *desc, uint32_t irq_id,
167  struct callback_desc *callback_desc);
168 
169 /* Unregisters a generic IRQ handling function */
170 int32_t irq_unregister(struct irq_ctrl_desc *desc, uint32_t irq_id);
171 
172 /* Global interrupt enable */
173 int32_t irq_global_enable(struct irq_ctrl_desc *desc);
174 
175 /* Global interrupt disable */
176 int32_t irq_global_disable(struct irq_ctrl_desc *desc);
177 
178 /* Set interrupt trigger level. */
179 int32_t irq_trigger_level_set(struct irq_ctrl_desc *desc, uint32_t irq_id,
180  enum irq_trig_level trig);
181 
182 /* Enable specific interrupt */
183 int32_t irq_enable(struct irq_ctrl_desc *desc, uint32_t irq_id);
184 
185 /* Disable specific interrupt */
186 int32_t irq_disable(struct irq_ctrl_desc *desc, uint32_t irq_id);
187 
188 #endif // IRQ_H_
irq_platform_ops::unregister
int32_t(* unregister)(struct irq_ctrl_desc *desc, uint32_t irq_id)
Definition: irq.h:138
irq_platform_ops::global_disable
int32_t(* global_disable)(struct irq_ctrl_desc *desc)
Definition: irq.h:142
irq_ctrl_desc
Definition: irq.h:98
irq_ctrl_desc::extra
void * extra
Definition: irq.h:104
irq_init_param::extra
void * extra
Definition: irq.h:91
IRQ_WRITE_DONE
@ IRQ_WRITE_DONE
Definition: irq.h:59
irq_init_param::platform_ops
const struct irq_platform_ops * platform_ops
Definition: irq.h:89
callback_desc::ctx
void * ctx
Definition: irq.h:120
IRQ_EDGE_BOTH
@ IRQ_EDGE_BOTH
Definition: irq.h:71
IRQ_LEVEL_LOW
@ IRQ_LEVEL_LOW
Definition: irq.h:67
irq_platform_ops::remove
int32_t(* remove)(struct irq_ctrl_desc *desc)
Definition: irq.h:151
IRQ_READ_DONE
@ IRQ_READ_DONE
Definition: irq.h:61
callback_desc::config
void * config
Definition: irq.h:122
irq_enable
int32_t irq_enable(struct irq_ctrl_desc *desc, uint32_t irq_id)
Enable specific interrupt.
Definition: irq.c:139
irq_global_enable
int32_t irq_global_enable(struct irq_ctrl_desc *desc)
Enable global interrupts.
Definition: irq.c:103
IRQ_LEVEL_HIGH
@ IRQ_LEVEL_HIGH
Definition: irq.h:68
irq_trig_level
irq_trig_level
Definition: irq.h:66
irq_global_disable
int32_t irq_global_disable(struct irq_ctrl_desc *desc)
Disable global interrupts.
Definition: irq.c:112
IRQ_ERROR
@ IRQ_ERROR
Definition: irq.h:63
irq_trigger_level_set
int32_t irq_trigger_level_set(struct irq_ctrl_desc *desc, uint32_t irq_id, enum irq_trig_level trig)
Set interrupt trigger level.
Definition: irq.c:124
irq_platform_ops::trigger_level_set
int32_t(* trigger_level_set)(struct irq_ctrl_desc *desc, uint32_t irq_id, enum irq_trig_level trig)
Definition: irq.h:144
callback_desc
Structure describing a callback to be registered.
Definition: irq.h:111
irq_platform_ops
Structure holding IRQ function pointers that point to the platform specific function.
Definition: irq.h:130
irq_id
irq_id
Interrupts IDs supported by the irq driver.
Definition: irq_extra.h:71
irq_platform_ops::enable
int32_t(* enable)(struct irq_ctrl_desc *desc, uint32_t irq_id)
Definition: irq.h:147
irq_ctrl_desc::irq_ctrl_id
uint32_t irq_ctrl_id
Definition: irq.h:100
callback_desc::callback
void(* callback)(void *ctx, uint32_t event, void *extra)
Definition: irq.h:118
irq_platform_ops::register_callback
int32_t(* register_callback)(struct irq_ctrl_desc *desc, uint32_t irq_id, struct callback_desc *callback_desc)
Definition: irq.h:135
irq_ctrl_remove
int32_t irq_ctrl_remove(struct irq_ctrl_desc *desc)
Free the resources allocated by irq_ctrl_init().
Definition: irq.c:70
irq_platform_ops::init
int32_t(* init)(struct irq_ctrl_desc **desc, const struct irq_init_param *param)
Definition: irq.h:132
irq_platform_ops::global_enable
int32_t(* global_enable)(struct irq_ctrl_desc *desc)
Definition: irq.h:140
irq_init_param::irq_ctrl_id
uint32_t irq_ctrl_id
Definition: irq.h:87
irq_register_callback
int32_t irq_register_callback(struct irq_ctrl_desc *desc, uint32_t irq_id, struct callback_desc *callback_desc)
Register a callback to handle the irq events.
Definition: irq.c:82
irq_uart_event_e
irq_uart_event_e
Possible events for uart interrupt.
Definition: irq.h:57
irq_ctrl_init
int32_t irq_ctrl_init(struct irq_ctrl_desc **desc, const struct irq_init_param *param)
Initialize the IRQ interrupts.
Definition: irq.c:51
irq_unregister
int32_t irq_unregister(struct irq_ctrl_desc *desc, uint32_t irq_id)
Unregisters a generic IRQ handling function.
Definition: irq.c:94
irq_platform_ops::disable
int32_t(* disable)(struct irq_ctrl_desc *desc, uint32_t irq_id)
Definition: irq.h:149
IRQ_EDGE_RISING
@ IRQ_EDGE_RISING
Definition: irq.h:70
irq_disable
int32_t irq_disable(struct irq_ctrl_desc *desc, uint32_t irq_id)
Disable specific interrupt.
Definition: irq.c:150
irq_ctrl_desc::platform_ops
const struct irq_platform_ops * platform_ops
Definition: irq.h:102
IRQ_EDGE_FALLING
@ IRQ_EDGE_FALLING
Definition: irq.h:69
irq_init_param
Structure holding the initial parameters for Interrupt Request.
Definition: irq.h:85