Ejemplo n.º 1
0
// -------------------------------------------------------------------------------------
// Setup - uP: ATMega16
//
void Setup()
{

 CD_ID_1 = 0x03;
 CD_ID_2 = 0x60; //was cammera

 HU_ID_1 = 0x01;
 HU_ID_2 = 0x60; //was 0x40

 showLog = 1;
 showLog2 = 1;

 MCUCR = 0; //turn on everything
 
 //Clear Timer on Compare Mode
 TCCR1B |= (1 << WGM12 | 1 << CS12); // Configure timer 1 for CTC mode with 256 prescaler
 TIMSK1 |= (1 << OCIE1A); // Enable CTC interrupt

 
 RS232_Init();
 AVCLan_Init();

 Event = EV_NOTHING;
 sei(); //enable global interupts

 //         T  * osc. freq. / prescaler - 1 (error: 1s per 50h)
 OCR1A   = 0.5 *   14745000 /       256 - 1; // Set CTC compare value

}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
int main()
{
 PIN_Setup();
 
 //delay_ms(100);

 AVCLan_Init();

 #ifndef SNIFFER
 	iPod_Init();
 #endif

#ifdef MONITOR
	RS232_Print("********************** RESET *********************\n");
 #endif

 while (1) {

	if (INPUT_IS_SET) {	 // if message from some device on AVCLan begin
  		AVCLan_Read_Message();
		// check command from HU
		if (answerReq != 0) AVCLan_SendAnswer();
	}

	#ifndef SNIFFER
	// HandleEvent
	if (Event & EV_STATUS)
		{
		Event &= ~EV_STATUS;
	  	if (CD_Mode!=stStop) {
			AVCLan_Send_Status();
			};
		}

	if (Event & EV_DISPLAY)
		{
		Event &= ~EV_DISPLAY;
		AVCLan_Send_Changer_Status();
		}
	#endif

	RS232_SendStuff();
 } // end while(1)
}
Ejemplo n.º 3
0
//------------------------------------------------------------------------------
int main()
{

 PIN_Setup();

 AVCLan_Init();

 iPod_Init();


#ifdef MONITOR
	delay_ms(100);
	 RS232_Print("********************** RESET *********************8\n");
 #endif

 while (1) {

	//Wait1msForAVCLan();
	if ((INPUT_IS_SET>0) & (ACC_IS_ON>0)) {	 // if message from some device on AVCLan begin
  		AVCLan_Read_Message();
	} else {
		// check command from HU
		if ((answerReq != 0) & (RXState == WAITING_FOR_FF)) AVCLan_SendAnswer();
	
    }

	// HandleEvent
	if (((Event & EV_STATUS)>0) & (RXState == WAITING_FOR_FF)) {
	  	if (CD_Mode != stStop) {
			if ((CD_Mode == stFF) | (CD_Mode == stRR)) {
				if (!AVCLan_Send_Status(0x18)) Event &= ~EV_STATUS;
				}
			else
				{
			    switch (playMode) {
					case 0: if (!AVCLan_Send_Status(0x03)) Event &= ~EV_STATUS; break;
					case 1:	if (!AVCLan_Send_Status(0x10)) Event &= ~EV_STATUS; break;
				};
			};
		};
    }

	if (Event & EV_DISPLAY)	{
		if (!AVCLan_Send_Changer_Status()) Event &= ~EV_DISPLAY;;
	};

	if (ACC_IS_ON) 	{
		// audio output
		if (CD_Mode == stStop)
			CHANNELS_OFF();

		if (CD_Mode == stPlay)
			{
			if (AuxInput==Aux2)
				CHANNEL_TWO();
			if (AuxInput==Aux1)
				CHANNEL_ONE();
			}
		}	else 	{ 
			CHANNELS_OFF();
			CD_Mode = stStop;
			playMode = 0;
		};

	// iPod
	if (AUX1ISIPOD)
		iPod_Poll();
	
	if (!(ACC_IS_ON))
		registered = 0;
	// zzzzz
	//if (sleepcounter > 5)
	//	{ 
	//	CHANNELS_OFF();
	//	sleep_mode();
	//	sleepcounter = 0;
	//	}
 } // end while(1)
}