• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ rt_tick_get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中rt_tick_get函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_tick_get函数的具体用法?C++ rt_tick_get怎么用?C++ rt_tick_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了rt_tick_get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: writespeed

static int writespeed(int fd, char *buff_ptr, unsigned int total_length, int block_size)
{
    int index, length;
    rt_tick_t tick;
	
	/* prepare write data */
	for (index = 0; index < block_size; index++)
	{
		buff_ptr[index] = index;
	}
	index = 0;

	/* get the beginning tick */
    tick = rt_tick_get();
	while (index < total_length / block_size)
	{
		length = write(fd, buff_ptr, block_size);
		if (length != block_size)
		{
			rt_kprintf("write failed\n");
			break;
		}

		index ++;
	}
    tick = rt_tick_get() - tick;

    /* calculate write speed */
    return (total_length / tick * RT_TICK_PER_SECOND);

}
开发者ID:cvrobot,项目名称:deepblueplane,代码行数:31,代码来源:fs_test.c


示例2: _sleep_entry

static void _sleep_entry(void)
{
	rt_tick_t timeout;
	rt_uint32_t ms;
	rt_uint32_t count;

	system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY);
	timeout = rt_timer_next_timeout_tick() - rt_tick_get();

	ms = timeout * (1000 / RT_TICK_PER_SECOND);
	rt_kprintf("os tick:%u entry sleep:%u tick\r\n", rt_tick_get(), timeout);

	_rtc_timer_start(ms);

	system_sleep();

	rt_enter_critical();
	count = rtc_count_get_count(&rtc_instance);
	ms = (count + 32) / 32.768;
	rtc_count_disable(&rtc_instance);
	sleep_tick_adjust(ms);
	timeout = rt_tick_get();
	rt_exit_critical();
	rt_kprintf("sleep exited, os tick:%u\n", timeout);
}
开发者ID:csz-cmy,项目名称:rt-thread,代码行数:25,代码来源:sleep_timer.c


示例3: msc_thread_entry

void msc_thread_entry(void *parameter)
{
    extern void player_ui_freeze(void);
    unsigned long test_unit_ready_start = rt_tick_get();
    test_unit_ready_last = test_unit_ready_start;

    /* wait connection */
    while( test_unit_ready_last == test_unit_ready_start )
    {
        rt_thread_delay( RT_TICK_PER_SECOND );
    }


    /* freeze player UI */
    player_ui_freeze();

    /* wait remove */
    while(1)
    {
        rt_thread_delay( RT_TICK_PER_SECOND/2 );
        if( rt_tick_get() - test_unit_ready_last > RT_TICK_PER_SECOND*2 )
        {
//            rt_kprintf("\r\nCable removed!\r\nSystemReset\r\n\r\n");
//            NVIC_SystemReset();
        }
    }
}
开发者ID:Manish-cimcon,项目名称:micro,代码行数:27,代码来源:usb_main.c


示例4: thread_entry

static void thread_entry(void* parameter)
{
	rt_tick_t tick;
	rt_kprintf("thread inited ok\n");

	tick = rt_tick_get();
	rt_kprintf("thread delay 10 tick\n");
	rt_thread_delay(10);
	if (rt_tick_get() - tick > 10)
	{
		tc_done(TC_STAT_FAILED);
		return;
	}

	tick = rt_tick_get();
	rt_kprintf("thread delay 15 tick\n");
	rt_thread_delay(15);
	if (rt_tick_get() - tick > 15)
	{
		tc_done(TC_STAT_FAILED);
		return;
	}

	rt_kprintf("thread exit\n");

	tc_done(TC_STAT_PASSED);
}
开发者ID:aspirefhaha,项目名称:ad7606_stm32107,代码行数:27,代码来源:thread_delay.c


示例5: PVD_IRQHandler

