75 lines
2.2 KiB
C++
75 lines
2.2 KiB
C++
#ifndef _DRV_UART_H__
|
|
#define _DRV_UART_H__
|
|
|
|
#include <QMainWindow>
|
|
#include "CH347DLL.H"
|
|
|
|
#define DbgPrint(format, ...) qDebug().nospace() << QString::asprintf(format, ##__VA_ARGS__)
|
|
|
|
// 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_UART_INFO
|
|
{
|
|
CHAR bDeviceName[2][256]; //设备名称
|
|
mDeviceInforS UartDevInfor[16]; //spiI2c设备信息
|
|
ULONG ulDevCnt; //设备数量
|
|
BOOL devIsOpened; //设备开启标志位
|
|
ULONG opendDevIndex; //当前设备索引号
|
|
}mDRV_Uart_Infors;
|
|
|
|
class DRV_Uart : public QObject
|
|
{
|
|
Q_OBJECT // 如果需要使用QT的信号槽机制
|
|
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param parent 父对象指针
|
|
*/
|
|
explicit DRV_Uart(QObject *parent = nullptr);
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
virtual ~DRV_Uart();
|
|
|
|
/*************函数定义*************/
|
|
ULONG Uart_enumDevice(); // 枚举UART设备
|
|
BOOL Uart_openDevice(ULONG UartIndex); // 打开设备
|
|
BOOL Uart_closeDevice(); // 关闭设备
|
|
BOOL Uart_setPara(ULONG Baudrate, UCHAR StopBits, UCHAR Parity, UCHAR DataSize, UCHAR Timeout);// 设置参数
|
|
BOOL Uart_Write(QByteArray &sendData);
|
|
LONGLONG Uart_readRxBufcnt(void);
|
|
BOOL Uart_Read(QByteArray &revData);
|
|
/*************变量定义*************/
|
|
mDRV_Uart_Infors m_DRV_Uart_Infors; //Spi驱动相关信息
|
|
|
|
signals:
|
|
// 可以添加DAC特定的信号
|
|
// void outputChanged(int channel, double value);
|
|
|
|
private:
|
|
// 私有成员变量
|
|
// double m_currentValues[]; // 当前各通道输出值(假设有多个通道)
|
|
|
|
// 私有方法
|
|
|
|
};
|
|
|
|
#endif
|