Browse Source

update

master
zhaohe 1 year ago
parent
commit
6720875c5d
  1. 50
      include/xsync_regs.hpp
  2. 247
      xsync.cpp
  3. 237
      xsync.hpp

50
include/xsync_regs.hpp

@ -30,8 +30,8 @@ using namespace std;
#define REGADDOFF__FPGA_INFO (0x0020)
#define REGADDOFF__TTLIN (0x0100)
#define REGADDOFF__EXTERNAL_TIMECODE (0x0120)
#define REGADDOFF__GENLOCK_IN (0x0130)
#define REGADDOFF__EXTERNAL_TIMECODE (0x0120)
#define REGADDOFF__EXTERNAL_GENLOCK (0x0130)
#define REGADDOFF__INTERNAL_TIMECODE (0x0300)
#define REGADDOFF__INTERNAL_GENLOCK (0x0310)
#define REGADDOFF__INTERNAL_CLOCK (0x0320)
@ -246,6 +246,52 @@ typedef enum {
timecode_output_bnc_outut_level_select = REGADDOFF__TIMECODE_OUT + 4,
timecode_output_headphone_outut_level_select = REGADDOFF__TIMECODE_OUT + 5,
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
external_genlock_module = REGADDOFF__EXTERNAL_GENLOCK + 0,
external_genlock_freq_detect_bias = REGADDOFF__EXTERNAL_GENLOCK + 1,
external_genlock_freq = REGADDOFF__EXTERNAL_GENLOCK + 2,
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
internal_genlock_module = REGADDOFF__INTERNAL_GENLOCK + 0,
internal_genlock_ctrl_mode = REGADDOFF__INTERNAL_GENLOCK + 1,
internal_genlock_en = REGADDOFF__INTERNAL_GENLOCK + 2,
internal_genlock_format = REGADDOFF__INTERNAL_GENLOCK + 3,
internal_genlock_freq = REGADDOFF__INTERNAL_GENLOCK + 4,
/*******************************************************************************
* SYSGENLOCK *
*******************************************************************************/
sys_genlock_module = REGADDOFF__SYS_GENLOCK,
sys_genlock_source = REGADDOFF__SYS_GENLOCK + 1,
sys_genlock_freq_detect_bias = REGADDOFF__SYS_GENLOCK + 2,
sys_genlock_freq = REGADDOFF__SYS_GENLOCK + 3,
/*******************************************************************************
* CLOCK *
*******************************************************************************/
internal_clock_module = REGADDOFF__INTERNAL_CLOCK + 0,
internal_clock_ctrl_mode = REGADDOFF__INTERNAL_CLOCK + 1,
internal_clock_en = REGADDOFF__INTERNAL_CLOCK + 2,
internal_clock_freq = REGADDOFF__INTERNAL_CLOCK + 3,
/*******************************************************************************
* SYSCLOCK *
*******************************************************************************/
sys_clock_module = REGADDOFF__SYS_CLOCK,
sys_clock_source = REGADDOFF__SYS_CLOCK + 1,
sys_clock_freq_division_ctrl = REGADDOFF__SYS_CLOCK + 2,
sys_clock_freq_multiplication_ctrl = REGADDOFF__SYS_CLOCK + 3,
sys_clock_freq_detect_bias = REGADDOFF__SYS_CLOCK + 4,
sys_clock_trigger_edge_select = REGADDOFF__SYS_CLOCK + 5,
sys_clock_infreq_detect = REGADDOFF__SYS_CLOCK + 0xE,
sys_clock_outfreq_detect = REGADDOFF__SYS_CLOCK + 0xF,
} RegAdd_t;
} // namespace reg

247
xsync.cpp