void PVD_IRQHandler(void)
{
	unsigned poweroff_cnt;
	unsigned long time;

	EXTI->PR = EXTI_Line16; //EXTI_ClearITPendingBit(EXTI_Line16);

	/* 系统上电前500ms, 不认为是掉电; 若已处于系统掉电状态, 将不再处理 */
	if ((rt_tick_get() < 50) || (NULL == rtc_dev) || is_system_powerdown) {
		return;
	}

	/*
		lcd_bl_led_off();
		buzzer_off(buzzer_gpio, buzzer_pin);
	*/
	is_system_powerdown = 1;
	sys_powerdown_delay4confirm = rt_tick_get();

	PWR_BackupAccessCmd(ENABLE);

	poweroff_cnt = BKP_ReadBackupRegister(RX_POWEROFF_CNT_BKP16BITS);
	BKP_WriteBackupRegister(RX_POWEROFF_CNT_BKP16BITS, ++poweroff_cnt);

	rt_device_control(rtc_dev, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
	BKP_WriteBackupRegister(RX_POWEROFF_N_BKP16BITS_H, (time>>16) & 0xffff);
	BKP_WriteBackupRegister(RX_POWEROFF_N_BKP16BITS_L, (time) & 0xffff);

	PWR_BackupAccessCmd(DISABLE);

	//rt_kprintf("%s", __FUNCTION__);

	return;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:34,代码来源:stm32f10x_it.c


示例6: Sram_thread_entry

void Sram_thread_entry(void* parameter)
{
	rt_tick_t t1,t2;
	SRAM_Init();
	Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F);  
	//DMA_Config();
//	while(flag)
//	{
//		rt_thread_delay(1);
//	}
	rt_sem_take(&rt_sram_sem, RT_WAITING_FOREVER);
	while(flag1)
	{
		int fd;
		//int i=1024;
		fd = open("/ud/text.txt", O_WRONLY | O_CREAT,0);	
			if (fd >= 0)
			{
				t1 = rt_tick_get();
//				while(i>0)
//				{
					write(fd, RAM_Buffer, sizeof(RAM_Buffer));
//					i--;
//				}
				t2 = rt_tick_get();
				rt_kprintf("%d\n\r",t2-t1);
				close(fd);
			}
			rt_thread_delay(100);
		//SRAM_ReadBuffer(aTxBuffer,0,BUFFER_SIZE);
	}
	while(1);
	//Fill_Buffer(aTxBuffer, BUFFER_SIZE, 0xA244250F); 
}
开发者ID:XHelaoshi,项目名称:USER,代码行数:34,代码来源:fsmc_sram.c


示例7: gsm_send_wait_func

rt_err_t gsm_send_wait_func( char *AT_cmd_string,
                             uint32_t timeout,
                             RESP_FUNC respfunc,
                             uint8_t no_of_attempts )
{
	rt_err_t		err;
	uint8_t			i;
	char			*pmsg;
	uint32_t		tick_start, tick_end;
	uint32_t		tm;
	__IO uint8_t	flag_wait;

	char			* pinfo;
	uint16_t		len;

	err = rt_sem_take( &sem_at, timeout );
	if( err != RT_EOK )
	{
		return err;
	}

	for( i = 0; i < no_of_attempts; i++ )
	{
		tick_start	= rt_tick_get( );
		tick_end	= tick_start + timeout;
		tm			= timeout;
		flag_wait	= 1;
		rt_kprintf( "%08d gsm>%s\r\n", tick_start, AT_cmd_string );
		m66_write( &dev_gsm, 0, AT_cmd_string, strlen( AT_cmd_string ) );
		while( flag_wait )
		{
			err = rt_mb_recv( &mb_gsmrx, (rt_uint32_t*)&pmsg, tm );
			if( err == RT_EOK )                         /*没有超时,判断信息是否正确*/
			{
				len		= ( *pmsg << 8 ) | ( *( pmsg + 1 ) );
				pinfo	= pmsg + 2;
				if( respfunc( pinfo, len ) == RT_EOK )  /*找到了*/
				{
					rt_free( pmsg );                    /*释放*/
					rt_sem_release( &sem_at );
					return RT_EOK;
				}
				rt_free( pmsg );                        /*释放*/
				/*计算剩下的超时时间,由于其他任务执行的延时,会溢出,要判断*/
				if( rt_tick_get( ) < tick_end )         /*还没有超时*/
				{
					tm = tick_end - rt_tick_get( );
				}else
				{
					flag_wait = 0;
				}
			}else /*已经超时*/
			{
				flag_wait = 0;
			}
		}
	}
	rt_sem_release( &sem_at );
	return ( -RT_ETIMEOUT );
}
开发者ID:baiyangmin,项目名称:RTT_GPS_TW703_H1,代码行数:60,代码来源:m66.c


示例8: i2c_davinci_wait_bus_not_busy

/*
 * Waiting for bus not busy
 */
static int i2c_davinci_wait_bus_not_busy(struct davinci_i2c_dev *dev,
					 char allow_sleep)
{
	unsigned long timeout;
	static rt_uint16_t to_cnt;

	timeout = rt_tick_get() + dev->bus->timeout;
	while (davinci_i2c_read_reg(dev, DAVINCI_I2C_STR_REG)
	       & DAVINCI_I2C_STR_BB) {
		if (to_cnt <= DAVINCI_I2C_MAX_TRIES) {
			if (rt_tick_get() >= timeout) {
				rt_kprintf("timeout waiting for bus ready\n");
				to_cnt++;
				return -RT_ETIMEOUT;
			} else {
				to_cnt = 0;
				i2c_recover_bus(dev);
				i2c_davinci_init(dev);
			}
		}
		if (allow_sleep)
			rt_thread_delay(2);
	}

	return 0;
}
开发者ID:dongjw777,项目名称:dm365-voip,代码行数:29,代码来源:i2c-davinci.c


示例9: rt_soft_timer_check

/**
 * This function will check timer list, if a timeout event happens, the
 * corresponding timeout function will be invoked.
 *
 */
void rt_soft_timer_check()
{
	rt_tick_t current_tick;
	rt_list_t *n;
	struct rt_timer *t;

#ifdef RT_TIMER_DEBUG
	rt_kprintf("software timer check enter\n");
#endif

	current_tick = rt_tick_get();

	for (n = rt_soft_timer_list.next; n != &(rt_soft_timer_list); )
	{
		t = rt_list_entry(n, struct rt_timer, list);
		
		/*
		 * It supposes that the new tick shall less than the half duration of tick max.
		 */
		if ((current_tick - t->timeout_tick) < RT_TICK_MAX/2)
		{
#ifdef RT_USING_HOOK
			if (rt_timer_timeout_hook != RT_NULL) rt_timer_timeout_hook(t);
#endif
			/* move node to the next */
			n = n->next;

			/* remove timer from timer list firstly */
			rt_list_remove(&(t->list));

			/* call timeout function */
			t->timeout_func(t->parameter);

			/* re-get tick */
			current_tick = rt_tick_get();

#ifdef RT_TIMER_DEBUG
			rt_kprintf("current tick: %d\n", current_tick);
#endif

			if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
					(t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
			{
				/* start it */
				t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
				rt_timer_start(t);
			}
			else
			{
				/* stop timer */
				t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
			}
		}
		else break; /* not check anymore */
	}

#ifdef RT_TIMER_DEBUG
	rt_kprintf("software timer check leave\n");
#endif
}
开发者ID:520lly,项目名称:-android-source-code,代码行数:65,代码来源:timer.c


示例10: rt_timer_check

/**
 * This function will check timer list, if a timeout event happens, the
 * corresponding timeout function will be invoked.
 *
 * @note this function shall be invoked in operating system timer interrupt.
 */
void rt_timer_check(void)
{
    struct rt_timer *t;
    rt_tick_t current_tick;
    register rt_base_t level;

    RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check enter\n"));

    current_tick = rt_tick_get();

    /* disable interrupt */
    level = rt_hw_interrupt_disable();

    while (!rt_list_isempty(&rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1]))
    {
        t = rt_list_entry(rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
                          struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);

        /*
         * It supposes that the new tick shall less than the half duration of
         * tick max.
         */
        if ((current_tick - t->timeout_tick) < RT_TICK_MAX/2)
        {
            RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));

            /* remove timer from timer list firstly */
            _rt_timer_remove(t);

            /* call timeout function */
            t->timeout_func(t->parameter);

            /* re-get tick */
            current_tick = rt_tick_get();

            RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));

            if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
                (t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
            {
                /* start it */
                t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
                rt_timer_start(t);
            }
            else
            {
                /* stop timer */
                t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
            }
        }
        else
            break;
    }

    /* enable interrupt */
    rt_hw_interrupt_enable(level);

    RT_DEBUG_LOG(RT_DEBUG_TIMER, ("timer check leave\n"));
}
开发者ID:KNCheung,项目名称:AlarmClockBeta,代码行数:65,代码来源:timer.c


