本文整理汇总了C++中rt_timer_start函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_timer_start函数的具体用法?C++ rt_timer_start怎么用?C++ rt_timer_start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_timer_start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timer_create_init
void timer_create_init()
{
/* 创建定时器1 */
timer1 = rt_timer_create("timer1", /* 定时器名字是 timer1 */
timeout1, /* 超时时回调的处理函数 */
RT_NULL, /* 超时函数的入口参数 */
10, /* 定时长度,以OS Tick为单位,即10个OS Tick */
RT_TIMER_FLAG_PERIODIC); /* 周期性定时器 */
/* 启动定时器 */
if (timer1 != RT_NULL)
rt_timer_start(timer1);
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
/* 创建定时器2 */
timer2 = rt_timer_create("timer2", /* 定时器名字是 timer2 */
timeout2, /* 超时时回调的处理函数 */
RT_NULL, /* 超时函数的入口参数 */
30, /* 定时长度为30个OS Tick */
RT_TIMER_FLAG_ONE_SHOT); /* 单次定时器 */
/* 启动定时器 */
if (timer2 != RT_NULL)
rt_timer_start(timer2);
else
tc_stat(TC_STAT_END | TC_STAT_FAILED);
}
示例2: tone
/* normally the tone frequency should be 31 to 4978, refer to piches.h */
void tone(uint8_t pin, uint16_t frequency, unsigned long duration)
{
static struct rt_timer timer2, timer3;
rt_timer_t timer;
RT_ASSERT(frequency * 2 < UINT16_MAX);
if(pin < 2 || pin > 3)
return;
if (pin == 2)
{
timer = &timer2;
}
else if (pin == 3)
{
timer = &timer3;
}
rt_timer_stop(timer);
rt_timer_init(timer, "pwmkill",
pwm_shutdown, (void*) pin,
rt_tick_from_millisecond(duration),
RT_TIMER_FLAG_ONE_SHOT);
TIM_config(pin, frequency);
pwmConfig(pin, UINT8_MAX / 2);
rt_timer_start(timer);
}
示例3: rt_completion_wait
rt_err_t rt_completion_wait(struct rt_completion *completion, rt_int32_t timeout)
{
rt_err_t result;
rt_base_t level;
rt_thread_t thread;
RT_ASSERT(completion != RT_NULL);
result = RT_EOK;
thread = rt_thread_self();
level = rt_hw_interrupt_disable();
if (completion->flag != RT_COMPLETED)
{
/* only one thread can suspend on complete */
RT_ASSERT(rt_list_isempty(&(completion->suspended_list)));
if (timeout == 0)
{
result = -RT_ETIMEOUT;
goto __exit;
}
else
{
/* reset thread error number */
thread->error = RT_EOK;
/* suspend thread */
rt_thread_suspend(thread);
/* add to suspended list */
rt_list_insert_before(&(completion->suspended_list), &(thread->tlist));
/* current context checking */
RT_DEBUG_NOT_IN_INTERRUPT;
/* start timer */
if (timeout > 0)
{
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_start(&(thread->thread_timer));
}
/* enable interrupt */
rt_hw_interrupt_enable(level);
/* do schedule */
rt_schedule();
/* thread is waked up */
result = thread->error;
level = rt_hw_interrupt_disable();
/* clean completed flag */
completion->flag = RT_UNCOMPLETED;
}
}
__exit:
rt_hw_interrupt_enable(level);
return result;
}
示例4: s3c2410_adc_stylus_action
static void s3c2410_adc_stylus_action(void)
{
rt_uint32_t data0;
rt_uint32_t data1;
data0 = ADCDAT0;
data1 = ADCDAT1;
ts.xp += data0 & S3C2410_ADCDAT0_XPDATA_MASK;
ts.yp += data1 & S3C2410_ADCDAT1_YPDATA_MASK;
ts.count ++;
if (ts.count < (1<<ts.shift))
{
ADCTSC = S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST;
ADCCON |= S3C2410_ADCCON_ENABLE_START;
}
else
{
if (touch->first_down_report)
{
report_touch_input(1);
ts.xp = 0;
ts.yp = 0;
ts.count = 0;
touch->first_down_report = 0;
}
/* start timer */
rt_timer_start(touch->poll_timer);
ADCTSC = WAIT4INT(1);
}
SUBSRCPND |= BIT_SUB_ADC;
}
示例5: rtgui_timer_start
void rtgui_timer_start(rtgui_timer_t* timer)
{
RT_ASSERT(timer != RT_NULL);
/* start rt-thread timer */
rt_timer_start(&(timer->timer));
}
示例6: 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
}
示例7: rt_thread_sleep
/**
* This function will let current thread sleep for some ticks.
*
* @param tick the sleep ticks
*
* @return RT_EOK
*
*/
rt_err_t rt_thread_sleep(rt_tick_t tick)
{
register rt_base_t temp;
struct rt_thread *thread;
/* disable interrupt */
temp = rt_hw_interrupt_disable();
/* set to current thread */
thread = rt_current_thread;
RT_ASSERT(thread != RT_NULL);
/* suspend thread */
rt_thread_suspend(thread);
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &tick);
rt_timer_start(&(thread->thread_timer));
/* enable interrupt */
rt_hw_interrupt_enable(temp);
rt_schedule();
/* clear error number of this thread to RT_EOK */
if (thread->error == -RT_ETIMEOUT)
thread->error = RT_EOK;
return RT_EOK;
}
示例8: logStartBlock
static int logStartBlock(int id, unsigned int period)
{
int i;
for (i=0; i<LOG_MAX_BLOCKS; i++)
if (logBlocks[i].id == id) break;
if (i >= LOG_MAX_BLOCKS) {
ERROR("Trying to start block id %d that doesn't exist.", id);
return ENOENT;
}
DEBUG("Starting block %d with period %dms\n", id, period);
if (period>0)
{
//xTimerChangePeriod(logBlocks[i].timer, M2T(period), 100);
logBlocks[i].timer->init_tick = M2T(period);
//xTimerStart(logBlocks[i].timer, 100);
rt_timer_start(logBlocks[i].timer);
} else {
// single-shoot run
workerSchedule(logRunBlock, &logBlocks[i]);
}
return 0;
}
示例9: mgpot_shortrng
int mgpot_shortrng(Mgpot *mg, int threadid, int threadcount) {
#ifdef MGPOT_TIMER
rt_timerhandle timer = rt_timer_create();
float totaltime=0, lasttime, elapsedtime;
#endif
TIMING( rt_timer_start(timer); );
示例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: write_grid
int write_grid(const char* ofile, float gridspacing, float cx, float cy, float cz, long int numplane, long int numcol, long int numpt, const float* eners) {
/* Write the current energy grid to a .dx file for later reading */
FILE* dx_out;
int i, j, k;
int arrpos;
int numentries;
float starttime, endtime;
rt_timerhandle timer;
arrpos=0;
dx_out = fopen(ofile, "w");
if (dx_out == NULL) {
fprintf(stderr, "Error: Couldn't open output dxfile %s. Exiting...", ofile);
return 1;
}
timer = rt_timer_create();
rt_timer_start(timer);
/* start the timer */
starttime = rt_timer_timenow(timer);
/* Write a dx header */
fprintf(dx_out, "# Data from cionize 1.0\n#\n# Potential (kT/e at 298.15K)\n#\n");
fprintf(dx_out, "object 1 class gridpositions counts %li %li %li\n", numpt, numcol, numplane);
fprintf(dx_out, "origin %12.6e %12.6e %12.6e\n", cx, cy, cz);
fprintf(dx_out, "delta %12.6e %12.6e %12.6e\n", gridspacing, 0.0, 0.0);
fprintf(dx_out, "delta %12.6e %12.6e %12.6e\n", 0.0, gridspacing, 0.0);
fprintf(dx_out, "delta %12.6e %12.6e %12.6e\n", 0.0, 0.0, gridspacing);
fprintf(dx_out, "object 2 class gridconnections counts %li %li %li\n", numpt, numcol, numplane);
fprintf(dx_out, "object 3 class array type double rank 0 items %li data follows\n", numplane * numcol * numpt);
/* Write the main data array */
numentries = 0;
for (i=0; i<numpt; i++) {
for (j=0; j<numcol; j++) {
for (k=0; k<numplane; k++) {
arrpos = (k*numcol * numpt + j*numpt + i);
fprintf(dx_out, "%-13.6e ", POT_CONV * eners[arrpos]);
if (numentries % 3 == 2) fprintf(dx_out, "\n");
numentries = numentries + 1;
}
}
}
/* Write the opendx footer */
if (arrpos % 3 != 2) fprintf(dx_out, "\n");
fprintf(dx_out, "attribute \"dep\" string \"positions\"\nobject \"regular positions regular connections\" class field\ncomponent \"positions\" value 1\ncomponent \"connections\" value 2\ncomponent \"data\" value 3");
fclose(dx_out);
/* check our time */
endtime = rt_timer_timenow(timer);
printf("Time for grid output: %.1f\n", endtime - starttime);
rt_timer_destroy(timer);
return 0;
}
示例12: rtgui_timer_start
void rtgui_timer_start(rtgui_timer_t *timer)
{
RT_ASSERT(timer != RT_NULL);
/* start rt-thread timer */
timer->state = RTGUI_TIMER_ST_RUNNING;
rt_timer_start(&(timer->timer));
}
示例13: timer_start
static rt_err_t timer_start(void)
{
timer_test = rt_timer_create("timer1",timeout_callbak,RT_NULL,timeout_value,RT_TIMER_FLAG_PERIODIC);
if (timer_test != RT_NULL){
rt_timer_start(timer_test);
}
return 0;
}
示例14: timer_static_init
void timer_static_init()
{
/* 初始化定时器 */
rt_timer_init(&timer1, "timer1", /* 定时器名字是 timer1 */
timeout1, /* 超时时回调的处理函数 */
RT_NULL, /* 超时函数的入口参数 */
10, /* 定时长度,以OS Tick为单位,即10个OS Tick */
RT_TIMER_FLAG_PERIODIC); /* 周期性定时器 */
rt_timer_init(&timer2, "timer2", /* 定时器名字是 timer2 */
timeout2, /* 超时时回调的处理函数 */
RT_NULL, /* 超时函数的入口参数 */
30, /* 定时长度为30个OS Tick */
RT_TIMER_FLAG_ONE_SHOT); /* 单次定时器 */
/* 启动定时器 */
rt_timer_start(&timer1);
rt_timer_start(&timer2);
}
示例15: renderio
/*
* Save the rendered image to disk.
*/
static void renderio(scenedef * scene) {
flt iotime;
char msgtxt[256];
rt_timerhandle ioth; /* I/O timer handle */
ioth=rt_timer_create();
rt_timer_start(ioth);
if (scene->imgbufformat == RT_IMAGE_BUFFER_RGB96F) {
if (scene->imgprocess & RT_IMAGE_NORMALIZE) {
normalize_rgb96f(scene->hres, scene->vres, (float *) scene->img);
rt_ui_message(MSG_0, "Post-processing: normalizing pixel values.");
}
if (scene->imgprocess & RT_IMAGE_GAMMA) {
gamma_rgb96f(scene->hres, scene->vres, (float *) scene->img,
scene->imggamma);
rt_ui_message(MSG_0, "Post-processing: gamma correcting pixel values.");
}
} else if (scene->imgbufformat == RT_IMAGE_BUFFER_RGB24) {
if (scene->imgprocess & (RT_IMAGE_NORMALIZE | RT_IMAGE_GAMMA))
rt_ui_message(MSG_0, "Can't post-process 24-bit integer image data");
}
/* support cropping of output images for SPECMPI benchmarks */
if (scene->imgcrop.cropmode == RT_CROP_DISABLED) {
writeimage(scene->outfilename, scene->hres, scene->vres,
scene->img, scene->imgbufformat, scene->imgfileformat);
} else {
/* crop image before writing if necessary */
if (scene->imgbufformat == RT_IMAGE_BUFFER_RGB96F) {
float *imgcrop;
imgcrop = image_crop_rgb96f(scene->hres, scene->vres, scene->img,
scene->imgcrop.xres, scene->imgcrop.yres,
scene->imgcrop.xstart, scene->imgcrop.ystart);
writeimage(scene->outfilename, scene->imgcrop.xres, scene->imgcrop.yres,
imgcrop, scene->imgbufformat, scene->imgfileformat);
free(imgcrop);
} else if (scene->imgbufformat == RT_IMAGE_BUFFER_RGB24) {
unsigned char *imgcrop;
imgcrop = image_crop_rgb24(scene->hres, scene->vres, scene->img,
scene->imgcrop.xres, scene->imgcrop.yres,
scene->imgcrop.xstart, scene->imgcrop.ystart);
writeimage(scene->outfilename, scene->imgcrop.xres, scene->imgcrop.yres,
imgcrop, scene->imgbufformat, scene->imgfileformat);
free(imgcrop);
}
}
rt_timer_stop(ioth);
iotime = rt_timer_time(ioth);
rt_timer_destroy(ioth);
sprintf(msgtxt, " Image I/O Time: %10.4f seconds", iotime);
rt_ui_message(MSG_0, msgtxt);
}