int initpwm(void) { int i; int retval; for(i = 0; i < RC_NUM; i++) { up_interval[i] = RANGE_MAP100(ranges[i][0], ranges[i][1], 0); reconfigured[i] = 0; } retval = InitGPIO(channels, sizeof(channels) / sizeof(channels[0])); if(retval) { rtdm_printk("TB6612FNG: GPIO initialization failed\n"); return retval; } rtdm_printk("TB6612FNG: GPIO initialized\n"); rtdm_printk("TB6612FNG: Starting PWM generation timers.\n"); retval = rtdm_timer_init(&up_timer, pwm_up, "up timer"); if(retval) { rtdm_printk("TB6612FNG: error initializing up-timer: %i\n", retval); return retval; } for(i = 0; i < RC_NUM; i++) { retval = rtdm_timer_init(&down_timer[i], pwm_down, "down timer"); if(retval) { rtdm_printk("TB6612FNG: error initializing down-timer #%i: %i\n", i, retval); return retval; } } retval = rtdm_timer_start(&up_timer, PERIOD, // we will use periodic timer PERIOD, // PERIOD period RTDM_TIMERMODE_RELATIVE); if(retval) { rtdm_printk("TB6612FNG: error starting up-timer: %i\n", retval); return retval; } rtdm_printk("TB6612FNG: timers created\n"); return 0; }
static int inj1_timer_init(void) { int ret; ret = rtdm_timer_init(&inj1_timer, inj1_int, "EMS-Inj1"); if(ret != 0) { return -1; } return 0; }
static int rtswitch_open(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int oflags) { rtswitch_context_t *ctx = (rtswitch_context_t *) context->dev_private; ctx->tasks = NULL; ctx->tasks_count = ctx->next_index = ctx->cpu = ctx->switches_count = 0; init_MUTEX(&ctx->lock); ctx->failed = 0; ctx->error.last_switch.from = ctx->error.last_switch.to = -1; ctx->pause_us = 0; rtdm_timer_init(&ctx->wake_up_delay, timed_wake_up, "switchtest timer"); return 0; }
static void rtcfg_client_recv_stage_2_cfg(int ifindex, struct rtskb *rtskb) { struct rtcfg_frm_stage_2_cfg *stage_2_cfg; struct rtcfg_device *rtcfg_dev = &device[ifindex]; size_t data_len; int ret; if (rtskb->len < sizeof(struct rtcfg_frm_stage_2_cfg)) { rtdm_mutex_unlock(&rtcfg_dev->dev_mutex); RTCFG_DEBUG(1, "RTcfg: received invalid stage_2_cfg frame\n"); kfree_rtskb(rtskb); return; } stage_2_cfg = (struct rtcfg_frm_stage_2_cfg *)rtskb->data; __rtskb_pull(rtskb, sizeof(struct rtcfg_frm_stage_2_cfg)); if (stage_2_cfg->heartbeat_period) { ret = rtdm_timer_init(&rtcfg_dev->timer, rtcfg_timer, "rtcfg-timer"); if (ret == 0) { ret = rtdm_timer_start(&rtcfg_dev->timer, XN_INFINITE, (nanosecs_rel_t)ntohs(stage_2_cfg->heartbeat_period) * 1000000, RTDM_TIMERMODE_RELATIVE); if (ret < 0) rtdm_timer_destroy(&rtcfg_dev->timer); } if (ret < 0) /*ERRMSG*/rtdm_printk("RTcfg: unable to create timer task\n"); else set_bit(FLAG_TIMER_STARTED, &rtcfg_dev->flags); } /* add server to station list */ if (rtcfg_add_to_station_list(rtcfg_dev, rtskb->mac.ethernet->h_source, stage_2_cfg->flags) < 0) { rtdm_mutex_unlock(&rtcfg_dev->dev_mutex); RTCFG_DEBUG(1, "RTcfg: unable to process stage_2_cfg frage\n"); kfree_rtskb(rtskb); return; } rtcfg_dev->other_stations = ntohl(stage_2_cfg->stations); rtcfg_dev->spec.clt.cfg_len = ntohl(stage_2_cfg->cfg_len); data_len = MIN(rtcfg_dev->spec.clt.cfg_len, rtskb->len); if (test_bit(RTCFG_FLAG_STAGE_2_DATA, &rtcfg_dev->flags) && (data_len > 0)) { rtcfg_client_queue_frag(ifindex, rtskb, data_len); rtskb = NULL; if (rtcfg_dev->stations_found == rtcfg_dev->other_stations) rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_ALL_KNOWN); } else { if (rtcfg_dev->stations_found == rtcfg_dev->other_stations) { rtcfg_complete_cmd(ifindex, RTCFG_CMD_ANNOUNCE, 0); rtcfg_next_main_state(ifindex, test_bit(RTCFG_FLAG_READY, &rtcfg_dev->flags) ? RTCFG_MAIN_CLIENT_READY : RTCFG_MAIN_CLIENT_2); } else rtcfg_next_main_state(ifindex, RTCFG_MAIN_CLIENT_ALL_FRAMES); rtcfg_send_ack(ifindex); } rtdm_mutex_unlock(&rtcfg_dev->dev_mutex); if (rtskb != NULL) kfree_rtskb(rtskb); }