//----- Include Files --------------------------------------------------------- #include // include I/O definitions (port names, pin names, etc) #include // include I/O definitions (port names, pin names, etc) #include // include interrupt support #include #include "global.h" // include our global settings #include "uart.h" // include uart function library #include "rprintf.h" // include printf function library #include "timer.h" // include timer function library (timing, PWM, etc) void timerTest(void); //----- Begin Code ------------------------------------------------------------ volatile uint32_t numofinterrupts; // total number of time interrupts since reset volatile uint64_t time; // total number of time interrupts since reset volatile int pong = 0; uint64_t start_time = 0; volatile uint64_t end_time = 0; //u08 FixedPtBits; // Real time interrupt function // time will equal the number of ticks that have happened // each tick is 4e-9 seconds SIGNAL(SIG_OUTPUT_COMPARE2) { //time = time + 250 + TCNT2; numofinterrupts++; time = (uint64_t)numofinterrupts * 250 + TCNT2; } SIGNAL(SIG_INTERRUPT2) { end_time = time; pong = 1; cbi(PORTB, 4); // Turn INIT off sbi(PORTB, 5); // Power OFF the sonar module. Yes 1 = off, its a PN!P } /* // fixedptInit() initializes fixed-point math function library void fixedptInit(u08 fixedPtBits) { // set the number of bits to use behind the point FixedPtBits = fixedPtBits; } s32 fixedptMultiply(s32 a, s32 b) { // multiply a and b (a*b) with fixed-point math return (a*b)>>FixedPtBits; } s32 fixedptDivide(s32 numer, s32 denom) { // divide numer by denom (numer/denom) with fixed-point math return (numer<