基本的 trait 实现

DebugProbe trait 是最基本的操作对象,其中需要实现 ProbeFactory trait

你可以 impl DebugProbe for FooDebugProbe 实现 probe

impl ProbeFactory for FooProbeFactory 实现 Factory

然后在 probe-rs/src/probe/list.rs 下添加 Factory 的列表

image.png

对于 Factory 只需参考其他的实现就行了,这里主要是通过 PeobeFactory::open 获取一个 DebugProbe

DebugProbe 实现细节

这里仅仅举例几个比较重要的函数

speed_khz()set_speed() 只需要修改自身字段即可,不用立即设置调试器的速度

struct FooDebugProbe {
	speed: u32,
	...
}

DebugProbe::set_speed(&mut self, speed_khz: u32) {
self.speed = speed_khz;
}

attach 函数比较重要, 根据字段配置调试器的工作模式,启用新速度,设置当前工作模式和传输协议等