Ejemplo n.º 1
0
static void spi_flash_call_task_within_time(spi_flash_dev *sfd, u32_t time, int res) {
  if (sfd->flash_conf.busy_poll_divisor > 0) {
    u32_t poll_time = time / sfd->flash_conf.busy_poll_divisor;
    if (poll_time < sfd->flash_conf.busy_poll_min_time) {
      poll_time = sfd->flash_conf.busy_poll_min_time;
    }

    sfd->busy_poll = TRUE;
    sfd->poll_count = 0;
    TASK_start_timer(sfd->task, &sfd->timer, res, sfd, poll_time, poll_time, "spif_poll");
  } else {
    sfd->busy_poll = FALSE;
    TASK_start_timer(sfd->task, &sfd->timer, res, sfd, time, 0, "spif_cb");
  }
}
Ejemplo n.º 2
0
static void app_rover_setup(app_common *com, app_remote *rem, configuration_t *cnf) {
  common = com;
  remote = rem;
  app_cfg = cnf;

#ifdef CONFIG_SPYBOT_HCSR
  RANGE_SENS_init(app_rover_radar_cb);
#endif

#ifdef CONFIG_I2C
  I2C_config(_I2C_BUS(0), 100000);

  STMPE_init();

#ifdef CONFIG_SPYBOT_LSM
  task *config_lsm_t = TASK_create(app_rover_setup_lsm, 0);
  ASSERT(config_lsm_t);
  TASK_run(config_lsm_t, 0, NULL);
#endif

  CFG_EE_init(&eeprom_dev, app_rover_cfg_cb);
  CFG_EE_load_config();

#endif // CONFIG_I2C
#ifdef CONFIG_SPYBOT_MOTOR
  MOTOR_init();
#endif
#ifdef CONFIG_SPYBOT_SERVO
  SERVO_init();
#endif
  mech_task = TASK_create(app_rover_mech_task, TASK_STATIC);
  TASK_start_timer(mech_task, &mech_timer, 0, 0, 0, 20, "mech");
#ifdef CONFIG_SPYBOT_HCSR
  radar_task = TASK_create(app_rover_radar_task, TASK_STATIC);
  TASK_start_timer(radar_task, &radar_timer, 0, 0, 100, 65, "radar");
#endif // CONFIG_SPYBOT_HCSR

#ifdef CONFIG_SPYBOT_LSM
  int i;
  for (i = 0; i < 3; i++) {
    acc_extremes[i][0] = S16_MAX;
    acc_extremes[i][1] = S16_MIN;
    mag_extremes[i][0] = S16_MAX;
    mag_extremes[i][1] = S16_MIN;
  }
#endif
  COMRAD_init();
}
Ejemplo n.º 3
0
static void app_rover_setup_lsm(u32_t a, void *b) {
  lsm_open(&lsm_dev, _I2C_BUS(0), FALSE, app_rover_lsm_cb_irq);
  // lock mutex for lsm config
  if (!TASK_mutex_lock(&i2c_mutex)) {
    return;
  }
  int res = lsm_config_default(&lsm_dev);
  ASSERT(res == I2C_OK);
  lsm_set_lowpass(&lsm_dev, 50, 50);

  lsm_task = TASK_create(app_rover_lsm_task, TASK_STATIC);
  TASK_start_timer(lsm_task, &lsm_timer, 0, 0, 500, 100, "lsm_read");
}