예제 #1
0
/** Initialize \a ir with the \a IR_DEFAULT_CONTRAST \n
 *  Initialize \a adc_buf_channel
 */
void ir_init(void) {
  RadOfIrFromContrast(IR_DEFAULT_CONTRAST);
  adc_buf_channel(ADC_CHANNEL_IR1, &buf_ir1, ADC_CHANNEL_IR_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_IR2, &buf_ir2, ADC_CHANNEL_IR_NB_SAMPLES);
#ifdef ADC_CHANNEL_IR_TOP
  adc_buf_channel(ADC_CHANNEL_IR_TOP, &buf_ir_top, ADC_CHANNEL_IR_NB_SAMPLES);
  z_contrast_mode = Z_CONTRAST_DEFAULT;
#else
  z_contrast_mode = 0;
#endif
 
  ir_roll_neutral  = RadOfDeg(IR_ROLL_NEUTRAL_DEFAULT);
  ir_pitch_neutral = RadOfDeg(IR_PITCH_NEUTRAL_DEFAULT);

  estimator_rad_of_ir = ir_rad_of_ir;

#if defined IR_CORRECTION_LEFT && defined IR_CORRECTION_RIGHT
  ir_correction_left = IR_CORRECTION_LEFT;
  ir_correction_right = IR_CORRECTION_RIGHT;
#endif

#if defined IR_CORRECTION_UP && defined IR_CORRECTION_DOWN
  ir_correction_up = IR_CORRECTION_UP;
  ir_correction_down = IR_CORRECTION_DOWN;
#endif

  ir_360 = TRUE;
  ir_estimated_phi_pi_4 = IR_ESTIMATED_PHI_PI_4;
  ir_estimated_phi_minus_pi_4 = IR_ESTIMATED_PHI_MINUS_PI_4;
  ir_estimated_theta_pi_4 = IR_ESTIMATED_THETA_PI_4;
  ir_estimated_theta_minus_pi_4 = IR_ESTIMATED_THETA_MINUS_PI_4;

  ir_contrast = IR_DEFAULT_CONTRAST;
  ir_rad_of_ir = IR_RAD_OF_IR_CONTRAST / IR_DEFAULT_CONTRAST;
}
예제 #2
0
void adc_generic_init( void ) {
#ifdef ADC_CHANNEL_GENERIC1
  adc_buf_channel(ADC_CHANNEL_GENERIC1, &buf_generic1, ADC_CHANNEL_GENERIC_NB_SAMPLES);
#endif
#ifdef ADC_CHANNEL_GENERIC2
  adc_buf_channel(ADC_CHANNEL_GENERIC2, &buf_generic2, ADC_CHANNEL_GENERIC_NB_SAMPLES);
#endif
}
예제 #3
0
static inline void main_init( void ) {
    mcu_init();
    sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
    adc_init();
    adc_buf_channel(0, &adc0_buf, 8);
    adc_buf_channel(1, &adc1_buf, 3);
    adc_buf_channel(2, &adc2_buf, 3);
    adc_buf_channel(3, &adc3_buf, 3);
}
예제 #4
0
파일: test_adc.c 프로젝트: FW-M/paparazzi
static inline void main_init( void ) {
    mcu_init();
    sys_time_init();
    adc_init();
    adc_buf_channel(0, &adc0_buf, 8);
    adc_buf_channel(1, &adc1_buf, 3);
    adc_buf_channel(2, &adc2_buf, 3);
    adc_buf_channel(3, &adc3_buf, 3);
}
예제 #5
0
static inline void main_init( void ) {
    mcu_init();
    sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
    adc_init();
    adc_buf_channel(0, &adc0_buf, 8);
    adc_buf_channel(1, &adc1_buf, 3);
    adc_buf_channel(2, &adc2_buf, 3);
    adc_buf_channel(3, &adc3_buf, 3);
    adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_buf, DEFAULT_AV_NB_SAMPLE);
}
예제 #6
0
void electrical_init(void) {
  electrical.vsupply = 0;
  electrical.current = 0;
  electrical.adc_battery = 0;

  adc_buf_channel(ADC_CHANNEL_VSUPPLY, &electrical_priv.vsupply_adc_buf, DEFAULT_AV_NB_SAMPLE);
#ifdef ADC_CHANNEL_CURRENT
  adc_buf_channel(ADC_CHANNEL_CURRENT, &electrical_priv.current_adc_buf, DEFAULT_AV_NB_SAMPLE);
#endif

#ifdef MILLIAMP_AT_FULL_THROTTLE
  electrical_priv.nonlin_factor = CURRENT_ESTIMATION_NONLINEARITY;
#endif
}
예제 #7
0
static inline void main_init(void)
{
  mcu_init();
  sys_time_register_timer((1. / 100), NULL);
  downlink_init();
  adc_init();

#ifdef ADC_0
  adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);