示例11: gsm_send_wait_str_ok

/***********************************************************
* Function:
* Description:
* Input:
* Input:
* Output:
* Return:
* Others:
***********************************************************/
rt_err_t gsm_send_wait_str_ok( char *AT_cmd_string,
                               uint32_t timeout,
                               char * respstr,
                               uint8_t no_of_attempts )
{
	rt_err_t		err;
	uint8_t			i = 0;
	char			*pmsg;
	uint32_t		tick_start, tick_end;
	uint32_t		tm;
	__IO uint8_t	flag_wait = 1;
	err = rt_sem_take( &sem_at, timeout );
	if( err != RT_EOK )
	{
		return err;
	}

	for( i = 0; i < no_of_attempts; i++ )
	{
		tick_start	= rt_tick_get( );
		tick_end	= tick_start + timeout;
		tm			= timeout;
		flag_wait	= 1;
		rt_kprintf( "%08d gsm>%s\r\n", tick_start, AT_cmd_string );
		m66_write( &dev_gsm, 0, AT_cmd_string, strlen( AT_cmd_string ) );
		while( flag_wait )
		{
			err = rt_mb_recv( &mb_gsmrx, (rt_uint32_t*)&pmsg, tm );
			if( err == RT_EOK )                                 /*没有超时,判断信息是否正确*/
			{
				if( strstr( pmsg + 2, respstr ) != RT_NULL )    /*找到了*/
				{
					rt_free( pmsg );                            /*释放*/
					goto lbl_send_wait_ok;
				}
				rt_free( pmsg );                                /*释放*/
				/*计算剩下的超时时间,由于其他任务执行的延时,会溢出,要判断*/
				if( rt_tick_get( ) < tick_end )                 /*还没有超时*/
				{
					tm = tick_end - rt_tick_get( );
				}else
				{
					flag_wait = 0;
				}
			}else /*已经超时*/
			{
				flag_wait = 0;
			}
		}
	}
	rt_sem_release( &sem_at );
	return -RT_ETIMEOUT;

lbl_send_wait_ok:
	err = gsm_wait_str( "OK", RT_TICK_PER_SECOND * 2 );
	rt_sem_release( &sem_at );
	return err;
}
开发者ID:baiyangmin,项目名称:RTT_GPS_TW703_H1,代码行数:67,代码来源:m66.c


