示例#1
0
static void
tftp_test(struct bootp *bp)
{
    int res;
    int server1_id = 0;
    int server2_id = 0;
    int server3_id = 0;

    extern struct tftpd_fileops dummy_fileops;

    server1_id = tftpd_start(0, &dummy_fileops);
    if (server1_id > 0) {
      diag_printf("TFTP server created - id: %x\n", server1_id);
    } else {
      diag_printf("Couldn't create first server!\n");
    }

#ifdef CYGSEM_NET_TFTPD_MULTITHREADED
    server2_id = tftpd_start(0, &dummy_fileops);
    if (server2_id > 0) {
      diag_printf("Second TFTP server created - id: %x\n", server2_id);
    } else {
      diag_printf("Couldn't create a second server!\n");
    }
#if CYGNUM_NET_TFTPD_MULTITHREADED_PORTS > 1
    server3_id = tftpd_start(1025, &dummy_fileops);
    if (server3_id > 0) {
      diag_printf("Third TFTP server created - id: %x\n", server3_id);
    } else {
      diag_printf("Couldn't create a third server!\n");
    }
#endif //CYGNUM_NET_TFTPD_MULTITHREADED_PORTS > 1
#else  //CYGSEM_NET_TFTPD_MULTITHREADED
    server2_id = tftpd_start(1025, &dummy_fileops);
    if (server2_id > 0) {
      diag_printf("Second TFTP server created - id: %x\n", server2_id);
    } else {
      diag_printf("Couldn't create a second server!\n");
    }
#endif //!CYGSEM_NET_TFTPD_MULTITHREADED
    
    // Only let the server run for 5 minutes
    cyg_thread_delay(2*100); // let the tftpd start up first
    TNR_ON();
    cyg_thread_delay(5*60*100);
    TNR_OFF();
    
    if (server1_id > 0) {
      res = tftpd_stop(server1_id);
      diag_printf("TFTP server - id: %x stopped - res: %d\n", server1_id, res);
    }
    if (server2_id > 0) {
      res = tftpd_stop(server2_id);
      diag_printf("TFTP server - id: %x stopped - res: %d\n", server2_id, res);
    }
    if (server3_id > 0) {
      res = tftpd_stop(server2_id);
      diag_printf("TFTP server - id: %x stopped - res: %d\n", server2_id, res);
    }
} 
示例#2
0
/* this is a simple program which runs in a thread */
void simple_program(cyg_addrword_t data)
{
    int message = (int) data;
    int delay;

    cyg_mutex_lock(&cliblock);
    printf("Beginning execution; thread data is %d\n", message);
    cyg_mutex_unlock(&cliblock);

    cyg_thread_delay(200);

    for (;;) {
        /* delay = 1000 + (rand() % 50); */
        delay = 5000*(1+message) + (rand() % 50);

        /* note: printf() must be protected by a
           call to cyg_mutex_lock() */
        cyg_mutex_lock(&cliblock);

        {
            cyg_tick_count_t tick;
            tick = cyg_current_time();
            #if 0
            printf("(%llu) Thread %d: and now a delay of %d clock ticks\n",
                        tick, message, delay);
            #else
//            printf("(%llu) Thread %d\n", tick, message);
            #endif

        }

        cyg_mutex_unlock(&cliblock);
        cyg_thread_delay(delay);
    }
}
示例#3
0
static void entry0( cyg_addrword_t data )
{
    CHECK( 222 == (int)data );

    cyg_thread_suspend(pt1);       
    cyg_thread_resume(pt1);

    cyg_thread_delay(1);

    cyg_thread_resume(pt1);

    cyg_thread_delay(1);

    CYG_TEST_PASS_FINISH("Kernel C API Thread 1 OK");
}
示例#4
0
static void
kbd_scan(cyg_addrword_t param)
{
    unsigned char ch;
    unsigned char *ev;

    diag_printf("Keyboard scan\n");
    while (true) {
        cyg_thread_delay(SCAN_DELAY);
        if (aaed2000_KeyboardTest()) {
            ch = aaed2000_KeyboardGetc();
            if (num_events < MAX_EVENTS) {
                num_events++;
                ev = &_events[_event_put++];
                if (_event_put == MAX_EVENTS) {
                    _event_put = 0;
                }
                *ev = ch;
                if (kbd_select_active) {
                    kbd_select_active = false;
                    cyg_selwakeup(&kbd_select_info);
                }
            }
        }
    }
}
示例#5
0
文件: vtask.c 项目: ibeilin/leon-wsn
/*
 * Author: xiaoyang
 * Created: 2011-9-22
 * Parameters:
 * Description:ecos thread for collecting
 */