#endif
#ifdef ADC_1
  adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES);
#endif
#ifdef ADC_2
  adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES);
#endif
#ifdef ADC_3
  adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES);
#endif
#ifdef ADC_4
  adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES);
#endif
#ifdef ADC_5
  adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES);
#endif
#ifdef ADC_6
  adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES);
#endif
#ifdef ADC_7
  adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES);
#endif

  mcu_int_enable();
}
예제 #8
0
/** Initialize \a adc_buf_channel
 */
void infrared_adc_init(void) {
#if ! (defined SITL || defined HITL)
  adc_buf_channel(ADC_CHANNEL_IR1, &buf_ir1, ADC_CHANNEL_IR_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_IR2, &buf_ir2, ADC_CHANNEL_IR_NB_SAMPLES);
#ifdef ADC_CHANNEL_IR_TOP
  adc_buf_channel(ADC_CHANNEL_IR_TOP, &buf_ir3, ADC_CHANNEL_IR_NB_SAMPLES);
#endif
#endif

  infrared_struct_init();

#if ! (defined ADC_CHANNEL_IR_TOP || defined HITL || defined SITL)
  ir_adc.ir3 = IR_DEFAULT_CONTRAST;
#endif
}
예제 #9
0
/********** INIT *************************************************************/
void init_rctx( void ) {
  hw_init();
  sys_time_init();
#ifdef LED
  led_init();
#endif
#ifdef USE_UART1
    Uart1Init();
#endif
#ifdef ADC
  adc_init();
  adc_buf_channel(ADC_CHANNEL_VSUPPLY, &vsupply_adc_buf, DEFAULT_AV_NB_SAMPLE);
#endif
#ifdef RADIO_CONTROL
  ppm_init();
#endif
  int_enable();

  /** - wait 0.5s (for modem init ?) */
  uint8_t init_cpt = 30;
  while (init_cpt) {
    if (sys_time_periodic())
      init_cpt--;
  }

#if defined DATALINK
#if DATALINK == XBEE
  xbee_init();
#endif
#endif /* DATALINK */
}
예제 #10
0
void csc_adc_init(void)
{
  adc_init();
  for (int i = 0; i < ADC_NB_CSC; i++) {
    adc_buf_channel(i, &adc_bufs[i], ADC_AV_NB);
  }
}
예제 #11
0
void aoa_adc_init(void) {
  aoa_adc.offset = AOA_OFFSET;
  aoa_adc.filter = AOA_FILTER;
  aoa_adc.sens = AOA_SENS;
  aoa_adc.angle = 0.0;
  adc_buf_channel(ADC_CHANNEL_AOA, &aoa_adc.buf, ADC_CHANNEL_AOA_NB_SAMPLES);
}
예제 #12
0
파일: AOA_adc.c 프로젝트: ERAUBB/paparazzi
void AOA_adc_init( void ) {
	AOA_offset = AOA_OFFSET;
	AOA_filter = AOA_FILTER;
	AOA_old = 0;
#ifndef SITL
	adc_buf_channel(ADC_CHANNEL_AOA, &buf_AOA, ADC_CHANNEL_AOA_NB_SAMPLES);
#endif
}
예제 #13
0
int main( void ) 
{
  uint8_t init_cpt;
  /* init peripherals */
  timer_init(); 
  modem_init();
  adc_init();
#ifdef CTL_BRD_V1_1  
  adc_buf_channel(ADC_CHANNEL_BAT, &buf_bat);
#endif
  spi_init();
  link_fbw_init();
  gps_init();
  nav_init();
  ir_init();
  estimator_init();
#	ifdef PAPABENCH_SINGLE
		fbw_init();
#	endif

  /* start interrupt task */
  //sei(); /*Fadia*/

  /* Wait 0.5s (for modem init ?) */
  init_cpt = 30;
  _Pragma("loopbound min 31 max 31")
  while (init_cpt) {
    if (timer_periodic())
      init_cpt--;
  }

  /*  enter mainloop */
#ifndef NO_MAINLOOP
  while( 1 ) {
#endif
    if(timer_periodic()) {
      periodic_task();
#		if PAPABENCH_SINGLE
			fbw_schedule();
#		endif
	}
    if (gps_msg_received) 
    {
	/*receive_gps_data_task()*/
	parse_gps_msg();
	send_gps_pos();
        send_radIR();
        send_takeOff();
    }
    if (link_fbw_receive_complete) {
      link_fbw_receive_complete = FALSE;
      radio_control_task();
    }
#ifndef NO_MAINLOOP
  } 
#endif
  return 0;
}
예제 #14
0
파일: mf_ptu.c 프로젝트: 2seasuav/paparuzzi
void mf_ptu_init(void)
{
  adc_buf_channel(ADC_CHANNEL_PRESSURE, &pressure_buf, ADC_CHANNEL_PTU_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_TEMPERATURE, &temp_buf, ADC_CHANNEL_PTU_NB_SAMPLES);

#ifdef PTU_POWER_GPIO
  gpio_setup_output(PTU_POWER_GPIO);
  gpio_set(PTU_POWER_GPIO);
#endif

  pressure_adc = 0;
  temp_adc = 0;
  humid_period = 0;

#if LOG_PTU
  log_ptu_started = false;
#endif
}
예제 #15
0
void sonar_adc_init(void)
{
  sonar_adc.meas = 0;
  sonar_adc.offset = SONAR_OFFSET;

#ifndef SITL
  adc_buf_channel(ADC_CHANNEL_SONAR, &sonar_adc_buf, DEFAULT_AV_NB_SAMPLE);
#endif
}
예제 #16
0
void range_init( void) {
    adc_buf_channel(ADC_CHANNEL_RANGE, &buf_range, ADC_CHANNEL_RANGE_NB_SAMPLES);
    range_scale=RANGE_SCALE;
    range_neutral=RANGE_NEUTRAL;
    for (pos=0; pos<SAMPLES; pos++) buf_range_tmp[pos]=0;
    pos=0;
    pos1=0;
    range_ave=0.f;
    range_hovering=0.f;
}
예제 #17
0
void electrical_init(void) {
  electrical.vsupply = 0;
  electrical.current = 0;

  electrical.bat_low = FALSE;
  electrical.bat_critical = FALSE;

#if defined ADC_CHANNEL_VSUPPLY
  adc_buf_channel(ADC_CHANNEL_VSUPPLY, &electrical_priv.vsupply_adc_buf, DEFAULT_AV_NB_SAMPLE);
#endif

  /* measure current if available, otherwise estimate it */
#if defined ADC_CHANNEL_CURRENT && !defined SITL
  adc_buf_channel(ADC_CHANNEL_CURRENT, &electrical_priv.current_adc_buf, DEFAULT_AV_NB_SAMPLE);
#elif defined MILLIAMP_AT_FULL_THROTTLE
PRINT_CONFIG_VAR(CURRENT_ESTIMATION_NONLINEARITY)
  electrical_priv.nonlin_factor = CURRENT_ESTIMATION_NONLINEARITY;
#endif
}
예제 #18
0
/**
 * Temperature ADC initialize channels
 */
