RaptorEagleV/raptor_eagle_cameralink.h
2024-12-01 20:16:00 +03:00

109 lines
3.9 KiB
C++

#pragma once
#include <chrono>
/*
CAMERALINK PROTOCOL DEFINITIONS
TO MANAGE RAPTOR EAGLE V 4240 CAMERA
*/
/* from EAGLE V 4240 Instruction Manual Revision 1.1 */
// default port settings
// the values are ones for EB1 grabber card (see XCLIB Reference manual)
// default read/write operation timeout in milliseconds (1 second)
static constexpr std::chrono::duration CL_DEFAULT_TIMEOUT = std::chrono::milliseconds(1000);
static constexpr int CL_DEFAULT_BAUD_RATE = 115200;
static constexpr int CL_DEFAULT_START_BIT = 1;
static constexpr int CL_DEFAULT_DATA_BITS = 8;
static constexpr int CL_DEFAULT_STOP_BIT = 1;
static constexpr bool CL_DEFAULT_ACK_ENABLED = true;
static constexpr bool CL_DEFAULT_CHK_SUM_ENABLED = true;
// ETX/ERROR codes
static constexpr char CL_ETX = 0x50;
static constexpr char CL_ETX_SER_TIMEOUT = 0x51;
static constexpr char CL_ETX_CK_SUM_ERR = 0x52;
static constexpr char CL_ETXI2C_ERR = 0x53;
static constexpr char CL_ETX_UNKNOWN_CMD = 0x54;
static constexpr char CL_ETX_DONE_LOW = 0x55;
/* BIT MASKS (0-7 bits) */
// system state
static constexpr char CL_SYSTEM_STATE_CK_SUM = 0x40; // 6-th bit
static constexpr char CL_SYSTEM_STATE_ACK = 0x10; // 4-th bit
static constexpr char CL_SYSTEM_STATE_FPGA_BOOT_OK = 0x4; // 2-nd bit
static constexpr char CL_SYSTEM_STATE_FPGA_RST_HOLD = 0x2; // 1-st bit
static constexpr char CL_SYSTEM_STATE_FPGA_EEPROM_COMMS = 0x1; // 0-th bit
// FPGA CTRL register
static constexpr char CL_FPGA_CTRL_REG_HIGH_GAIN = 0x80; // 7-th bit (0 if high pre-amp gain)
static constexpr char CL_FPGA_CTRL_REG_TMP_TRIP_RST = 0x2; // 1-st bit
static constexpr char CL_FPGA_CTRL_REG_ENABLE_TEC = 0x1; // 0-th bit
// trigger mode
static constexpr char CL_TRIGGER_MODE_ENABLE_RISING_EDGE = 0x80; // 7-th bit
static constexpr char CL_TRIGGER_MODE_EXT_TRIGGER = 0x40; // 6-th bit
static constexpr char CL_TRIGGER_MODE_ABORT_CURRENT_EXP = 0x8; // 3-rd bit
static constexpr char CL_TRIGGER_MODE_CONTINUOUS_SEQ = 0x4; // 2-nd bit
static constexpr char CL_TRIGGER_MODE_FIXED_FRAME_RATE = 0x2; // 1-st bit
static constexpr char CL_TRIGGER_MODE_SNAPSHOT = 0x1; // 0-th bit
/* SETUP CONTROL VALUES */
// shutter
static constexpr char CL_SHUTTER_CLOSED = 0x0;
static constexpr char CL_SHUTTER_OPEN = 0x1;
static constexpr char CL_SHUTTER_EXP = 0x2;
// readout rate (registers values)
static constexpr char CL_READOUT_CLOCK_RATE_A3_2MHZ = 0x02;
static constexpr char CL_READOUT_CLOCK_RATE_A4_2MHZ = 0x02;
static constexpr char CL_READOUT_CLOCK_RATE_A3_75KHZ = 0x43;
static constexpr char CL_READOUT_CLOCK_RATE_A4_75KHZ = 0x80;
// readout mode
static constexpr char CL_READOUT_MODE_NORMAL = 0x01;
static constexpr char CL_READOUT_MODE_TEST = 0x04;
static constexpr double ADC_CALIBRATION_POINT_1 = 0.0; // at 0 Celcius degree
static constexpr double ADC_CALIBRATION_POINT_2 = 40.0; // at +40 Celcius degree
static constexpr double DAC_CALIBRATION_POINT_1 = 0.0; // at 0 Celcius degree
static constexpr double DAC_CALIBRATION_POINT_2 = 40.0; // at +40 Celcius degree
/* COMMANDS */
static unsigned char CL_COMMAND_SET_ADDRESS[] = {
0x53, 0xE0, 0x01, 0x00}; // set address given by the last byte. the last byte should be set by user)
static unsigned char CL_COMMAND_READ_VALUE[] = {0x53, 0xE1, 0x01}; // read a byte value
static unsigned char CL_COMMAND_WRITE_VALUE[] = {0x53, 0xE0, 0x02, 0x00,
0x00}; // write a byte value given by the last byte
// at address given by 3-rd byte (starting from 0)
static constexpr unsigned char CL_COMMAND_GET_MANUFACTURER_DATA_1[] = {
0x53, 0xAE, 0x05, 0x01, 0x00, 0x00, 0x02, 0x00}; // 1st command to get manufacturer's data
static constexpr unsigned char CL_COMMAND_GET_MANUFACTURER_DATA_2[] = {0x53, 0xAF, 0x12}; // the second one