@ -31,13 +31,13 @@ using namespace std;
if (ecode != kxs_ec_success) return ecode; \
}
#define DO_XSYNC_REG_WRITE(reg, value) \
#define REG_WRITE(reg, value) \
{ \
DO_XSYNC(reg_write(reg, value, 10)); \
return kxs_ec_success; \
}
#define DO_XSYNC_REG_READ(reg, value) \
#define REG_READ(reg, value) \
{ \
uint32_t readbak = 0; \
DO_XSYNC(reg_read(reg, readbak, 10)); \
@ -610,136 +610,19 @@ xs_error_code_t Xsync::doaction(uint32_t action, uint32_t actionval, uint32_t *a
return ecode;
}
xs_error_code_t Xsync::Basic_setGenlockFormat(GenlockFormat_t format) {
DO_XSYNC(SigGenerator_setGenlockFormat(format));
return kxs_ec_success;
}
xs_error_code_t Xsync::Basic_getGenlockFormat(GenlockFormat_t &format) {
DO_XSYNC(SigGenerator_getGenlockFormat(format));
return kxs_ec_success;
}
xs_error_code_t Xsync::Basic_setTimecodeFormat(TimecodeFormat_t format) {
uint32_t readbak = 0;
return kxs_ec_success;
}
// xs_error_code_t Xsync::Basic_getTimecodeFormat(TimecodeFormat_t &format) {
// DO_XSYNC(SigGenerator_getTimecodeFormat(format));
// xs_error_code_t Xsync::Basic_setGenlockFormat(GenlockFormat_t format) {
// DO_XSYNC(SigGenerator_setGenlockFormat(format));
// return kxs_ec_success;
// }
// xs_error_code_t Xsync::Basic_getGenlockFormat(GenlockFormat_t &format) {
// DO_XSYNC(SigGenerator_getGenlockFormat(format));
// return kxs_ec_success;
// }
// xs_error_code_t Xsync::Basic_setTimecodeFormat(TimecodeFormat_t format) {
// uint32_t readbak = 0;
// return kxs_ec_success;
// }
/*******************************************************************************
* TTLOutputModule *
*******************************************************************************/
xs_error_code_t Xsync::SigGenerator_setControlMode(sig_generator_module::ControlMode_t mode) {
uint32_t readbak = 0;
return reg_write(reg::kSigGenerator_ctl, mode, readbak, 10);
}
xs_error_code_t Xsync::SigGenerator_getControlMode(sig_generator_module::ControlMode_t &mode) {
uint32_t readbak = 0;
auto ecode = reg_read(reg::kSigGenerator_ctl, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
mode = (sig_generator_module::ControlMode_t)readbak;
return ecode;
}
xs_error_code_t Xsync::SigGenerator_manualStart() {
uint32_t readbak = 0;
return reg_write(reg::kSigGenerator_control_trigger_reg, 1, readbak, 10);
}
xs_error_code_t Xsync::SigGenerator_manualStop() {
uint32_t readbak = 0;
return reg_write(reg::kSigGenerator_control_trigger_reg, 0, readbak, 10);
}
xs_error_code_t Xsync::SigGenerator_setTimecode(XsyncTimecode_t timecode) {
uint32_t readbak = 0;
xs_error_code_t ecode = kxs_ec_success;
Timecode64_t tc64 = timecodeTo64(timecode);
ecode = reg_write(reg::kSigGenerator_timecode0, tc64.tc0, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
ecode = reg_write(reg::kSigGenerator_timecode1, tc64.tc1, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
return ecode;
}
xs_error_code_t Xsync::SigGenerator_getTimecode(XsyncTimecode_t &timecode) {
uint32_t readbak = 0;
xs_error_code_t ecode = kxs_ec_success;
uint32_t tc0 = 0;
uint32_t tc1 = 0;
ecode = reg_read(reg::kSigGenerator_timecode0, tc0, 10);
if (ecode != kxs_ec_success) return ecode;
ecode = reg_read(reg::kSigGenerator_timecode1, tc1, 10);
if (ecode != kxs_ec_success) return ecode;
Timecode64_t tc64;
tc64.tc0 = tc0;
tc64.tc1 = tc1;
timecode = timecode64ToXsyncTimeCode(tc64);
return ecode;
}
xs_error_code_t Xsync::SigGenerator_setAutoStartTimecode(XsyncTimecode_t timecode) {
uint32_t readbak = 0;
xs_error_code_t ecode = kxs_ec_success;
Timecode64_t tc64 = timecodeTo64(timecode);
ecode = reg_write(reg::kSigGenerator_timecode_start0, tc64.tc0, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
ecode = reg_write(reg::kSigGenerator_timecode_start1, tc64.tc1, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
return ecode;
}
xs_error_code_t Xsync::SigGenerator_getAutoStartTimecode(XsyncTimecode_t &timecode) {
uint32_t readbak = 0;
xs_error_code_t ecode = kxs_ec_success;
uint32_t tc0 = 0;
uint32_t tc1 = 0;
ecode = reg_read(reg::kSigGenerator_timecode_start0, tc0, 10);
if (ecode != kxs_ec_success) return ecode;
ecode = reg_read(reg::kSigGenerator_timecode_start1, tc1, 10);
if (ecode != kxs_ec_success) return ecode;
Timecode64_t tc64;
tc64.tc0 = tc0;
tc64.tc1 = tc1;
timecode = timecode64ToXsyncTimeCode(tc64);
return ecode;
}
xs_error_code_t Xsync::SigGenerator_getWorkState(uint32_t &work_state) {
uint32_t readbak = 0;
auto ecode = reg_read(reg::kSigGenerator_work_state, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
work_state = readbak;
return ecode;
}
xs_error_code_t Xsync::SigGenerator_setGenlockFormat(GenlockFormat_t format) {
uint32_t readbak = 0;
return reg_write(reg::kSigGenerator_genlock_format, format, readbak, 10);
}
xs_error_code_t Xsync::SigGenerator_getGenlockFormat(GenlockFormat_t &format) {
uint32_t readbak = 0;
auto ecode = reg_read(reg::kSigGenerator_genlock_format, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
format = (GenlockFormat_t)readbak;
return ecode;
}
xs_error_code_t Xsync::SigGenerator_setTimecodeFormat(TimecodeFormat_t format) { return Basic_setTimecodeFormat(format); }
xs_error_code_t Xsync::SigGenerator_getTimecodeFormat(TimecodeFormat_t &format) {
uint32_t readbak = 0;
auto ecode = reg_read(reg::kSigGenerator_timecode_format, readbak, 10);
if (ecode != kxs_ec_success) return ecode;
format = (TimecodeFormat_t)readbak;
return ecode;
}
xs_error_code_t Xsync::CameraSyncPacketGeneratorModule_setTriggerSig(camera_sync_packet_generator_module::TriggerSigType_t sig) {
uint32_t readbak = 0;
DO_XSYNC(reg_write(reg::kcamera_sync_out_camera_sync_select, sig, readbak, 10));
@ -824,7 +707,7 @@ xs_error_code_t Xsync::TTLOutputModule1_setSrcSigType(SignalType_t source) {
} else {
DO_XSYNC(reg_write(reg::kreg_ttlout1_signal_process_mode, 3, 10)); // 转发模式
}
DO_XSYNC_REG_WRITE(reg::kreg_ttlout1_input_signal_select, source);
REG_WRITE(reg::kreg_ttlout1_input_signal_select, source);
}
xs_error_code_t Xsync::TTLOutputModule2_setSrcSigType(SignalType_t source) {
if (source == SIGNAL_TTLIN1 || source == SIGNAL_TTLIN2 || source == SIGNAL_TTLIN3 || source == SIGNAL_TTLIN4) {
@ -832,7 +715,7 @@ xs_error_code_t Xsync::TTLOutputModule2_setSrcSigType(SignalType_t source) {
} else {
DO_XSYNC(reg_write(reg::kreg_ttlout2_signal_process_mode, 3, 10)); // 转发模式
}
DO_XSYNC_REG_WRITE(reg::kreg_ttlout2_input_signal_select, source);
REG_WRITE(reg::kreg_ttlout2_input_signal_select, source);
}
xs_error_code_t Xsync::TTLOutputModule3_setSrcSigType(SignalType_t source) {
if (source == SIGNAL_TTLIN1 || source == SIGNAL_TTLIN2 || source == SIGNAL_TTLIN3 || source == SIGNAL_TTLIN4) {
@ -840,7 +723,7 @@ xs_error_code_t Xsync::TTLOutputModule3_setSrcSigType(SignalType_t source) {
} else {
DO_XSYNC(reg_write(reg::kreg_ttlout3_signal_process_mode, 3, 10)); // 转发模式
}
DO_XSYNC_REG_WRITE(reg::kreg_ttlout3_input_signal_select, source);
REG_WRITE(reg::kreg_ttlout3_input_signal_select, source);
}
xs_error_code_t Xsync::TTLOutputModule4_setSrcSigType(SignalType_t source) {
if (source == SIGNAL_TTLIN1 || source == SIGNAL_TTLIN2 || source == SIGNAL_TTLIN3 || source == SIGNAL_TTLIN4) {
@ -848,33 +731,33 @@ xs_error_code_t Xsync::TTLOutputModule4_setSrcSigType(SignalType_t source) {
} else {
DO_XSYNC(reg_write(reg::kreg_ttlout4_signal_process_mode, 3, 10)); // 转发模式
}
DO_XSYNC_REG_WRITE(reg::kreg_ttlout4_input_signal_select, source);
REG_WRITE(reg::kreg_ttlout4_input_signal_select, source);
}
xs_error_code_t Xsync::TTLOutputModule1_getSrcSigType(SignalType_t &source) { DO_XSYNC_REG_READ(reg::kreg_ttlout1_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule2_getSrcSigType(SignalType_t &source) { DO_XSYNC_REG_READ(reg::kreg_ttlout2_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule3_getSrcSigType(SignalType_t &source) { DO_XSYNC_REG_READ(reg::kreg_ttlout3_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule4_getSrcSigType(SignalType_t &source) { DO_XSYNC_REG_READ(reg::kreg_ttlout4_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule1_getSrcSigType(SignalType_t &source) { REG_READ(reg::kreg_ttlout1_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule2_getSrcSigType(SignalType_t &source) { REG_READ(reg::kreg_ttlout2_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule3_getSrcSigType(SignalType_t &source) { REG_READ(reg::kreg_ttlout3_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule4_getSrcSigType(SignalType_t &source) { REG_READ(reg::kreg_ttlout4_input_signal_select, source); }
xs_error_code_t Xsync::TTLOutputModule1_setFreqDivision(uint32_t div) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout1_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule2_setFreqDivision(uint32_t div) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout2_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule3_setFreqDivision(uint32_t div) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout3_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule4_setFreqDivision(uint32_t div) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout4_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule1_setFreqDivision(uint32_t div) { REG_WRITE(reg::kreg_ttlout1_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule2_setFreqDivision(uint32_t div) { REG_WRITE(reg::kreg_ttlout2_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule3_setFreqDivision(uint32_t div) { REG_WRITE(reg::kreg_ttlout3_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule4_setFreqDivision(uint32_t div) { REG_WRITE(reg::kreg_ttlout4_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule1_getFreqDivision(uint32_t &div) { DO_XSYNC_REG_READ(reg::kreg_ttlout1_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule2_getFreqDivision(uint32_t &div) { DO_XSYNC_REG_READ(reg::kreg_ttlout2_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule3_getFreqDivision(uint32_t &div) { DO_XSYNC_REG_READ(reg::kreg_ttlout3_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule4_getFreqDivision(uint32_t &div) { DO_XSYNC_REG_READ(reg::kreg_ttlout4_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule1_getFreqDivision(uint32_t &div) { REG_READ(reg::kreg_ttlout1_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule2_getFreqDivision(uint32_t &div) { REG_READ(reg::kreg_ttlout2_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule3_getFreqDivision(uint32_t &div) { REG_READ(reg::kreg_ttlout3_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule4_getFreqDivision(uint32_t &div) { REG_READ(reg::kreg_ttlout4_pllout_freq_division_ctrl, div); }
xs_error_code_t Xsync::TTLOutputModule1_setFreqMultiplication(uint32_t multi) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout1_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule2_setFreqMultiplication(uint32_t multi) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout2_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule3_setFreqMultiplication(uint32_t multi) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout3_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule4_setFreqMultiplication(uint32_t multi) { DO_XSYNC_REG_WRITE(reg::kreg_ttlout4_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule1_setFreqMultiplication(uint32_t multi) { REG_WRITE(reg::kreg_ttlout1_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule2_setFreqMultiplication(uint32_t multi) { REG_WRITE(reg::kreg_ttlout2_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule3_setFreqMultiplication(uint32_t multi) { REG_WRITE(reg::kreg_ttlout3_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule4_setFreqMultiplication(uint32_t multi) { REG_WRITE(reg::kreg_ttlout4_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule1_getFreqMultiplication(uint32_t &multi) { DO_XSYNC_REG_READ(reg::kreg_ttlout1_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule2_getFreqMultiplication(uint32_t &multi) { DO_XSYNC_REG_READ(reg::kreg_ttlout2_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule3_getFreqMultiplication(uint32_t &multi) { DO_XSYNC_REG_READ(reg::kreg_ttlout3_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule4_getFreqMultiplication(uint32_t &multi) { DO_XSYNC_REG_READ(reg::kreg_ttlout4_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule1_getFreqMultiplication(uint32_t &multi) { REG_READ(reg::kreg_ttlout1_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule2_getFreqMultiplication(uint32_t &multi) { REG_READ(reg::kreg_ttlout2_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule3_getFreqMultiplication(uint32_t &multi) { REG_READ(reg::kreg_ttlout3_pllout_freq_multiplication_ctrl, multi); }
xs_error_code_t Xsync::TTLOutputModule4_getFreqMultiplication(uint32_t &multi) { REG_READ(reg::kreg_ttlout4_pllout_freq_multiplication_ctrl, multi); }
/*******************************************************************************
* TimecodeInputModule *
@ -905,15 +788,15 @@ xs_error_code_t Xsync::ExternalTimecode_getSource(InputInterface_t &timecode_sel
}
return kxs_ec_success;
}
xs_error_code_t Xsync::ExternalTimecode_setFormat(TimecodeFormat_t format) { DO_XSYNC_REG_WRITE(reg::external_timecode_format, format); }
xs_error_code_t Xsync::ExternalTimecode_getFormat(TimecodeFormat_t &format) { DO_XSYNC_REG_READ(reg::external_timecode_format, format); }
xs_error_code_t Xsync::ExternalTimecode_setFormat(TimecodeFormat_t format) { REG_WRITE(reg::external_timecode_format, format); }
xs_error_code_t Xsync::ExternalTimecode_getFormat(TimecodeFormat_t &format) { REG_READ(reg::external_timecode_format, format); }
xs_error_code_t Xsync::ExternalTimecode_readCode(XsyncTimecode_t &timecode) { return readtimecode(reg::external_timecode_code0, reg::external_timecode_code1, timecode); }
/*******************************************************************************
* InternalTimecode *
*******************************************************************************/
xs_error_code_t Xsync::InternalTimecode_setFormat(TimecodeFormat_t format) { DO_XSYNC_REG_WRITE(reg::internal_timecode_format, format); }
xs_error_code_t Xsync::InternalTimecode_getFormat(TimecodeFormat_t &format) { DO_XSYNC_REG_READ(reg::internal_timecode_format, format); }
xs_error_code_t Xsync::InternalTimecode_setFormat(TimecodeFormat_t format) { REG_WRITE(reg::internal_timecode_format, format); }
xs_error_code_t Xsync::InternalTimecode_getFormat(TimecodeFormat_t &format) { REG_READ(reg::internal_timecode_format, format); }
xs_error_code_t Xsync::InternalTimecode_setCode(XsyncTimecode_t timecode) {
DO_XSYNC(reg_write(reg::internal_timecode_en, 0));
DO_XSYNC(writetimecode(reg::internal_timecode_data0, reg::internal_timecode_data1, timecode));
@ -925,14 +808,50 @@ xs_error_code_t Xsync::InternalTimecode_getCode(XsyncTimecode_t &timecode) { ret
/*******************************************************************************
* SysTimecode *
*******************************************************************************/
xs_error_code_t Xsync::SysTimecode_setSource(uint32_t sig) { DO_XSYNC_REG_WRITE(reg::sys_timecode_select, sig); }
xs_error_code_t Xsync::SysTimecode_getSource(uint32_t &sig) { DO_XSYNC_REG_READ(reg::sys_timecode_select, sig); }
xs_error_code_t Xsync::SysTimecode_readFormat(TimecodeFormat_t &format) { DO_XSYNC_REG_READ(reg::sys_timecode_format, format); }
xs_error_code_t Xsync::SysTimecode_setSource(uint32_t sig) { REG_WRITE(reg::sys_timecode_select, sig); }
xs_error_code_t Xsync::SysTimecode_getSource(uint32_t &sig) { REG_READ(reg::sys_timecode_select, sig); }
xs_error_code_t Xsync::SysTimecode_readFormat(TimecodeFormat_t &format) { REG_READ(reg::sys_timecode_format, format); }
xs_error_code_t Xsync::SysTimecode_readCode(XsyncTimecode_t &timecode) { return readtimecode(reg::sys_timecode_data0, reg::sys_timecode_data1, timecode); }
/*******************************************************************************
* TimecodeOutputModule *
*******************************************************************************/
xs_error_code_t Xsync::TimecodeOutputModule_setBncOutputLevel(int level) { DO_XSYNC_REG_WRITE(reg::timecode_output_bnc_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_getBncOutputLevel(int &level) { DO_XSYNC_REG_READ(reg::timecode_output_bnc_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_setHeadphoneOutputLevel(int level) { DO_XSYNC_REG_WRITE(reg::timecode_output_headphone_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_getHeadphoneOutputLevel(int &level) { DO_XSYNC_REG_READ(reg::timecode_output_headphone_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_setBncOutputLevel(int level) { REG_WRITE(reg::timecode_output_bnc_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_getBncOutputLevel(int &level) { REG_READ(reg::timecode_output_bnc_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_setHeadphoneOutputLevel(int level) { REG_WRITE(reg::timecode_output_headphone_outut_level_select, level); }
xs_error_code_t Xsync::TimecodeOutputModule_getHeadphoneOutputLevel(int &level) { REG_READ(reg::timecode_output_headphone_outut_level_select, level); }
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
xs_error_code_t Xsync::ExternalGenlock_detectFreq(float &freq) { return readfreq(reg::external_genlock_freq, freq); }
xs_error_code_t Xsync::InternalGenlock_setFormat(GenlockFormat_t format) { return reg_write(reg::internal_genlock_format, format); }
xs_error_code_t Xsync::InternalGenlock_getFormat(GenlockFormat_t &format) { REG_READ(reg::internal_genlock_format, format); }
xs_error_code_t Xsync::SysGenlock_setSrc(SignalType_t sig) { return reg_write(reg::sys_genlock_source, sig); }
xs_error_code_t Xsync::SysGenlock_getSrc(SignalType_t &sig) { REG_READ(reg::sys_genlock_source, sig); }
xs_error_code_t Xsync::SysGenlock_readFreq(float &freq) { return readfreq(reg::sys_genlock_freq, freq); }
/*******************************************************************************
* INTERNAL_CLOCK *
*******************************************************************************/
xs_error_code_t Xsync::InternalClock_setFreq(float freq) {
double T = 1.0 / freq;
double T_ns = T * 1000 * 1000 * 1000;
double cnt = T_ns / 100 + 0.5; // 10MHZ <=> 100ns
uint32_t cnt_u32 = uint32_t(cnt);
return reg_write(reg::internal_clock_freq, cnt_u32);
return kxs_ec_success;
}
xs_error_code_t Xsync::InternalClock_getFreq(float &freq) { return readfreq(reg::internal_clock_freq, freq); }
/*******************************************************************************
* SysClock *
*******************************************************************************/
xs_error_code_t Xsync::SysClock_setSrc(SignalType_t sig) { return reg_write(reg::sys_clock_source, sig); }
xs_error_code_t Xsync::SysClock_getSrc(SignalType_t &sig) { REG_READ(reg::sys_clock_source, sig); }
xs_error_code_t Xsync::SysClock_setTriggerEdge(TriggerEdge_t edge) { return reg_write(reg::sys_clock_trigger_edge_select, edge); }
xs_error_code_t Xsync::SysClock_getTriggerEdge(TriggerEdge_t &edge) { return _reg_read(reg::sys_clock_trigger_edge_select, edge); }
xs_error_code_t Xsync::SysClock_setFreqDivision(uint32_t div) { return reg_write(reg::sys_clock_freq_division_ctrl, div); }
xs_error_code_t Xsync::SysClock_geFreqtDivision(uint32_t &div) { return _reg_read(reg::sys_clock_freq_division_ctrl, div); }
xs_error_code_t Xsync::SysClock_setFreqMultiplication(uint32_t muti) { return reg_write(reg::sys_clock_freq_multiplication_ctrl, muti); }
xs_error_code_t Xsync::SysClock_getFreqMultiplication(uint32_t &muti) { return _reg_read(reg::sys_clock_freq_multiplication_ctrl, muti); }
xs_error_code_t Xsync::SysClock_readFreq(float &freq) { return readfreq(reg::sys_clock_outfreq_detect, freq); }
xs_error_code_t Xsync::SysClock_readInputFreq(float &freq) { return readfreq(reg::sys_clock_infreq_detect, freq); }

237
xsync.hpp

@ -153,6 +153,7 @@ class Xsync {
xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, uint32_t &regbackvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_write(uint32_t regadd, uint32_t regvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_read(uint32_t regadd, uint32_t &regvalue, int32_t overtime_ms = 100);
xs_error_code_t reg_read_muti(uint32_t regadd, uint32_t nreg, vector<uint32_t> &regvalues, int32_t overtime_ms = 100);
/*******************************************************************************
@ -165,102 +166,9 @@ class Xsync {
xs_error_code_t Basic_clearXsyncCameraSyncIndexCount();
xs_error_code_t Basic_setGenlockFormat(GenlockFormat_t format);
xs_error_code_t Basic_getGenlockFormat(GenlockFormat_t &format);
xs_error_code_t Basic_setTimecodeFormat(TimecodeFormat_t format);
// xs_error_code_t Basic_getTimecodeFormat(TimecodeFormat_t &format);
/*******************************************************************************
* *
*******************************************************************************/
/**
* :
* 0.
* 1. TIMECODE触发模式下
*/
/**
* @brief
*
* @param mode
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_setControlMode(sig_generator_module::ControlMode_t mode);
/**
* @brief
*
* @param mode
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_getControlMode(sig_generator_module::ControlMode_t &mode);
/**
* @brief
*
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_manualStart();
/**
* @brief
*
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_manualStop();
/**
* @brief
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_setTimecode(XsyncTimecode_t timecode);
/**
* @brief
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_getTimecode(XsyncTimecode_t &timecode);
/**
* @brief
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_setAutoStartTimecode(XsyncTimecode_t timecode);
/**
* @brief
*
* @param timecode
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_getAutoStartTimecode(XsyncTimecode_t &timecode);
/**
* @brief
*
* @param work_state
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_getWorkState(uint32_t &work_state);
/**
* @brief genlock格式
*
* @param format
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_setGenlockFormat(GenlockFormat_t format); // 不建议使用这个方法,用Basic_setGenlockFormat
xs_error_code_t SigGenerator_getGenlockFormat(GenlockFormat_t &format); // 不建议使用这个方法,用Basic_getGenlockFormat
/**
* @brief timecode格式
*
* @param format
* @return xs_error_code_t
*/
xs_error_code_t SigGenerator_setTimecodeFormat(TimecodeFormat_t format); // 不建议使用这个方法,用Basic_setTimecodeFormat
xs_error_code_t SigGenerator_getTimecodeFormat(TimecodeFormat_t &format); // 不建议使用这个方法,用Basic_getTimecodeFormat
// xs_error_code_t Basic_setGenlockFormat(GenlockFormat_t format);
// xs_error_code_t Basic_getGenlockFormat(GenlockFormat_t &format);
// xs_error_code_t Basic_setTimecodeFormat(TimecodeFormat_t format);
public:
/*******************************************************************************
* *
@ -484,6 +392,133 @@ class Xsync {
xs_error_code_t TTLOutputModule3_getFreqMultiplication(uint32_t &multi);
xs_error_code_t TTLOutputModule4_getFreqMultiplication(uint32_t &multi);
/*******************************************************************************
* GENLOCK *
*******************************************************************************/
/**
* @brief Genlock输入模块的频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t ExternalGenlock_detectFreq(float &freq);
/**
* @brief Genlock信号发生器
*
* @param format
* :
* GENLOCK_FPS2397
* GENLOCK_FPS2398
* GENLOCK_FPS2400
* GENLOCK_FPS2500
* GENLOCK_FPS2997
* GENLOCK_FPS3000
* GENLOCK_FPS5000
* GENLOCK_FPS5994
* GENLOCK_FPS6000
* @return xs_error_code_t
*/
xs_error_code_t InternalGenlock_setFormat(GenlockFormat_t format);
xs_error_code_t InternalGenlock_getFormat(GenlockFormat_t &format);
/**
* @brief Genlock选择时钟源
*
* @param sig
* :
* SIGNAL_EXT_GENLOCK_FREQ
* SIGNAL_INTERNAL_GENLOCK_FREQ
*
* @return xs_error_code_t
*/
xs_error_code_t SysGenlock_setSrc(SignalType_t sig);
xs_error_code_t SysGenlock_getSrc(SignalType_t &sig);
/**
* @brief Genlock频率
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysGenlock_readFreq(float &freq);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param freq HZ,0.1HZ
* @return xs_error_code_t
*/
xs_error_code_t InternalClock_setFreq(float freq);
xs_error_code_t InternalClock_getFreq(float &freq);
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* @param mode
* :
* SIGNAL_TTLIN1
* SIGNAL_TTLIN1
* SIGNAL_TTLIN2
* SIGNAL_TTLIN3
* SIGNAL_TTLIN4
* SIGNAL_INTERNAL_FREQ_SIG
* SIGNAL_SYS_GENLOCK_OUTPUT
*
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setSrc(SignalType_t sig);
xs_error_code_t SysClock_getSrc(SignalType_t &sig);
/**
* @brief 沿
*
* @param edge
* TRIGGER_EDGE_RISING
* TRIGGER_EDGE_FALLING
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setTriggerEdge(TriggerEdge_t edge);
xs_error_code_t SysClock_getTriggerEdge(TriggerEdge_t &edge);
/**
* @brief
*
* @param div
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setFreqDivision(uint32_t div);
xs_error_code_t SysClock_geFreqtDivision(uint32_t &div);
/**
* @brief
*
* @param muti
* @return xs_error_code_t
*/
xs_error_code_t SysClock_setFreqMultiplication(uint32_t muti);
xs_error_code_t SysClock_getFreqMultiplication(uint32_t &muti);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_readFreq(float &freq);
/**
* @brief
*
* @param freq
* @return xs_error_code_t
*/
xs_error_code_t SysClock_readInputFreq(float &freq);
private:
xs_error_code_t doaction(uint32_t action, uint32_t actionval, uint32_t *ackreturn, int32_t overtime_ms = 100);
xs_error_code_t storageConfig();
@ -493,6 +528,16 @@ class Xsync {
xs_error_code_t writetimecode(uint32_t reg0, uint32_t reg1, XsyncTimecode_t timecode);
xs_error_code_t readfreq(uint32_t reg, float &freq);
template <typename T>
xs_error_code_t _reg_read(uint32_t regadd, T &regvalue, int32_t overtime_ms = 100) {
uint32_t regvalue_u32;
xs_error_code_t ret = reg_read(regadd, regvalue_u32, overtime_ms);
if (ret == kxs_ec_success) {
regvalue = (T)regvalue_u32;
}
return ret;
}
void parseTimecodeMsgAndReport(XsyncNetAdd &from, uint8_t *data, size_t length);
void parseCameraSyncMsgAndReport(XsyncNetAdd &from, uint8_t *data, size_t length);
};

Loading…
Cancel
Save