void temp_adc_init(void)
{
  temp_adc_sync_send = TEMP_ADC_SYNC_SEND;

#ifdef TEMP_ADC_CHANNEL1
  adc_buf_channel(TEMP_ADC_CHANNEL1, &temp_buf1, TEMP_ADC_NB_SAMPLES);
#endif

#ifdef TEMP_ADC_CHANNEL2
  adc_buf_channel(TEMP_ADC_CHANNEL2, &temp_buf2, TEMP_ADC_NB_SAMPLES);
#endif

#ifdef TEMP_ADC_CHANNEL3
  adc_buf_channel(TEMP_ADC_CHANNEL3, &temp_buf3, TEMP_ADC_NB_SAMPLES);
#endif

#if PERIODIC_TELEMETRY
  register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_TEMP_ADC, temp_adc_downlink);
#endif
}
예제 #19
0
void sonar_adc_init(void) {
  sonar_meas = 0;
  sonar_data_available = FALSE;
  sonar_distance = 0;
  sonar_offset = SONAR_OFFSET;
  sonar_scale = SONAR_SCALE;

#ifndef SITL
  adc_buf_channel(ADC_CHANNEL_SONAR, &sonar_adc, DEFAULT_AV_NB_SAMPLE);
#endif
}
예제 #20
0
void imu_impl_init(void)
{

  analog_imu_available = FALSE;
  imu_overrun = 0;

#ifdef ADC_CHANNEL_GYRO_P
  adc_buf_channel(ADC_CHANNEL_GYRO_P, &analog_imu_adc_buf[0], ADC_CHANNEL_GYRO_NB_SAMPLES);
#endif
#ifdef ADC_CHANNEL_GYRO_Q
  adc_buf_channel(ADC_CHANNEL_GYRO_Q, &analog_imu_adc_buf[1], ADC_CHANNEL_GYRO_NB_SAMPLES);
#endif
#ifdef ADC_CHANNEL_GYRO_R
  adc_buf_channel(ADC_CHANNEL_GYRO_R, &analog_imu_adc_buf[2], ADC_CHANNEL_GYRO_NB_SAMPLES);
#endif
#ifdef ADC_CHANNEL_ACCEL_X
  adc_buf_channel(ADC_CHANNEL_ACCEL_X, &analog_imu_adc_buf[3], ADC_CHANNEL_ACCEL_NB_SAMPLES);
#endif
#ifdef ADC_CHANNEL_ACCEL_Y
  adc_buf_channel(ADC_CHANNEL_ACCEL_Y, &analog_imu_adc_buf[4], ADC_CHANNEL_ACCEL_NB_SAMPLES);
#endif
#ifdef ADC_CHANNEL_ACCEL_Z
  adc_buf_channel(ADC_CHANNEL_ACCEL_Z, &analog_imu_adc_buf[5], ADC_CHANNEL_ACCEL_NB_SAMPLES);
#endif

}
예제 #21
0
void agl_vf_init(float init_z, float init_zdot, float init_bias) {
  agl_vf_z = init_z;
  agl_vf_zdot = init_zdot;
  agl_vf_bias = init_bias;
  int i, j;
  for (i=0; i<STATE_SIZE; i++) {
    for (j=0; j<STATE_SIZE; j++)
      agl_vf_P[i][j] = 0.;
    agl_vf_P[i][i] = INIT_PXX;
  }
  adc_buf_channel(ADC_CHANNEL_TELEMETER, &agl_adc_buf, DEFAULT_AV_NB_SAMPLE);

}
예제 #22
0
void baro_init( void ) {

  adc_buf_channel(ADC_CHANNEL_BARO, &baro_board.buf, DEFAULT_AV_NB_SAMPLE);

  baro_board.status = BB_UNINITIALIZED;
  baro_board.absolute = 0;
  baro_board.offset = 1023;
  DACSet(baro_board.offset);
  baro_board.value_filtered = 0;
#ifdef BARO_LED
  LED_OFF(BARO_LED);
#endif
}
static inline void main_init(void) {

	hw_init();
	sys_time_init();
	imu_init();
	baro_init();
	radio_control_init();
	actuators_init();
	overo_link_init();
	cscp_init();
	adc_init();

#ifdef PASSTHROUGH_CYGNUS
	autopilot_init();
	nav_init();
	guidance_h_init();
	guidance_v_init();
	stabilization_init();

	ahrs_aligner_init();
	ahrs_init();

	ins_init();
#endif

	adc_buf_channel(0, &adc0_buf, 8);
	adc_buf_channel(1, &adc1_buf, 8);
	adc_buf_channel(2, &adc2_buf, 8);
	adc_buf_channel(3, &adc3_buf, 8);

	cscp_register_callback(CSC_VANE_MSG_ID, on_vane_msg, (void *)&csc_vane_msg);
	new_radio_msg = FALSE;
	new_baro_diff = FALSE;
	new_baro_abs = FALSE;
	new_vane = FALSE;
	new_adc = FALSE;

	overo_link.up.msg.imu_tick = 0;
}
예제 #24
0
파일: enose.c 프로젝트: AxSt/paparazzi
void enose_init( void ) {
  uint8_t i;
  for (i=0; i< ENOSE_NB_SENSOR; i++) {
    enose_heat[i] = ENOSE_HEAT_INIT;
    enose_val[i] = 0;
  }
  enose_status = ENOSE_IDLE;
  enose_conf_requested = TRUE;
  enose_i2c_done = TRUE;

#ifdef ADC_CHANNEL_PID
  adc_buf_channel(ADC_CHANNEL_PID, &buf_PID, ADC_CHANNEL_PID_NB_SAMPLES);
#endif
}
예제 #25
0
void airspeed_adc_init(void)
{
  airspeed_adc.airspeed = 0.0f;
  airspeed_adc.offset = AIRSPEED_ADC_BIAS;
#ifdef AIRSPEED_ADC_QUADRATIC_SCALE
  airspeed_adc.scale = AIRSPEED_ADC_QUADRATIC_SCALE;
#else
  airspeed_adc.scale = AIRSPEED_ADC_SCALE;
#endif

#ifndef SITL
  adc_buf_channel(ADC_CHANNEL_AIRSPEED, &buf_airspeed, ADC_CHANNEL_AIRSPEED_NB_SAMPLES);
#endif
}
예제 #26
0
int main (int argc, char** argv) {
  hw_init();
  sys_time_init();
  led_init();
  adc_init();

  adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES);
#ifdef ADC_6
  adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES);
#endif
#ifdef ADC_7
  adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES);
#endif

#if NB_ADC != 8
#error "8 ADCs expected !"
#endif

#ifdef USE_UART0
  Uart0Init();
#endif
#ifdef USE_UART1
  Uart1Init();
#endif

  int_enable();

  while(1) {
    if (sys_time_periodic()) {
      LED_TOGGLE(1);
      uint16_t values[NB_ADC];
      uint8_t i;
      for(i = 0; i < NB_ADC; i++)
	values[i] = buf_adc[i].sum / ADC_NB_SAMPLES;

      uint8_t id = 42;
      DOWNLINK_SEND_ADC(&id, NB_ADC, values);
    }
  }
  return 0;
}
예제 #27
0
int main (int argc, char** argv) {
  mcu_init();
  sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  led_init();
  adc_init();

  adc_buf_channel(ADC_0, &buf_adc[0], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_1, &buf_adc[1], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_2, &buf_adc[2], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_3, &buf_adc[3], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_4, &buf_adc[4], ADC_NB_SAMPLES);
  adc_buf_channel(ADC_5, &buf_adc[5], ADC_NB_SAMPLES);
#ifdef ADC_6
  adc_buf_channel(ADC_6, &buf_adc[6], ADC_NB_SAMPLES);
#endif
#ifdef ADC_7
  adc_buf_channel(ADC_7, &buf_adc[7], ADC_NB_SAMPLES);
#endif

#if NB_ADC != 8
#error "8 ADCs expected !"
#endif

#ifdef USE_UART0
  uart_periph_init(&uart0);
#endif
#ifdef USE_UART1
  uart_periph_init(&uart1);
#endif

  mcu_int_enable();

  while(1) {
    if (sys_time_check_and_ack_timer(0)) {
      LED_TOGGLE(1);
      uint16_t values[NB_ADC];
      uint8_t i;
      for(i = 0; i < NB_ADC; i++)
	values[i] = buf_adc[i].sum / ADC_NB_SAMPLES;

      uint8_t id = 42;
      DOWNLINK_SEND_ADC(&id, NB_ADC, values);
    }
  }
  return 0;
}
예제 #28
0
void init_ap( void ) {
  OSCCAL=0xB1;

  uart1_init_rx();
  uart0_init_rx();

  /** adc_init done in fbw */
  adc_buf_channel(ADC_CHANNEL_RANGEMETER, &rangemeter_adc_buf, DEFAULT_AV_NB_SAMPLE);

  gps_init ();

  int_enable();

  /** Debug */
  SetBit(DDRD, 5);
}
예제 #29
0
void imu_impl_init(void) {

  analog_imu_available = FALSE;

  adc_buf_channel(ADC_CHANNEL_GYRO_P, &analog_imu_adc_buf[0], ADC_CHANNEL_GYRO_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_GYRO_Q, &analog_imu_adc_buf[1], ADC_CHANNEL_GYRO_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_GYRO_R, &analog_imu_adc_buf[2], ADC_CHANNEL_GYRO_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_ACCEL_X, &analog_imu_adc_buf[3], ADC_CHANNEL_ACCEL_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_ACCEL_Y, &analog_imu_adc_buf[4], ADC_CHANNEL_ACCEL_NB_SAMPLES);
  adc_buf_channel(ADC_CHANNEL_ACCEL_Z, &analog_imu_adc_buf[5], ADC_CHANNEL_ACCEL_NB_SAMPLES);

}
예제 #30
0
void mb_mode_init(void) {
  adc_buf_channel(1, &mb_modes_adc_buf, 16);
  mb_modes_mode = MB_MODES_IDLE;
  mb_modes_throttle = 0.;

  mb_modes_ramp_duration = 200;

  mb_modes_step_low_throttle = 0.48;
  mb_modes_step_high_throttle = 0.65;
  mb_modes_step_duration = 0.5;

  mb_modes_sine_freq = 80.;
  mb_modes_sine_mean = 0.5;
  mb_modes_sine_ampl = 0.1;

  //  mb_static_init();

}