Skip to content

Commit 98c9b1f

Browse files
authored
Merge pull request #4 from gpgreen/main
Updating spi,serial modules to use embedded-hal 1.0
2 parents 892ea3c + 48444d9 commit 98c9b1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+8509
-2630
lines changed

.github/workflows/changelog.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout sources
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313

1414
- name: Changelog updated
15-
uses: Zomzog/changelog-checker@v1.1.0
15+
uses: Zomzog/changelog-checker@v1.2.0
1616
with:
1717
fileName: CHANGELOG.md
1818
env:

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ on:
22
push:
33
branches: [ staging, trying, master ]
44
pull_request:
5+
merge_group:
56

67
name: Continuous integration
78

@@ -17,14 +18,17 @@ jobs:
1718
experimental: true
1819

1920
steps:
20-
- uses: actions/checkout@v2
21-
- uses: actions-rs/toolchain@v1
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
24+
- name: Install Rust
25+
uses: actions-rs/toolchain@v1
2226
with:
2327
profile: minimal
2428
toolchain: ${{ matrix.rust }}
2529
target: thumbv6m-none-eabi
2630
override: true
27-
31+
2832
- name: Regular build
2933
run: python tools/check.py
3034

CHANGELOG.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,91 @@
22

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

5+
## v0.2.0
6+
7+
This version depends on py32-rs v0.2.0 or later
8+
9+
### Added
10+
11+
- added optional feature "rtic" to implement `rtic-monotonic::Monotonic` trait on timers.
12+
- added optional feature "defmt" to implement `defmt::Format` trait on Errors in various modules
13+
- added feature "with-dma" for internal use to simplify dma related code
14+
- added module `dma`
15+
- module `gpio` has the following new types and traits:
16+
* Struct `PartiallyErasedPin` and `ErasedPin` replaces previous `Pin`
17+
* Struct `DynamicPin` allows pin to swap between an `Input` and `Output` pin during runtime at the cost of possible runtime errors
18+
* Trait `ExtiPin` allows connecting a pin to EXTI lines for interrupt and event handling
19+
* Struct `Debugger` marks pins that upon bootup are dedicated to the DBG peripheral, must be `activate` before use as a gpio
20+
* Trait `PinExt` adds functions to retrieve pin number and port id ('A', 'B', etc)
21+
- gpio Pins can be temporarily mode changed to do an action, using these methods:
22+
* `as_push_pull_output`
23+
* `as_push_pull_output_with_state`
24+
* `as_open_drain_output`
25+
* `as_open_drain_output_with_state`
26+
* `as_floating_input`
27+
* `as_pull_up_input`
28+
* `as_pull_down_input`
29+
- module `rcc`
30+
* new traits and implementations `Enable`, `Reset`, `BusClock`, `BusTimerClock`, `RccBus`
31+
* added function `debug_stop_mode` for control of clock function in sleep and stop conditions
32+
- added module `rtc` and examples thereof
33+
- module `serial`
34+
* Implemented embedded-hal v1.0 nb::Read/Write traits
35+
* Implemented embedded-hal v1.0 io::Write trait
36+
* Implemented `with_dma` methods, so Rx/Tx can use DMA
37+
* Added `SerialExt` trait and implementations for construction methods
38+
* Can configure stop bits, parity, word length
39+
* added `reconfigure`
40+
- module `spi`
41+
* Implemented embedded-hal v1.0 SpiBus, nb, and blocking, traits
42+
* Implemented `with_dma` methods, both Rx/Tx can use DMA, separately and together
43+
* Added `SpiExt` trait and implementations for construction methods
44+
* Works with both 8 and 16 bit words, though 16bit not tested
45+
* Added `SpiSlave` for slave functionality, though it is not tested
46+
* Added frame size conversion methods, [ex: `frame_size_8_bit`]
47+
- module `timer`
48+
* Old module `timers` was removed. Now follows both hal 1.0 and 0.2.7 traits
49+
50+
### Changed
51+
52+
- Fixed repo url's
53+
- Changed all examples to use new api's where necessary, and to remove code structure that was causing much of the example to be optimized away
54+
- module `adc` changed to use new rcc enable, reset, and bus frequencies
55+
- module `gpio`
56+
* pin `into_<mode>` fns have removed the atomic context parameter which is not needed depending on what OS is used
57+
* implemented `split_without_reset`
58+
* Pin type doesn't represent an erased pin, but the most specific type of pin, see Added above
59+
* embedded-hal v0.2.7 traits moved to gpio/hal_02 module
60+
- module `i2c` changed to use rcc enable, reset, and bus frequencies
61+
- module `prelude` removed all embedded-hal traits
62+
- module `pwm` changed to use rcc enable, reset, and bus frequencies
63+
- module `serial`
64+
* embedded-hal v0.2.7 trait implementations moved to serial/hal_02 module
65+
* changed to use rcc enable, reset, and bus frequencies
66+
- module `spi`
67+
* embedded-hal v0.2.7 trait implementations moved to spi/hal_02 module
68+
* changed to use rcc enable, reset, and bus frequencies
69+
- module `time` changed to use fugit crate, this alters how you specify frequency, ie, hz -> Hz, etc
70+
71+
### Removed
72+
73+
- `delay` and `timers` modules removed, the functionality is in the `timer` module now
74+
- `spi::Event::Crc` removed, as that doesn't exist on this micro
75+
- `timers` module removed, replaced by `timer`
76+
77+
### Fixed
78+
79+
- Fixed github action `changelog.yml`
80+
- Fixed github action `ci.yml`
81+
- Fixed `tool/check.py`
82+
83+
## v0.1.1 - 2024-10-10
84+
85+
## V0.1.0 - 2024-09-07
86+
87+
## v0.0.1 - 2023-06-10
88+
89+
- Original Release
90+
591
The format is based on [Keep a Changelog](http://keepachangelog.com/)
692
and this project adheres to [Semantic Versioning](http://semver.org/).
7-

Cargo.toml

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
[package]
2-
edition = "2018"
2+
name = "py32f0xx-hal"
3+
version = "0.2.0"
34
authors = [
4-
"Daniel Egger <daniel@eggers-club.de>",
5-
"Thomas Bytheway <github@harkonen.net>",
6-
"Jesse Braham <jesse@beta7.io>",
5+
"creatoy@yeah.net",
6+
"Greg Green <ggreen@bit-builder.com>",
77
]
8-
categories = ["embedded", "hardware-support", "no-std"]
9-
description = "Peripheral access API for py32F0 series microcontrollers"
10-
documentation = "https://docs.rs/crate/py32f0xx-hal"
8+
edition = "2021"
119

1210
keywords = ["arm", "cortex-m", "py32f0xx", "hal"]
1311
license = "0BSD"
14-
name = "py32f0xx-hal"
1512
readme = "README.md"
16-
repository = "https://github.com/creatoy/py32f0xx-hal"
17-
version = "0.1.1"
13+
repository = "https://github.com/py32-rust/py32f0xx-hal"
14+
categories = ["embedded", "hardware-support", "no-std"]
15+
description = "Peripheral access API for py32F0 series microcontrollers"
16+
documentation = "https://docs.rs/crate/py32f0xx-hal"
1817

1918
[package.metadata.docs.rs]
2019
features = ["py32f030", "rt"]
@@ -24,14 +23,24 @@ targets = ["thumbv6m-none-eabi"]
2423
bare-metal = { version = "1.0.0" }
2524
cast = "0.3.0"
2625
cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] }
27-
embedded-hal = { version = "0.2.7", features = ["unproven"] }
26+
py32f0 = "0.2.0"
27+
embedded-hal = "1.0"
28+
embedded-hal-nb = "1.0"
29+
embedded-dma = "0.2.0"
30+
embedded-io = "0.6.1"
2831
embedded-time = "0.12.1"
2932
nb = "1.1.0"
3033
void = { version = "1.0.2", default-features = false }
34+
defmt = { version = "0.3.8", optional = true }
35+
bitflags = "1.3.2"
36+
fugit = "0.3.7"
37+
fugit-timer = "0.1.3"
38+
rtic-monotonic = { version = "1.0", optional = true }
3139