示例12: rt_soft_timer_check

/**
 * This function will check timer list, if a timeout event happens, the
 * corresponding timeout function will be invoked.
 */
void rt_soft_timer_check(void)
{
    rt_tick_t current_tick;
    rt_list_t *n;
    struct rt_timer *t;

    RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check enter\n"));

    current_tick = rt_tick_get();

    for (n = rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1].next;
         n != &(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1]);)
    {
        t = rt_list_entry(n, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL-1]);

        /*
         * It supposes that the new tick shall less than the half duration of
         * tick max.
         */
        if ((current_tick - t->timeout_tick) < RT_TICK_MAX / 2)
        {
            RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));

            /* move node to the next */
            n = n->next;

            /* remove timer from timer list firstly */
            _rt_timer_remove(t);

            /* call timeout function */
            t->timeout_func(t->parameter);

            /* re-get tick */
            current_tick = rt_tick_get();

            RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));

            if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
                (t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
            {
                /* start it */
                t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
                rt_timer_start(t);
            }
            else
            {
                /* stop timer */
                t->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
            }
        }
        else break; /* not check anymore */
    }

    RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n"));
}
开发者ID:KNCheung,项目名称:AlarmClockBeta,代码行数:59,代码来源:timer.c


示例13: rt_thread_gsm_power_on

