本文整理汇总了C++中rt_tick_get函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_tick_get函数的具体用法?C++ rt_tick_get怎么用?C++ rt_tick_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_tick_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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);
}
示例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 );
}
示例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;
}
示例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
}
示例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"));
}
示例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;
}
示例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"));
}
示例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状态,可以拨号,连接*/
}
示例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);
}
示例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;
}