예제 #1
0
파일: baro_board.c 프로젝트: HWal/paparazzi
void baro_periodic(void)
{
  // check i2c_done
  if (!i2c_idle(&i2c2)) { return; }

  switch (baro_board.status) {
    case LBS_UNINITIALIZED:
      baro_board_send_reset();
      baro_board.status = LBS_RESETED;
      break;
    case LBS_RESETED:
      baro_board_send_config_abs();
      baro_board.status = LBS_INITIALIZING_ABS;
      break;
    case LBS_INITIALIZING_ABS:
      baro_board_set_current_register(BARO_ABS_ADDR, 0x00);
      baro_board.status = LBS_INITIALIZING_ABS_1;
      break;
    case LBS_INITIALIZING_ABS_1:
      baro_board_send_config_diff();
      baro_board.status = LBS_INITIALIZING_DIFF;
      break;
    case LBS_INITIALIZING_DIFF:
      baro_board_set_current_register(BARO_DIFF_ADDR, 0x00);
      baro_board.status = LBS_INITIALIZING_DIFF_1;
      //    baro_board.status = LBS_UNINITIALIZED;
      break;
    case LBS_INITIALIZING_DIFF_1:
      baro_board.running = true;
      /* Falls through. */
    case LBS_READ_DIFF:
      baro_board_read_from_current_register(BARO_ABS_ADDR);
      baro_board.status = LBS_READING_ABS;
      break;
    case LBS_READ_ABS:
      baro_board_read_from_current_register(BARO_DIFF_ADDR);
      baro_board.status = LBS_READING_DIFF;
      break;
    default:
      break;
  }

#ifdef BARO_LED
  if (baro_board.running == TRUE) {
    LED_ON(BARO_LED);
  } else {
    LED_TOGGLE(BARO_LED);
  }
#endif
}
예제 #2
0
void baro_periodic(void) {
  
  // check i2c_done
  if (!i2c_idle(&i2c2)) return;

  switch (baro_board.status) {
  case LBS_UNINITIALIZED:
    baro_board_send_reset();
    baro_board.status = LBS_RESETED;

    break;
  case LBS_RESETED:
    baro_board_send_config_abs();
    baro_board.status = LBS_INITIALIZING_ABS;
    break;
  case LBS_INITIALIZING_ABS:
    baro_board_set_current_register(BARO_ABS_ADDR, 0x00);
    baro_board.status = LBS_INITIALIZING_ABS_1;
    break;
  case LBS_INITIALIZING_ABS_1:
    baro_board_send_config_diff();
    baro_board.status = LBS_INITIALIZING_DIFF;
    break;
  case LBS_INITIALIZING_DIFF:
    baro_board_set_current_register(BARO_DIFF_ADDR, 0x00);
    baro_board.status = LBS_INITIALIZING_DIFF_1;
    //    baro_board.status = LBS_UNINITIALIZED;
    break;
  case LBS_INITIALIZING_DIFF_1:
    baro.status = BS_RUNNING;
    
  case LBS_READ_DIFF:
    baro_board_read_from_current_register(BARO_ABS_ADDR);
    baro_board.status = LBS_READING_ABS;
    //LED_TOGGLE(6);
    break;
  case LBS_READ_ABS:
    baro_board_read_from_current_register(BARO_DIFF_ADDR);
    baro_board.status = LBS_READING_DIFF;
    LED_TOGGLE(6);
      					
    break;
  default:
    break;
  }

}