Skip to content

Commit 35e50a0

Browse files
authored
Merge pull request #110 from diondokter/compile-time-explosion
Compile time explosion & 1.0.7
2 parents 65af39a + b74d925 commit 35e50a0

File tree

9 files changed

+1666
-16
lines changed

9 files changed

+1666
-16
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
### Unreleased
44

5+
### 1.0.7 (30-07-25)
6+
7+
- Fix a compilation time explosion issue. The generated `read_all_registers` functions have been simplified.
8+
On devices with many registers, the async variant would explode in compilation time because of the many awaits.
9+
The callback name parameter now doesn't include the index anymore for repeated registers.
10+
https://github.com/rust-lang/rust/issues/144635
11+
512
### 1.0.6 (18-06-25)
613

714
- Fixed regression introduced in 1.0.3 where signed integers were not sign-extended

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
"tests",
1010
]
1111

12-
package.version = "1.0.6"
12+
package.version = "1.0.7"
1313
package.authors = ["Dion Dokter <[email protected]>"]
1414
package.license = "MIT OR Apache-2.0"
1515
package.homepage = "https://github.com/diondokter/device-driver"

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ default-run = "device-driver-cli"
1515
[dependencies]
1616
anyhow = "1.0.98"
1717
clap = { version = "4.5.20", features = ["derive"] }
18-
device-driver-generation = { version = "=1.0.6", path = "../generation" }
18+
device-driver-generation = { version = "=1.0.7", path = "../generation" }
1919
syn = { version = "2.0" }

device-driver/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ description = "A toolkit to write better device drivers, faster"
1212
readme = "README.md"
1313

1414
[dependencies]
15-
device-driver-macros = { version = "=1.0.6", path = "../macros", default-features = false, optional = true }
15+
device-driver-macros = { version = "=1.0.7", path = "../macros", default-features = false, optional = true }
1616

1717
embedded-io = "0.6.1"
1818
embedded-io-async = "0.6.1"

generation/templates/rust/block.rs.j2

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ impl{{block_generics}} {{ block.name }}{{block_generics}} {
7676
callback({{method.address}} + 0 * 0, "{{method.name}}", reg.into());
7777
{% endwhen %}
7878
{% when BlockMethodKind::Repeated { count, stride } %}
79-
{% for index in 0..*count %}
80-
{{method.cfg_attr}}
81-
let reg = self.{{method.name}}({{index}}).read()?;
82-
{{method.cfg_attr}}
83-
callback({{method.address}} + {{index}} * {{stride}}, "{{method.name}}[{{index}}]", reg.into());
84-
{% endfor %}
79+
{{method.cfg_attr}}
80+
for index in 0..{{count}} {
81+
let reg = self.{{method.name}}(index).read()?;
82+
callback({{method.address}} + index as {{device.register_address_type}} * {{stride}}, "{{method.name}}", reg.into());
83+
}
8584
{% endwhen %}
8685
{% endmatch %}
8786
{% endif %}
@@ -124,12 +123,11 @@ impl{{block_generics}} {{ block.name }}{{block_generics}} {
124123
callback({{method.address}} + 0 * 0, "{{method.name}}", reg.into());
125124
{% endwhen %}
126125
{% when BlockMethodKind::Repeated { count, stride } %}
127-
{% for index in 0..*count %}
128-
{{method.cfg_attr}}
129-
let reg = self.{{method.name}}({{index}}).read_async().await?;
130-
{{method.cfg_attr}}
131-
callback({{method.address}} + {{index}} * {{stride}}, "{{method.name}}[{{index}}]", reg.into());
132-
{% endfor %}
126+
{{method.cfg_attr}}
127+
for index in 0..{{count}} {
128+
let reg = self.{{method.name}}(index).read_async().await?;
129+
callback({{method.address}} + index as {{device.register_address_type}} * {{stride}}, "{{method.name}}", reg.into());
130+
}
133131
{% endwhen %}
134132
{% endmatch %}
135133
{% endif %}

macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ readme = "README.md"
1616
proc-macro = true
1717

1818
[dependencies]
19-
device-driver-generation = { version = "=1.0.6", path = "../generation", default-features = false }
19+
device-driver-generation = { version = "=1.0.7", path = "../generation", default-features = false }
2020
syn = { version = "2.0" }
2121
proc-macro2 = "1.0"
2222

0 commit comments

Comments
 (0)