32-
[dependencies.py32f0]
33-
version = "0.1.1"
34-
features = []
40+
[dependencies.embedded-hal-02]
41+
package = "embedded-hal"
42+
version = "0.2.7"
43+
features = ["unproven"]
3544

3645
[dev-dependencies]
3746
cortex-m-rt = "0.7.3"
@@ -44,11 +53,13 @@ mfrc522 = "0.6.1"
4453
[features]
4554
device-selected = []
4655
rt = ["py32f0/rt"]
47-
py32f030 = ["py32f0/py32f030", "device-selected"]
48-
py32f003 = ["py32f0/py32f003", "device-selected"]
56+
py32f030 = ["py32f0/py32f030", "device-selected", "with-dma"]
57+
py32f003 = ["py32f0/py32f003", "device-selected", "with-dma"]
4958
py32f002a = ["py32f0/py32f002a", "device-selected"]
5059
py32f002b = ["py32f0/py32f002b", "device-selected"]
5160

61+
defmt = ["dep:defmt"]
62+
5263
# Features based on Flash size (in kbytes)
5364
flash-16 = []
5465
flash-20 = []
@@ -64,6 +75,9 @@ ram-4 = []
6475
ram-6 = []
6576
ram-8 = []
6677

78+
# optional peripherals
79+
with-dma = []
80+
6781
# MCU aliases
6882
#
6983
# Features correspond specific mcu series
@@ -81,6 +95,9 @@ py32f003xx8 = ["py32f003", "flash-64", "ram-8"]
8195
py32f002ax5 = ["py32f002a", "flash-20", "ram-3"]
8296
py32f002bx5 = ["py32f002b", "flash-24", "ram-3"]
8397

