Ejemplo n.º 1
0
//---------------------------------------------------------------------------
template<> void TProc1::exec()
{
    for(;;)
    {
        ef.Wait();
    }     
}
Ejemplo n.º 2
0
//---------------------------------------------------------------------------
template<> void TProc2::exec()
{
    for(;;)
    {
        Timer_B_Ovf.Wait();
        P1OUT &= ~(1 << 4);
    }
}
Ejemplo n.º 3
0
void TUART0::Exec()
{
	UCSR0A=0x00;
	UCSR0B=(1<<RXCIE0)|(1<<RXEN0);
	UCSR0C=(1<<UCSZ01)|(1<<UCSZ00);
	UBRR0H=0;
	UBRR0L=11;

	cur_net_pack=0;
	set_uart0_to_receive();

	for(;;)
    {
		//PORTC|=_BV(PC1);
//		#if !UART0_MASTER
		efUART0.Wait(150);
//		#endif
        set_uart0_to_receive();

		if(uart_status0&UART_RX_OK)
		{
            uiNetCounter=0;
			PORTC&=~_BV(PC1);			//Блималка при гарному пакеті
			uart_status0&=~UART_RX_OK;
//----------------------------------------------------------------------------
			memcpy(	(uint8_t*)&(data_for_slave1.devs_net_cmd[0]),
					(uint8_t*)&rx_local_buffer0[3],
					sizeof(NET_INPUT_STRUCT1)-sizeof(HEAD_NET_STRUCT));
//----------------------------------------------------------------------------
		}
		else {
			PORTC|=_BV(PC1);
            if (uiNetCounter<60) uiNetCounter++;
//			UCSR0B=(1<<RXEN0)|(1<<RXCIE0);
		}
            uart_status0=0;
			uart_init0();
			set_uart0_to_receive();
//---------------------------------------------------------------------------------------
        //Mutex1.Lock();
            memcpy((uint8_t*)&tx_local_buffer0,
            (uint8_t*)&data_from_slave1,
            sizeof(NET_OUTPUT_STRUCT1));
            cur_address0=data_for_slave1.head.adr;
        //Mutex1.Unlock();
//---------------------------------------------------------------------------------------

#if UART0_MASTER
			UCSR0B=(1<<TXEN0)|(1<<TXCIE0);   //разрешение передатчика
			set_uart0_to_transmitt();
			_delay_us(100);
			UDR0='#';
#else
            UCSR0B=(1<<RXEN0)|(1<<RXCIE0);
#endif
		Sleep(20);//7//10.37ms      //BULO 50
    }
}
Ejemplo n.º 4
0
void TUART1::Exec()
{
	UCSR1A=0x00;
	UCSR1B=(1<<RXCIE1)|(1<<RXEN1);
	UCSR1C=(1<<UCSZ11)|(1<<UCSZ10);
	UBRR1H=0;
	UBRR1L=11;
	set_uart1_to_receive();
	Uart1Counter=0;

	for(;;)
    {
		//#if !UART1_MASTER
		if (Uart1Counter==2) {
			efUART1.Wait(30);//200
		}
		else {
			efUART1.Wait(10);//200
		}
		//#endif
		if (Uart1Counter==0) {
			if (uart_status1&UART_TX_OK) Shota|=UART_TX_OK; else Shota&=~UART_TX_OK;
			if (uart_status1&UART_RX_OK) Shota|=UART_RX_OK; else Shota&=~UART_RX_OK;
		}
		//if (uart_status1&UART_TX_OK) {
		//	uart_status1&=~UART_TX_OK;

			if(uart_status1&UART_RX_OK)
			{
				uart_status1&=~UART_RX_OK;
				NetPackInfo2[Uart1Counter+ZSUV]=0x00;//
				switch(Uart1Counter)
				{
					case 0://типа shafa
					{
						memcpy(	(uint8_t*)&(data_for_slave2.devs_net_stat[0]),
								(uint8_t*)&rx_local_buffer1[3],
								sizeof(NET_INPUT_STRUCT2)-sizeof(HEAD_NET_STRUCT));
					//}
					break;
					}

					case 1://типа кнопки
					{
						memcpy(	(uint8_t*)&(key_data.key[0]),
								(uint8_t*)&rx_local_buffer1[3],
								sizeof(LCD_INPUT_STRUCT)-sizeof(HEAD_NET_STRUCT));
                        ProcesFlag|=0x01;

					break;
					}

					case 2:{ //типа мнемосхема

					}
					break;
				}
			}
			else {
				//if (uart_status1&UART_TX_OK) {
				//	uart_status1&=~UART_TX_OK;
					if(NetPackInfo2[Uart1Counter+ZSUV]<12) NetPackInfo2[Uart1Counter+ZSUV]++;
				//}
				//if(NetPackInfo2[Uart1Counter]<12) NetPackInfo2[Uart1Counter]++;
			}
		//}

		//Uart1Counter=0;
		if (Uart1Counter<2)
			Uart1Counter++;
		else Uart1Counter=0;

		//mnemo_counter++;
		if (Uart1Counter==2) mnemo_counter++;
		//if (mnemo_counter>=3) mnemo_counter=0;
		//mnemo_counter=0;
		if (mnemo_counter>=NUM_OF_MNEMO) mnemo_counter=0;

		if ((NetPackInfo2[0+ZSUV])) PORTC|=_BV(PC1);	else PORTC&=~_BV(PC1);
		switch(Uart1Counter)
		{
			case 0: {
				memcpy(	(uint8_t*)&tx_local_buffer1,
						(uint8_t*)&data_from_slave2,
						sizeof(NET_OUTPUT_STRUCT2));
						cur_address1=0x51;
				//cur_address1=data_from_slave1.head.adr;
			}
			break;

			case 1: {
				if(tech_fl&SOUND)
				{
					lcd_data.out_lcd[0]=0x00;
					lcd_data.out_lcd[1]=0x44;
				}
				else {
					if(!LCD_light)
					{
						if (tech_fl&SOUND_KEY){
							lcd_data.out_lcd[0]='1';
							lcd_data.out_lcd[1]='4';
							tech_fl&=~SOUND_KEY;
						}
						else {
							lcd_data.out_lcd[0]='0';
							lcd_data.out_lcd[1]='0';
						}
					}
					else
					{
						if (tech_fl&SOUND_KEY){
							lcd_data.out_lcd[0]='1';//31
							lcd_data.out_lcd[1]='D';//44
							tech_fl&=~SOUND_KEY;
						}
						else {
							lcd_data.out_lcd[0]='0';
							lcd_data.out_lcd[1]='8';
						}

					}
				}
				memcpy((uint8_t*)&lcd_data.out_lcd[2],(uint8_t*)&LCD_str[0],20);//16 //bulo 20
				lcd_data.out_lcd[22]='\\';//18     //bulo  22
				lcd_data.out_lcd[23]='n';//19		//bulo  23
				memcpy((uint8_t*)&lcd_data.out_lcd[24],(uint8_t*)&LCD_str[20],20);//20 16 16 	//bulo 24 20 20
				memcpy((uint8_t*)&tx_local_buffer1,(uint8_t*)&lcd_data,sizeof(LCD_OUTPUT_STRUCT));
				cur_address1=0x20;
			}
			break;

			case 2: {  //(-1|-5)
				if(mnemo_counter<(NUM_OF_MNEMO)) {
					if(scafe_fl&MNEMO_WRK)
					{
						color=0xff;
						if(scafe_fl&RED) color=0xf0;
						else if(scafe_fl&YELLOW) color=0x00;
						else if(scafe_fl&GREEN) color=0x0f;

						if(scafe_fl&FIELD)
						{
							for(tmp_counter=0;tmp_counter<80;tmp_counter++)
							{
								if(mnemo_test_counter==(mnemo_counter))
								{
									mnemo[mnemo_counter].rg_led[tmp_counter+1]=color;
								}
								else
								{
									mnemo[mnemo_counter].rg_led[tmp_counter+1]=0xff;
								}
							}
						}
						else
						{
							if(mnemo_test_counter==(mnemo_counter))
								if(!(scafe_fl&FREEZ)) loop_counter++;
							if(loop_counter>79) loop_counter=0;
							for(tmp_counter=0;tmp_counter<80;tmp_counter++)
							{
								if(tmp_counter==loop_counter)
									mnemo[mnemo_counter].rg_led[tmp_counter+1]=color;
								else
									mnemo[mnemo_counter].rg_led[tmp_counter+1]=0xff;
							}
						}
						memcpy((uint8_t*)&tx_local_buffer1,(uint8_t*)&mnemo[mnemo_counter],
						sizeof(MNEMO_OUTPUT_STRUCT));
					}
					else
					{
						memcpy((uint8_t*)&mnemo[mnemo_counter].rg_led[1],
						(uint8_t*)&LED_FIELD[80*(mnemo_counter)],80);
						memcpy((uint8_t*)&tx_local_buffer1,(uint8_t*)&mnemo[mnemo_counter],
						sizeof(MNEMO_OUTPUT_STRUCT));
					}
					cur_address1=0x30+(mnemo_counter);
					//mnemo_counter++;
				}
			}
			break;
		}
		uart_status1=0;
		uart_init1();
		set_uart1_to_receive();
#if UART1_MASTER
			UCSR1B=(1<<TXEN1)|(1<<TXCIE1);   //разрешение передатчика
			set_uart1_to_transmitt();
			_delay_us(100);
			UDR1='#';
#else
			UCSR1B=(1<<RXEN1)|(1<<RXCIE1);
#endif
		//Sleep(10);//70//10.37ms////bulo 25 26_11_08
    }
}