All pastes #130913 Raw Edit

Anonymous

public c v1 · immutable
#130913 ·published 2006-08-14 06:48 UTC
rendered paste body
int main(void)	{	xdata unsigned char oldCounter;	EA = 1;							// Enable Global interrupts	initSystemCounter();	ET2 = 1;							// Enable Timer2 overflow interrupt	SPIwrite(INTCON, BANK0 | RAND_ADDRESS | EN_HW_ADDRESS);	SPIwrite(IODIRB, (OFF_SW | DISPLAY_SW | PANEL_OUTPUT_SW) & (~(E_LCD | R_W_LCD |RS_LCD)));	// 1 = input	SPIwrite(IPOLB, OFF_SW | DISPLAY_SW | PANEL_OUTPUT_SW);					// 1 = invert read value of pin	SPIwrite(GPPUB, OFF_SW | DISPLAY_SW | PANEL_OUTPUT_SW);					// 1 = enable pull-up resistors	latching_relay	= LATCHING_RELAY_OFF;	panel_output = PANEL_DISABLED;	fan = FAN_OFF;	oldCounter = counter;	while((counter - oldCounter) < T500MS)		// 500mS second loop (give capacitors time to charge)		{		getSwitchStatus();		if(switchStatus & OFF_SW)			while(0 == 0);								// loop untill power is cut		}	latching_relay	= LATCHING_RELAY_ON;// *** MAIN PROGRAM LOOP ***	while(0 == 0)		// B.F.L.		{		getSwitchStatus();		if(switchStatus & OFF_SW)			{			switchStatus ^= OFF_SW;					// Acknowledge panel output switch			if(panel_output == PANEL_ENABLED)				panel_output = PANEL_DISABLED;			oldCounter = counter;			while((counter - oldCounter) < T500MS);			latching_relay	= LATCHING_RELAY_OFF;			while(0 == 0);								// Loop forever untill power is cut			}		else if(switchStatus & PANEL_OUTPUT_SW)			{			switchStatus ^= PANEL_OUTPUT_SW;		// Acknowledge switch press			if(panel_output == PANEL_ENABLED)	// Toggle panel output status				panel_output = PANEL_DISABLED;			else				panel_output = PANEL_ENABLED;			}		}	return 0;			// program never returns, just needed to be UNIX compatible	}