1#include "main-header.h"
6#define IRQ_STATUS_DUE 0
23int register_softirq(MCULIB_HANDLE handle,
int pin, softirq *callback,
void *opaque) {
28 for (i = 0; i < MAX_IRQS; i++) {
29 sf = ®istrations[i];
30 if (sf->callback == NULL) {
42 printf(
"Not enough softirqs available\r\n");
47 usf->callback = callback;
51void release_irq_by_handle(MCULIB_HANDLE handle) {
55 for (i = 0; i < MAX_IRQS; i++) {
56 sf = ®istrations[i];
57 if ((sf->callback != NULL) && (sf->handle == handle)) {
67 for (i = 0; i < MAX_IRQS; i++) {
68 sf = ®istrations[i];
69 if ((sf->callback != NULL) && (sf->pin == pin)) {
80 for (i = 0; i < MAX_IRQS; i++) {
81 sf = ®istrations[i];
82 if ((sf->callback != NULL) && (sf->status & (1 << IRQ_STATUS_DUE))) {
83 sf->status = sf->status & ~(1 << IRQ_STATUS_DUE);
85 sf->callback(sf->pin, sf->opaque);
86 sf->status = sf->status & ~(1 << IRQ_STATUS_DUE);
91static void pinirq(
int pin) __attribute__((no_instrument_function));
94static void pinirq(
int pin) {
100 sf->status = sf->status | (1 << IRQ_STATUS_DUE);
103void irq_router_init() {
104 memset(®istrations,
sizeof(registrations), 0);
105 mculib_pin_in_callback(MAIN_MCULIBHANDLE, &pinirq);