初始化版本控制:TS660 DLL 源码、构建脚本与 SDK(Release) 产物

This commit is contained in:
roxin
2026-11-21 12:00:13 +08:00
commit e832938129
42 changed files with 4201 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
/* example.c: TS660_DLL 调用示例
*
* 编译: cl /I. example.c /link TS660_DLL.lib /OUT:example.exe
* 运行: example.exe COM10
*/
#include "TS660API.h"
#include <stdio.h>
int main(int argc, char** argv) {
const char* port = (argc >= 2) ? argv[1] : "COM3";
printf("=== TS660 Example ===\nPort: %s\n\n", port);
/* 1. 打开设备 */
void* h = ts660_init(port, 0); /* 0 = 默认波特率 115200 */
if (!h) { printf("[FAIL] 打开失败\n"); return -1; }
printf("[OK] 设备已打开\n");
/* 2. 读取温度 */
float temp = 0;
if (ts660_read_temperature(h, &temp) == 0)
printf("温度: %.2f C\n", temp);
else
printf("[FAIL] 读取温度失败\n");
/* 3. 读取时序配置(通道1) */
long long delay_ns = 0, width_ns = 0;
int trig_mode = 0;
double trig_freq = 0;
if (ts660_read_timing_config(h, 1, &delay_ns, &width_ns, &trig_mode, &trig_freq) == 0) {
printf("通道1: 延时=%lldns, 脉宽=%lldns\n", delay_ns, width_ns);
printf("触发模式=%d, 频率=%.1fHz\n", trig_mode, trig_freq);
}
/* 4. 配置: 内触发 1kHz, 通道1延时10ns/脉宽100ns */
ts660_set_trigger(h, 0); /* 内部触发 */
ts660_set_trigger_freq(h, 1000.0); /* 1kHz */
ts660_set_delay(h, 1, 10); /* 通道1延时10ns */
ts660_set_pulse_width(h, 1, 100); /* 通道1脉宽100ns */
ts660_set_output_channel(h, 1, 1); /* 使能通道1 */
ts660_set_global_output(h, 1); /* 开启全局输出 */
printf("[OK] 配置完成\n");
/* 5. (可选) 软件触发 */
/* ts660_set_trigger(h, 2); */ /* 先切到软件触发模式 */
/* ts660_software_trigger(h); */
/* 6. 关闭 */
ts660_close(h);
printf("[OK] 设备已关闭\n");
return 0;
}