98+
# rtic os
99+
rtic = ["dep:rtic-monotonic"]
100+
84101
[profile.dev]
85102
debug = true
86103
lto = true

README.md

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
py32f0xx-hal
22
=============
33

4-
> This repo is modified from [stm32f0xx-hal](https://github.com/stm32-rs/stm32f0xx-hal)
4+
> [HAL] for the py32f0xx family of microcontrollers
55
6-
> **NOTE: The function is not fully tested, and you are responsible for any problems with the use of this repository.**
6+
> **NOTE: The function's are not fully tested, and you are responsible for any problems with the use of this repository.**
77
8-
Known issue:
9-
- I2C not work
8+
Known issues:
9+
- I2C master/slave not tested
10+
- rtc not tested
1011

11-
[![Continuous integration](https://github.com/creatoy/py32f0xx-hal/workflows/Continuous%20integration/badge.svg)](https://github.com/creatoy/py32f0xx-hal)
12+
[![Crates.io](https://img.shields.io/crates/d/py32f0xx-hal.svg)](https://crates.io/crates/py32f0xx-hal)
1213
[![Crates.io](https://img.shields.io/crates/v/py32f0xx-hal.svg)](https://crates.io/crates/py32f0xx-hal)
1314
[![docs.rs](https://docs.rs/py32f0xx-hal/badge.svg)](https://docs.rs/py32f0xx-hal/)
15+
[![dependency status](https://deps.rs/repo/github/[py32-rust/py32f0xx-hal/status.svg)](https://deps.rs/repo/github/py32-rust/py32f0xx-hal)
16+
[![Continuous integration](https://github.com/creatoy/py32f0xx-hal/workflows/Continuous%20integration/badge.svg)](https://github.com/py32-rust/py32f0xx-hal)
1417

15-
[_py32f0xx-hal_](https://github.com/creatoy/py32f0xx-hal) contains a hardware abstraction on top of the peripheral access API for the puyasemi PY32F0xx family of microcontrollers.
18+
[_py32f0xx-hal_](https://github.com/py32-rust/py32f0xx-hal) contains a hardware abstraction on top of the peripheral access API for the puyasemi PY32F0xx family of microcontrollers.
1619

1720
Collaboration on this crate is highly welcome, as are pull requests!
1821

1922
Supported
2023
------------------------
2124

22-
* __py32f030__ (py32f030xx4, py32f030xx6, py32f030xx7, py32f030xx8)
23-
* __py32f003__ (py32f003xx4, py32f003xx6, py32f030xx8)
24-
* __py32f002a__ (py32f002ax5)
25-
* __py32f002b__ (py32f002bx5)
25+
* __py32f030__ (py32f030xx4, py32f030xx6, py32f030xx7, py32f030xx8)
26+
* __py32f003__ (py32f003xx4, py32f003xx6, py32f030xx8)
27+
* __py32f002a__ (py32f002ax5)
28+
* __py32f002b__ (py32f002bx5)
2629

2730
Getting Started
2831
---------------
@@ -34,16 +37,20 @@ $ cargo build --features=py32f002ax5 --example=blinky
3437
To use py32f0xx-hal as a dependency in a standalone project the target device feature must be specified in the `Cargo.toml` file:
3538
```
3639
[dependencies]
40+
embedded-hal = "1"
41+
nb = "1"
3742
cortex-m = "0.7.7"
3843
cortex-m-rt = "0.7.3"
39-
py32f0xx-hal = { version = "0.1.0", features = ["py32f002ax5"]}
44+
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
45+
panic-halt = "0.2.0"
46+
py32f0xx-hal = { version = "0.2.0", features = ["py32f002ax5"]}
4047
```
4148

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

44-
- [Embedded Rust Documentation](https://docs.rust-embedded.org/)
45-
- [The Embedded Rust Book](https://docs.rust-embedded.org/book/)
46-
- [Rust Embedded FAQ](https://docs.rust-embedded.org/faq.html)
51+
- [Embedded Rust Documentation](https://docs.rust-embedded.org/)
52+
- [The Embedded Rust Book](https://docs.rust-embedded.org/book/)
53+
- [Rust Embedded FAQ](https://docs.rust-embedded.org/faq.html)
4754
- [rust-embedded/awesome-embedded-rust](https://github.com/rust-embedded/awesome-embedded-rust)
4855

4956

@@ -58,6 +65,11 @@ Changelog
5865
See [CHANGELOG.md](CHANGELOG.md).
5966

6067

68+
Credits
69+
-------
70+
71+
> This repo was inspired by [stm32f0xx-hal](https://github.com/stm32-rs/stm32f0xx-hal) and [stm32f1xx-hal](https://github.com/stm32-rs/stm32f1xx-hal)
72+
6173
License
6274
-------
6375

0 commit comments

Comments
 (0)