//***************************************************************************** // File Name : datalogger.c // // Title : Windlogger // Revision : 0.3 22-10-2006 // Revision History: // When Who Description of change // ----------- ----------- ----------------------- // 20-Oct-2002 pstang Created the program // Oct - 2006 RifRaf changes stuff //***************************************************************************** //----- Include Files --------------------------------------------------------- #include // include I/O definitions (port names, pin names, etc) #include // include "signal" names (interrupt names) #include // include interrupt support #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) #include "a2d.h" // include A/D converter function library #include "vt100.h" // include VT100 terminal support #include "extint.h" // include external interrupt library #define SetBit(BIT, PORT) PORT |= (1< 580) { mode = 0; SwitchToLoad(); } if (volts < 540) { mode = 1; SwitchToCharging(); } vt100SetCursorPos(1,1); rprintf("[%d%d%d%d%d%d]\r\n",volts,shuntvolts,rpm,windpulse,mode,direction); } } int windDirection() { stateEntry_t test; int n; test.state.TPD7 = IsHigh(7, PORTD); test.state.TPD6 = IsHigh(6, PORTD); test.state.TPD5 = IsHigh(5, PORTD); test.state.TPD4 = IsHigh(4, PORTD); test.state.TPC2 = IsHigh(2, PORTC); test.state.TPC3 = IsHigh(3, PORTC); test.state.TPC4 = IsHigh(4, PORTC); test.state.TPC5 = IsHigh(5, PORTC); for (n = 0; n < 32; n++) { if( stateTable[n].stateBits == test.stateBits ) { return stateTable[n].next; } } return -1; // we dont know!? } void rpmSetup(void) { extintInit(); extintConfigure(EXTINT0, EXTINT_EDGE_RISING); extintConfigure(EXTINT1, EXTINT_EDGE_RISING); extintAttach(EXTINT0, myInt0Handler); extintAttach(EXTINT1, myInt1Handler); sbi(GIMSK, INT0); sbi(GIMSK, INT1); } void myInt0Handler(void) { Int0Count++; } void myInt1Handler(void) { Int1Count++; } void SwitchToCharging(void) { ClearBit(0, PORTB) ; return; } void SwitchToLoad(void) { SetBit(0, PORTB) ; return; }