Skip to content

Commit e430a64

Browse files
committed
Fixed bug with gpio output mode setting
gpio push pull output mode setting was incorrect, causing random resets
1 parent 98c9b1f commit e430a64

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

CHANGELOG.md

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

33
All notable changes to this project will be documented in this file.
44

5-
## v0.2.0
5+
## v0.2.1 - 2025-02-04
6+
7+
### Fixed
8+
9+
- Fixed bug with gpio mode setting for output push pull vs open drain, causing hardware resets.
10+
11+
## v0.2.0 - 2025-01-21
612

713
This version depends on py32-rs v0.2.0 or later
814

@@ -80,11 +86,11 @@ This version depends on py32-rs v0.2.0 or later
8086
- Fixed github action `ci.yml`
8187
- Fixed `tool/check.py`
8288

83-
## v0.1.1 - 2024-10-10
89+
## v0.1.1 - 2024-10-10 - 2024-10-10
8490

85-
## V0.1.0 - 2024-09-07
91+
## V0.1.0 - 2024-09-07 - 2024-09-07
8692

87-
## v0.0.1 - 2023-06-10
93+
## v0.0.1 - 2023-06-10 - 2023-06-10
8894

8995
- Original Release
9096

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "py32f0xx-hal"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = [
55
"creatoy@yeah.net",
66
"Greg Green <ggreen@bit-builder.com>",
@@ -23,7 +23,7 @@ targets = ["thumbv6m-none-eabi"]
2323
bare-metal = { version = "1.0.0" }
2424
cast = "0.3.0"
2525
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
26-
py32f0 = "0.2.0"
26+
py32f0 = "= 0.2.0"
2727
embedded-hal = "1.0"
2828
embedded-hal-nb = "1.0"
2929
embedded-dma = "0.2.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cortex-m = "0.7.7"
4343
cortex-m-rt = "0.7.3"
4444
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
4545
panic-halt = "0.2.0"
46-
py32f0xx-hal = { version = "0.2.0", features = ["py32f002ax5"]}
46+
py32f0xx-hal = { version = "0.2.1", features = ["py32f002ax5"]}
4747
```
4848

4949
If you are unfamiliar with embedded development using Rust, there are a number of fantastic resources available to help.

src/gpio.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,12 +1073,12 @@ impl<const P: char, const N: u8, M> Pin<P, N, M> {
10731073
};
10741074
// if an output, set output type
10751075
if MODE::MODE == Mode::Output {
1076-
let otyperv = if MODE::CNF == Cnf::OpenDrain {
1077-
0b1 << N
1078-
} else {
1079-
!(0b1 << N)
1076+
let otv = match MODE::CNF {
1077+
Cnf::OpenDrain => 0b1,
1078+
Cnf::PushPull => 0b0,
10801079
};
1081-
unsafe { gpio.otyper.modify(|r, w| w.bits(r.bits() | otyperv)) };
1080+
gpio.otyper
1081+
.modify(|r, w| unsafe { w.bits((r.bits() & !(0b1 << N)) | (otv << N)) });
10821082
}
10831083
// if an alternate function pin, set that
10841084
if let Some(af) = MODE::AF {

0 commit comments

Comments
 (0)