本文整理汇总了C++中cyg_thread_delay函数的典型用法代码示例。如果您正苦于以下问题:C++ cyg_thread_delay函数的具体用法?C++ cyg_thread_delay怎么用?C++ cyg_thread_delay使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cyg_thread_delay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: simple_program
/* 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);
}
}
示例2: entry0
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");
}
示例3: kbd_scan
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);
}
}
}
}
}
示例4: vtsk_handle
/*
* 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");
}
示例5: cyg_clock_get_resolution
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);
}
示例6: nasd_start
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");
}
}
示例7: igd_start
/* 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;
}
示例8: program_flash
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();
}
示例9: simple_programB
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);
}
}
示例10: identify_FLASH
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();
}
}
示例11: e_thread_delay
static int
e_thread_delay(lua_State *L)
{
int delay = luaL_checkint(L, 1);
cyg_thread_delay(delay);
return 0;
}
示例12: thread_a
// 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");
}
示例13: net_test
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(ð0_bootp_data, 3, TESTTIME);
}
#endif
#ifdef CYGHWR_NET_DRIVER_ETH1
if (eth1_up) {
do_snmp_tests(ð1_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");
}
示例14: nas_sleep_ms
void
nas_sleep_ms(uint ms)
{
cyg_tick_count_t ostick;
ostick = ms / 10;
cyg_thread_delay(ostick);
}
示例15: hipri_test
void
hipri_test(CYG_ADDRESS id)
{
while( 1 )
{
cyg_thread_delay( CYGNUM_KERNEL_SCHED_TIMESLICE_TICKS/2 );
}
}