Пример #1
0
void alarmfn1(cyg_handle_t alarmh, cyg_addrword_t data)
{
    db_printf("%s: %d\n",__PRETTY_FUNCTION__,cyg_counter_current_value( counter ));

    alarmfn_called[1]++;

    // Reschedule alarm[0] to run every tick until alarm[2] next runs.
    
    cyg_alarm_initialize( alarm[0], cyg_counter_current_value( counter )+1, 1 );

}
Пример #2
0
void alarmfn2(cyg_handle_t alarmh, cyg_addrword_t data)
{
    db_printf("%s: %d\n",__PRETTY_FUNCTION__,cyg_counter_current_value( counter ));
    
    alarmfn_called[2]++;

    // Reschedule alarm[0] to run every 2 ticks until alarm[1] next runs.

    cyg_alarm_initialize( alarm[0], cyg_counter_current_value( counter )+1, 2 );

    // Reschedule alarm[1] to run every 3 ticks starting in 6 ticks time.
    
    cyg_alarm_initialize( alarm[1], cyg_counter_current_value( counter )+6, 3 );
}
Пример #3
0
void alarmfn0(cyg_handle_t alarmh, cyg_addrword_t data)
{
    db_printf("%s: %d\n",__PRETTY_FUNCTION__,cyg_counter_current_value( counter ));

    // alarmfn0 just counts how many times it has been called
    
    alarmfn_called[0]++;
}
Пример #4
0
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");
}
Пример #5
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);

}