#include #define ACK -1 #define ABin -1 #define ACKRESP(x) -1 void async_loop() { // Every execution of this function will do one of the following: // * Master the bus and send data across the parallel port // * Be mastered and read data from the parallel port // * Nothing static enum { S_IDLE, S_EXER, S_EXEI } state; typedef enum { C_DATA = 1, C_RESET = 0 } command_t; state = S_IDLE; while(1) { if(state == S_IDLE) { usleep(.1); // sleep while idle so we don't eat up all the CPU if(ACK) { // someone is trying to gain mastery of the bus ACKRESP(1); // tell them that it is okay to continue command = ABin; } } else if(state == S_EXER) { // we have been mastered... so start executing commands command = AB; } } return; } int main(int argc, char *argv[]) { return 0; }