コード例 #1
0
ファイル: osc_dev.c プロジェクト: Announcement/linux
static struct lu_device *osc_device_alloc(const struct lu_env *env,
					  struct lu_device_type *t,
					  struct lustre_cfg *cfg)
{
	struct lu_device *d;
	struct osc_device *od;
	struct obd_device *obd;
	int rc;

	od = kzalloc(sizeof(*od), GFP_NOFS);
	if (!od)
		return ERR_PTR(-ENOMEM);

	cl_device_init(&od->od_cl, t);
	d = osc2lu_dev(od);
	d->ld_ops = &osc_lu_ops;

	/* Setup OSC OBD */
	obd = class_name2obd(lustre_cfg_string(cfg, 0));
	LASSERT(obd);
	rc = osc_setup(obd, cfg);
	if (rc) {
		osc_device_free(env, d);
		return ERR_PTR(rc);
	}
	od->od_exp = obd->obd_self_export;
	return d;
}
コード例 #2
0
ファイル: osc_dev.c プロジェクト: Lezval/lustre
static struct lu_device *osc_device_alloc(const struct lu_env *env,
                                          struct lu_device_type *t,
                                          struct lustre_cfg *cfg)
{
        struct lu_device *d;
        struct osc_device *od;
        struct obd_device *obd;
        int rc;

        OBD_ALLOC_PTR(od);
        if (od == NULL)
                RETURN(ERR_PTR(-ENOMEM));

        cl_device_init(&od->od_cl, t);
        d = osc2lu_dev(od);
        d->ld_ops = &osc_lu_ops;
        od->od_cl.cd_ops = &osc_cl_ops;

        /* Setup OSC OBD */
        obd = class_name2obd(lustre_cfg_string(cfg, 0));
        LASSERT(obd != NULL);
        rc = osc_setup(obd, cfg);
        if (rc) {
                osc_device_free(env, d);
                RETURN(ERR_PTR(rc));
        }
        od->od_exp = obd->obd_self_export;
        RETURN(d);
}
コード例 #3
0
ファイル: d_osc.c プロジェクト: BurntBrunch/rockbox-fft
/* ----------------------- global setup routine ---------------- */
void d_osc_setup(void)
{
    phasor_setup();
    cos_setup();
    osc_setup();
    sigvcf_setup();
    noise_setup();
}
コード例 #4
0
ファイル: main.c プロジェクト: texane/documation_m600
int main(void)
{
  volatile int is_done = 0;

  osc_setup();
  int_setup();
  serial_setup();
  m600_setup();

  while (!is_done)
    {
      m600_request_t req;
      m600_reply_t rep;

      if (m600_read_request(&req) == -1)
	continue ;

      switch (req)
	{
	case M600_REQ_READ_CARD:
	  {
	    toggle_led(0);

	    rep.alarms = m600_read_card(rep.card_data);
	    break;
	  }

	case M600_REQ_READ_ALARMS:
	  {
	    toggle_led(1);

	    rep.alarms = m600_read_alarms();
	    break;
	  }

	default:
	  {
	    break;
	  }
	}

      m600_write_reply(&rep);
    }

  return 0;
}
コード例 #5
0
ファイル: main.c プロジェクト: texane/dibal
void main(void)
{
  sched_timer_t* light_timer;
  sched_timer_t* dist_timer;

  unsigned char is_light_disabled;
  unsigned char is_dist_disabled;

  osc_setup();
  int_setup();

  srf04_setup();
  sched_setup();

  behavior_setup();

  /* sensor timers */

  light_timer = sched_add_timer(2, on_light_timer, 1);
  is_light_disabled = 0;

  dist_timer = sched_add_timer(2, on_distance_timer, 1);
  is_dist_disabled = 0;

  /* default behaviour */

  behavior_start(BEHAVIOR_ID_LAND_EXPLORER);

  /* main loop */

  sched_enable();

  while (1)
    {
      /* sensors. order matters so that object
	 avoider takes priority over light tracker.
	 this can be removed as soon as behavior
	 priority is implemented.
       */

      if (TIMER_MAP_ISSET(DISTANCE))
	{
	  {
#define MIN_DISTANCE_VALUE 0x0a00 /* 20 cms */
	    unsigned int dist = srf04_get_distance(MIN_DISTANCE_VALUE);

	    if (dist <= MIN_DISTANCE_VALUE)
	      {
		if (behavior_switch(BEHAVIOR_ID_OBJECT_AVOIDER) != -1)
		  {
		    sched_disable_timer(dist_timer);
		    is_dist_disabled = 1;
		  }
	      }
	  }

	  /* clear after the timer may have been disabled */

	  TIMER_MAP_CLEAR(DISTANCE);
	}

      if (TIMER_MAP_ISSET(LIGHT))
	{
	  {
	    unsigned short light = adc_read(LIGHT_ADC_CHANNEL);

	    if ((light <= ADC_QUANTIZE_5_10(2.35)) || (light >= ADC_QUANTIZE_5_10(2.65)))
	      {
		if (behavior_switch(BEHAVIOR_ID_LIGHT_TRACKER) != -1)
		  {
		    sched_disable_timer(light_timer);
		    is_light_disabled = 1;
		  }
	      }
	  }

	  TIMER_MAP_CLEAR(LIGHT);
	}

      /* schedule behavior */

      behavior_next();

      if (behavior_is_done())
	{
	  /* reenable timer */

	  if (is_light_disabled)
	    {
	      sched_enable_timer(light_timer);
	      is_light_disabled = 0;
	    }

	  if (is_dist_disabled)
	    {
	      sched_enable_timer(dist_timer);
	      is_dist_disabled = 0;
	    }

	  /* switch to default behavior */

	  behavior_switch(BEHAVIOR_ID_DEFAULT);
	}
    }
}