Beispiel #1
0
//flash led for errors
UBYTE flash_leds()
{
	UBYTE i;

	for(i=0; i<15; i++)
	{
		LED_CAT(1);
		LED_HEATED_CAT(1);
		LED_DTC(1);
		LED_EVAP(1);
		LED_AIR(1);
		LED_O2(1);
		LED_HEATED_O2(1);
		LED_EGR(1);
		LED_MISFIRE(1);
		LED_AC(1);
		LED_FUEL(1);
		LED_COMP(1);
		delay_ms(100);
		LED_CAT(0);
		LED_HEATED_CAT(0);
		LED_DTC(0);
		LED_EVAP(0);
		LED_AIR(0);
		LED_O2(0);
		LED_HEATED_O2(0);
		LED_EGR(0);
		LED_MISFIRE(0);
		LED_AC(0);
		LED_FUEL(0);
		LED_COMP(0);
		delay_ms(100);		
	}
	return 0;
}
struct pacer {
	struct timer	timer;
	unsigned char	pattern;
	unsigned	pattern_bit	: 3;
	unsigned	repeat		: 1;
	unsigned	port_bit	: 3;
	volatile char	*port;
};
static struct pacer	pacers[PACER_MAX] = {
	{EXPIRED, 0x00, 0x1, 0, KEY_BEEP_BIT,      &beep_bits},
	{EXPIRED, 0x00, 0x1, 0, ERR_BEEP_BIT,      &beep_bits},
	{EXPIRED, 0x00, 0x1, 0, LED_ERROR_BIT,     &LED_ERROR(LAT)},
	{EXPIRED, 0x00, 0x1, 0, LED_LOCKED_BIT,    &LED_LOCKED(LAT)},
	{EXPIRED, 0x00, 0x1, 0, LED_CARTRIDGE_BIT, &LED_CARTRIDGE(LAT)},
	{EXPIRED, 0x00, 0x1, 0, LED_CAT_BIT,       &LED_CAT(LAT)}
};


/******************************************************************************/
/* Local Prototypes							      */
/******************************************************************************/

static void set_pacer (unsigned char pacer, unsigned char pattern, unsigned char repeat);


/******************************************************************************/
/* Global Implementations						      */
/******************************************************************************/

unsigned char catgenie_init (void)
Beispiel #3
0
//This function is used to process and display data
UBYTE display(UBYTE *data, UBYTE len,UBYTE connect)
{
	
	static UBYTE errors=0;
	//first we need to check for errors in the data stream
	//we know the data stream should be 10 bytes long
	if (len==20)
	{
		//check CRC/checksum for each ECU
		if (check_errors(data,10,connect) || check_errors(&data[10],10,connect))
		{
			flash_leds();
			printf("Error: Two ECMs checksum/crc error\n\r");
			return 0;
		}
		//CRC/checksum passed
				
		//add the error codes from two ecms
		data[5]=(data[5] & 0xEF) + (data[15] & 0xEF);
		data[6]=data[6] | data[16];
		data[7]=data[7] | data[17];
		data[8]=data[8] | data[18];
	}else if (len!=10)
	{
		errors++;
		printf("Error: processing data length problems %u",len);
		if (errors>=5)
		{		
			flash_leds();
			errors=0;
		}
		return 0;
	}

	if (len==10)
	{
		if (check_errors(data,len,connect)!=0)
		{
			errors++;
			if (errors>=5)
			{
				flash_leds();
				errors=0;
			}
			return 0;
		}
	}
 
	//we have good data lets process it 
	
	//first check for DTC 
	if (data[5] & 0x7F)
	{
		LED_DTC(1);
	}else
	{
		LED_DTC(0);
	}

	//now lets check for the Catalyst
	if (data[7] & 0x01)
	{
		//monitor supported
		if (data[8] & 0x01)
		{
			LED_CAT(0); //Not complete
		}else
		{
			LED_CAT(1);
		}
	}else
	{
		LED_CAT(1); //not applicabple
	}

	if (data[7] & 0x02)
	{
		//monitor supported
		if (data[8] & 0x02)
		{
			LED_HEATED_CAT(0); //Not complete
		}else
		{
			LED_HEATED_CAT(1);
		}
	}else
	{
		LED_HEATED_CAT(1); //not applicabple
	}

	if (data[7] & 0x04)
	{
		//monitor supported
		if (data[8] & 0x04)
		{
			LED_EVAP(0); //Not complete
		}else
		{
			LED_EVAP(1);
		}
	}else
	{
		LED_EVAP(1); //not applicabple
	}

	if (data[7] & 0x08)
	{
		//monitor supported
		if (data[8] & 0x08)
		{
			LED_AIR(0); //Not complete
		}else
		{
			LED_AIR(1);
		}
	}else
	{
		LED_AIR(1); //not applicabple
	}

	if (data[7] & 0x10)
	{
		//monitor supported
		if (data[8] & 0x10)
		{
			LED_AC(0); //Not complete
		}else
		{
			LED_AC(1);
		}
	}else
	{
		LED_AC(1); //not applicabple
	}
	if (data[7] & 0x20)
	{
		//monitor supported
		if (data[8] & 0x20)
		{
			LED_O2(0); //Not complete
		}else
		{
			LED_O2(1);
		}
	}else
	{
		LED_O2(1); //not applicabple
	}

	if (data[7] & 0x40)
	{
		//monitor supported
		if (data[8] & 0x40)
		{
			LED_HEATED_O2(0); //Not complete
		}else
		{
			LED_HEATED_O2(1);
		}
	}else
	{
		LED_HEATED_O2(1); //not applicabple
	}
	if (data[7] & 0x80)
	{
		//monitor supported
		if (data[8] & 0x80)
		{
			LED_EGR(0); //Not complete
		}else
		{
			LED_EGR(1);
		}
	}else
	{
		LED_EGR(1); //not applicabple
	}

	if (data[6] & 0x01)
	{
		//monitor supported
		if (data[6] & 0x10)
		{
			LED_MISFIRE(0); //Not complete
		}else
		{
			LED_MISFIRE(1);
		}
	}else
	{
		LED_MISFIRE(1); //not applicabple
	}

	if (data[6] & 0x02)
	{
		//monitor supported
		if (data[6] & 0x20)
		{
			LED_FUEL(0); //Not complete
		}else
		{
			LED_FUEL(1);
		}
	}else
	{
		LED_FUEL(1); //not applicabple
	}

	if (data[6] & 0x04)
	{
		//monitor supported
		if (data[6] & 0x40)
		{
			LED_COMP(0); //Not complete
		}else
		{
			LED_COMP(1);
		}
	}else
	{
		LED_COMP(1); //not applicabple
	}
	errors=0;
	return 0;
}