hf2/lib.rs
1/// This command states the current mode of the device:
2mod bininfo;
3pub use bininfo::*;
4
5///Compute checksum of a number of pages. Maximum value for num_pages is max_message_size / 2 - 2. The checksum algorithm used is CRC-16-CCITT.
6mod checksumpages;
7pub use checksumpages::*;
8
9///Return internal log buffer if any. The result is a character array.
10mod dmesg;
11pub use dmesg::*;
12
13/// Various device information. The result is a character array. See INFO_UF2.TXT in UF2 format for details.
14mod info;
15pub use info::*;
16
17///Read a number of words from memory. Memory is read word by word (and not byte by byte), and target_addr must be suitably aligned. This is to support reading of special IO regions.
18mod readwords;
19pub use readwords::*;
20
21///Reset the device into user-space app. Usually, no response at all will arrive for this command.
22mod resetintoapp;
23pub use resetintoapp::*;
24
25///Reset the device into bootloader, usually for flashing. Usually, no response at all will arrive for this command.
26mod resetintobootloader;
27pub use resetintobootloader::*;
28
29/// When issued in bootloader mode, it has no effect. In user-space mode it causes handover to bootloader. A BININFO command can be issued to verify that.
30mod startflash;
31pub use startflash::*;
32
33///Write a single page of flash memory. No Result.
34mod writeflashpage;
35pub use writeflashpage::*;
36
37///Dual of READ WORDS, with the same constraints. No Result.
38mod writewords;
39pub use writewords::*;
40
41/// Errors and traits to build a command
42mod command;
43
44#[derive(Clone, Debug)]
45pub enum Error {
46 Arguments,
47 Parse,
48 CommandNotRecognized,
49 Execution,
50 Sequence,
51 Transmission,
52}
53
54///trait to implement HID devices
55pub trait ReadWrite {
56 fn hf2_write(&self, data: &[u8]) -> Result<usize, Error>;
57 fn hf2_read(&self, buf: &mut [u8]) -> Result<usize, Error>;
58}
59
60#[cfg(feature = "hidapi")]
61mod hidapi_trait;
62
63#[cfg(feature = "utils")]
64pub mod utils;