コード例 #1
0
ファイル: scheduling.c プロジェクト: PAAW/mAEWing1
void init_scheduler(void)
{
	int rtc_ticks_per_sec;

	/* get handle to the system realtime clock */
	rtclock = cyg_real_time_clock ();
	rtc_resolution = cyg_clock_get_resolution ( rtclock );
	rtc_ticks_per_sec = rtc_resolution.divisor;
	cyg_clock_to_counter ( rtclock, &rtc_counter );
	
	// Real time clock frequency must be changed in eCos configuration, as there is another
	// macro that depends on its value.
	//fprintf ( stderr, "cyg_realtime_clock() resolution: dividend=%d, \t divisor=%d\n", rtc_resolution.dividend, rtc_resolution.divisor );

	// Create alarms
	cyg_alarm_create ( rtc_counter, alarm_handlerfn_daq,0,&alarm_hdl[0],&alarm_obj[0] );
	cyg_alarm_create ( rtc_counter, alarm_handlerfn_actuators,0,&alarm_hdl[1],&alarm_obj[1] );
	cyg_alarm_create ( rtc_counter, alarm_handlerfn_thread1,0,&alarm_hdl[2],&alarm_obj[2] );

	// Initialize conditional variables
	pthread_cond_init (&trigger_daq, NULL);
	pthread_cond_init (&trigger_actuators, NULL);
	pthread_cond_init (&trigger_thread1, NULL);

	// Start alarms
	// DAQ, executes at t0 + 0.0000
	cyg_alarm_initialize ( alarm_hdl[0], DAQ_OFFSET*rtc_ticks_per_sec, rtc_ticks_per_sec/BASE_HZ );
	
	// ACTUATORS, executes at t0 + 0.014
	cyg_alarm_initialize ( alarm_hdl[1], ACTUATORS_OFFSET*rtc_ticks_per_sec, rtc_ticks_per_sec/BASE_HZ);

	// Thread1, executes at t0 + 0.0130
	cyg_alarm_initialize ( alarm_hdl[2], THREAD1_OFFSET*rtc_ticks_per_sec, rtc_ticks_per_sec/THREAD1_HZ );

}
コード例 #2
0
    void NSFOSThread::sleep(UInt32 sleepTime)
    {
        static cyg_resolution_t timerResolution = cyg_clock_get_resolution(cyg_real_time_clock());

        // Assumes cyg_clock_get_resolution(cyg_real_time_clock()).divisor is in Hz (ticks/sec), as per documentation.
        cyg_thread_delay(((sleepTime * timerResolution.divisor) + 999) / 1000);
    }
