void cc253x_p2_unregister_handler(struct cc253x_p2_handler *remove) { uint8_t flags; struct cc253x_p2_handler *h = handlers; // Protect against dumb users if(!h || !remove) { return; } cc253x_p2_irq_disable(flags); if(h == remove) { // First element in the list handlers = h->next; } else { while(h->next) { if(h->next == remove) { h->next = h->next->next; break; } h = h->next; } } cc253x_p2_irq_enable(flags); }
void cc253x_p2_register_handler(struct cc253x_p2_handler * h) { uint8_t flags; if(!h) { return; } cc253x_p2_irq_disable(flags); h->next = handlers; handlers = h; cc253x_p2_irq_enable(flags); }