#pragma once #include #include #include #include "Common.h" #ifdef SPI_API_LIB #define SPI_API __declspec(dllexport) #else #define SPI_API __declspec(dllimport) #endif class SpiHandler; class SPI_API SpiApi { public: SpiApi(); ~SpiApi(); /** * @breaf 初始化所有CH347并返回列表 * * @return 已知的CH347设备列表 */ std::vector initUsbDevice(); /** * @breaf 向设备下发参数 * * @param devs 指定接收参数的设备 * @param cmdarg 控制字参数,具体定义见Common.h * @param varg 电压参数,具体定义见Common.h * * @return 成功返回true */ bool applyArg(DevSimple devs, SetCommandArg cmdarg, SetVotegeArg varg); /** * @breaf 设为true可以在exe的工作目录的debug.log中输出打包后要下发的十六进制参数 */ void debug(bool on = true); private: std::shared_ptr sh_; std::string lastError_; };