#ifndef _APP_ICD_H__ #define _APP_ICD_H__ #include #include #include #include #include "drivers/spi/drv_spi.h" #include "drivers/uart/drv_uart.h" // typedef struct _USB_DEVICE_DESCRIPTOR { // UCHAR bLength; // UCHAR bDescriptorType; // USHORT bcdUSB; // UCHAR bDeviceClass; // UCHAR bDeviceSubClass; // UCHAR bDeviceProtocol; // UCHAR bMaxPacketSize0; // USHORT idVendor; // USHORT idProduct; // USHORT bcdDevice; // UCHAR iManufacturer; // UCHAR iProduct; // UCHAR iSerialNumber; // UCHAR bNumConfigurations; // } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR; // typedef struct _DRV_SPI_INFO // { // CHAR bDeviceName[256]; //设备名称 // mDeviceInforS SpiI2cDevInfor[16]; //spiI2c设备信息 // ULONG ulDevCnt; //设备数量 // BOOL devIsOpened; //设备开启标志位 // ULONG opendDevIndex; //当前设备索引号 // }mDRV_Spi_Infors; // 使用结构体存储更复杂的数据 // struct ComboBoxSubGroupItem { // QString displayText; // int value; // }; // 解析结果结构体 struct ParsedData { quint8 EN_TADC; quint8 N_CLKDIV18; // 2位组合值 quint8 VCON; // 2位组合值 quint16 CH_TEST; // 9位组合值 (CH_TEST[8:0]) quint8 FBK_EN; quint8 TEMPTEST_EN; quint8 TRIG_TADC; quint8 TEST_TADC; quint8 ICON18; // 4位组合值 quint16 ADC_OUT; // 10位组合值 (ADC_OUT[9:0]) quint8 EOC; quint16 D_FB; // 10位组合值 (D_FB[9:0]) }; // 命令枚举值 enum { SP_CMD_NA = 0x00, // 无效命令 SP_CMD_ZERO = 0x01, // 参数归零命令 SP_CMD_SAME_VALUE = 0x02, // 同值配置命令 SP_CMD_DIF_VALUE = 0x03, // 异值配置命令 SP_CMD_REG_WR = 0x04, // 寄存器配置命令 SP_CMD_REG_RD = 0x05, // 寄存器读取命令 }; class APP_Icd : public QObject { Q_OBJECT // 如果需要使用QT的信号槽机制 public: /** * @brief 构造函数 * @param parent 父对象指针 */ explicit APP_Icd(QObject *parent = nullptr); /** * @brief 析构函数 */ virtual ~APP_Icd(); /*************函数定义*************/ bool ICD_init(); // ICD初始化 bool ICD_setDAC256Data10bit(int row, int col, int value); // 设置DAC256 10bit数组的值大小 bool ICD_volCMDProtoEncode(uint8_t CMD, uint8_t group, uint8_t subGroup); quint8 ICD_calcChecksum(const QByteArray &data, int endPos); bool ICD_sumProtoEncode(uint8_t CMD, const QByteArray &ctrl_data); QByteArray ICD_pack10BitData(int data[16][16]); bool ICD_regWCMDProtoEncode(uint8_t dacID, uint8_t dacCH, uint8_t funcEN, uint8_t adcCurrConfig); bool ICD_regRCMDProtoEncode(uint8_t dacID); bool ICD_newDataRecordingFile(void); bool ICD_addContextToDataRecordingFile(bool isWrite, QByteArray &Data); ParsedData ICD_parseRegisterData(const QByteArray &revData); /*************变量定义*************/ // mDRV_Spi_Infors m_DRV_Spi_Infors; //Spi驱动相关信息 DRV_Spi *m_spiDriver; // SPI驱动实例 DRV_Uart *m_uartDriver; // UART驱动实例 // 定义子分组的所有名称数据集 QMap comboBox_subGroupInfo = { {0, {"所有DAC"}}, // 对应选项1 {1, {"A分组所有DAC", "B分组所有DAC"}}, // 对应选项2 {2, {"OPA分组0", "OPA分组1", "OPA分组2", "OPA分组3", "OPA分组4"}}, // 对应选项3 {3, {"编号1", "编号2", "编号3", "编号4", "编号5", // 对应选项3 "编号6", "编号7", "编号8", "编号9", "编号10", "编号11", "编号12", "编号13", "编号14", "编号15", "编号16", "编号17", "编号18", "编号19", "编号20" } } }; // 256个10bit数据 int DAC256_10bit_data[16][16] = {{0}}; // 控制字参数 QByteArray ICD_ctrlPara; // 电压值参数 QByteArray ICD_volValuePara; // 整体帧 QByteArray ICD_allData; QString dataRecordingFile; signals: // 可以添加DAC特定的信号 // void outputChanged(int channel, double value); private: // 私有成员变量 // double m_currentValues[]; // 当前各通道输出值(假设有多个通道) // 私有方法 bool ICD_initSpi(); bool ICD_initUart(); // 私有方法 }; #endif