/*gsm供电的处理纤程*/
static void rt_thread_gsm_power_on( void* parameter )
{
	rt_err_t	ret;
	int			i;
	AT_CMD_RESP at_init[] =
	{
		{ "",			   RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 5, 1	 },
		{ "",			   RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 5, 1	 },
		{ "ATE0\r\n",	   RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 5, 1	 },
		{ "ATV1\r\n",	   RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 5, 1	 },
		{ "AT%TSIM\r\n",   RESP_TYPE_STR_WITHOK,  RT_NULL,	  "%TSIM 1",	  RT_TICK_PER_SECOND * 2, 5	 },


		{ "AT+CMGF=0\r\n", RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 3, 3	 },
		{ "AT+CNMI=1,2\r\n",RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 3, 3	 },

		
		{ "AT+CPIN?\r\n",  RESP_TYPE_STR_WITHOK,  RT_NULL,	  "+CPIN: READY", RT_TICK_PER_SECOND * 2, 30 },
		
		{ "AT+CIMI\r\n",   RESP_TYPE_FUNC_WITHOK, resp_CIMI,  RT_NULL,		  RT_TICK_PER_SECOND * 2, 10 },
		{ "AT+CLIP=1\r\n", RESP_TYPE_STR,		  RT_NULL,	  "OK",			  RT_TICK_PER_SECOND * 2, 10 },
		{ "AT+CREG?\r\n",  RESP_TYPE_FUNC_WITHOK, resp_CGREG, RT_NULL,		  RT_TICK_PER_SECOND * 2, 30 },
	};

lbl_poweron_start:
	rt_kprintf( "%08d gsm_power_on>start\r\n", rt_tick_get( ) );

	GPIO_ResetBits( GSM_PWR_PORT, GSM_PWR_PIN );
	GPIO_ResetBits( GSM_TERMON_PORT, GSM_TERMON_PIN );
	rt_thread_delay( RT_TICK_PER_SECOND / 10 );
	GPIO_SetBits( GSM_TERMON_PORT, GSM_TERMON_PIN );
	GPIO_SetBits( GSM_PWR_PORT, GSM_PWR_PIN );

	for( i = 0; i < sizeof( at_init ) / sizeof( AT_CMD_RESP ); i++ )
	{
		if( gsm_send( at_init[i].atcmd, \
		              at_init[i].resp, \
		              at_init[i].compare_str, \
		              at_init[i].type, \
		              at_init[i].timeout, \
		              at_init[i].retry ) != RT_EOK )
		{
			/*todo 错误计数,通知显示*/
			rt_kprintf( "%08d stage=%d\r\n", rt_tick_get( ), i );
			goto lbl_poweron_start;
		}
	}

	rt_kprintf( "%08d gsm_power_on>end\r\n", rt_tick_get( ) );

	gsm_state = GSM_AT; /*当前出于AT状态,可以拨号,连接*/
}
开发者ID:baiyangmin,项目名称:RTT_GPS_TW703_H1,代码行数:53,代码来源:m66.c


示例14: _touch_session

static void _touch_session()
{
    touch_point_t tpd;
#ifdef RT_USING_RTGUI
    struct rtgui_event_mouse emouse;
#endif

    ft5406_read_touch(&tpd);

#ifdef RT_USING_RTGUI
    emouse.parent.sender = RT_NULL;
    emouse.wid = RT_NULL;

    emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
    emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_DOWN;
    emouse.x = tpd.TOUCH_X;
    emouse.y = tpd.TOUCH_Y;
    emouse.ts = rt_tick_get();
    emouse.id = emouse.ts;
    if (emouse.id == 0) emouse.id = 1;
    rtgui_server_post_event(&emouse.parent, sizeof(emouse));
#endif

    do
    {
        rt_thread_delay(RT_TICK_PER_SECOND / BSP_TOUCH_SAMPLE_HZ);
        if (ft5406_read_touch(&tpd) != 0)
            break;

#ifdef RT_USING_RTGUI
        emouse.parent.type = RTGUI_EVENT_MOUSE_MOTION;
        emouse.x = tpd.TOUCH_X;
        emouse.y = tpd.TOUCH_Y;
        emouse.ts = rt_tick_get();
        rtgui_server_post_event(&emouse.parent, sizeof(emouse));
#endif
    }
    while (1);

#ifdef RT_USING_RTGUI
    /* Always send touch up event. */
    emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
    emouse.button = RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP;
    emouse.x = tpd.TOUCH_X;
    emouse.y = tpd.TOUCH_Y;
    emouse.ts = rt_tick_get();
    rtgui_server_post_event(&emouse.parent, sizeof(emouse));
#endif

    //} while (rt_sem_take(&_tp_sem, TOUCH_SLP_TIME) == RT_EOK);
}
开发者ID:heyuanjie87,项目名称:rt-thread,代码行数:51,代码来源:drv_ft5406.c


