stm32f3xx-hal

适用于 STM32 F3 系列所有 MCU 的 Rust 嵌入式 HAL。「A Rust embedded-hal HAL for all MCUs in the STM32 F3 family」

  • 所有者: stm32-rs/stm32f3xx-hal
  • 平台: Embedded Systems
  • 许可证: Apache License 2.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

stm32f3xx-hal

Build Status
Crate
Docs
Crates.io
Minimum Supported Rust Version

stm32f3xx-hal contains a multi device hardware abstraction on top of the
peripheral access API for the STMicro STM32F3 series microcontrollers. The
selection of the MCU is done by feature gates, typically specified by board
support crates. An excerpt of supported chip variants:

  • stm32f301
  • stm32f318
  • stm32f302
  • stm32f303
  • stm32f373
  • stm32f378
  • stm32f334
  • stm32f328
  • stm32f358
  • stm32f398

The idea behind this crate is to gloss over the slight differences in the
various peripherals available on those MCUs so a HAL can be written for all
chips in that same family without having to cut and paste crates for every
single model.

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

This crate relies on Adam Greigs fantastic stm32f3 crate to provide
appropriate register definitions and implements a partial set of the
embedded-hal traits.

Almost all of the implementation was shamelessly adapted from the
stm32f30x-hal crate by Jorge Aparicio.

Getting Started

Adding stm32f3xx-hal and other dependencies

Cargo.toml:

[package]
# ...
resolver = "2"

[dependencies]
cortex-m = "0.7.2"
cortex-m-rt = { version = "0.6.13", features = ["device"] }
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2.0"
# Replace stm32f303xc with your target chip, see next section for more info
stm32f3xx-hal = { version = "0.9.0", features = ["ld", "rt", "stm32f303xc"] }

We also need to tell Rust about target architecture and how to link our
executable by creating .cargo/config.

.cargo/config:

[target.thumbv7em-none-eabihf]
rustflags = [
  "-C", "link-arg=-Tlink.x",
]

[build]
target = "thumbv7em-none-eabihf"

Selecting the right chip

This crate requires you to specify your target chip as a feature.

Example: The STM32F3Discovery board has a STM32F303VCT6 chip according to the
user manual. So you need to specify stm32f303xc in your Cargo.toml
(note that VC → xc).

All possible chip variants are selectable via cargo features.
You can find a list here, in the docs.

Note

  1. This features are mutually exclusive. Only one feature / chip variant can be
    chosen.
  2. You have to choose exactly one feature to build this crate at all.

Background

For some of the stm32f3xx chips there are sub-variants that differ in
functionality, peripheral use and hence 'under the hood' implementation.
To allow the full use of all peripherals on certain sub-variants without
allowing for code that just doesn't run on other sub-variants, they are
distinct features that need to be specified.

Basic Usage

#![no_std]
#![no_main]

use cortex_m::asm;
use cortex_m_rt::entry;
use panic_halt as _;
use stm32f3xx_hal::{self as hal, pac, prelude::*};

#[entry]
fn main() -> ! {
      let dp = pac::Peripherals::take().unwrap();

      let mut rcc = dp.RCC.constrain();
      let mut gpioe = dp.GPIOE.split(&mut rcc.ahb);

      let mut led = gpioe
            .pe13
            .into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);

      loop {
            led.toggle().unwrap();
            asm::delay(8_000_000);
      }
}

See the examples folder for more example programs.

Changelog

Minimum Supported Rust Version (MSRV)

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.

Contributing

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.

主要指标

概览
名称与所有者stm32-rs/stm32f3xx-hal
主编程语言Rust
编程语言Rust (语言数: 3)
平台
许可证Apache License 2.0
所有者活动
创建于2019-04-01 01:23:58
推送于2024-07-24 20:44:13
最后一次提交2023-11-30 21:11:26
发布数25
最新版本名称v0.10.0 (发布于 2023-11-30 21:11:59)
第一版名称v0.1.1 (发布于 2019-12-24 01:02:49)
用户参与
星数173
关注者数7
派生数69
提交数1k
已启用问题?
问题数110
打开的问题数35
拉请求数211
打开的拉请求数21
关闭的拉请求数31
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?