Skip to content

Commit c74f460

Browse files
bors[bot]burrbull
andauthored
Merge #106
106: serde skip serialization r=therealprof a=burrbull Part of #101 This change should not be breaking. Co-authored-by: Andrey Zgarbul <[email protected]>
2 parents 720a2c6 + f75a8bb commit c74f460

12 files changed

+245
-5
lines changed

src/svd/bitrange.rs

+4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ use crate::types::Parse;
88
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
99
#[derive(Clone, Copy, Debug, PartialEq)]
1010
pub struct BitRange {
11+
/// Value defining the position of the least significant bit of the field within the register
1112
pub offset: u32,
13+
14+
/// Value defining the bit-width of the bitfield within the register
1215
pub width: u32,
16+
1317
pub range_type: BitRangeType,
1418
}
1519

src/svd/clusterinfo.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,35 @@ use crate::svd::{registercluster::RegisterCluster, registerproperties::RegisterP
1414
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1515
#[derive(Clone, Debug, PartialEq)]
1616
pub struct ClusterInfo {
17+
/// String to identify the cluster.
18+
/// Cluster names are required to be unique within the scope of a peripheral
1719
pub name: String,
20+
21+
/// Cluster address relative to the `baseAddress` of the peripheral
22+
pub address_offset: u32,
23+
24+
/// Specify the cluster name from which to inherit data.
25+
/// Elements specified subsequently override inherited values
26+
#[cfg_attr(feature = "serde", serde(default))]
27+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
1828
pub derived_from: Option<String>,
29+
30+
/// String describing the details of the register cluster
31+
#[cfg_attr(feature = "serde", serde(default))]
32+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
1933
pub description: Option<String>,
34+
35+
/// Specify the struct type name created in the device header file
36+
#[cfg_attr(feature = "serde", serde(default))]
37+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2038
pub header_struct_name: Option<String>,
21-
pub address_offset: u32,
39+
2240
pub default_register_properties: RegisterProperties,
41+
2342
pub children: Vec<RegisterCluster>,
43+
2444
// Reserve the right to add more fields to this struct
45+
#[cfg_attr(feature = "serde", serde(skip))]
2546
_extensible: (),
2647
}
2748

src/svd/cpu.rs

+12
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@ use crate::types::Parse;
1616
#[derive(Clone, Debug, PartialEq)]
1717
pub struct Cpu {
1818
pub name: String,
19+
20+
/// Define the HW revision of the processor
1921
pub revision: String,
22+
23+
/// Define the endianness of the processor
2024
pub endian: Endian,
25+
26+
/// Indicate whether the processor is equipped with a memory protection unit (MPU)
2127
pub mpu_present: bool,
28+
29+
/// Indicate whether the processor is equipped with a hardware floating point unit (FPU)
2230
pub fpu_present: bool,
31+
32+
/// Define the number of bits available in the Nested Vectored Interrupt Controller (NVIC) for configuring priority
2333
pub nvic_priority_bits: u32,
34+
35+
/// Indicate whether the processor implements a vendor-specific System Tick Timer
2436
pub has_vendor_systick: bool,
2537

2638
// Reserve the right to add more fields to this struct

src/svd/device.rs

+30
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,46 @@ use crate::svd::{cpu::Cpu, peripheral::Peripheral, registerproperties::RegisterP
1818
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1919
#[derive(Clone, Debug)]
2020
pub struct Device {
21+
/// The string identifies the device or device series. Device names are required to be unique
2122
pub name: String,
23+
24+
/// Specify the compliant CMSIS-SVD schema version
25+
#[cfg_attr(feature = "serde", serde(default))]
26+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2227
schema_version: Option<String>,
28+
29+
/// Define the version of the SVD file
30+
#[cfg_attr(feature = "serde", serde(default))]
31+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2332
pub version: Option<String>,
33+
34+
/// Describe the main features of the device (for example CPU, clock frequency, peripheral overview)
35+
#[cfg_attr(feature = "serde", serde(default))]
36+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2437
pub description: Option<String>,
38+
39+
/// Define the number of data bits uniquely selected by each address
40+
#[cfg_attr(feature = "serde", serde(default))]
41+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2542
pub address_unit_bits: Option<u32>,
43+
44+
/// Define the number of data bit-width of the maximum single data transfer supported by the bus infrastructure
45+
#[cfg_attr(feature = "serde", serde(default))]
46+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2647
pub width: Option<u32>,
48+
49+
/// Describe the processor included in the device
50+
#[cfg_attr(feature = "serde", serde(default))]
51+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2752
pub cpu: Option<Cpu>,
53+
54+
/// Group to define peripherals
2855
pub peripherals: Vec<Peripheral>,
56+
2957
pub default_register_properties: RegisterProperties,
58+
3059
// Reserve the right to add more fields to this struct
60+
#[cfg_attr(feature = "serde", serde(skip))]
3161
_extensible: (),
3262
}
3363

src/svd/dimelement.rs

+10
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@ use crate::error::*;
1313
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1414
#[derive(Clone, Debug, PartialEq)]
1515
pub struct DimElement {
16+
/// Defines the number of elements in an array or list
1617
pub dim: u32,
18+
19+
/// Specify the address increment between two neighboring array or list members in the address map
1720
pub dim_increment: u32,
21+
22+
/// Specify the strings that substitue the placeholder `%s` within `name` and `displayName`.
23+
/// By default, <dimIndex> is a value starting with 0
24+
#[cfg_attr(feature = "serde", serde(default))]
25+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
1826
pub dim_index: Option<Vec<String>>,
27+
1928
// Reserve the right to add more fields to this struct
29+
#[cfg_attr(feature = "serde", serde(skip))]
2030
_extensible: (),
2131
}
2232

src/svd/enumeratedvalue.rs

+15
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@ use crate::types::Parse;
1515
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1616
#[derive(Clone, Debug, PartialEq)]
1717
pub struct EnumeratedValue {
18+
/// String describing the semantics of the value. Can be displayed instead of the value
1819
pub name: String,
20+
21+
/// Extended string describing the value
22+
#[cfg_attr(feature = "serde", serde(default))]
23+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
1924
pub description: Option<String>,
25+
26+
/// Defines the constant for the bit-field as decimal, hexadecimal or binary number
27+
#[cfg_attr(feature = "serde", serde(default))]
28+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2029
pub value: Option<u32>,
30+
31+
/// Defines the name and description for all other values that are not listed explicitly
32+
#[cfg_attr(feature = "serde", serde(default))]
33+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2134
pub is_default: Option<bool>,
35+
2236
// Reserve the right to add more fields to this struct
37+
#[cfg_attr(feature = "serde", serde(skip))]
2338
pub(crate) _extensible: (),
2439
}
2540
impl EnumeratedValue {

src/svd/enumeratedvalues.rs

+14
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,25 @@ use crate::types::Parse;
1616
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1717
#[derive(Clone, Debug, PartialEq)]
1818
pub struct EnumeratedValues {
19+
/// Identifier for the whole enumeration section
20+
#[cfg_attr(feature = "serde", serde(default))]
21+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
1922
pub name: Option<String>,
23+
24+
#[cfg_attr(feature = "serde", serde(default))]
25+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2026
pub usage: Option<Usage>,
27+
28+
/// Makes a copy from a previously defined enumeratedValues section.
29+
/// No modifications are allowed
30+
#[cfg_attr(feature = "serde", serde(default))]
31+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2132
pub derived_from: Option<String>,
33+
2234
pub values: Vec<EnumeratedValue>,
35+
2336
// Reserve the right to add more fields to this struct
37+
#[cfg_attr(feature = "serde", serde(skip))]
2438
pub(crate) _extensible: (),
2539
}
2640

src/svd/fieldinfo.rs

+29-1
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,43 @@ use crate::svd::{
2020
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
2121
#[derive(Clone, Debug, PartialEq)]
2222
pub struct FieldInfo {
23+
/// Name string used to identify the field.
24+
/// Field names must be unique within a register
2325
pub name: String,
26+
27+
pub bit_range: BitRange,
28+
29+
/// Specify the field name from which to inherit data.
30+
/// Elements specified subsequently override inherited values
31+
#[cfg_attr(feature = "serde", serde(default))]
32+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2433
pub derived_from: Option<String>,
34+
35+
/// String describing the details of the register
36+
#[cfg_attr(feature = "serde", serde(default))]
37+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2538
pub description: Option<String>,
26-
pub bit_range: BitRange,
39+
40+
/// Predefined strings set the access type.
41+
/// The element can be omitted if access rights get inherited from parent elements
42+
#[cfg_attr(feature = "serde", serde(default))]
43+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2744
pub access: Option<Access>,
45+
46+
#[cfg_attr(feature = "serde", serde(default))]
47+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Vec::is_empty"))]
2848
pub enumerated_values: Vec<EnumeratedValues>,
49+
50+
#[cfg_attr(feature = "serde", serde(default))]
51+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2952
pub write_constraint: Option<WriteConstraint>,
53+
54+
#[cfg_attr(feature = "serde", serde(default))]
55+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3056
pub modified_write_values: Option<ModifiedWriteValues>,
57+
3158
// Reserve the right to add more fields to this struct
59+
#[cfg_attr(feature = "serde", serde(skip))]
3260
pub(crate) _extensible: (),
3361
}
3462

src/svd/interrupt.rs

+7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ use crate::types::Parse;
1515
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1616
#[derive(Clone, Debug, PartialEq)]
1717
pub struct Interrupt {
18+
/// The string represents the interrupt name
1819
pub name: String,
20+
21+
/// The string describes the interrupt
22+
#[cfg_attr(feature = "serde", serde(default))]
23+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
1924
pub description: Option<String>,
25+
26+
/// Represents the enumeration index value associated to the interrupt
2027
pub value: u32,
2128
}
2229

src/svd/peripheral.rs

+37-1
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,55 @@ use crate::svd::{
2121
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
2222
#[derive(Clone, Debug)]
2323
pub struct Peripheral {
24+
/// The string identifies the peripheral. Peripheral names are required to be unique for a device
2425
pub name: String,
26+
27+
/// Lowest address reserved or used by the peripheral
28+
pub base_address: u32,
29+
30+
/// The string specifies the version of this peripheral description
31+
#[cfg_attr(feature = "serde", serde(default))]
32+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2533
pub version: Option<String>,
34+
35+
#[cfg_attr(feature = "serde", serde(default))]
36+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2637
pub display_name: Option<String>,
38+
39+
#[cfg_attr(feature = "serde", serde(default))]
40+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2741
pub group_name: Option<String>,
42+
43+
/// The string provides an overview of the purpose and functionality of the peripheral
44+
#[cfg_attr(feature = "serde", serde(default))]
45+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2846
pub description: Option<String>,
29-
pub base_address: u32,
47+
48+
/// Specify an address range uniquely mapped to this peripheral
49+
#[cfg_attr(feature = "serde", serde(default))]
50+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3051
pub address_block: Option<AddressBlock>,
52+
53+
/// A peripheral can have multiple associated interrupts
54+
#[cfg_attr(feature = "serde", serde(default))]
55+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Vec::is_empty"))]
3156
pub interrupt: Vec<Interrupt>,
57+
3258
pub default_register_properties: RegisterProperties,
59+
60+
/// Group to enclose register definitions.
3361
/// `None` indicates that the `<registers>` node is not present
62+
#[cfg_attr(feature = "serde", serde(default))]
63+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3464
pub registers: Option<Vec<RegisterCluster>>,
65+
66+
/// Specify the peripheral name from which to inherit data. Elements specified subsequently override inherited values
67+
#[cfg_attr(feature = "serde", serde(default))]
68+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3569
pub derived_from: Option<String>,
70+
3671
// Reserve the right to add more fields to this struct
72+
#[cfg_attr(feature = "serde", serde(skip))]
3773
_extensible: (),
3874
}
3975

src/svd/registerinfo.rs

+47-1
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,67 @@ use crate::svd::{
2020
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
2121
#[derive(Clone, Debug, PartialEq)]
2222
pub struct RegisterInfo {
23+
/// String to identify the register.
24+
/// Register names are required to be unique within the scope of a peripheral
2325
pub name: String,
26+
27+
/// Define the address offset relative to the enclosing element
28+
pub address_offset: u32,
29+
30+
/// Specifies a group name associated with all alternate register that have the same name
31+
#[cfg_attr(feature = "serde", serde(default))]
32+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2433
pub alternate_group: Option<String>,
34+
35+
/// This tag can reference a register that has been defined above to
36+
/// current location in the description and that describes the memory location already
37+
#[cfg_attr(feature = "serde", serde(default))]
38+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2539
pub alternate_register: Option<String>,
40+
41+
/// Specify the register name from which to inherit data.
42+
/// Elements specified subsequently override inherited values
43+
#[cfg_attr(feature = "serde", serde(default))]
44+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2645
pub derived_from: Option<String>,
46+
47+
/// String describing the details of the register
48+
#[cfg_attr(feature = "serde", serde(default))]
49+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2750
pub description: Option<String>,
28-
pub address_offset: u32,
51+
52+
#[cfg_attr(feature = "serde", serde(default))]
53+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
2954
pub size: Option<u32>,
55+
56+
#[cfg_attr(feature = "serde", serde(default))]
57+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3058
pub access: Option<Access>,
59+
60+
#[cfg_attr(feature = "serde", serde(default))]
61+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3162
pub reset_value: Option<u32>,
63+
64+
#[cfg_attr(feature = "serde", serde(default))]
65+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3266
pub reset_mask: Option<u32>,
67+
3368
/// `None` indicates that the `<fields>` node is not present
69+
#[cfg_attr(feature = "serde", serde(default))]
70+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3471
pub fields: Option<Vec<Field>>,
72+
73+
#[cfg_attr(feature = "serde", serde(default))]
74+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3575
pub write_constraint: Option<WriteConstraint>,
76+
77+
/// Element to describe the manipulation of data written to a register
78+
#[cfg_attr(feature = "serde", serde(default))]
79+
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
3680
pub modified_write_values: Option<ModifiedWriteValues>,
81+
3782
// Reserve the right to add more fields to this struct
83+
#[cfg_attr(feature = "serde", serde(skip))]
3884
pub(crate) _extensible: (),
3985
}
4086

0 commit comments

Comments
 (0)