Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic IntoAf #308

Merged
merged 5 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.52"
msrv = "1.54"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.52.0
toolchain: 1.54.0
target: thumbv7em-none-eabihf
override: true
profile: minimal
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- The MSRV was bumped to 1.54 ([#308])
- Generic `into_af_push_pull<A>` and `into_af_open_drain<A>` ([#308])
- `BusClock` and `BusTimerClock` traits ([#302])
- `RccBus`, `Enable`, `Reset` traits and implementations for peripherals ([#299])
- Support cortex-m-rt `v0.7.0` but still allow `v0.6.13` ([#283])
Expand Down Expand Up @@ -508,6 +510,7 @@ let clocks = rcc
[defmt]: https://github.com/knurling-rs/defmt
[filter]: https://defmt.ferrous-systems.com/filtering.html

[#308]: https://github.com/stm32-rs/stm32f3xx-hal/pull/308
[#304]: https://github.com/stm32-rs/stm32f3xx-hal/pull/304
[#302]: https://github.com/stm32-rs/stm32f3xx-hal/pull/302
[#299]: https://github.com/stm32-rs/stm32f3xx-hal/pull/299
Expand Down
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ exclude = [
".markdownlint.yml"
]
resolver = "2"
rust-version = "1.52"
rust-version = "1.54"

[workspace]
members = [
Expand All @@ -35,7 +35,7 @@ rustc-args = ["--cfg", "docsrs"]

[dependencies]
cfg-if = "1.0.0"
cortex-m = "0.7.2"
cortex-m = "0.7.4"
cortex-m-rt = "0.7"
defmt = { version = ">=0.2.3, <0.4.0", optional = true }
embedded-dma = "0.1.2"
Expand All @@ -55,18 +55,17 @@ enumset = { version = "1.0.6", optional = true}
bare-metal = "0.2.5"

[dev-dependencies]
cortex-m = "0.7.2"
cortex-m-semihosting = "0.3.7"
defmt-rtt = "0.3.0"
defmt-test = "0.3.0"
panic-probe = "0.3.0"
panic-semihosting = "0.5.6"
usbd-serial = "0.1.1"
usb-device = "0.2.8"
cortex-m-rtic = "=0.6.0-rc.4, <0.6.0-rc.5"
systick-monotonic = "0.1.0-rc.2"
cortex-m-rtic = "1.0"
systick-monotonic = "1.0"
panic-rtt-target = { version = "0.1", features = ["cortex-m"] }
rtt-target = { version = "0.3.0", features = ["cortex-m"] }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }

[build-dependencies]
slice-group-by = "0.2.6"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Crate](https://img.shields.io/crates/v/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal)
[![Docs](https://docs.rs/stm32f3xx-hal/badge.svg)](https://docs.rs/stm32f3xx-hal)
[![Crates.io](https://img.shields.io/crates/d/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal)
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.52+-blue.svg)
![Minimum Supported Rust Version](https://img.shields.io/badge/rustc-1.54+-blue.svg)

`stm32f3xx-hal` contains a multi device hardware abstraction on top of the
peripheral access API for the STMicro STM32F3 series microcontrollers. The
Expand Down Expand Up @@ -139,7 +139,7 @@ See the [examples folder](examples) for more example programs.

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.52.0 and up. It *might*
This crate is guaranteed to compile on stable Rust 1.54.0 and up. It *might*
compile with older versions but that may change in any new patch release.

<!-- This should not prevent anyone to use newer features. -->
Expand Down
13 changes: 6 additions & 7 deletions examples/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,20 @@ fn main() -> ! {
// Configure CAN RX and TX pins (AF9)
let rx = gpioa
.pa11
.into_af9_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
let tx = gpioa
.pa12
.into_af9_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);

// Initialize the CAN peripheral
let mut can = Can::new(dp.CAN, tx, rx, &mut rcc.apb1);

// Use loopback mode: No pins need to be assigned to peripheral.
// APB1 (PCLK1): 64MHz, Bit rate: 500kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
can.modify_config()
let mut can = bxcan::Can::builder(Can::new(dp.CAN, tx, rx, &mut rcc.apb1))
.set_bit_timing(0x001c_0003)
.set_loopback(false)
.set_silent(false);
.set_silent(false)
.leave_disabled();

let mut filters = can.modify_filters();

Expand All @@ -67,7 +66,7 @@ fn main() -> ! {
drop(filters);

// Sync to the bus and start normal operation.
block!(can.enable()).ok();
block!(can.enable_non_blocking()).ok();

let mut led0 = gpiob
.pb15
Expand Down
4 changes: 2 additions & 2 deletions examples/i2c_scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ fn main() -> ! {
let mut scl =
gpiob
.pb6
.into_af4_open_drain(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
.into_af_open_drain(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
let mut sda =
gpiob
.pb7
.into_af4_open_drain(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
.into_af_open_drain(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
scl.internal_pull_up(&mut gpiob.pupdr, true);
sda.internal_pull_up(&mut gpiob.pupdr, true);
let mut i2c = hal::i2c::I2c::new(
Expand Down
20 changes: 10 additions & 10 deletions examples/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,38 @@ fn main() -> ! {
let mut gpioa = dp.GPIOA.split(&mut rcc.ahb);
let pa4 = gpioa
.pa4
.into_af2_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl);
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl);
let pa6 = gpioa
.pa6
.into_af2_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl);
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl);
let pa7 = gpioa
.pa7
.into_af2_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl);
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrl);

let mut gpiob = dp.GPIOB.split(&mut rcc.ahb);
let pb0 = gpiob
.pb0
.into_af2_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
.into_af_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
let pb1 = gpiob
.pb1
.into_af2_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
.into_af_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
let pb4 = gpiob
.pb4
.into_af2_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
.into_af_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
let pb5 = gpiob
.pb5
.into_af2_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
.into_af_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrl);
let pb8 = gpiob
.pb8
.into_af1_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrh);
.into_af_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrh);
let pb10 = gpiob
.pb10
.into_af1_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrh);
.into_af_push_pull(&mut gpiob.moder, &mut gpiob.otyper, &mut gpiob.afrh);

let mut gpioc = dp.GPIOC.split(&mut rcc.ahb);
let pc10 = gpioc
.pc10
.into_af4_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);
.into_af_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);

// TIM3
//
Expand Down
4 changes: 2 additions & 2 deletions examples/serial_dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ fn main() -> ! {
let pins = (
gpioa
.pa9
.into_af7_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
gpioa
.pa10
.into_af7_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
);
let serial = Serial::new(dp.USART1, pins, 9600.Bd(), clocks, &mut rcc.apb2);
let (tx, rx) = serial.split();
Expand Down
4 changes: 2 additions & 2 deletions examples/serial_echo_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ mod app {
// configure this pin to make use of its `USART1_TX` alternative function
// (AF mapping taken from table 14 "Alternate functions for port A" of the datasheet at
// https://www.st.com/en/microcontrollers-microprocessors/stm32f303vc.html)
.into_af7_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
gpioa
// Rx pin
.pa10
// configure this pin to make use of its `USART1_RX` alternative function
// (AF mapping taken from table 14 "Alternate functions for port A" of the datasheet at
// https://www.st.com/en/microcontrollers-microprocessors/stm32f303vc.html)
.into_af7_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh),
);
pins.1.internal_pull_up(&mut gpioa.pupdr, true);
let mut serial: SerialType =
Expand Down
6 changes: 3 additions & 3 deletions examples/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ fn main() -> ! {
// Configure pins for SPI
let sck = gpioc
.pc10
.into_af6_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);
.into_af_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);
let miso = gpioc
.pc11
.into_af6_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);
.into_af_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);
let mosi = gpioc
.pc12
.into_af6_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);
.into_af_push_pull(&mut gpioc.moder, &mut gpioc.otyper, &mut gpioc.afrh);

let mut spi = Spi::new(dp.SPI3, (sck, miso, mosi), 3.MHz(), clocks, &mut rcc.apb1);

Expand Down
9 changes: 4 additions & 5 deletions examples/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ fn main() -> ! {
usb_dp.set_low().ok();
delay(clocks.sysclk().0 / 100);

let usb_dm =
gpioa
.pa11
.into_af14_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
let usb_dp = usb_dp.into_af14_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
let usb_dm = gpioa
.pa11
.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);
let usb_dp = usb_dp.into_af_push_pull(&mut gpioa.moder, &mut gpioa.otyper, &mut gpioa.afrh);

let usb = Peripheral {
usb: dp.USB,
Expand Down
4 changes: 2 additions & 2 deletions src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ where
Rx: RxPin,
{
/// Create a new `bxcan::CAN` instance.
pub fn new(can: pac::CAN, tx: Tx, rx: Rx, apb1: &mut APB1) -> bxcan::Can<Self> {
pub fn new(can: pac::CAN, tx: Tx, rx: Rx, apb1: &mut APB1) -> Self {
pac::CAN::enable(apb1);
pac::CAN::reset(apb1);

bxcan::Can::builder(Can { can, tx, rx }).enable()
Can { can, tx, rx }
}

/// Releases the CAN peripheral and associated pins
Expand Down
Loading