本文整理汇总了C++中rtimer_set函数的典型用法代码示例。如果您正苦于以下问题:C++ rtimer_set函数的具体用法?C++ rtimer_set怎么用?C++ rtimer_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtimer_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
/*---------------------------------------------------------------------------*/
static void
init(void)
{
radio_is_on = 0;
PT_INIT(&pt);
#if NURTIMER
rtimer_setup(&rt, RTIMER_HARD,
(void (*)(struct rtimer *, void *, int status))powercycle,
NULL);
rtimer_schedule(&rt, CYCLE_TIME, 1);
#else
rtimer_set(&rt, RTIMER_NOW() + CYCLE_TIME, 1,
(void (*)(struct rtimer *, void *))powercycle, NULL);
#endif
contikimac_is_on = 1;
#if WITH_PHASE_OPTIMIZATION
phase_init(&phase_list);
#endif /* WITH_PHASE_OPTIMIZATION */
#if CONTIKIMAC_CONF_ANNOUNCEMENTS
announcement_register_listen_callback(listen_callback);
ctimer_set(&announcement_cycle_ctimer, ANNOUNCEMENT_TIME,
cycle_announcement, NULL);
#endif /* CONTIKIMAC_CONF_ANNOUNCEMENTS */
}
示例2: turn_on
/*---------------------------------------------------------------------------*/
static int
turn_on(void)
{
xmac_is_on = 1;
rtimer_set(&rt, RTIMER_NOW() + xmac_config.off_time, 1,
(void (*)(struct rtimer *, void *))powercycle, NULL);
return 1;
}
示例3: rtimer_task
static char
rtimer_task(struct rtimer *t, void *ptr)
{
PT_BEGIN(&pt);
while (1) {
leds_on(LEDS_ALL);
rtimer_set(t, RTIMER_NOW() + LEDS_ON_PERIOD, 0, (rtimer_callback_t)rtimer_task, NULL);
PT_YIELD(&pt);
leds_off(LEDS_ALL);
rtimer_set(t, timesynch_time_to_rtimer(0), 0, (rtimer_callback_t)rtimer_task, NULL);
PT_YIELD(&pt);
}
PT_END(&pt);
}
示例4: PROCESS_THREAD
/**
* \brief rtimer process only set the callback ok
* \param
*
*/
PROCESS_THREAD(rtimer_ex_process, ev, data)
{
PROCESS_BEGIN();
led_init();
/* start the led, period 200ms */
rtimer_set(&ex_timer, 1000, 0, led_on, NULL);
PROCESS_END();
}
示例5: do_timeout3
//Rtimer callback function
void do_timeout3(struct rtimer *timer, void *ptr) {
counter_rtimer++;
printf("\n\rProcess 3: RTimer callback called");
/* Re-arm rtimer */
rtimer_set(&timer_rtimer, RTIMER_NOW() + timeout_rtimer, 0, do_timeout3,
NULL);
}
示例6: PROCESS_THREAD
//Rtimer thread
PROCESS_THREAD(process3, ev, data) {
PROCESS_BEGIN();
while(1) {
rtimer_set(&timer_rtimer, RTIMER_NOW() + timeout_rtimer, 0, do_timeout3, NULL);
PROCESS_YIELD();
}
PROCESS_END();
}
示例7: turn_on
/*---------------------------------------------------------------------------*/
static int
turn_on(void)
{
if(contikimac_is_on == 0) {
contikimac_is_on = 1;
contikimac_keep_radio_on = 0;
rtimer_set(&rt, RTIMER_NOW() + CYCLE_TIME, 1, powercycle_wrapper, NULL);
}
return 1;
}
示例8: test_rtimer
static void test_rtimer(void)
{
while(1)
{
printf("Now = %u\r\n",RTIMER_NOW());
rtimer_set(&task, RTIMER_NOW() + RTIMER_SECOND*2, RTIMER_SECOND, &callback, NULL);
PROCESS_WAIT_UNTIL(sem);
sem=0;
}
}
示例9: zero_cross_callback
static void
zero_cross_callback(uint8_t port, uint8_t pin)
{
//INTERRUPTS_DISABLE();
//if (pin == BUTTON_LEFT_PIN)
//{
// GPIO_DISABLE_INTERRUPT(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
//do{
//} while ((GPIO_READ_PIN(GPIO_B_BASE, 0x08)&0x08)==0x08);
// clock_delay_usec(8000);
// GPIO_SET_PIN(GPIO_C_BASE, 0x04);
// clock_delay_usec(50);
//disable simistor
// GPIO_CLR_PIN(GPIO_C_BASE, 0x04);
// GPIO_ENABLE_INTERRUPT(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
//INTERRUPTS_ENABLE();
// count50++;
// if (count50==100) {
// GPIO_SET_PIN(GPIO_C_BASE, 0x80);
// count50=0;
// ctimer_set(&my_ct, CLOCK_SECOND/128, my_rt_callback, NULL);
// GPIO_DISABLE_INTERRUPT(BUTTON_LEFT_PORT_BASE, BUTTON_LEFT_PIN_MASK);
// nvic_interrupt_disable(BUTTON_LEFT_VECTOR);
// clock_delay_usec(4000);
// GPIO_ENABLE_INTERRUPT(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN);
// nvic_interrupt_enable(BUTTON_LEFT_VECTOR);
//timer if RISING detect
// rtimer_set(&zero_detector_rtimer, RTIMER_NOW()+(RTIMER_SECOND/1000)*9, 1, zero_detector_enable_callback, NULL);
// if (GPIO_READ_PIN(GPIO_B_BASE, 0x08)&0x08)
// rtimer_set(&my_rt, RTIMER_NOW()+(RTIMER_SECOND/10000)*abs(95-dimming_time), 1, my_rt_callback, NULL);
// rtimer_set(&simistor_strob_rtimer, RTIMER_NOW()+(RTIMER_SECOND/10000)*abs(95-dimming_time), 1, simistor_strob_callback, NULL);
if (dim_chan0.thyristor_open_time)
// rtimer_set(&dim_chan0.thyristor_rtimer, RTIMER_NOW()+(RTIMER_SECOND/10000)*(255 - dim_chan0.thyristor_open_time)/2.68, 1, simistor_strob_callback, NULL);
rtimer_set(&dim_chan0.thyristor_rtimer, RTIMER_NOW()+(RTIMER_SECOND/10000)*((100 - dim_chan0.thyristor_open_time)/1.02), 1, simistor_strob_callback, NULL);
// else
// nvic_interrupt_enable(BUTTON_LEFT_VECTOR);
// }
//}
}
示例10: turn_on
/*---------------------------------------------------------------------------*/
static int
turn_on(void)
{
if(contikimac_is_on == 0) {
contikimac_is_on = 1;
contikimac_keep_radio_on = 0;
rtimer_set(&rt, RTIMER_NOW() + CYCLE_TIME, 1,
(void (*)(struct rtimer *, void *))powercycle, NULL);
}
return 1;
}
示例11: timeout
static void timeout(struct rtimer *t, void *ptr) {
// it is assumed that the timeout rtimer always expires within
// the off phase of powercycle immediately after the first received strobe
waiting_for_packet = 0;
leds_off(LEDS_GREEN);
if (we_are_sending == 0)
{
off();
}
rtimer_set(t, last_on + xmac_config.on_time + xmac_config.off_time, 1,
(void (*)(struct rtimer *, void *))powercycle, ptr);
}
示例12: schedule_powercycle
static void
schedule_powercycle(struct rtimer *t, rtimer_clock_t time)
{
int r;
if(xmac_is_on) {
r = rtimer_set(t, RTIMER_TIME(t) + time, 1,
(void (*)(struct rtimer *, void *))powercycle, NULL);
if(r) {
PRINTF("schedule_powercycle: could not set rtimer\n");
}
}
}
示例13: powercycle
/*---------------------------------------------------------------------------*/
#if GLOSSY
static volatile int in_on_phase = 0;
char powercycle(void) {
PT_BEGIN(&pt);
while(1)
{
if((xmac_config.off_time > 0) && (!was_timeout))
{
if(we_are_sending == 0)
{
in_on_phase = 1;
off();
}
if(xmac_is_on)
{
TBCCR3 += xmac_config.off_time;
}
PT_YIELD(&pt);
}
last_on = TBCCR3;
was_timeout = 0;
if(we_are_sending == 0)
{
in_on_phase = 0;
on();
}
if(xmac_is_on)
{
TBCCR3 += xmac_config.on_time;
in_on_phase = 0;
}
PT_YIELD(&pt);
}
PT_END(&pt);
}
#else /* GLOSSY */
static char powercycle(struct rtimer *t, void *ptr) {
int r;
PT_BEGIN(&pt);
while(1)
{
if((xmac_config.off_time > 0) && (!was_timeout))
{
if(we_are_sending == 0)
{
off();
}
if(xmac_is_on)
{
r = rtimer_set(t, RTIMER_TIME(t) + xmac_config.off_time, 1,
(void (*)(struct rtimer *, void *))powercycle, ptr);
}
PT_YIELD(&pt);
}
last_on = RTIMER_TIME(t);
was_timeout = 0;
if(we_are_sending == 0)
{
on();
}
if(xmac_is_on)
{
r = rtimer_set(t, RTIMER_TIME(t) + xmac_config.on_time, 1,
(void (*)(struct rtimer *, void *))powercycle, ptr);
}
PT_YIELD(&pt);
}
PT_END(&pt);
}
示例14: on
// turn on RDC layer
static int on(void)
{
PRINTF("turn on RDC layer\n");
#ifdef SF_MOTE_TYPE_AP
rtimer_set(&BSTimer,RTIMER_NOW()+segment_period,0,TDMA_BS_send,NULL);
return NETSTACK_RADIO.on();
#else
// SF_MOTE_TYPE_SENSOR
TDMA_SN_listen();
return 1;
#endif
}
示例15: plb_powercycle
/*---------------------------------------------------------------------------*/
static char
plb_powercycle(void)
{
PRINT_P("plb_powercycle [sr:%d cw:%d]\n",send_req,c_wait);
PT_BEGIN(&pt);
while(1) {
// check on/send state
if(send_req == 1 && c_wait==1){
PRINTF("plb_powercycle send DATA <start>\n");
send_req = 0; //avoid repeat sending
plb_send_data(sent_callback, sent_ptr);
PRINTF("plb_powercycle send DATA <end>\n");
radio_off();
NETSTACK_MAC.input();
}
/* on */
radio_on();
rtimer_set(&rt, RTIMER_NOW() + PC_ON_TIME, 1,
(void (*)(struct rtimer *, void *))plb_powercycle, NULL);
PT_YIELD(&pt);
/* off */
if(wait_packet == 0){
radio_off();
}
else if (wait_packet > 0)
{
wait_packet = 0;
}
rtimer_set(&rt, RTIMER_NOW() + PC_OFF_TIME, 1,
(void (*)(struct rtimer *, void *))plb_powercycle, NULL);
PT_YIELD(&pt);
}
PT_END(&pt);
}