示例15: mqtt_waitForDNS

mqtt_err_t mqtt_waitForDNS(uint32_t timeout)
{
	rt_tick_t ticks = timeout * RT_TICK_PER_SECOND/1000;
	ticks += rt_tick_get();

	while(!dnsDone){
		if(rt_tick_get() > ticks)
		{
			dnsDone = 0;
			return mqtt_timeout;
		}
	}
		dnsDone = 0;
		return mqtt_errSuccess;
}
开发者ID:EmuxEvans,项目名称:MQTT,代码行数:15,代码来源:mqtt_net.c


示例16: AvoidTimeout

//****************************防超时程序********************************
//函数定义: uint8_t AvoidTimeout(uint32_t TimeOfTimeout,uint32_t Period,uint8_t (*DetectCondition)())
//描    述:在TimeOfTimeout时间内,每Period时间检测一次DetectCondition()返回的值是否有效
//入口参数:TimeOfTimeout:防超时总时间(单位:systick)
//          Period       :每Period时间检测一次,即时间因子(单位:systick)
//          (*DetectCondition)():检测条件,等于ConditionValue则条件满足,检测结束,否则延时Period时间继续检测
//          ConditionValue      ;条件成立的值
//出口参数:0:在TimeOfTimeout时间内,检测到条件成立
//          1:在TimeOfTimeout时间内,没有检测到条件成立
//备    注:Editor:Armink 2012-03-09    Company: BXXJS
//**********************************************************************
uint8_t AvoidTimeout(uint32_t TimeOfTimeout,uint32_t Period,uint8_t (*DetectCondition)(),uint8_t ConditionValue)
{
	uint32_t LastTimeLocal, CurTimeLocal;
	uint8_t ConditionValueLocal;
	LastTimeLocal = rt_tick_get();
	CurTimeLocal  =  LastTimeLocal;
	while(CurTimeLocal - LastTimeLocal < TimeOfTimeout)
	{	 
		CurTimeLocal = rt_tick_get();
		ConditionValueLocal = DetectCondition();
		if (ConditionValueLocal == ConditionValue) return 0;
		rt_thread_delay(Period);
	}	
	return 1;
} 
开发者ID:uincore,项目名称:FreeModbus_Slave-Master-RTT-STM32,代码行数:26,代码来源:bsp.c


示例17: _lg_fmtout

static void _lg_fmtout(
        struct log_trace_session *session, const char *fmt, va_list argptr)
{
    /* 1 for ']' */
    static char _trace_buf[1+LOG_TRACE_BUFSZ];
    char *ptr;
    rt_size_t length;

    RT_ASSERT(session);
    RT_ASSERT(fmt);

    rt_snprintf(_trace_buf, sizeof(_trace_buf), "[%08x][", rt_tick_get());
    if (_traceout_device != RT_NULL)
    {
        rt_device_write(_traceout_device, -1, _trace_buf, 11);
        rt_device_write(_traceout_device, -1,
                session->id.name, _idname_len(session->id.num));
    }

    _trace_buf[0] = ']';
    ptr = &_trace_buf[1];
    length = rt_vsnprintf(ptr, LOG_TRACE_BUFSZ, fmt, argptr);

    if (length >= LOG_TRACE_BUFSZ)
        length = LOG_TRACE_BUFSZ - 1;

    if (_traceout_device != RT_NULL)
    {
        rt_device_write(_traceout_device, -1, _trace_buf, length + 1);
    }
}
开发者ID:byteboy2013,项目名称:rt-thread,代码行数:31,代码来源:log_trace.c


