Browse Source

update

master
zhaohe 1 year ago
parent
commit
272d663cd4
  1. 3
      .gitmodules
  2. 4
      src/app/main.cpp
  3. 733
      src/app/syncbox16ch/sdk/clst_controler.cpp
  4. 0
      src/app/syncbox16ch/sdk/syncbox16ch_reg.hpp
  5. 0
      src/app/syncbox16ch/sdk/syncbox16ch_sdk.cpp
  6. 0
      src/app/syncbox16ch/sdk/syncbox16ch_sdk.hpp
  7. 28
      src/zqui/mainpage/mainwindow.cpp
  8. 2
      src/zqui/mainpage/mainwindow.h
  9. 92
      src/zqui/mainpage/mainwindow.ui
  10. 3
      src/zqui/version.h
  11. 1
      src/zqui/zqui.cpp
  12. 6
      src/zqui/zqui.hpp
  13. 1
      zfpga_basic_protocol

3
.gitmodules

@ -0,0 +1,3 @@
[submodule "zfpga_basic_protocol"]
path = zfpga_basic_protocol
url = zwsd@192.168.1.3:zfpga/zfpga_basic_protocol.git

4
src/app/main.cpp

@ -37,8 +37,10 @@ int main(int argc, char* argv[]) {
WSAStartup(MAKEWORD(2, 2), &wsaData);
QApplication a(argc, argv);
AppMgr::ins()->regAppBuilder([](QWidget* p) { return new SyncBox16CH(p); });
ZQUI::ins()->initialize();
DOINUI([]() { ZQUI::ins()->mainW()->setVersionInfo(1, "APP_VERSION", "1.0.0"); });
return a.exec();
}

733
src/app/syncbox16ch/sdk/clst_controler.cpp

