Files
TS660_DLL/TS660API.h
T

84 lines
3.1 KiB
C

// TS660API.h: 数字延迟发生器 TS660 的 C 接口(extern "C")
// 通过 void* 不透明句柄使用,适合跨语言调用
// 用户只需本头文件 + TS660_DLL.lib,无需 TS660DDG.h/SerialPort.h
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _WIN32
#ifdef TS660_DLL_EXPORTS
#define TS660_DLL_API __declspec(dllexport)
#else
#define TS660_DLL_API __declspec(dllimport)
#endif
#else
#define TS660_DLL_API
#endif
// === 初始化 ===
// com_port: ASCII 串口名,如 "COM3" 或 "COM10"(COM10+ 会自动加 \\.\ 前缀)
// baud_rate: 波特率,0 或负数使用默认值 115200
// 返回: 不透明句柄; 失败返回 NULL
TS660_DLL_API void* ts660_init(const char* com_port, int baud_rate);
// 关闭并释放资源
TS660_DLL_API void ts660_close(void* handle);
// === 读取时序配置参数 ===
// channel: 通道号 1~8(四通道卡仅 1~4 有效)
// out_delay_ns, out_width_ns: 输出延时/脉宽(ns)
// out_trigger_mode: 输出触发模式(1=内触发计数器, 2=外触发, 3=软件触发, 4=内触发DDS)
// out_trig_freq_hz: 输出内触发频率(Hz)
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_read_timing_config(void* handle, int channel,
long long* out_delay_ns,
long long* out_width_ns,
int* out_trigger_mode,
double* out_trig_freq_hz);
// === 读取温度 ===
// out_temp: 输出温度(摄氏度)
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_read_temperature(void* handle, float* out_temp);
// === 触发设置 ===
// mode: 0=内部触发, 1=外部触发, 2=软件触发(API值,内部映射为协议值1/2/3)
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_set_trigger(void* handle, int mode);
// === 内触发频率设置 ===
// freq_hz: 频率(Hz),内部按 周期/4ns 换算为控制字
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_set_trigger_freq(void* handle, double freq_hz);
// === 输出通道设置 ===
// channel: 通道号 1~8, enable: 1=启用, 0=关闭
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_set_output_channel(void* handle, int channel, int enable);
// === 延时调节 ===
// channel: 通道号 1~8, delay_ns: 延时(ns,内部按 ns*100 换算为 10ps 控制字)
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_set_delay(void* handle, int channel, long long delay_ns);
// === 脉宽调节 ===
// channel: 通道号 1~8, width_ns: 脉宽(ns,内部按 ns*100 换算为 10ps 控制字)
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_set_pulse_width(void* handle, int channel, long long width_ns);
// === 全局输出设置 ===
// enable: 1=启用所有通道输出, 0=关闭
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_set_global_output(void* handle, int enable);
// === 软件触发发射 ===
// 注意: 需先调用 ts660_set_trigger(mode=2) 切换到软件触发模式
// 返回: 0 成功, 非0 失败
TS660_DLL_API int ts660_software_trigger(void* handle);
#ifdef __cplusplus
} // extern "C"
#endif