stm32_uart_loader/
protocol.rs

1
2
3pub const UART_DISC: u8 = 0x7F;
4
5pub const UART_ACK: u8 = 0x79;
6pub const UART_NACK: u8 = 0x1F;
7
8pub const MAX_CHUNK: usize = 256;
9
10#[derive(Debug, PartialEq, Clone)]
11pub enum Command {
12    /// Fetch bootloader version and allowed commands
13    Get = 0x00,
14
15    /// Gets the bootloader version and the Read Protection status of the Flash memory.
16    GetVersionReadStatus = 0x01,
17    
18    /// Gets the chip ID
19    GetId = 0x02,
20
21    /// Reads up to 256 bytes of memory starting from an address specified by the application.
22    ReadMemory = 0x11,
23
24    /// Jumps to user application code located in the internal Flash memory or in the SRAM.
25    Go = 0x21,
26
27    /// Writes up to 256 bytes to the RAM or Flash memory starting from an address specified by the application.
28    WriteMemory = 0x31,
29
30    /// Erases from one to all the Flash memory pages.
31    Erase = 0x43,
32
33    /// Erases from one to all the Flash memory pages using two byte addressing mode (available only for v3.0 USART bootloader versions and above).
34    ExtendedErase = 0x44,
35
36    /// Enables the write protection for some sectors.
37    WriteProtect = 0x63,
38
39    /// Disables the write protection for all Flash memory sectors
40    WriteUnprotect = 0x73,
41
42    /// Enables the read protection
43    ReadoutProtect = 0x82,
44
45    /// Disables the read protection.
46    ReadoutUnprotect = 0x92,
47}