Пример #1
0
void SendCAN(unsigned int Mbox)
{
	// Check for bus off
	ECanaShadow.CANMC.all = ECanaRegs.CANMC.all;
	if (ECanaShadow.CANMC.bit.CCR == 1)
	{
		BUS_OFF();
	}
	// 1UL so there's a mask for at least 32 mailboxes
	mask = 1UL << Mbox;
	ECanaRegs.CANTRS.all = mask;

	//todo Nathan: calibrate sendcan stopwatch
	StopWatchRestart(can_watch);

	do{ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;}
	while(((ECanaShadow.CANTA.all & mask) != mask) && (isStopWatchComplete(can_watch) == 0)); //wait to send or hit stop watch

	ECanaRegs.CANTA.all = mask;						//clear flag
	if (isStopWatchComplete(can_watch) == 1)					//if stopwatch flag
	{
		ops.Flags.bit.can_error = 1;
	}
	else if (ops.Flags.bit.can_error == 1)		//if no stopwatch and flagged reset
	{
		ops.Flags.bit.can_error = 0;
	}
}
void PerformSystemChecks()
{
	//exit and stopwatch error if timeout
	if (isStopWatchComplete(conv_watch_in_sys) == 1)
	{
		ops_temp_sys.SystemFlags.bit.cov_error = 1;
	}
	else
	{
		ops_temp_sys.SystemFlags.bit.cov_error = 0;
	}

	/*
	 * No longer used in MCN v2.0 because 12V button no longer exists
	if (ops_temp_sys.SystemFlags.all != 0)
	{
		SET12V();
	}
	else
	{
		CLEAR12V();
	}
	*/
}