Skip to main content

sftool_lib/sf32lb55/
ram_command.rs

1use crate::Result;
2use crate::common::ram_command::{CommandConfig, RamOps};
3use crate::common::serial_io::for_tool;
4use crate::sf32lb55::SF32LB55Tool;
5
6// 重新导出公共类型
7pub use crate::common::ram_command::{Command, DownloadStub, RamCommand, Response};
8
9impl RamCommand for SF32LB55Tool {
10    fn command(&mut self, cmd: Command) -> Result<Response> {
11        let cmd_string = self.format_command(&cmd);
12        let memory_type = self.base.memory_type.clone();
13        let mut io = for_tool(self);
14        RamOps::send_command_and_wait_response(&mut io, cmd, &cmd_string, memory_type.as_str())
15    }
16
17    fn send_data(&mut self, data: &[u8]) -> Result<Response> {
18        let config = CommandConfig {
19            compat_mode: self.base.compat,
20            ..Default::default()
21        };
22        let mut io = for_tool(self);
23        RamOps::send_data_and_wait_response(&mut io, data, &config)
24    }
25}
26
27impl DownloadStub for SF32LB55Tool {
28    fn download_stub(&mut self) -> Result<()> {
29        // Use SifliTool trait methods
30        self.download_stub_impl()
31    }
32}