@ -1,733 +0,0 @@
#include "clst_controler.hpp"
#include <stdlib.h>
#include <string.h>
#include "logger.hpp"
#include "reginfo.hpp"
using namespace iflytop;
using namespace clst;
#define TAG "CLSTControler"
#define PACKET_LEN(__packet) (sizeof(zaf_packet_header_t) + (__packet->ndata) * sizeof(uint32_t) + 1 /*checksum*/ + 2 /*tail*/)
#define DO_CMD(exptr) \
{ \
zaf_error_code_t ecode = exptr; \
if (ecode != kaf_ec_success) return ecode; \
}
CLSTControler *CLSTControler::ins() {
static CLSTControler *ins = nullptr;
if (ins == nullptr) {
ins = new CLSTControler();
}
return ins;
}
void CLSTControler::initialize(IDataChannel *channel) { //
m_channel = channel;
m_channel->regRxListener([this](uint8_t *data, size_t len) {
{
lock_guard<mutex> lock(lock_);
if (len + m_rxlen > sizeof(m_rxcache)) {
m_rxlen = 0;
}
memcpy(m_rxcache + m_rxlen, data, len);
m_rxlen += len;
}
});
m_thread.reset(new thread([this]() {
uint32_t last_rx_cnt = 0;
uint8_t rx_process_cache[1024];
uint32_t rx_process_cache_len;
while (true) {
this_thread::sleep_for(chrono::milliseconds(4));
{
lock_guard<mutex> lock(lock_);
if (last_rx_cnt == m_rxlen && m_rxlen != 0) {
memcpy(rx_process_cache, m_rxcache, m_rxlen);
rx_process_cache_len = m_rxlen;
m_rxlen = 0;
last_rx_cnt = 0;
}
}
if (rx_process_cache_len != 0) {
processRxData(rx_process_cache, rx_process_cache_len);
memset(rx_process_cache, 0, sizeof(rx_process_cache));
rx_process_cache_len = 0;
}
last_rx_cnt = m_rxlen;
}
}));
}
void CLSTControler::regRawDataListener(raw_data_cb_t cb) { m_raw_data_cb = cb; }
void CLSTControler::processRxData(uint8_t *rx, uint32_t rxlen) {
/**
* @brief
* 1. findHeader
* 2. processRx
*
* :
* 5A 5A 02 00 01 00 01 00 01 00 01 00 00 00 06 A5 A5
*
*/
// ZLOGI(TAG, "processRxData %d", rxlen);
for (uint32_t i = 0; i < rxlen; i++) {
zaf_packet_header_t *header = (zaf_packet_header_t *)(&rx[i]);
uint8_t *packetu8 = &rx[i];
if (header->packet_header == PACKET_HEADER) {
uint8_t check = packetu8[header->ndata * 4 + sizeof(zaf_packet_header_t) + 0];
uint8_t tail0 = packetu8[header->ndata * 4 + sizeof(zaf_packet_header_t) + 1];
uint8_t tail1 = packetu8[header->ndata * 4 + sizeof(zaf_packet_header_t) + 2];
uint16_t tail = (tail1 << 8) | tail0;
uint8_t expectcheck = 0;
for (uint32_t j = 2; j < header->ndata * 4 + sizeof(zaf_packet_header_t); j++) {
expectcheck += packetu8[j];
}
if (tail == PACKET_TAIL) {
if (expectcheck == check) {
processRxPacket(header);
} else {
ZLOGE(TAG, "Rx packet check error %d != %d", expectcheck, check);
}
}
}
}
}
void CLSTControler::processRxPacket(zaf_packet_header_t *packet) {
//
// ZLOGI(TAG, "RX packet");
// ZLOGI(TAG, " type :%d", packet->packet_type);
// ZLOGI(TAG, " index :%d", packet->index);
// ZLOGI(TAG, " cmd :%d", packet->cmd);
// ZLOGI(TAG, " ndata :%d", packet->ndata);
// for (uint32_t i = 0; i < packet->ndata; i++) {
// ZLOGI(TAG, " data[%d]:%d", i, packet->data[i]);
// }
// ZLOGI(TAG, "Rx.....");
uint32_t packetlen = sizeof(zaf_packet_header_t) + packet->ndata * 4 + 3;
if (m_raw_data_cb) {
m_raw_data_cb(kuart_raw_rx, (uint8_t *)packet, packetlen);
}
if (packet->packet_type == kzaf_packet_type_receipt) {
lock_guard<mutex> lock(m_rxReceiptContext_lock);
if (m_rxReceiptContext.waittingForReceipt) {
if (m_rxReceiptContext.waittingIndex == packet->index) {
m_rxReceiptContext.receiptIsReady = true;
m_rxReceiptContext.receiptLen = PACKET_LEN(packet);
memcpy(m_rxReceiptContext.receipt, packet, PACKET_LEN(packet));
}
m_rxReceiptContext.waittingForReceipt = false;
}
}
}
bool CLSTControler::ping() {}
zaf_error_code_t CLSTControler::sendPacket(zaf_packet_header_t *packet, uint32_t len, uint32_t overtime) {
zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
{
lock_guard<mutex> lock(m_rxReceiptContext_lock);
m_rxReceiptContext.waittingIndex = packet->index;
m_rxReceiptContext.waittingForReceipt = true;
m_rxReceiptContext.receiptIsReady = false;
m_rxReceiptContext.receiptLen = 0;
}
if (!m_channel) {
return kaf_ec_device_notopen;
}
if (m_channel->isOpen() == false) {
return kaf_ec_device_notopen;
}
if (m_raw_data_cb) {
m_raw_data_cb(kuart_raw_tx, (uint8_t *)packet, PACKET_LEN(packet));
}
// ZLOGI(TAG, "Tx.....");
m_channel->send((uint8_t *)packet, len);
for (size_t i = 0; i < overtime; i++) {
{
lock_guard<mutex> lock(m_rxReceiptContext_lock);
// ZLOGI(TAG, "wait for ready %d", m_rxReceiptContext.receiptIsReady);
if (m_rxReceiptContext.receiptIsReady) {
if (rxpacket->data[0] != 0) {
return (zaf_error_code_t)rxpacket->data[0];
} else {
return kaf_ec_success;
}
}
}
this_thread::sleep_for(chrono::milliseconds(1));
}
return kaf_ec_overtime;
}
zaf_error_code_t CLSTControler::reg_write(uint32_t regadd, uint32_t regvalue, uint32_t &regbackvalue, int32_t overtime_ms) {
Reginfo *reg = GetRegInfo(regadd);
if (reg == nullptr) {
return kaf_ec_param_error;
}
if (!(reg->flag & kreg_flag_force_write)) {
if (!reg->dirty && reg->regshadow == regvalue) {
return kaf_ec_success;
}
}
zaf_error_code_t ecode = _reg_write(regadd, regvalue, regbackvalue, overtime_ms);
if (ecode == kaf_ec_success) {
reg->dirty = false;
reg->regshadow = regvalue;
}
return ecode;
}
zaf_error_code_t CLSTControler::reg_read(uint32_t regadd, uint32_t &regvalue, int32_t overtime_ms) {
Reginfo *reg = GetRegInfo(regadd);
if (reg == nullptr) {
return kaf_ec_param_error;
}
if (!(reg->flag & kreg_flag_force_read)) {
if (!reg->dirty) {
regvalue = reg->regshadow;
return kaf_ec_success;
}
}
uint32_t regbackvalue = 0;
zaf_error_code_t ecode = _reg_read(regadd, regbackvalue, overtime_ms);
if (ecode == kaf_ec_success) {
reg->dirty = false;
reg->regshadow = regbackvalue;
regvalue = regbackvalue;
}
return ecode;
}
zaf_error_code_t CLSTControler::_reg_write(uint32_t regadd, uint32_t regvalue, uint32_t &regbackvalue, int32_t overtime_ms) { //
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
txpacket->packet_header = PACKET_HEADER;
txpacket->packet_type = kzaf_packet_type_cmd;
txpacket->index = ++txindex;
txpacket->cmd = kzaf_cmd_reg_write;
txpacket->ndata = 2;
txpacket->data[0] = regadd;
txpacket->data[1] = regvalue;
uint32_t txpacklen = PACKET_LEN(txpacket);
uint8_t checksum = 0;
for (int i = 2; i < txpacklen - 3; i++) {
checksum += txdata[i];
}
txdata[txpacklen - 3] = checksum;
txdata[txpacklen - 2] = PACKET_TAIL & 0xFF;
txdata[txpacklen - 1] = (PACKET_TAIL >> 8) & 0xFF;
zaf_error_code_t ecode = sendPacket(txpacket, txpacklen, overtime_ms);
if (ecode != kaf_ec_success) {
return ecode;
}
regbackvalue = rxpacket->data[1];
return kaf_ec_success;
}
uint32_t CLSTControler::reg_read_v2(uint32_t regadd) {
uint32_t regvalue = 0;
reg_read(regadd, regvalue, 30);
return regvalue;
}
void CLSTControler::setAllShawdowRegDirty() { RegInfo_Reset(); }
zaf_error_code_t CLSTControler::_reg_read(uint32_t regadd, uint32_t &regvalue, int32_t overtime_ms) {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
txpacket->packet_header = PACKET_HEADER;
txpacket->packet_type = kzaf_packet_type_cmd;
txpacket->index = ++txindex;
txpacket->cmd = kzaf_cmd_reg_read;
txpacket->ndata = 1;
txpacket->data[0] = regadd;
uint32_t txpacklen = PACKET_LEN(txpacket);
uint8_t checksum = 0;
for (int i = 2; i < txpacklen - 3; i++) {
checksum += txdata[i];
}
txdata[txpacklen - 3] = checksum;
txdata[txpacklen - 2] = PACKET_TAIL & 0xFF;
txdata[txpacklen - 1] = (PACKET_TAIL >> 8) & 0xFF;
zaf_error_code_t ecode = sendPacket(txpacket, txpacklen, overtime_ms);
if (ecode != kaf_ec_success) {
return ecode;
}
regvalue = rxpacket->data[1];
// ZLOGI(TAG, "RX packet");
// ZLOGI(TAG, " type :%d", rxpacket->packet_type);
// ZLOGI(TAG, " index :%d", rxpacket->index);
// ZLOGI(TAG, " cmd :%d", rxpacket->cmd);
// ZLOGI(TAG, " ndata :%d", rxpacket->ndata);
// for (uint32_t i = 0; i < rxpacket->ndata; i++) {
// ZLOGI(TAG, " data[%d]:%d", i, rxpacket->data[i]);
// }
// ZLOGI(TAG, "RX:%d", regvalue);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::factoryReset() {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
txpacket->packet_header = PACKET_HEADER;
txpacket->packet_type = kzaf_packet_type_cmd;
txpacket->index = ++txindex;
txpacket->cmd = kzaf_cmd_factory_reset;
txpacket->ndata = 0;
uint32_t txpacklen = PACKET_LEN(txpacket);
uint8_t checksum = 0;
for (int i = 2; i < txpacklen - 3; i++) {
checksum += txdata[i];
}
txdata[txpacklen - 3] = checksum;
txdata[txpacklen - 2] = PACKET_TAIL & 0xFF;
txdata[txpacklen - 1] = (PACKET_TAIL >> 8) & 0xFF;
zaf_error_code_t ecode = sendPacket(txpacket, txpacklen, 1500);
if (ecode != kaf_ec_success) return ecode;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::reboot() {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
txpacket->packet_header = PACKET_HEADER;
txpacket->packet_type = kzaf_packet_type_cmd;
txpacket->index = ++txindex;
txpacket->cmd = kzaf_cmd_reboot;
txpacket->ndata = 0;
uint32_t txpacklen = PACKET_LEN(txpacket);
uint8_t checksum = 0;
for (int i = 2; i < txpacklen - 3; i++) {
checksum += txdata[i];
}
txdata[txpacklen - 3] = checksum;
txdata[txpacklen - 2] = PACKET_TAIL & 0xFF;
txdata[txpacklen - 1] = (PACKET_TAIL >> 8) & 0xFF;
zaf_error_code_t ecode = sendPacket(txpacket, txpacklen, 100);
if (ecode != kaf_ec_success) return ecode;
return kaf_ec_success;
}
void CLSTControler::initDevice() {
/**
* @brief
*/
reg_write(kreg_internal_clk_tri_fileter_coefficient, 0);
}
zaf_error_code_t CLSTControler::storageConfigs() {
lock_guard<mutex> lock(m_tx_lock);
uint8_t txdata[128] = {0};
zaf_packet_header_t *txpacket = (zaf_packet_header_t *)txdata;
zaf_packet_header_t *rxpacket = (zaf_packet_header_t *)&m_rxReceiptContext.receipt[0];
txpacket->packet_header = PACKET_HEADER;
txpacket->packet_type = kzaf_packet_type_cmd;
txpacket->index = ++txindex;
txpacket->cmd = kzaf_cmd_storage_cfg;
txpacket->ndata = 0;
uint32_t txpacklen = PACKET_LEN(txpacket);
uint8_t checksum = 0;
for (int i = 2; i < txpacklen - 3; i++) {
checksum += txdata[i];
}
txdata[txpacklen - 3] = checksum;
txdata[txpacklen - 2] = PACKET_TAIL & 0xFF;
txdata[txpacklen - 1] = (PACKET_TAIL >> 8) & 0xFF;
zaf_error_code_t ecode = sendPacket(txpacket, txpacklen, 1500);
if (ecode != kaf_ec_success) return ecode;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::readFreq(uint32_t reg, float &freqfloat) {
uint32_t freq_cnt = 0;
DO_CMD(reg_read(reg, freq_cnt, 30));
if (freq_cnt == 0) {
freqfloat = 0;
}
if (freq_cnt != 0) {
uint32_t freq_1000x = ((1.0 / (freq_cnt * 1.0 / (100 * 1000 * 1000))) * 1000 + 0.5); //
// ZLOGI(TAG, "freq_10x %f", freq_10x);
freqfloat = freq_1000x / 1000.0;
} else {
freqfloat = 0;
}
if (freqfloat < 0.05) {
freqfloat = 0;
}
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::readSigPeriodUs(uint32_t reg, float &us) {
uint32_t freq_cnt = 0;
DO_CMD(reg_read(reg, freq_cnt, 30));
us = freq_cnt * 10 / 1000.0;
if (us > 1100000) {
us = 0;
}
return kaf_ec_success;
}
/*******************************************************************************
* ???? *
*******************************************************************************/
zaf_error_code_t CLSTControler::readFPGAVersion(uint32_t &freq) { return reg_read(kreg_fpga_version, freq); }
zaf_error_code_t CLSTControler::readStm32Version(uint32_t &freq) { return reg_read(kreg_software_version, freq); }
zaf_error_code_t CLSTControler::InterClk_setFreq(float freq) { //
DO_CMD(InterClk_stop());
ZLOGI(TAG, "InterClk_setFreq %f", freq);
double T = 1.0 / freq;
double T_ns = T * 1000 * 1000 * 1000;
double cnt = T_ns / 10 + 0.5; // 100MHZ <=> 10ns
uint32_t cnt_u32 = uint32_t(cnt);
ZLOGI(TAG, "InterClk_setFreq %f %d", freq, cnt_u32);
return reg_write(kreg_internal_clk_freq_cnt, cnt_u32);
}
zaf_error_code_t CLSTControler::InterClk_setPluseCnt(uint32_t cnt) { //
return reg_write(kreg_internal_clk_pluse_cnt, cnt);
}
zaf_error_code_t CLSTControler::InterClk_setSeqCtrlPluseCntMax(uint32_t cnt) { //
if (cnt == 0) return kaf_ec_param_error;
return reg_write(kreg_internal_clk_tri_sequential_control_pluse_cnt_max, cnt - 1);
}
zaf_error_code_t CLSTControler::InterClk_getFreq(float &freq) { //
return readFreq(kreg_internal_clk_freq_cnt, freq);
}
zaf_error_code_t CLSTControler::InterClk_getPluseCnt(uint32_t &cnt) { //
return reg_read(kreg_internal_clk_pluse_cnt, cnt);
}
zaf_error_code_t CLSTControler::InterClk_getSeqCtrlPluseCntMax(uint32_t &cnt) { //
DO_CMD(reg_read(kreg_internal_clk_tri_sequential_control_pluse_cnt_max, cnt));
cnt++;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::InterClk_readTriOutSignalFreq(float &freq) { //
return readFreq(kreg_internal_clk_tri_out_signal_freq, freq);
}
zaf_error_code_t CLSTControler::InterClk_trigger() { //
return reg_write(kreg_internal_clk_ctrl, 1);
}
zaf_error_code_t CLSTControler::InterClk_stop() { //
return reg_write(kreg_internal_clk_ctrl, 0);
}
/*******************************************************************************
* TTL????? *
*******************************************************************************/
// kreg_trigger_in1_module
// kreg_trigger_in1_src_slect
// kreg_trigger_in1_fileter_coefficient
// kreg_trigger_in1_freq_detect_bias
// kreg_trigger_in1_mode
// kreg_trigger_in1_trigger_mode_trigger_edge
// kreg_trigger_in1_trigger_mode_freq_division
// kreg_trigger_in1_trigger_mode_freq_multiplication
// kreg_trigger_in1_sequential_control_pluse_cnt_max
// kreg_trigger_in1_in_signal_freq
// kreg_trigger_in1_out_signal_freq
zaf_error_code_t CLSTControler::TriInX_setSrcSelect(int32_t index, ExtTriggerSrcType src) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_src_slect + (index - 1) * 32, src.getVal());
}
zaf_error_code_t CLSTControler::TriInX_setFileterCoefficient(int32_t index, uint32_t coefficient) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_fileter_coefficient + (index - 1) * 32, coefficient);
}
zaf_error_code_t CLSTControler::TriInX_setFreqDetectBias(int32_t index, uint32_t bias) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_freq_detect_bias + (index - 1) * 32, bias);
}
zaf_error_code_t CLSTControler::TriInX_setMode(int32_t index, SigProcessMode mode) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_mode + (index - 1) * 32, mode.getVal());
}
zaf_error_code_t CLSTControler::TriInX_setTriggerModeTriggerEdge(int32_t index, TriggerEdge edge) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_trigger_mode_trigger_edge + (index - 1) * 32, edge);
}
zaf_error_code_t CLSTControler::TriInX_setTriggerModeFreqDivision(int32_t index, uint32_t division) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_trigger_mode_freq_division + (index - 1) * 32, division);
}
zaf_error_code_t CLSTControler::TriInX_setTriggerModeFreqMultiplication(int32_t index, uint32_t multiplication) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_trigger_mode_freq_multiplication + (index - 1) * 32, multiplication);
}
zaf_error_code_t CLSTControler::TriInX_setSequentialControlPluseCntMax(int32_t index, uint32_t cnt) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_trigger_in1_sequential_control_pluse_cnt_max + (index - 1) * 32, cnt - 1);
}
zaf_error_code_t CLSTControler::TriInX_getSrcSelect(int32_t index, ExtTriggerSrcType &src) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t val;
DO_CMD(reg_read(kreg_trigger_in1_src_slect + (index - 1) * 32, val));
src = ExtTriggerSrcType(val);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::TriInX_getFileterCoefficient(int32_t index, uint32_t &coefficient) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_read(kreg_trigger_in1_fileter_coefficient + (index - 1) * 32, coefficient);
}
zaf_error_code_t CLSTControler::TriInX_getFreqDetectBias(int32_t index, uint32_t &bias) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_read(kreg_trigger_in1_freq_detect_bias + (index - 1) * 32, bias);
}
zaf_error_code_t CLSTControler::TriInX_getMode(int32_t index, SigProcessMode &mode) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t reakbak = 0;
DO_CMD(reg_read(kreg_trigger_in1_mode + (index - 1) * 32, reakbak));
mode = SigProcessMode(reakbak);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::TriInX_getTriggerModeTriggerEdge(int32_t index, TriggerEdge &edge) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t val;
DO_CMD(reg_read(kreg_trigger_in1_trigger_mode_trigger_edge + (index - 1) * 32, val));
edge = TriggerEdge(val);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::TriInX_getTriggerModeFreqDivision(int32_t index, uint32_t &division) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_read(kreg_trigger_in1_trigger_mode_freq_division + (index - 1) * 32, division);
}
zaf_error_code_t CLSTControler::TriInX_getTriggerModeFreqMultiplication(int32_t index, uint32_t &multiplication) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_read(kreg_trigger_in1_trigger_mode_freq_multiplication + (index - 1) * 32, multiplication);
}
zaf_error_code_t CLSTControler::TriInX_readInSignalPeriodUs(int32_t index, float &us) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return readSigPeriodUs(kreg_trigger_in1_in_signal_freq + (index - 1) * 32, us);
}
zaf_error_code_t CLSTControler::TriInX_readOutSignalPeriodUs(int32_t index, float &us) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return readSigPeriodUs(kreg_trigger_in1_out_signal_freq + (index - 1) * 32, us);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::TriInX_getSequentialControlPluseCntMax(int32_t index, uint32_t &cnt) {
if (index < 1 || index > 4) return kaf_ec_param_error;
DO_CMD(reg_read(kreg_trigger_in1_sequential_control_pluse_cnt_max + (index - 1) * 32, cnt));
cnt++;
return kaf_ec_success;
}
/*******************************************************************************
* ???? *
*******************************************************************************/
zaf_error_code_t CLSTControler::LightSrcX_setTriSrc(int32_t index, InternalSig src) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_light_ctrol_module1_source_select + (index - 1) * 32, src);
}
zaf_error_code_t CLSTControler::LightSrcX_setTriggerModePluseWidth(int32_t index, uint32_t width) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_light_ctrol_module1_trigger_mode_pluse_width + (index - 1) * 32, width * 10); // 0.1us
}
zaf_error_code_t CLSTControler::LightSrcX_setTriggerModeFirstPluseOffset(int32_t index, uint32_t offset) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_write(kreg_light_ctrol_module1_trigger_mode_first_pluse_offset + (index - 1) * 32, offset * 10); // 0.1us
}
zaf_error_code_t CLSTControler::LightSrcX_setLightIntensityDuty(int32_t index, float duty) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
duty=duty*0.4;
uint32_t freqcnt = 0;
DO_CMD(reg_read(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freqcnt));
if (duty >= 99) {
duty = 99;
}
uint32_t cnt = freqcnt * (duty / 100.0) + 0.5;
if (duty < 1) {
cnt = 1;
}
if (cnt >= freqcnt) {
cnt = freqcnt - 1;
}
// float bakduty = (cnt * 100.0 / freqcnt);
return reg_write(kreg_light_ctrol_module1_light_intensity_cnt + (index - 1) * 32, cnt);
}
zaf_error_code_t CLSTControler::LightSrcX_setLightDriverFreq(int32_t index, float freq) { //
double T = 1.0 / freq;
double T_ns = T * 1000 * 1000 * 1000;
double cnt = T_ns / 10 + 0.5; // 100MHZ <=> 10ns
uint32_t cnt_u32 = uint32_t(cnt);
return reg_write(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, cnt_u32);
}
zaf_error_code_t CLSTControler::LightSrcX_getTriSrc(int32_t index, InternalSig &src) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t val;
DO_CMD(reg_read(kreg_light_ctrol_module1_source_select + (index - 1) * 32, val));
src = InternalSig(val);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::LightSrcX_getTriggerModePluseWidth(int32_t index, uint32_t &width) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t val;
DO_CMD(reg_read(kreg_light_ctrol_module1_trigger_mode_pluse_width + (index - 1) * 32, val));
width = val / 10;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::LightSrcX_getTriggerModeFirstPluseOffset(int32_t index, uint32_t &offset) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t val;
DO_CMD(reg_read(kreg_light_ctrol_module1_trigger_mode_first_pluse_offset + (index - 1) * 32, val));
offset = val / 10;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::LightSrcX_getLightIntensityDuty(int32_t index, float &duty) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
uint32_t freqcnt = 0;
DO_CMD(reg_read(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freqcnt));
uint32_t cnt = 0;
DO_CMD(reg_read(kreg_light_ctrol_module1_light_intensity_cnt + (index - 1) * 32, cnt));
duty = (cnt * 100.0 / freqcnt);
duty=duty/0.4;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::LightSrcX_getLightDriverFreq(int32_t index, float &freq) { //
return readFreq(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freq);
}
zaf_error_code_t CLSTControler::LightSrcX_readLightSrcErrorState(int32_t index, uint32_t &state) { //
if (index < 1 || index > 4) return kaf_ec_param_error;
return reg_read(kreg_light_ctrol_module1_light_src_error_state + (index - 1) * 32, state);
}
zaf_error_code_t CLSTControler::LightSrcX_readInSigPeriodUsDetect(int32_t index, float &us) { //
return readSigPeriodUs(kreg_light_ctrol_module1_in_sig_freq_detect + (index - 1) * 32, us);
}
zaf_error_code_t CLSTControler::LightSrcX_readOutSigPeriodUsDetect(int32_t index, float &us) { //
return readSigPeriodUs(kreg_light_ctrol_module1_out_sig_freq_detect + (index - 1) * 32, us);
}
/*******************************************************************************
* *
*******************************************************************************/
zaf_error_code_t CLSTControler::ShutterX_setOutputCtrlMode(int32_t index, SigProcessMode mode) { //
return reg_write(kreg_ttl_output_module1_output_ctrl_mode + (index - 1) * 32, mode);
}
zaf_error_code_t CLSTControler::ShutterX_setLtEnBind(int32_t index, uint32_t lt_en_sig_index, uint32_t state) { //
uint32_t readbak_state = 0;
DO_CMD(reg_read(kreg_ttl_output_module1_lt_en_bind + (index - 1) * 32, readbak_state));
if (state == 1) {
readbak_state |= (1 << (lt_en_sig_index - 1));
} else {
readbak_state &= ~(1 << (lt_en_sig_index - 1));
}
DO_CMD(reg_write(kreg_ttl_output_module1_lt_en_bind + (index - 1) * 32, readbak_state));
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::ShutterX_setLtEnOffset(int32_t index, uint32_t offset) { //
return reg_write(kreg_ttl_output_module1_lt_en_offset + (index - 1) * 32, offset * 10); // 0.1us
}
zaf_error_code_t CLSTControler::ShutterX_setInSigSelect(int32_t index, InternalSig sig) { //
return reg_write(kreg_ttl_output_module1_in_sig_select + (index - 1) * 32, sig);
}
zaf_error_code_t CLSTControler::ShutterX_setOutPolarityReversal(int32_t index, uint32_t reversal) { return reg_write(kreg_ttl_output_module1_out_polarity_reversal + (index - 1) * 32, reversal); }
zaf_error_code_t CLSTControler::ShutterX_getOutputCtrlMode(int32_t index, SigProcessMode &mode) { //
uint32_t val;
DO_CMD(reg_read(kreg_ttl_output_module1_output_ctrl_mode + (index - 1) * 32, val));
mode = SigProcessMode(val);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::ShutterX_getLtEnBind(int32_t index, uint32_t lt_en_sig_index, uint32_t &state) { //
uint32_t readbak_state = 0;
DO_CMD(reg_read(kreg_ttl_output_module1_lt_en_bind + (index - 1) * 32, readbak_state));
state = (readbak_state >> (lt_en_sig_index - 1)) & 0x01;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::ShutterX_getLtEnOffset(int32_t index, uint32_t &offset) { //
uint32_t val;
DO_CMD(reg_read(kreg_ttl_output_module1_lt_en_offset + (index - 1) * 32, val));
offset = val / 10;
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::ShutterX_getInSigSelect(int32_t index, InternalSig &sig) { //
uint32_t val;
DO_CMD(reg_read(kreg_ttl_output_module1_in_sig_select + (index - 1) * 32, val));
sig = InternalSig(val);
return kaf_ec_success;
}
zaf_error_code_t CLSTControler::ShutterX_getOutPolarityReversal(int32_t index, uint32_t &reversal) {
DO_CMD(reg_read(kreg_ttl_output_module1_out_polarity_reversal + (index - 1) * 32, reversal));
return kaf_ec_success;
}

0
src/app/syncbox16ch/sdk/reg.hpp → src/app/syncbox16ch/sdk/syncbox16ch_reg.hpp

0
src/app/syncbox16ch/sdk/clst_controler.hpp → src/app/syncbox16ch/sdk/syncbox16ch_sdk.cpp

0
src/app/syncbox16ch/sdk/syncbox16ch_sdk.hpp

28
src/zqui/mainpage/mainwindow.cpp

@ -13,7 +13,6 @@
#include "zqui/appmgr/appmgr.hpp"
#include "zqui/zqui.hpp"
// #include "app/syncbox16ch.h"
// #include "version.h"
using namespace iflytop;
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
@ -23,6 +22,13 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->serialPortCB->installEventFilter(this);
startTimer(1000);
ui->version_label_po1->hide();
ui->version_pos1->hide();
ui->version_label_po2->hide();
ui->version_pos2->hide();
ui->version_label_po3->hide();
ui->version_pos3->hide();
QWidget *app = AppMgr::ins()->buildApp(ui->app_content);
if (app) app->show();
}
@ -73,6 +79,26 @@ void MainWindow::buildUI() {
void MainWindow::on_serialPortCB_customContextMenuRequested(const QPoint &pos) {}
void MainWindow::setVersionInfo(int pos, QString versionName, QString version) {
if (pos == 1) {
ui->version_label_po1->setText(versionName);
ui->version_pos1->setText(version);
ui->version_label_po1->show();
ui->version_pos1->show();
} else if (pos == 2) {
ui->version_label_po2->setText(versionName);
ui->version_pos2->setText(version);
ui->version_label_po2->show();
ui->version_pos2->show();
} else if (pos == 3) {
ui->version_label_po3->setText(versionName);
ui->version_pos3->setText(version);
ui->version_label_po3->show();
ui->version_pos3->show();
}
}
void MainWindow::fillinSerialPort() {
// int curIndex = ui->serialPortCB->currentIndex();
ui->serialPortCB->clear();

2
src/zqui/mainpage/mainwindow.h

@ -56,6 +56,8 @@ class MainWindow : public QMainWindow {
void binaryClear();
void setConnectedStatus(bool connect);
void setVersionInfo(int pos,QString versionName, QString version);
private slots:
void on_serialPortCB_customContextMenuRequested(const QPoint &pos);
bool eventFilter(QObject *watched, QEvent *event);

92
src/zqui/mainpage/mainwindow.ui

@ -788,11 +788,99 @@ QGroupBox:title {
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="VersionInfo">
<property name="title">
<string>软件信息</string>
</property>
<layout class="QGridLayout" name="gridLayout_3"/>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QLineEdit" name="version_pos1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="version_label_po3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="version_pos3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="version_label_po1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="version_pos2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="version_label_po2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>

3
src/zqui/version.h

@ -1,4 +1 @@
#pragma once
#define VERSION 17
#define MAUFACTURER "iflytop"

1
src/zqui/zqui.cpp

@ -8,7 +8,6 @@ using namespace std;
/***********************************************************************************************************************
* PreviewShow *
***********************************************************************************************************************/
MainWindow *pmainW;
ZQUI *ZQUI::ins() {
static ZQUI instance;

6
src/zqui/zqui.hpp

@ -35,13 +35,15 @@
#include <vector>
#include "base/QFunction.hpp"
#include "mainpage/mainwindow.h"
class ZQUI : public QObject {
Q_OBJECT
public:
typedef std::function<void(QString)> display_fn_t;
typedef std::function<void()> display_clear_fn_t;
MainWindow *pmainW = nullptr;
;
public:
static ZQUI *ins();
@ -62,6 +64,8 @@ class ZQUI : public QObject {
void setDeviceConnectedStatus(bool connect);
MainWindow *mainW() { return pmainW; }
private slots:
void doinui_slot(QFunction);

1
zfpga_basic_protocol

@ -0,0 +1 @@
Subproject commit 3c83221293a425eb1b5e8fee3c1f108156465cc3
Loading…
Cancel
Save