All pastes #124972 Raw Edit

Something

public c v1 · immutable
·published 2006-08-10 10:33 UTC
rendered paste body
struct event_t {	void* fnx1(void*);	void* fnx2(void*);	void* fnx3(void*);	void* data1;	void* data2;	void* data3;} events;	events e;void event_init(void) {}void event_add( (void*)fnx(void*), (void*)data, uint16_t time) {	if (!e->fnx1) {		e->fnx1 = fnx;		e->data1 = data;		OCR1A = TCNT1 + time;		sbi( TIMSK, OCIE1A);	} else if (!e->fnx2) {		e->fnx2 = fnx;		e->data2 = data;		OCR1B = TCNT1 + time;		sbi( TIMSK, OCIE1B);	} else if (!e->fnx3) {		e->fnx3 = fnx;		e->data3 = data;		OCR1C = TCNT1 + time;		sbi( ETIMSK, OCIE1C);	} else {		critical("unable to schedule task!\n");	}}ISR(TIMER1_COMPA_vect) {	cbi( TIMSK, OCIE1A );	(void)(e->fnx1)(e->data1);	e->fnx1 = NULL;}ISR(TIMER1_COMPB_vect) {	cbi( TIMSK, OCIE1B );	(void)(e->fnx2)(e->data2);	e->fnx2 = NULL;}ISR(TIMER1_COMPC_vect) {	cbi( ETIMSK, OCIE1C );	(void)(e->fnx3)(e->data3);	e->fnx3 = NULL;}