void vtsk_handle(cyg_addrword_t data) {
	// uart test
	led_off(LEDG0);
	//dprintf("test begin.\n");
	//cyg_thread_delay(1000);
	//led_on(LEDG0);
	//apbuart_test(UART0_BASE);
	//serial test
	//dprintf("serial test begin.\n");
	//serial_test();
	
	//OV7660_init();
	//OV7660_work();
	//while (1) {
			/*do your own work here*/
			//dprintf("uart0 test ok.\n");
			//led_on(LEDG0);
			//cyg_thread_delay(50);
			//led_off(LEDG0);
			//cyg_thread_delay(50);
			/*do your own work here*/
	//}
	//fs_test();
	OV7660_init();
	OV7660_work();
	while(1){
		ov7660_pin_test();
		cyg_thread_delay(400);
	}

	dprintf("test end.\n");
}
    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);
    }
示例#7
0
void
nasd_start(void)
{
	int wait_time = 1 * 100; /* 1 second */

	if (!_nas_pid ||
	     !oslib_waitpid(_nas_pid, NULL)) {
		cyg_thread_create(7,
		                     (cyg_thread_entry_t *)nas_main,
		                     (cyg_addrword_t)NULL,
		                     "NAS",
		                     (void *)nas_main_stack,
		                     sizeof(nas_main_stack),
		                     &nas_main_hdl,
		                     &nas_thread);
		cyg_thread_resume(nas_main_hdl);

		/* Make sure nas stared and initial completed. Otherwise,
		 * it may lost some wireless driver events.
		 */
		while (_nas_ready == 0 && wait_time > 0) {
			cyg_thread_delay(10);
			wait_time -= 10;
		}

		NASMSG("NAS task started\n");
	}
}
/* Initialize IGD */
void
igd_start(void)
{
	char *value;

	/* 
	 * Stop igd_mainloop anyway,
	 * if not enabled.
	 */
	value = nvram_get("upnp_enable");
	if (value == 0 || atoi(value) == 0) {
		igd_stop_handler();
		return;
	}

	if (igd_running == 0) {
		igd_down = 0;
		cyg_thread_create(
			IGD_PRIORITY,
			(cyg_thread_entry_t *)&igd_main,
			0,
			"IGD",
			igd_main_stack,
			sizeof(igd_main_stack),
			&igd_main_tid,
			&igd_main_thread);
		cyg_thread_resume(igd_main_tid);

		/* Wait until thread scheduled */
		while (!igd_running && !igd_down)
			cyg_thread_delay(1);
	}

	return;
}
示例#9
0
static void
program_flash(cyg_addrword_t arg)
{
    diag_printf("PROGRAM FLASH here!\n");
    HAL_UCACHE_SYNC();     // ROM space is marked cacheable which causes problems!
    HAL_UCACHE_DISABLE();  // So, just disable caches.
    identify_FLASH();
    diag_printf("About to program FLASH using data at %x..%x\n", flash_buffer, flash_buffer_end);
    diag_printf("*** Press RESET now to abort!\n");
    cyg_thread_delay(5*100);
    diag_printf("\n");
    diag_printf("... Erase sector\n");
    if (erase_sector(ROM_address)) {
        diag_printf("... Programming FLASH\n");
        while (flash_buffer < flash_buffer_end) {
            if (!write_flash(flash_buffer++, ROM_address++)) break;
        }
    }
    
    // Exit Program Mode
    switch (manuf_code) {
    case ATMEL_MANUF:
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_START_CMD1;
        FLASH[ATMEL_SEQ_ADD2] = ATMEL_START_CMD2;
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_STOP_CMD;
        break;
    case INTEL_MANUF:
        FLASH[0] = INTEL_STOP_CMD;
        break;
    }
    diag_printf("All done!\n");
    cyg_test_exit();
}
示例#10
0
void simple_programB(cyg_addrword_t data)
{
    int msg = (int) data;
    int delay;
    printf("Starting thread : %d\n",msg);
    cyg_thread_delay(200);
    for(;;)
    {
        delay = 200 + (rand()%50);
        resFree(resAllocated);
        cyg_mutex_lock(&mut_t);
        printf("Allocating resource for thread %d\n", msg);
        cyg_mutex_unlock(&mut_t);
        cyg_thread_delay(delay);
    }
}
示例#11
0
void
identify_FLASH(void )
{
    // Enter Software Product Identification Mode
    FLASH[ATMEL_SEQ_ADD1] = ATMEL_START_CMD1;
    FLASH[ATMEL_SEQ_ADD2] = ATMEL_START_CMD2;
    FLASH[ATMEL_SEQ_ADD1] = ATMEL_ID_CMD;

    // Wait at least 10ms
    cyg_thread_delay(2);

    // Read Manufacturer and device code from the device
    manuf_code = FLASH[0] >> 16;
    device_code = FLASH[1] >> 16;

    diag_printf("manufacturer: 0x%04x, device: 0x%04x\n", manuf_code, device_code);

    // Exit Software Product Identification Mode
    switch (manuf_code) {
    case ATMEL_MANUF:
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_START_CMD1;
        FLASH[ATMEL_SEQ_ADD2] = ATMEL_START_CMD2;
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_STOP_CMD;
        break;
    case INTEL_MANUF:
        FLASH[0] = INTEL_STOP_CMD;
        break;
    default:
        diag_printf("Unrecognized FLASH manufacturer - I give up!\n");
        cyg_test_exit();
    }
}
示例#12
0
static int
e_thread_delay(lua_State *L)
{
    int delay = luaL_checkint(L, 1);
    cyg_thread_delay(delay);
    return 0;
}
示例#13
0
// Thread A - signals thread B via semaphore.
void thread_a(cyg_addrword_t data)
{
    // Store the data value passed in for this thread.
    int msg = (int)data;

    weak_function ();
    
    while(thread_a_count < 5)
    {
        // Increment the thread a count.
        thread_a_count++;


        // Send out a message to the diagnostic port.
        diag_printf("INFO:<Thread A, count: %d  message: %d>\n", thread_a_count, msg);

        // Delay for 1 second.
        cyg_thread_delay(100);

        // Signal thread B using the semaphore.
        cyg_semaphore_post(&sem_signal_thread);
    }
    
    CYG_TEST_CHECK(weak_fn_called == 2 , "Application week function not called");
    CYG_TEST_FINISH("Object loader test finished");
}
示例#14
0
void
net_test(cyg_addrword_t param)
{
    extern void cyg_net_snmp_init(void);

    CYG_TEST_INIT();
    CYG_TEST_INFO("Start multiple SNMP server test");
    init_all_network_interfaces();

    autohost_init();

    cyg_net_snmp_init();

    TNR_INIT();
    
    // Now command the host to do ping to us...
#ifdef CYGHWR_NET_DRIVER_ETH0
    if (eth0_up) {
        do_snmp_tests(&eth0_bootp_data, 3, TESTTIME);
    }
#endif
#ifdef CYGHWR_NET_DRIVER_ETH1
    if (eth1_up) {
        do_snmp_tests(&eth1_bootp_data, 3, TESTTIME);
    }
#endif
    // Let the server run for 5 minutes
    cyg_thread_delay(2*100); // let the stuff start up first
    TNR_ON();
    cyg_thread_delay(TESTTIME*100); // FIXME - assume cS clock.
    // Additional delay 'cos host may be slower than us - and it has to
    // complete a transfer anyway:
    cyg_thread_delay(  30    *100); // FIXME - assume cS clock.
    TNR_OFF();

    autohost_end( 3 * (0
#ifdef CYGHWR_NET_DRIVER_ETH0
                  + eth0_up
#endif
#ifdef CYGHWR_NET_DRIVER_ETH1
                  + eth1_up
#endif
        ) ); // check for N pass messages from hosts

    TNR_PRINT_ACTIVITY();
    CYG_TEST_EXIT("Done");
}
示例#15
0
void
nas_sleep_ms(uint ms)
{
	cyg_tick_count_t ostick;

	ostick = ms / 10;
	cyg_thread_delay(ostick);
}
示例#16
0
void 
hipri_test(CYG_ADDRESS id)
{
    while( 1 )
    {
        cyg_thread_delay( CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS/2 );
    }
}
示例#17
0
static void cyg_httpd_init(cyg_addrword_t arg)
{
    int i;
    int err = 0;

    /* Delay for a configurable length of time to give the application
     * a chance to get going, or even complete, without interference
     * from the HTTPD.
     */
    if( CYGNUM_HTTPD_SERVER_DELAY > 0 )
    {
        cyg_thread_delay( CYGNUM_HTTPD_SERVER_DELAY );
    }
    
    server_address.sin_family = AF_INET;
    server_address.sin_len = sizeof(server_address);
    server_address.sin_addr.s_addr = INADDR_ANY;
    server_address.sin_port = htons(CYGNUM_HTTPD_SERVER_PORT);

    /* Get the network going. This is benign if the application has
     * already done this.
     */
    init_all_network_interfaces();

    /* Create and bind the server socket.
     */
    server_socket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
    CYG_ASSERT( server_socket > 0, "Socket create failed");

    err = bind( server_socket, (struct sockaddr *)&server_address,
                sizeof(server_address) );
    CYG_ASSERT( err == 0, "bind() returned error");

    err = listen( server_socket, SOMAXCONN );
    CYG_ASSERT( err == 0, "listen() returned error" );

    /* If we are configured to have more than one server thread,
     * create them now.
     */
    for( i = 1; i < CYGNUM_HTTPD_THREAD_COUNT; i++ )
    {
        cyg_thread_create( CYGNUM_HTTPD_THREAD_PRIORITY,
                           cyg_httpd_server,
                           0,
                           "HTTPD",
                           &httpd_stacks[i][0],
                           sizeof(httpd_stacks[i]),
                           &httpd_thread[i],
                           &httpd_thread_object[i]
            );
    
        cyg_thread_resume( httpd_thread[i] );
    }

    /* Now go be a server ourself.
     */
    cyg_httpd_server(arg);
}
示例#18
0
static void
do_delay(int ticks)
{
#ifdef CYGPKG_KERNEL
    cyg_thread_delay(ticks);
#else
    CYGACC_CALL_IF_DELAY_US(10000*ticks);
#endif
}
示例#19
0
int main( int argc, char *argv[] )
{
	int i;
	HAL_DCACHE_ENABLE();
	
	printf("begin mutex_test_posix\n");

	
	// initialize mutex with default attributes
	pthread_mutex_init(&mutex, NULL);
	pthread_mutex_lock(&mutex);
	
	printf("creating hw thread... ");
	POSIX_HWT_CREATE(0,0,thread_resources);
	
	printf("ok\n");
	cyg_thread_delay(50);

	for(i = 0; i < 10; i++){
		unsigned long ticks = cyg_current_time();
		//printf("current time = %ld ticks\n",ticks); // XXX remove
		pthread_mutex_unlock(&mutex);
		while(cyg_current_time() - ticks < 10); // wait for 0.1 seconds
		pthread_mutex_lock(&mutex);
		ticks = cyg_current_time() - ticks;
		//printf("delta t = %ld ticks\n", ticks); // XXX remove
		
		printf("mutex lock and release by hwthread: ");
		if(ticks > 20 && ticks < 40){
			printf("success\n");
		}
		else if(ticks <= 20){
			printf("too early\n"); // should not happen
		}
		else {
			printf("too late\n"); // should not happen
		}
		cyg_thread_delay(50);
	}
	
	printf("mutex_test_posix done.\n");
	
	return 0;
}
示例#20
0
int
world_thread(CYG_ADDRWORD data)
{
    int argc = 1;
    char *argv[] = {"world" };

    cyg_thread_delay(10*100);
    INIT_PER_THREAD_DATA();
    world_main(argc, argv);
}
示例#21
0
static void
tftp_test(struct bootp *bp)
{
    int server_id, res;
    extern struct tftpd_fileops dummy_fileops;
    server_id = tftpd_start(0, &dummy_fileops);
    if (server_id > 0) {
        diag_printf("TFTP server created - id: %x\n", server_id);
        // Only let the server run for 5 minutes
        cyg_thread_delay(2*100); // let the tftpd start up first
        TNR_ON();
        cyg_thread_delay(5*60*100);
        TNR_OFF();
        res = tftpd_stop(server_id);
        diag_printf("TFTP server stopped - res: %d\n", res);
    } else {
        diag_printf("Couldn't create a server!\n");
    }
}
示例#22
0
int simple_multi_thread(void)
{
	NET_DATA_T netdata1, netdata2, netdata3, netdata4, netdata5, netdata6, netdata7;
	
	netdata1.iport = 40;
	netdata1.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf1);
	netdata2.iport = 41;
	netdata2.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf2);
	netdata3.iport = 42;
	netdata3.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf3);
	netdata4.iport = 43;
	netdata4.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf4);
	netdata5.iport = 44;
	netdata5.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf5);
	netdata6.iport = 45;
	netdata6.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf6);
	netdata7.iport = 46;
	netdata7.pbuf = (char*)NON_CACHE(g_RemoteNet_Buf7);
	cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata1, "simple_tcpserver1",
					thread_stack1, STACK_SIZE, &thread_handle1, &thread1);
	cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata2, "simple_tcpserver2",
					thread_stack2, STACK_SIZE, &thread_handle2, &thread2);
	cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata3, "simple_tcpserver3",
					thread_stack3, STACK_SIZE, &thread_handle3, &thread3);
	cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata4, "simple_tcpserver4",
					thread_stack4, STACK_SIZE, &thread_handle4, &thread4);
	cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata5, "simple_tcpserver5",
					thread_stack5, STACK_SIZE, &thread_handle5, &thread5);
	cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata6, "simple_tcpserver6",
					thread_stack6, STACK_SIZE, &thread_handle6, &thread6);
	//cyg_thread_create(THREAD_PRIORITY, &simple_tcpserver, (cyg_addrword_t)&netdata7, "simple_tcpserver7",
	//				thread_stack7, STACK_SIZE, &thread_handle7, &thread7);
	/*
	cyg_thread_create(THREAD_PRIORITY, &simple_udpserver, (cyg_addrword_t)&netdata1, "simple_udpserver1",
					thread_stack1, STACK_SIZE, &thread_handle1, &thread1);
	cyg_thread_create(THREAD_PRIORITY, &simple_udpserver, (cyg_addrword_t)&netdata2, "simple_udpserver2",
					thread_stack2, STACK_SIZE, &thread_handle2, &thread2);
	cyg_thread_create(THREAD_PRIORITY, &simple_udpserver, (cyg_addrword_t)&netdata3, "simple_udpserver3",
					thread_stack3, STACK_SIZE, &thread_handle3, &thread3);
	*/
	
	tbegin = cyg_current_time();
	cyg_thread_resume(thread_handle1);
	cyg_thread_resume(thread_handle2);
	cyg_thread_resume(thread_handle3);
	cyg_thread_resume(thread_handle4);
	cyg_thread_resume(thread_handle5);
	cyg_thread_resume(thread_handle6);
	//cyg_thread_resume(thread_handle7);
	
	while(1)
	{
		cyg_thread_delay(100000);
	}
}
示例#23
0
文件: hello.c 项目: fbinder/EZS_UE
//Funktion eventuell static machen
void test_thread(cyg_addrword_t arg){
	/* Einmalige Aufgaben ... */
	int message = (int) arg;
	printf("Beginning hello world excecution: thread data is %d\n", message);

	while(1){
		/* Periodische Aufgaben ... */
		diag_printf("Hello World!\n");
		cyg_thread_delay(1000);
	}
}
示例#24
0
int
erase_sector(volatile long *mem)
{
    long data1, data2;
    long status;
    int timer;
    switch (manuf_code) {
    case ATMEL_MANUF:
        // Erase sector command
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_START_CMD1;
        FLASH[ATMEL_SEQ_ADD2] = ATMEL_START_CMD2;
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_ERASE_CMD;
        FLASH[ATMEL_SEQ_ADD1] = ATMEL_START_CMD1;
        FLASH[ATMEL_SEQ_ADD2] = ATMEL_START_CMD2;
        *mem = ATMEL_SECTOR_ERASE_CMD;
        while (TRUE) {
            data1 = *mem;  // Read cell back twice
            data2 = *mem;
            // Bits 6+2 toggle between reads while programming in progress
            if ((data1 & ATMEL_ERASE_TOGGLE) == (data2 & ATMEL_ERASE_TOGGLE)) break;
        }
        break;
    case INTEL_MANUF:
        // Clear current errors
        FLASH[0] = INTEL_CLEAR_STATUS;
        // Issue erase block command
        FLASH[0] = INTEL_ERASE_CMD;
        *mem = INTEL_ERASE_CONFIRM;
        timer = ERASE_TIMEOUT*50;
        // Read the status register while erase in progress
        do {
            cyg_thread_delay(2);
            status = FLASH[0];
        } while (((status & INTEL_SB_WSMS) != INTEL_SB_WSMS) &&
                 (--timer > 0));
        // Check for errors
        if (timer == 0) {
            diag_printf("Erase not complete after %d seconds - status: 0x%08x\n", 
                        ERASE_TIMEOUT, status);
        }
        if ((status & INTEL_SB_ERASE_ERROR) != 0) {
            diag_printf("Device reports erase error - status: 0x%08x\n", status);
        }
        // Exit erase mode
        FLASH[0] = INTEL_STOP_CMD;
        break;
    }
    if (*mem != 0xFFFFFFFF) {
        diag_printf("Erase failed at 0x%08x - read: 0x%08x\n",
                    mem, *mem);
        return (FALSE);
    }
    return (TRUE);
}
示例#25
0
文件: tcp_echo.c 项目: LucidOne/Rovio
void
net_test(cyg_addrword_t param)
{
    cyg_serial_baud_rate_t old;    
    cyg_ppp_options_t options;
    cyg_ppp_handle_t ppp_handle;

    CYG_TEST_INIT();
    
    diag_printf("Start TCP test - ECHO mode\n");
    init_all_network_interfaces();
    calibrate_load(DESIRED_BACKGROUND_LOAD);
#ifdef CYGPKG_SNMPAGENT
    {
        extern void cyg_net_snmp_init(void);
        cyg_net_snmp_init();
    }
#endif

    old = ppp_test_set_baud( CYGNUM_SERIAL_BAUD_115200 );

    ppp_test_announce( "TCP_ECHO" );
    
    cyg_ppp_options_init( &options );

//    options.debug = 1;
//    options.kdebugflag = 1;
//    options.flowctl = CYG_PPP_FLOWCTL_SOFTWARE;

    ppp_handle = cyg_ppp_up( CYGPKG_PPP_TEST_DEVICE, &options );

    CYG_TEST_INFO( "Waiting for PPP to come up");
    
    cyg_ppp_wait_up( ppp_handle );

    echo_test(param);

    CYG_TEST_INFO( "Bringing PPP down");

    cyg_ppp_down( ppp_handle );
    
    CYG_TEST_INFO( "Waiting for PPP to go down");

    cyg_ppp_wait_down( ppp_handle );

    cyg_thread_delay( 200 );
    
    ppp_test_set_baud( old );

    ppp_test_finish();
    
    CYG_TEST_PASS_FINISH("TCP ECHO test OK");
}
示例#26
0
void
httpd_test(cyg_addrword_t p)
{
  
  CYG_TEST_INIT();

  init_all_network_interfaces();

  cyg_thread_delay(1 * 60 * 100);

  CYG_TEST_PASS_FINISH( "httpd test finished" );
}
//
// These thread(s) do some amount of "background" computing.  This is used
// to simulate a given load level.  They need to be run at a higher priority 
// than the network code itself.
//
// Like the "idle" thread, they run as long as their "switch" (aka semaphore)
// is enabled.
//
void
net_load(cyg_addrword_t who)
{
    int i;
    while (true) {
        cyg_semaphore_wait(&load_thread_sem[who]);
        for (i = 0;  i < load_thread_level;  i++) {
            do_some_random_computation(i);
        }
        cyg_thread_delay(1);  // Wait until the next 'tick'
        cyg_semaphore_post(&load_thread_sem[who]);
    }
}
示例#28
0
///
/// Load a bitstream via ICAP
///
/// @param bitstream pointer to the bitstream array
/// @param length    length of bitstream in bytes
///
void icap_load(unsigned char * bitstream, size_t length){

        XStatus status;

        if (!cyg_mutex_lock(&icap_mutex)) {
            CYG_FAIL("mutex lock failed, aborting thread\n");
        } else {

            // wait until ICAP is ready
            while (HwIcap.IsTransferInProgress) {
                diag_printf("icap_load(): transfer in progress, waiting...\n");
                cyg_thread_delay(1);
            }
            while (! (XHwIcap_GetStatusReg(&HwIcap) & XHI_SR_DONE_MASK)) {
                diag_printf("icap_load(): device busy, waiting...\n");
                cyg_thread_delay(1);
            }

            status = XHwIcap_DeviceWrite(&HwIcap, (Xuint32*)bitstream, length/4);
            if (status != XST_SUCCESS)
            {
                if(status == XST_DEVICE_BUSY) diag_printf("HWICAP: device busy\n");
                if(status == XST_INVALID_PARAM) diag_printf("HWICAP: invalid parameter\n");
                CYG_FAIL("failed to load bitstream\naborting\n");
            }

            // wait until ICAP is ready
            while (HwIcap.IsTransferInProgress) {
                diag_printf("icap_load(): transfer in progress, waiting...\n");
                cyg_thread_delay(1);
            }
            while (! (XHwIcap_GetStatusReg(&HwIcap) & XHI_SR_DONE_MASK)) {
                diag_printf("icap_load(): device busy, waiting...\n");
                cyg_thread_delay(1);
            }

            cyg_mutex_unlock(&icap_mutex);
        }
}
示例#29
0
static int tsec_fake_int(cyg_addrword_t param)
{
	struct eth_drv_sc *sc = (struct eth_drv_sc *) param;
	cyg_uint32 int_state;

	while (true)
	{
		cyg_thread_delay(1); // 10ms
		HAL_DISABLE_INTERRUPTS(int_state);
		tsec_eth_int(sc);
		HAL_RESTORE_INTERRUPTS(int_state);
	}
}
示例#30
0
文件: lcd_test.c 项目: 0xCA5A/dd-wrt
static void
lcd_test(int depth)
{
    int i, j;
    diag_printf("Set depth %d\n", depth);
    lcd_on(depth);
    lcd_clear();
    for (j = 0;  j < 5;  j++) {
        for (i = 0;  i < width;  i++) {
            lcd_putc('A');
        }
    }
    lcd_putc('\n');
    lcd_putc('\n');
    cyg_thread_delay(5*100);
    for (j = 0;  j < 5;  j++) {
        for (i = FIRST_CHAR;  i <= LAST_CHAR;  i++) {
            lcd_putc(i);
        }
    }
    cyg_thread_delay(5*100);
}