コード例 #3
0
CECOSTimerHandler::CECOSTimerHandler(){
  cyg_semaphore_init(&m_stSemaphore, 0);

  m_stSystemclockHandle = cyg_real_time_clock();
  cyg_clock_to_counter(m_stSystemclockHandle, &m_stCounterHandle);

  cyg_alarm_create(m_stCounterHandle, timerHandlerFunc, (cyg_addrword_t) 0, &m_stAlarmHandle, &m_stAlarm);
}
コード例 #4
0
ファイル: sco.c プロジェクト: LucidOne/Rovio
static void sco_sock_init_timer(struct sock *sk)
{
//	init_timer(&sk->timer);
//	sk->timer.function = sco_sock_timeout;
//	sk->timer.data = (unsigned long)sk;
	cyg_clock_to_counter(cyg_real_time_clock(), &sk->h);
    cyg_alarm_create(sk->h, sco_sock_timeout, (cyg_addrword_t)sk, &sk->timeout_alarm_handle, &sk->timeout_alarm);
}
コード例 #5
0
ファイル: fptest.c プロジェクト: EPiCS/reconos_v2
void fptest_main( void )
{
    
    CYG_TEST_INIT();

    if( cyg_test_is_simulator )
    {
        run_ticks = RUN_TICKS_SIM;
    }

    CYG_TEST_INFO("Run fptest in cyg_start");
    do_test( fpt3_values, FP3_COUNT, 1000, 0, "start" );
    CYG_TEST_INFO( "cyg_start run done");
    
    cyg_thread_create( BASE_PRI-1,
                       fptest1,
                       0,
                       "fptest1",
                       &stacks[0][0],
                       STACK_SIZE,
                       &thread[0],
                       &thread_struct[0]);

    cyg_thread_resume( thread[0] );

    cyg_thread_create( BASE_PRI,
                       fptest2,
                       1,
                       "fptest2",
                       &stacks[1][0],
                       STACK_SIZE,
                       &thread[1],
                       &thread_struct[1]);

    cyg_thread_resume( thread[1] );

    cyg_thread_create( BASE_PRI,
                       fptest3,
                       2,
                       "fptest3",
                       &stacks[2][0],
                       STACK_SIZE,
                       &thread[2],
                       &thread_struct[2]);

    cyg_thread_resume( thread[2] );

    cyg_alarm_create( cyg_real_time_clock(),
                      alarm_fn,
                      0,
                      &alarm,
                      &alarm_struct );

    cyg_alarm_initialize( alarm, cyg_current_time()+1, 1 );
    
    cyg_scheduler_start();

}
void tcp_hole()
{
	int interval = 30000;
	
	TCP_HOLE_FLAG = 1;
  	
  	/* Attach the timer to the CloseTcpHole clock */
    CloseTcpHole_SysClk = cyg_real_time_clock();

    cyg_clock_to_counter(CloseTcpHole_SysClk, &CloseTcpHole_Counter);

    cyg_alarm_create(CloseTcpHole_Counter, (cyg_alarm_t *)CloseTcpHole,
                     0,
                     &CloseTcpHole_Alarm, &CloseTcpHole_timerAlarm);

    /* This creates a periodic timer */
    cyg_alarm_initialize(CloseTcpHole_Alarm, cyg_current_time() + interval, 0); //only trigger once after 5 minutes   

}
コード例 #7
0
ファイル: app.c プロジェクト: rbsn/FAU-EZS
void cyg_user_start(void)
{
	printf("initializing SB16\n");
	ezs_sb16_init(&sb16,
			0x220 /* io address */,
			5 /* interrupt */,
			1 /* 8 bit DMA */,
			5 /* 16 bit DMA */);

	printf("initializing HPET\n");
	ezs_counter_init();

	// Initialize Tracer
	printf("initializing tracer\n");
	int res = ezs_trace_init();
	printf("tracer resolution: %d\r\n" , res);

	cyg_clock_to_counter(cyg_real_time_clock(), &s_real_time_counter);

	init_tasks();
}
コード例 #8
0
ファイル: timeout.c プロジェクト: Palantir555/ecos-mars-zx3
// ------------------------------------------------------------------------
// INITIALIZATION FUNCTION
void
cyg_alarm_timeout_init( void )
{
    // Init the alarm object, attached to the real time clock
    cyg_handle_t h;
    cyg_clock_to_counter(cyg_real_time_clock(), &h);
    cyg_alarm_create(h, do_alarm, 0, &timeout_alarm_handle, &timeout_alarm);
    // Init the flag of waking up
    cyg_flag_init( &alarm_flag );
    // Create alarm background thread to run the callbacks
    cyg_thread_create(
        CYGPKG_NET_FAST_THREAD_PRIORITY, // Priority
        alarm_thread,                   // entry
        0,                              // entry parameter
        "Network alarm support",        // Name
        &alarm_stack[0],                // Stack
        STACK_SIZE,                     // Size
        &alarm_thread_handle,           // Handle
        &alarm_thread_data              // Thread data structure
        );
    cyg_thread_resume(alarm_thread_handle);    // Start it
}
void linklocal_alarm(void){


	/* 10 sec, Follow Link Local IP Stard. If we got ip conflict twice 
	   within 10 seconds, we have to change our link local ip.  
	   											<<<Ron 12/13/04  >>> */    
    int interval = 10; //10 sec
    
    /* Attach the timer to the real-time clock */
    hSysClk = cyg_real_time_clock();

    cyg_clock_to_counter(hSysClk, &hCounter);

//    cyg_alarm_create(hCounter, (cyg_alarm_t *)linklocal_msg_post,
	cyg_alarm_create(hCounter, (cyg_alarm_t *)linklocal_msg_timer,
                     (cyg_addrword_t) &alarmData,
                     &hAlarm, &timerAlarm);

    /* This creates a periodic timer */
    cyg_alarm_initialize(hAlarm, cyg_current_time() + interval, 10);
	
}
コード例 #10
0
ファイル: sys-ecos.c プロジェクト: KublaikhanGeek/dd-wrt
/*
 * sys_init - System-dependent initialization.
 */
