probe_rs_target/
flash_properties.rs

1use super::memory::SectorDescription;
2use crate::serialize::{hex_range, hex_u_int};
3use serde::{Deserialize, Serialize};
4use std::ops::Range;
5
6/// Properties of flash memory, which
7/// are used when programming Flash memory.
8///
9/// These values are read from the
10/// YAML target description files.
11#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
12pub struct FlashProperties {
13    /// The range of the device flash.
14    #[serde(serialize_with = "hex_range")]
15    pub address_range: Range<u64>,
16    /// The page size of the device flash.
17    #[serde(serialize_with = "hex_u_int")]
18    pub page_size: u32,
19    /// The value of a byte in flash that was just erased.
20    #[serde(serialize_with = "hex_u_int")]
21    pub erased_byte_value: u8,
22    /// The approximate time it takes to program a page.
23    pub program_page_timeout: u32,
24    /// The approximate time it takes to erase a sector.
25    pub erase_sector_timeout: u32,
26    /// The available sectors of the device flash.
27    #[serde(default)]
28    pub sectors: Vec<SectorDescription>,
29}
30
31impl Default for FlashProperties {
32    fn default() -> Self {
33        FlashProperties {
34            address_range: 0..0,
35            page_size: 0,
36            erased_byte_value: 0,
37            program_page_timeout: 0,
38            erase_sector_timeout: 0,
39            sectors: vec![],
40        }
41    }
42}