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); }
/* 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); }
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; }
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; }
void rtgui_timer_start(rtgui_timer_t* timer) { RT_ASSERT(timer != RT_NULL); /* start rt-thread timer */ rt_timer_start(&(timer->timer)); }
/** * 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 }
static rt_err_t _rt_rms_init(struct rt_rms *rms, rt_uint8_t period, rt_uint8_t wcet) { /* init rms list */ rt_list_init(&(rms->rlist)); rms->thread->stat = RT_RMS_INIT; rms->period = period; rms->wcet = wcet; rms->utilization = (float)wcet / period; utilization += rms->utilization; RT_ASSERT(utilization <= 1); /* init the rms timer for activating next job */ rt_timer_init(&(rms->rms_timer), rms->thread->name, rt_rms_wakeup, (void *)rms->period, rms->period, RT_TIMER_FLAG_PERIODIC); /* start the rms timer */ rt_timer_start(&(rms->rms_timer)); return RT_RMS_EOK; }
/** * 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; }
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; }
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); );
/** * 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")); }
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; }
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)); }
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; }
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); }
/* * 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); }
static void init_per_get_time(void) { rt_timer_init(&get_time_timer, "rtc", /* 定时器名字是 timer1 */ per_get_time, /* 超时时回调的处理函数 */ RT_NULL, /* 超时函数的入口参数 */ 100, /* 定时长度,以OS Tick为单位,即100个OS Tick */ RT_TIMER_FLAG_SOFT_TIMER | RT_TIMER_FLAG_PERIODIC); /* 周期性定时器 */ rt_timer_start(&get_time_timer); }
/// Start or restart timer osStatus osTimerStart(osTimerId timer_id, uint32_t millisec) { rt_err_t result; result = rt_timer_start(timer_id); if (result == RT_EOK) return osOK; else return osErrorOS; }
static rt_err_t rt_key_open(rt_device_t dev, rt_uint16_t oflag) { rt_timer_t timer; timer = rt_timer_create("timer", timer_callback, &s_dev_key, rt_tick_from_millisecond(KEY_TIMER_INTERVAL), RT_TIMER_FLAG_PERIODIC/* | RT_TIMER_FLAG_SOFT_TIMER */); RT_ASSERT(timer != RT_NULL); rt_timer_start(timer); return RT_EOK; }
/** * 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")); }
void vMBMasterPortTimersRespondTimeoutEnable() { rt_tick_t timer_tick = MB_MASTER_TIMEOUT_MS_RESPOND * RT_TICK_PER_SECOND / 1000; /* Set current timer mode, don't change it.*/ vMBMasterSetCurTimerMode(MB_TMODE_RESPOND_TIMEOUT); rt_timer_control(&timer, RT_TIMER_CTRL_SET_TIME, &timer_tick); rt_timer_start(&timer); }
void vMBMasterPortTimersConvertDelayEnable() { rt_tick_t timer_tick = MB_MASTER_DELAY_MS_CONVERT * RT_TICK_PER_SECOND / 1000; /* Set current timer mode, don't change it.*/ vMBMasterSetCurTimerMode(MB_TMODE_CONVERT_DELAY); rt_timer_control(&timer, RT_TIMER_CTRL_SET_TIME, &timer_tick); rt_timer_start(&timer); }
void vMBMasterPortTimersT35Enable() { rt_tick_t timer_tick = (50 * usT35TimeOut50us) / (1000 * 1000 / RT_TICK_PER_SECOND); /* Set current timer mode, don't change it.*/ vMBMasterSetCurTimerMode(MB_TMODE_T35); rt_timer_control(&timer, RT_TIMER_CTRL_SET_TIME, &timer_tick); rt_timer_start(&timer); }
/// Start or restart timer osStatus osTimerStart(osTimerId timer_id, uint32_t millisec) { rt_err_t result; rt_tick_t ticks; ticks = rt_tick_from_millisecond(millisec); rt_timer_control(timer_id, RT_TIMER_CTRL_SET_TIME, &ticks); result = rt_timer_start(timer_id); if (result == RT_EOK) return osOK; else return osErrorOS; }
int rt_application_init() { timer1 = rt_timer_create("timer1", timeout1, RT_NULL, 100, RT_TIMER_FLAG_PERIODIC); if (timer1 != RT_NULL) rt_timer_start(timer1); return 0; }
void EXTI9_5_IRQHandler(void) { if ((EXTI_GetITStatus(key1_exti_line) == SET) || (EXTI_GetITStatus(key2_exti_line) == SET)) { /* disable interrupt */ EXTI_Enable(1, 0); EXTI_Enable(2, 0); /* start timer */ rt_timer_start(key->poll_timer); EXTI_ClearITPendingBit(key1_exti_line | key2_exti_line); } }
//thread_mpu 线程初始化 void thread_mpu_timer_init(void) { /* 初始化一个信号量 */ rt_sem_init(&sem_mpu,"mpu",0 ,RT_IPC_FLAG_FIFO); /* 创建定时器mpu */ rt_timer_init(&tim_mpu, "mpu", /* 定时器名字 */ timer_mpu, /* 超时时回调的处理函数*/ RT_NULL, /* 超时函数的入口参数*/ MPU_UPDATE_PERIOD, /* 定时长度,以OS Tick为单位*/ RT_TIMER_FLAG_PERIODIC);/* 周期性定时器*/ /* 启动定时器*/ rt_timer_start(&tim_mpu); }
//定时器初始化 void thread_hmc_timer_init(void) { /* 初始化一个信号量 */ rt_sem_init(&sem_hmc,"hmc",0 ,RT_IPC_FLAG_FIFO); /* 创建定时器hmc */ rt_timer_init(&tim_hmc, /* 控制块 */ "hmc", /* 定时器名字 */ timer_hmc, /* 超时时回调的处理函数*/ RT_NULL, /* 超时函数的入口参数*/ 20, /* 定时长度,以OS Tick为单位*/ RT_TIMER_FLAG_PERIODIC);/* 周期性定时器*/ /* 启动定时器*/ rt_timer_start(&tim_hmc); }
void timer_conrol(void) { timeout_value+=10; rt_timer_control(timer_test, RT_TIMER_CTRL_SET_TIME, (void *)&timeout_value); // rt_kprintf("timer timeout time set to %d !\n", timeout_value); if (timeout_value==500) { rt_timer_stop(timer_test); /* 停止定时器 */ rt_kprintf("timer stoped !\n"); } if (timeout_value>=510) { /* 再次启动定时器 */ rt_timer_start(timer_test); timeout_value=10; rt_timer_control(timer_test, RT_TIMER_CTRL_SET_TIME, (void *)&timeout_value); } }
/* init gsm */ void _gsm_startup(void) { rt_err_t result; // 二. RT 相关初始化 //------------- sem init --------------------------------- // 创建DF 读写信号量 rt_sem_init( &sem_DF, "sem_DF", 0, 0 ); rt_sem_release( &sem_DF); rt_mq_init( &mq_GSM, "mq_GSM", &GSM_rawinfo[0], 1400 - sizeof( void * ), GSM_RAWINFO_SIZE, RT_IPC_FLAG_FIFO ); //--------- timer_gsm ---------- // 1. create timer 100ms=Dur timer_gsm = rt_timer_create("tim_gsm", timeout_gsm, RT_NULL, 100, RT_TIMER_FLAG_PERIODIC); //| RT_TIMER_FLAG_SOFT_TIMER); // 2. start timer if(timer_gsm != RT_NULL) rt_timer_start(timer_gsm); result = rt_thread_init(&gsm_thread, "GsmThrd", gsm_thread_entry, RT_NULL, &gsm_thread_stack[0], sizeof(gsm_thread_stack), Prio_GSM, 10); if (result == RT_EOK) { rt_thread_startup(&gsm_thread); } Device_GSM.type = RT_Device_Class_Char; Device_GSM.init = Device_GSM_init; Device_GSM.open = Device_GSM_open; Device_GSM.close = Device_GSM_close; Device_GSM.read = Device_GSM_read; Device_GSM.write = Device_GSM_write; Device_GSM.control = Device_GSM_control; rt_device_register( &Device_GSM, "GsmDev", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE ); rt_device_init( &Device_GSM ); }