示例18: rt_timer_start

/**
 * This function will start the timer
 *
 * @param timer the timer to be started
 *
 * @return the operation status, RT_EOK on OK, -RT_ERROR on error
 *
 */
rt_err_t rt_timer_start(rt_timer_t timer)
{
	struct rt_timer* t;
	register rt_base_t level;
	rt_list_t *n, *timer_list;

	/* timer check */
	RT_ASSERT(timer != RT_NULL);
	if (timer->parent.flag & RT_TIMER_FLAG_ACTIVATED) return -RT_ERROR;

#ifdef RT_USING_HOOK
	if (rt_object_take_hook != RT_NULL) rt_object_take_hook(&(timer->parent));
#endif

	/* disable interrupt */
	level = rt_hw_interrupt_disable();

	/* get timeout tick, the max timeout tick shall not great than RT_TICK_MAX/2 */
	RT_ASSERT(timer->init_tick < RT_TICK_MAX/2);
	timer->timeout_tick = rt_tick_get() + timer->init_tick;

#ifdef RT_USING_TIMER_SOFT
	if (timer->parent.flag & RT_TIMER_FLAG_SOFT_TIMER)
	{
		/* insert timer to soft timer list */
		timer_list = &rt_soft_timer_list;
	}
	else
#endif
	{
		/* insert timer to system timer list */
		timer_list = &rt_timer_list;
	}

	for (n = timer_list->next; n != timer_list; n = n->next)
	{
		t = rt_list_entry(n, struct rt_timer, list);
		
		/*
		 * It supposes that the new tick shall less than the half duration of tick max.
		 */
		if ((t->timeout_tick - timer->timeout_tick) < RT_TICK_MAX/2)
		{
			rt_list_insert_before(n, &(timer->list));
			break;
		}
	}
	/* no found suitable position in timer list */
	if (n == timer_list)
	{
		rt_list_insert_before(n, &(timer->list));
	}
		
	timer->parent.flag |= RT_TIMER_FLAG_ACTIVATED;

	/* enable interrupt */
	rt_hw_interrupt_enable(level);

	return -RT_EOK;
}
开发者ID:520lly,项目名称:-android-source-code,代码行数:68,代码来源:timer.c


示例19: sleep_tick_adjust

static void sleep_tick_adjust(uint32_t ms)
{
	uint32_t diff;

	diff = rt_tick_from_millisecond(ms);

	rt_tick_set(rt_tick_get() + diff);
	{
		struct rt_thread *thread;

		/* check time slice */
		thread = rt_thread_self();

		if (thread->remaining_tick <= diff)
		{
			/* change to initialized tick */
			thread->remaining_tick = thread->init_tick;

			/* yield */
			rt_thread_yield();
		}
		else
		{
			thread->remaining_tick -= diff;
		}

		/* check timer */
		rt_timer_check();
	}
}
开发者ID:csz-cmy,项目名称:rt-thread,代码行数:30,代码来源:sleep_timer.c


示例20: clock_settime

int clock_settime (clockid_t clockid, const struct timespec *tp)
{
	int second;
	rt_tick_t tick;
	rt_device_t device;

	if ((clockid != CLOCK_REALTIME) || (tp == RT_NULL)) {
		rt_set_errno(EINVAL);
		return -1;
	}

	/* get second */
	second = tp->tv_sec;
	/* get tick */
	tick = rt_tick_get();

	/* update timevalue */
	_timevalue.tv_usec = MICROSECOND_PER_SECOND - (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK;
	_timevalue.tv_sec = second - tick/RT_TICK_PER_SECOND - 1;

	/* update for RTC device */
	device = rt_device_find("rtc");
	if (device != RT_NULL) {
		/* set realtime seconds */
		rt_device_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &second);
	} else return -1;

	return 0;
}
开发者ID:malooei,项目名称:yeejoin-workspace,代码行数:29,代码来源:clock_time.c



注:本文中的rt_tick_get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rt_timer_start函数代码示例发布时间:2022-05-30
下一篇:
C++ rt_thread_startup函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap