示例#1
0
文件: camera.c 项目: RTS2/rts2
extern int
camera_expose (int chip, float *exposure, int light)
{
  CAMERA *C;
  int imstate;
  if (!is_init)
    return -1;

  sem_lock ();

#ifdef INIT_SHUTTER
  init_shutter ();
#else
  if (!light)			// init shutter only for dark images
    init_shutter ();
#endif

  if (OpenCCD (chip, &C))
    goto err;
  if (CCDExpose (C, (int) 100 * (*exposure) + 0.5, light))
    goto err;

  sem_unlock ();

  // wait for completing exp
  do
    {
      sem_lock ();
      imstate = CCDImagingState (C);
      sem_unlock ();

      pthread_testcancel ();
      TimerDelay (100000);
    }
  while (imstate);

  sem_lock ();
  readout_line[chip] = 0;
  if (CCDReadout
      (img[chip], C, 0, 0, C->vertImage, C->horzImage,
       ch_info[chip].binning_vertical))
    goto err;
  CloseCCD (C);
  sem_unlock ();

  return 0;

err:
  CloseCCD (C);
  sem_unlock ();
  errno = ENODEV;
  return -1;
}
示例#2
0
文件: gpio.c 项目: MosesLab/flightSW
/*sets up the memory used in powering the instrument*/
int init_gpio() {
    int rc;
    char msg[255];

    gpio_out_state.val = 0;
    gpio_out_state.bf.tcs1 = 1; // initialize TCS systems to one to ensure that they are off. 
    gpio_out_state.bf.tcs2 = 1; // The TCS systems use inverse logic.
    gpio_out_state.bf.tcs3 = 1;
    

    U32 mask = 0x00000002;
    unsigned int i;
    for (i = 0; i < 32; i++) {
        power_subsystem_mask[i] = mask;
        mask = mask << 1;
    }

    mask = 0x00000001;
    for (i = 0; i < NUM_CONTROL_GPIO; i++) {
        gpio_control_mask[i] = mask;
        mask = mask << 1;
    }

    /*initialize bar properties*/
    bar_index = (U8) GPIO_BAR_INDEX;
    bar_sz_buffer = PLX_BUFFER_WIDTH;
    type_bit = BitSize32;

    /*Read current BAR properties*/
    rc = PlxPci_PciBarProperties(&fpga_dev, bar_index, &bar_properties);

    /*Check if bar properties were read successfully*/
    if (rc != ApiSuccess) {
        record("*ERROR* - API failed, unable to read BAR properties \n");
        PlxSdkErrorDisplay(rc);
        return FALSE;
    }

    /*reset FPGA so interrupts are delivered appropriately*/
    reset_fpga();

    /*initialize dma channel*/
    //    initializeDMA();  This is moved to the beginning of fpga.c


    /*enable GPIO pins on the FPGA*/
    //    poke_gpio(GPIO_I_INT_ENABLE, 0x87FFFFFF); // Enable all input gpio interrupts
    poke_gpio(GPIO_I_INT_ENABLE, 0x83FFFFFF); // Disable ddr2 error signal

    /*initialize acknowledge register*/
    poke_gpio(GPIO_I_INT_ACK, 0xFFFFFFFF);

    // Initialize the system
    //    WriteDword(&fpga_dev, 2, GPIO_I_INT_ENABLE, input_gpio_int_en); // Disable all the input gpio interrupts
    //    input_gpio_int_ack = 0xFFFFFFFF;
    //    WriteDword(&fpga_dev, 2, GPIO_I_INT_ACK, input_gpio_int_ack); // Acknowledge all active interrupts, if any
    input_gpio_int_ack = 0x00000000;
    WriteDword(&fpga_dev, 2, GPIO_I_INT_ACK, input_gpio_int_ack);
    //    output_gpio |= 0x00003000; // Set output_gpio value to display LED value 3
    //    WriteDword(&fpga_dev, 2, 0x14, output_gpio)

    output_ddr2_addr = 0x003FFFFC;
    WriteDword(&fpga_dev, 2, OUTPUT_DDR2_ADDRESS_ADDR, output_ddr2_addr); // Sets the DDR2 address to zero (currently unused)
    output_ddr2_ctrl = 0x00000000;
    WriteDword(&fpga_dev, 2, OUTPUT_DDR2_CTRL_ADDR, output_ddr2_ctrl); // Set the Data Manager control signal to zero

    /*set camera interface to simulated or real*/
    if (config_values[image_sim_interface] == 0) {
        gpio_out_state.bf.camer_mux_sel = 0; // Simulated camera interface
    } else {
        gpio_out_state.bf.camer_mux_sel = 1; // actual ROE camera interface
    }
    sprintf(msg, "Camera mux is: %d\n", gpio_out_state.val);
    record(msg);
    rc = poke_gpio(OUTPUT_GPIO_ADDR, gpio_out_state.val);
    if (rc == FALSE) {
        record("Error writing GPIO output\n");
    }

    init_shutter();

    return TRUE;

}