Skip to content

Commit 11ea850

Browse files
committed
Merge branch 'master' into canbus-with-crate
2 parents d2595f5 + 20c51f1 commit 11ea850

26 files changed

+3151
-1682
lines changed

.github/workflows/ci.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Note: The checkout@v2 action sometimes checks out the wrong commit:
2+
# https://github.com/actions/checkout/issues/237
3+
# Until that is fixed we use checkout@v1 here instead.
4+
5+
name: CI
6+
7+
on:
8+
push:
9+
branches: [master]
10+
pull_request:
11+
12+
jobs:
13+
check:
14+
name: Check
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
mcu:
19+
- stm32f301
20+
- stm32f318
21+
- stm32f302xb
22+
- stm32f302xc
23+
- stm32f302xd
24+
- stm32f302xe
25+
- stm32f303xb
26+
- stm32f303xc
27+
- stm32f303xd
28+
- stm32f303xe
29+
- stm32f303x6
30+
- stm32f303x8
31+
- stm32f373
32+
- stm32f378
33+
- stm32f334
34+
- stm32f328
35+
- stm32f358
36+
- stm32f398
37+
features: ["rt"]
38+
include:
39+
- mcu: stm32f303xc
40+
features: rt,stm32-usbd
41+
steps:
42+
- uses: actions/checkout@v1
43+
- uses: actions-rs/toolchain@v1
44+
with:
45+
toolchain: stable
46+
target: thumbv7em-none-eabihf
47+
override: true
48+
profile: minimal
49+
- uses: actions-rs/cargo@v1
50+
with:
51+
command: check
52+
args: --features=${{ matrix.mcu }},${{ matrix.features }} --examples
53+
54+
clippy:
55+
name: Clippy
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v1
59+
- uses: actions-rs/toolchain@v1
60+
with:
61+
toolchain: nightly
62+
target: thumbv7em-none-eabihf
63+
override: true
64+
profile: minimal
65+
components: clippy
66+
- uses: actions-rs/clippy-check@v1
67+
with:
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
args: >
70+
--features=stm32f303xc,rt,stm32-usbd --examples
71+
-- -D warnings
72+
73+
rustfmt:
74+
name: Rustfmt
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v1
78+
- uses: actions-rs/toolchain@v1
79+
with:
80+
toolchain: stable
81+
override: true
82+
profile: minimal
83+
components: rustfmt
84+
- uses: actions-rs/cargo@v1
85+
with:
86+
command: fmt
87+
args: --all -- --check

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
- SPI support for reclock after initialization ([#98](https://github.com/stm32-rs/stm32f3xx-hal/pull/98))
12+
13+
## [v0.5.0] - 2020-07-21
14+
15+
### Added
16+
17+
- Implement `InputPin` for `Output<OpenDrain>` pins ([#114](https://github.com/stm32-rs/stm32f3xx-hal/pull/114))
18+
- Support for safe one-shot DMA transfers ([#86](https://github.com/stm32-rs/stm32f3xx-hal/pull/86))
19+
- DMA support for serial reception and transmission ([#86](https://github.com/stm32-rs/stm32f3xx-hal/pull/86))
20+
- ADC support for `stm32f303` devices ([#47](https://github.com/stm32-rs/stm32f3xx-hal/pull/47))
21+
1022
### Fixed
1123

1224
- `PLL` was calculated wrong for devices, which do not divide `HSI` ([#67](https://github.com/stm32-rs/stm32f3xx-hal/pull/67))
@@ -28,7 +40,7 @@ let clocks = rcc
2840
.use_hse(32.mhz())
2941
.sysclk(72.mhz())
3042
```
31-
This is possible through utilizing the divider, which can devide the
43+
This is possible through utilizing the divider, which can divide the
3244
external oscillator clock on most devices. Some devices have even the
3345
possibility to divide the internal oscillator clock.
3446

@@ -37,6 +49,10 @@ let clocks = rcc
3749
- The feature gate requires you to select a subvariant if possible. ([#75](https://github.com/stm32-rs/stm32f3xx-hal/pull/75))
3850
- Split up `stm32f302` into sub-targets `stm32f302xb`,`stm32f302xc`,`stm32f302xd`,`stm32f302xe`
3951
- Bump `stm32f3` dependency to `0.11.0` ([#97](https://github.com/stm32-rs/stm32f3xx-hal/pull/97))
52+
- The `stm32f3` reexport is now renamed from `stm32` to `pac` ([#101](https://github.com/stm32-rs/stm32f3xx-hal/pull/101))
53+
- The correct `stm32f3` modules are now used for the `stm32f318` and `stm32f738`
54+
targets. As a result, some previously (wrongly) supported peripherals have
55+
been removed from these targets. ([#116](https://github.com/stm32-rs/stm32f3xx-hal/pull/116))
4056

4157
## [v0.4.3] - 2020-04-11
4258

@@ -178,7 +194,8 @@ let clocks = rcc
178194

179195
- Support `stm32f303` device
180196

181-
[Unreleased]: https://github.com/stm32-rs/stm32f3xx-hal/compare/v0.4.3...HEAD
197+
[Unreleased]: https://github.com/stm32-rs/stm32f3xx-hal/compare/v0.5.0...HEAD
198+
[v0.5.0]: https://github.com/stm32-rs/stm32f3xx-hal/compare/v0.4.3...v0.5.0
182199
[v0.4.3]: https://github.com/stm32-rs/stm32f3xx-hal/compare/v0.4.2...v0.4.3
183200
[v0.4.2]: https://github.com/stm32-rs/stm32f3xx-hal/compare/v0.4.1...v0.4.2
184201
[v0.4.1]: https://github.com/stm32-rs/stm32f3xx-hal/compare/v0.4.0...v0.4.1

Cargo.toml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ name = "stm32f3xx-hal"
99
readme = "README.md"
1010
repository = "https://github.com/stm32-rs/stm32f3xx-hal"
1111
documentation = "https://docs.rs/stm32f3xx-hal"
12-
version = "0.4.3"
12+
version = "0.5.0"
1313

1414
[package.metadata.docs.rs]
1515
features = ["stm32f303xc", "rt", "stm32-usbd"]
1616
targets = ["thumbv7em-none-eabihf"]
1717

18-
[badges]
19-
travis-ci = { repository = "stm32-rs/stm32f3xx-hal" }
20-
2118
[dependencies]
2219
cortex-m = "0.6"
2320
cortex-m-rt = "0.6"
@@ -38,35 +35,39 @@ version = "0.2"
3835
features = ["const-fn"]
3936

4037
[dependencies.cast]
41-
default-features = false
4238
version = "0.2"
43-
44-
[dependencies.void]
4539
default-features = false
40+
41+
[dependencies.stable_deref_trait]
4642
version = "1"
43+
default-features = false
4744

4845
[dependencies.stm32-usbd]
4946
version = "0.5"
5047
optional = true
5148

49+
[dependencies.void]
50+
version = "1"
51+
default-features = false
52+
5253
[dev-dependencies]
5354
panic-semihosting = "0.5"
5455
usb-device = "0.2"
5556
usbd-serial = "0.1"
57+
cortex-m-semihosting = "0.3"
5658

5759
[features]
5860
default = ["unproven"]
61+
unproven = ["embedded-hal/unproven"]
5962
device-selected = []
6063
direct-call-deprecated = []
6164
rt = ["stm32f3/rt"]
6265
can = ["embedded-hal-can", "heapless"]
63-
# Any Changes here should be mirrored in README.md and src/lib.rs
64-
stm32f301 = ["stm32f3/stm32f301", "direct-call-deprecated"]
65-
stm32f301xb = ["stm32f301", "device-selected"]
66-
stm32f301xc = ["stm32f301", "device-selected"]
67-
stm32f301xd = ["stm32f301", "device-selected"]
68-
stm32f301xe = ["stm32f301", "device-selected"]
69-
stm32f318 = ["stm32f3/stm32f3x8", "device-selected"]
66+
67+
# Any Changes here should be mirrored in README.md, src/lib.rs, and
68+
# .github/workflows/ci.yml.
69+
stm32f301 = ["stm32f3/stm32f301", "device-selected"]
70+
stm32f318 = ["stm32f3/stm32f301", "device-selected"]
7071
stm32f302 = ["stm32f3/stm32f302", "direct-call-deprecated"]
7172
stm32f302xb = ["stm32f302", "device-selected"]
7273
stm32f302xc = ["stm32f302", "device-selected"]
@@ -82,12 +83,11 @@ stm32f303xe = ["stm32f303", "stm32-usbd/ram_access_2x16", "device-selected"]
8283
stm32f303x6 = ["stm32f303", "device-selected"]
8384
stm32f303x8 = ["stm32f303", "device-selected"]
8485
stm32f373 = ["stm32f3/stm32f373", "device-selected"]
85-
stm32f378 = ["stm32f3/stm32f3x8", "device-selected"]
86+
stm32f378 = ["stm32f3/stm32f373", "device-selected"]
8687
stm32f334 = ["stm32f3/stm32f3x4", "device-selected"]
8788
stm32f328 = ["stm32f3/stm32f3x8", "device-selected"]
8889
stm32f358 = ["stm32f3/stm32f3x8", "device-selected"]
8990
stm32f398 = ["stm32f3/stm32f3x8", "device-selected"]
90-
unproven = ["embedded-hal/unproven"]
9191

9292
[profile.dev]
9393
debug = true
@@ -115,5 +115,14 @@ name = "spi"
115115
required-features = ["stm32f303"]
116116

117117
[[example]]
118+
<<<<<<< HEAD
118119
name = "can"
119120
required-features = ["rt", "can", "stm32f303"]
121+
=======
122+
name = "serial_dma"
123+
required-features = ["stm32f303"]
124+
125+
[[example]]
126+
name = "adc"
127+
required-features = ["stm32f303"]
128+
>>>>>>> master

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# stm32f3xx-hal
22

3-
[![Build Status](https://travis-ci.com/stm32-rs/stm32f3xx-hal.svg)](https://travis-ci.com/stm32-rs/stm32f3xx-hal)
3+
[![Build Status](https://github.com/stm32-rs/stm32f3xx-hal/workflows/CI/badge.svg)](https://github.com/stm32-rs/stm32f3xx-hal/actions)
44
[![Crate](https://img.shields.io/crates/v/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal)
55
[![Docs](https://docs.rs/stm32f3xx-hal/badge.svg)](https://docs.rs/stm32f3xx-hal)
66

ci/build.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

examples/adc.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#![no_std]
2+
#![no_main]
3+
4+
//! Example usage for ADC on STM32F303
5+
6+
extern crate panic_semihosting;
7+
8+
use cortex_m_rt::entry;
9+
use cortex_m_semihosting::hprintln;
10+
11+
use stm32f3xx_hal::{adc, pac, prelude::*};
12+
13+
#[entry]
14+
/// Main Thread
15+
fn main() -> ! {
16+
// Get peripherals, clocks and freeze them
17+
let mut dp = pac::Peripherals::take().unwrap();
18+
let mut rcc = dp.RCC.constrain();
19+
let clocks = rcc.cfgr.freeze(&mut dp.FLASH.constrain().acr);
20+
21+
// set up adc1
22+
let mut adc1 = adc::Adc::adc1(
23+
dp.ADC1, // The ADC we are going to control
24+
// The following is only needed to make sure the clock signal for the ADC is set up
25+
// correctly.
26+
&mut dp.ADC1_2,
27+
&mut rcc.ahb,
28+
adc::CkMode::default(),
29+
clocks,
30+
);
31+
32+
// Set up pin PA0 as analog pin.
33+
// This pin is connected to the user button on the stm32f3discovery board.
34+
let mut gpio_a = dp.GPIOA.split(&mut rcc.ahb);
35+
let mut adc1_in1_pin = gpio_a.pa0.into_analog(&mut gpio_a.moder, &mut gpio_a.pupdr);
36+
37+
// Be aware that the values in the table below depend on the input of VREF.
38+
// To have a stable VREF input, put a condensator and a volt limiting diode in front of it.
39+
//
40+
// Also know that integer division and the ADC hardware unit always round down.
41+
// To make up for those errors, see this forum entry:
42+
// [https://forum.allaboutcircuits.com/threads/why-adc-1024-is-correct-and-adc-1023-is-just-plain-wrong.80018/]
43+
hprintln!("
44+
The ADC has a 12 bit resolution, i.e. if your reference Value is 3V:
45+
approx. ADC value | approx. volt value
46+
==================+===================
47+
0 | 0 mV
48+
2048 | 1500 mV
49+
4095 | 3000 mV
50+
51+
If you are using a STM32F3Discovery, PA0 is connected to the User Button.
52+
Pressing it should connect the user Button to to HIGH and the value should change from 0 to 4095.
53+
").expect("Error using hprintln.");
54+
55+
loop {
56+
let adc1_in1_data: u16 = adc1.read(&mut adc1_in1_pin).expect("Error reading adc1.");
57+
hprintln!("PA0 reads {}", adc1_in1_data).ok();
58+
}
59+
}

0 commit comments

Comments
 (0)