void
sys_init()
{
    if( sockfd == -1 )
    {
        /* Get an internet socket for doing socket ioctl's on. */
        if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
            syslog(LOG_ERR, "Couldn't create IP socket: %d",errno);
            die(1);
        }
    }

    ppp_tty.pppd_wakeup = 0;
    ppp_tty.pppd_thread_running = true;
    
    ppp_rtc = cyg_real_time_clock();
    ppp_rtc_resolution = cyg_clock_get_resolution( ppp_rtc );

    cyg_alarm_create( ppp_rtc,
                      wait_input_alarm,
                      (cyg_addrword_t)&ppp_tty,
                      &ppp_tty.alarm,
                      &ppp_tty.alarm_obj);
}
コード例 #11
0
ファイル: kclock0.c プロジェクト: EPiCS/reconos_v2
void kclock0_main(void)
{
    CYG_TEST_INIT();

    CHECK(flash());
    CHECK(flash());

    cyg_counter_create( &counter0, &counter0o);

    CHECK( 0 == cyg_counter_current_value( counter0 ) );

    cyg_counter_tick(counter0);

    CHECK( 1 == cyg_counter_current_value(counter0) );

    cyg_counter_tick(counter0);

    CHECK( 2 == cyg_counter_current_value(counter0) );

    cyg_counter_set_value( counter0, 0xffffffff );

    CHECK( 0xffffffff == cyg_counter_current_value(counter0) );

    cyg_counter_tick(counter0); // Overflows 32 bits
    
    CHECK( 0x100000000ULL == cyg_counter_current_value(counter0) );

    cyg_counter_set_value(counter0, 11);
    CHECK( 11 == cyg_counter_current_value(counter0) );
    
    /* the call_me functions cause the "called" bits to toggle
    // checking the value of called checks the parity of # of calls
    // made by each alarm.
    */

    cyg_alarm_create(counter0,
                     call_me,  (cyg_addrword_t)0x1, &alarm0, &alarmo[0]);
    cyg_alarm_create(counter0,
                     call_me,  (cyg_addrword_t)0x2, &alarm1, &alarmo[1]);
    cyg_alarm_create(counter0,
                     call_me2, (cyg_addrword_t)0x4, &alarm2, &alarmo[2]);
    
    CHECK( 0x00 == called );
    cyg_alarm_initialize(alarm0, 12,3);
    cyg_alarm_initialize(alarm2, 21,2);
    CHECK( 0x00 == called );

    cyg_counter_tick(counter0);         /* 12 a0 */
    CHECK( 0x01 == called );

    cyg_alarm_initialize(alarm1, 13,0);
    cyg_counter_tick(counter0);         /* 13 a1 */
    CHECK( 0x03 == called );

    cyg_alarm_initialize(alarm1, 17,0);
    cyg_counter_tick(counter0);         /* 14 */
    CHECK( 0x03 == called );

    cyg_counter_tick(counter0);         /* 15 a0 */
    CHECK( 0x02 == called );

    cyg_counter_tick(counter0);         /* 16 */
    cyg_counter_tick(counter0);         /* 17 a1 */
    CHECK( 0x00 == called );

    cyg_counter_tick(counter0);         /* 18 a0 */
    CHECK( 0x01 == called );

    cyg_counter_tick(counter0);         /* 19 */
    cyg_counter_tick(counter0);         /* 20 */
    cyg_counter_tick(counter0);         /* 21 a0 a2 */
    CHECK( 0x14 == called );

    cyg_counter_tick(counter0);         /* 22 */
    cyg_counter_tick(counter0);         /* 23 a2 */
    CHECK( 0x00 == called );
    
    cyg_alarm_disable(alarm2);  

    cyg_counter_tick(counter0);         /* 24 a0 */
    cyg_counter_tick(counter0);         /* 25 */
    CHECK( 0x01 == called );
    
    cyg_alarm_enable(alarm2);           /* a2 (enabled at 25) */
    CHECK( 0x15 == called );

    cyg_counter_tick(counter0);         /* 26 */
    CHECK( 0x15 == called );
    
    cyg_counter_tick(counter0);         /* 27 a0 a2 */
    cyg_counter_tick(counter0);         /* 28 */
    CHECK( 0x00 == called );
    
    cyg_counter_tick(counter0);         /* 29 a2 */
    cyg_counter_tick(counter0);         /* 30 a0 */
    cyg_counter_tick(counter0);         /* 31 a2 */
    CHECK( 0x01 == called );

    res0.dividend = 100;
    res0.divisor   = 3;

    cyg_clock_create( res0, &clock0, &clock0o );

    res1 = cyg_clock_get_resolution(clock0);
    CHECK( res0.dividend == res1.dividend );
    CHECK( res0.divisor == res1.divisor );

    res1.dividend = 12;
    res1.divisor = 25;

    cyg_clock_set_resolution(clock0, res1);
    res0 = cyg_clock_get_resolution(clock0);
    CHECK( res0.dividend == res1.dividend );
    CHECK( res0.divisor == res1.divisor );

    cyg_clock_to_counter(clock0, &counter1);

    CHECK( 0 == cyg_counter_current_value( counter1 ) );
    CHECK( 0 == cyg_current_time() );

    cyg_counter_tick(counter1);

    CHECK( 1 == cyg_counter_current_value(counter1) );

    res0 = cyg_clock_get_resolution(cyg_real_time_clock());

    /* Current time should be 0 as interrupts will still be disabled */
    CHECK( 0 == cyg_current_time() );

    CYG_TEST_PASS_FINISH("Kernel C API Clock 0 OK");
}
コード例 #12
0
ファイル: app.c プロジェクト: rbsn/FAU-EZS
void cyg_user_start(void){
	// Initialize framebuffer in graphic mode
	ezs_fb_init();
	// Initialize soundblaster
	ezs_sb16_init(&sb16,
			0x220 /* io address */,
			5 /* interrupt */,
			1 /* 8 bit DMA */,
			5 /* 16 bit DMA */);

	// Initialize HPET counter
	ezs_counter_init();

	// Initialize Tracer
	int res = ezs_trace_init();
	printf("init res: %d\r\n" , res);

	// Create keyboard interrupt, attach to handler table and umask
	cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_KEYBOARD, 1, (cyg_addrword_t) &keyhandle, keyb_isr_handler, keyb_dsr_handler, &handle, &intr) ;
	cyg_interrupt_attach(handle);
	cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_KEYBOARD);

	// Create test thread
	cyg_thread_create(17, &thread, 0, "Abtastung1", my_stack, STACKSIZE,
		&threadhndl1, &threaddata);

	// Create keyboard thread
	cyg_thread_create(1, &keythread, 0, "Keyboard", keystack, STACKSIZE,
			&keyhandle, &keydata);
			
	// Create other threads
	cyg_thread_create(1, abtastung1, 0, "thread_abtastung1", my_stack_abt1, STACKSIZE,
				&(threadhndl_abt1), &(threaddata_abt1));
	cyg_thread_create(5, abtastung2, 0, "thread_abtastung2", my_stack_abt2, STACKSIZE,
				&(threadhndl_abt2), &(threaddata_abt2));
	cyg_thread_create(10, analyse, 0, "thread_analyse", my_stack_anal, STACKSIZE,
				&(threadhndl_anal), &(threaddata_anal));
	cyg_thread_create(15, darstellung, 0, "thread_darstellung", my_stack_darst, STACKSIZE,
				&(threadhndl_darst), &(threaddata_darst));
	
	cyg_handle_t counter;
	cyg_clock_to_counter(cyg_real_time_clock(), &counter);

	/*
	cyg_alarm_create(counter, alarm_handler, (cyg_addrword_t) &threadhndl1 , &alarmhnd1, &alarm1);
	cyg_alarm_initialize(alarmhnd1, 0, 10);
	cyg_alarm_enable(alarmhnd1);
	*/
	
	cyg_alarm_create(counter, alarm_handler, (cyg_addrword_t) &threadhndl_abt1 , &alarmhnd_abt1, &alarm_abt1);
	cyg_alarm_initialize(alarmhnd_abt1, cyg_counter_current_value(counter) + 10, 10);
	
	cyg_alarm_create(counter, alarm_handler, (cyg_addrword_t) &threadhndl_abt2 , &alarmhnd_abt2, &alarm_abt2);
	cyg_alarm_initialize(alarmhnd_abt2, cyg_counter_current_value(counter) + 12, 20);
	
	cyg_alarm_create(counter, alarm_handler, (cyg_addrword_t) &threadhndl_anal , &alarmhnd_anal, &alarm_anal);
	cyg_alarm_initialize(alarmhnd_anal, cyg_counter_current_value(counter) + 14, 20);
	
	cyg_alarm_create(counter, alarm_handler, (cyg_addrword_t) &threadhndl_darst , &alarmhnd_darst, &alarm_darst);
	cyg_alarm_initialize(alarmhnd_darst, cyg_counter_current_value(counter) + 22, 100);

}