I haven't reviewed the code fully yet, but I do have a comment about style.
You have written the following:
Code:
//If we're in debug mode, include stdio.h for printf.
#ifdef IR_DEBUG_MODE
#include <stdio.h>
#endif
//then, somewhere in the body..
#ifdef IR_DEBUG_MODE
printf("FIRSTIR:" ... );
#endif
A) You do not need to put an include guard on stdio. There is an include guard defined in its header file already, and as soon as you include it in any file it should be in your compilation unit. Plus, it only takes a fraction of a second to compile it anyway.
B) Instead of having to type preprocessor If's all the time, you can consolidate your printf's with something like this..
In the .h file:
Code:
#define IR_DEBUG 1
#ifdef IR_DEBUG
#define IRDEBUG(S,A,B,C,D) printf(S,A,B,C,D)
#else
#define IRDEBUG(S,A,B,C,D) ;
#endif
In the .c file (whenever you want to print a debug statement.):
Code:
IRDEBUG("FIRSTIR: CMD Inputs...0: %d, 1: %d, 2: %d, 3: %d\r\n",IR_CMD0_INPUT, IR_CMD1_INPUT, IR_CMD2_INPUT, IR_CMD3_INPUT);
This should clean up your code a bit, and will give you the same ease of use.