All pastes #124991 Raw Edit

Something

public c v1 · immutable
·published 2006-08-10 10:48 UTC
rendered paste body
#include <stdio.h>#include <avr/io.h>#include <avr/interrupt.h>struct event_t {	void* fnx1(void*);	void* fnx2;	void* fnx3;	void* data1;	void* data2;	void* data3;};	struct event_t e;void event_init(void) {}void event_add( void* fnx, void* data, uint16_t time) {	if (!e.fnx1) {		OCR1A = TCNT1 + time;		e.fnx1 = fnx;		e.data1 = data;		sbi( TIMSK, OCIE1A);	} else if (!e.fnx2) {		OCR1B = TCNT1 + time;		e.fnx2 = fnx;		e.data2 = data;		sbi( TIMSK, OCIE1B);	} else if (!e.fnx3) {		OCR1C = TCNT1 + time;		e.fnx3 = fnx;		e.data3 = data;		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;}