Esempio n. 1
0
//---------------------------------------------------------------------------
template<> OS_PROCESS void TProc2::exec()
{
    for(;;)
    {
        Timer_B_Ovf.wait();
    }
}
Esempio n. 2
0
OS_INTERRUPT void Uart0Rx_ISR()
{
	OS_ISR_ENTER();
	_CLI();
	uint8_t ret_val;

	ret_val=Receive_buffer_uart0(cur_address0);
	switch(ret_val)
	{
		case 2:
		{
			UCSR0B=0;
			#if !UART0_MASTER
			efUART0.Signal();
			#endif
			break;
		}
		case 3:
		{
			uart_status0|=UART_RX_OK;
			uart_init0();
			#if !UART0_MASTER
			set_uart0_to_transmitt();
			UCSR0B&=~(1<<RXEN0)|(1<<RXCIE0);
			UCSR0B=(1<<TXEN0)|(1<<TXCIE0);   //разрешение передатчика
			//set_uart0_to_transmitt();
			UDR0='!';
			#endif
			break;


		}
	}
	OS_ISR_EXIT();
}
Esempio n. 3
0
//---------------------------------------------------------------------------
template<> void TProc1::exec()
{
    for(;;)
    {
        ef.Wait();
    }     
}
Esempio n. 4
0
//---------------------------------------------------------------------------
template<> void TTerminalProc::exec()
{
    sleep(1000);
    
    for(;;)
    {
    LBegin:
        NewLineIncoming.wait();
        uint16_t n = strcspn(RxBuf, " \0");
        if(n == 0)
        {
            UART::send("\n\n");
            continue;
        }
        strncpy(command, RxBuf, n);
        command[n] = 0;
        for(uint16_t i = 0; i < sizeof(command_dict)/sizeof(command_dict[0]); i++)
        {
            if(strcmp(command, command_dict[i]) == 0)
            {
                UART::send("... Ok\r");
                char *s = RxBuf + n + 1;
                (*fptr[i])(s);
                goto LBegin;
            }
        }
        UART::send("... error: unknown command\r");
    }
}
Esempio n. 5
0
//---------------------------------------------------------------------------
template<> OS_PROCESS void TProc1::exec()
{
    for(;;)
    {
        ef.wait();
    }     
}
//---------------------------------------------------------------------------
template<> void TProc3::exec()
{
    for(;;)
    {
        sleep(2);
        ef.signal();
    }
}
//---------------------------------------------------------------------------
template<> void TProc2::exec()
{
    for(;;)
    {
        ef.wait();
        MMR16(FIO_FLAG_C) = (1 << 8);
    }
}
Esempio n. 8
0
//---------------------------------------------------------------------------
template<> OS_PROCESS void TProc1::exec()
{
    for(;;)
    {
        Timer_Flag.wait();
        SlonQueue.push(&African);
    }     
}
OS_INTERRUPT void Timer1_period_ISR()
{
    OS::TISRW_SS ISRW;

    ENABLE_NESTED_INTERRUPTS();

    Timer1_Ovf.signal_isr();
}
Esempio n. 10
0
//---------------------------------------------------------------------------
template<> void TProc2::exec()
{
    for(;;)
    {
        Timer_B_Ovf.Wait();
        P1OUT &= ~(1 << 4);
    }
}
Esempio n. 11
0
//---------------------------------------------------------------------------
template<> OS_PROCESS void TProc3::exec()
{
    for(;;)
    {
        OS::sleep(10);
        ef.signal();
    }
}
//---------------------------------------------------------------------------
template<> void TProc1::exec()
{
    for(;;)
    {
        ef_timer0.wait();
        MMR16(FIO_FLAG_C) = (1 << 9);
    }
}
//---------------------------------------------------------------------------
template<> void TProc1::exec()
{
    for(;;)
    {
        Timer1_Ovf.wait();
        SlonQueue.push(&African);
    }
}
Esempio n. 14
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
    }
}
Esempio n. 15
0
OS_INTERRUPT void Timer_B_ISR()
{
    OS::TISRW ISRW;

    ENABLE_NESTED_INTERRUPTS();

    P1OUT |= (1 << 4);
    Timer_B_Ovf.SignalISR();
}
template<> void TProc1::exec()
{

    for(;;)
    {
    	ef_timer0.wait();
    }

}
//---------------------------------------------------------------------------
template<> void TProc3::exec()
{
    for(;;)
    {
        sleep(3);
        MMR16(FIO_FLAG_S) = (1 << 8);
        ef.signal();
    }
}
Esempio n. 18
0
//---------------------------------------------------------------------------
void OS::system_timer_user_hook()
{
    static int cnt=0;
    if (++cnt == 25)
    {
        cnt = 0;
        Timer_B_Ovf.signal_isr();
    }
}
void OS::system_timer_user_hook()
{
	static int timer_event_counter = 5;
	if (!--timer_event_counter)
	{
		timer_event_counter = 5;
        LED1.On();
		TimerEvent.signal_isr();
	}
}
Esempio n. 20
0
OS_INTERRUPT void Timer_ISR()
{
    OS::TISRW ISRW;

    T1IR = T1IR;                    // clear int flag

    IOCLR0 = (1 << 10);
    TimerEvent.signal_isr();

    IRQ_DONE();
}
OS_INTERRUPT void timer_b_isr()
{
    OS::TISRW ISRW;

    ++Timer_B_Ticks;

    ENABLE_NESTED_INTERRUPTS();

    P1OUT |= (1 << 4);
    Timer_B_Ovf.signal_isr();
}
Esempio n. 22
0
void OS::system_timer_user_hook()
{
    static const int reload_value = 10;	// 100 Hz
    static int counter = reload_value;
    if (!--counter)
    {
        counter = reload_value;
        red_led::On();
        timer_event.signal_isr();
    }
}
//---------------------------------------------------------------------------
template<> void TProc2::exec()
{
    for(;;)
    {
        ef.wait();
        MMR16(FIO_FLAG_C) = (1 << 8);
        for(int i = 0; i < 100000; ++i)
        {
            asm( " nop;");
        }
    }
}
Esempio n. 24
0
OS_INTERRUPT void TIMER1_IRQHandler()
{
    OS::TISRW ISRW;
    
    // Clear all sources for the timer (we used just one in this simple sample)
    LPC_TIM1->IR = 0x3F;

    TIMER_ISR::On();
    TIMER_TO_PROC1::On();
    TimerEvent.signal_isr();
    TIMER_ISR::Off();
}
Esempio n. 25
0
INTERRUPT_HANDLER(Timer3_period_ISR, ITC_IRQ_TIM3_OVF)
{
    TIMER3_ISR.On();
    TIM3->SR1 &= ~TIM3_SR1_UIF;

    OS::TISRW ISRW;

    TIMER3_TO_PROC1.On();

    Timer3_Ovf.signal_isr();
    TIMER3_ISR.Off();
}
template<> void TProc2::exec()
{
	 for(;;)
	    {
		 ef.wait();
		 for(int i = 0; i < 100000; ++i)
		        {
		            asm( " nop;");
		        }
	    }

}
//---------------------------------------------------------------------------
template<> void TProc3::exec()
{
    for(;;)
    {
        sleep(3);
        for(int i = 0; i < 10000; ++i)
        {
            asm( " nop;");
        }
        MMR16(FIO_FLAG_S) = (1 << 8);
        ef.signal();
    }
}
Esempio n. 28
0
//---------------------------------------------------------------------------
template<> void TProc3::exec()
{
    for(;;)
    {
        sleep(1);
        ef.Signal();

        for(uint_fast8_t i = 0; i < OS::PROCESS_COUNT; ++i)
        {
            StackSlacks[i] = OS::get_proc(i)->stack_slack();
        }
    }
}
template<> void TProc3::exec()
{
	 for(;;)
	    {
		 sleep(3);
		 for(int i = 0; i < 10000; ++i)
		        {
		            asm( " nop;");
		        }
		 ef.signal();
	    }

}
Esempio n. 30
0
//void set_uart1_receive();
OS_INTERRUPT void Uart1Tx_ISR()
{
	OS_ISR_ENTER();
	_CLI();
	Transmitt_buffer_uart1();

	#if !UART1_MASTER
	if(uart_status1&UART_TX_OK)
	{
		efUART1.Signal();
	}
	#endif
	OS_ISR_EXIT();
}