stm32f3xx-hal-STM32F3系列微控制器的外设访问API-Rust开发

  • U6_810570
    了解作者
  • 94.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 21:30
    上传日期
stm32f3xx-hal stm32f3xx-hal在STMicro STM32F3系列微控制器的外围访问API之上包含多设备硬件抽象stm32f3xx-hal stm32f3xx-hal在STMicro STM32F3系列微控制器的外围访问API之上包含多设备硬件抽象。 MCU的选择是通过功能门完成的,功能门通常由主板支持板条箱指定。 当前支持的配置为:stm32f301:check_mark:是! stm32f318:check_mark:是的! stm32f302:check_mark:是的! stm32f303:check_mark:是的! stm32f373:check_mark:是的! stm32f378:check_mark:是的! stm32f334:check_mark:是的! stm32f328:check_mark:是的! stm32f358:check_mark:是的! stm32f398:check_mark:是的! Ť
stm32f3xx-hal-master.zip
内容介绍
# `stm32f3xx-hal` [![Build Status](https://github.com/stm32-rs/stm32f3xx-hal/workflows/CI/badge.svg)](https://github.com/stm32-rs/stm32f3xx-hal/actions) [![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) `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. Currently supported configurations are: * 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. [`stm32f3`]: https://crates.io/crates/stm32f3 [`stm32f30x-hal`]: https://github.com/japaric/stm32f30x-hal [`embedded-hal`]: https://github.com/japaric/embedded-hal ## Getting Started ### Adding stm32f3xx-hal and other dependencies Cargo.toml: ```toml [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.7.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: ```toml [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).* #### Possible chips [comment]: # (Any changes here should be mirrored in src/lib.rs) Please select one of the following (`x` denotes any character in [a-z]): * stm32f301x6 * stm32f301x8 * stm32f318x8 * stm32f302x6 * stm32f302x8 * stm32f302xb * stm32f302xc * stm32f302xd * stm32f302xe * stm32f303x6 * stm32f303x8 * stm32f303xb * stm32f303xc * stm32f303xd * stm32f303xe * stm32f328x8 * stm32f358xc * stm32f398xe * stm32f373x8 * stm32f373xb * stm32f373xc * stm32f378xc * stm32f334x4 * stm32f334x6 * stm32f334x8 #### 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 subvariants without allowing for code that just doesn't run on other sub-vairants, they are distinct features that need to be specified. [user manual]: https://www.st.com/content/ccc/resource/technical/document/user_manual/8a/56/97/63/8d/56/41/73/DM00063382.pdf/files/DM00063382.pdf/jcr:content/translations/en.DM00063382.pdf ### Basic Usage ```rust #![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](examples) for more example programs. ## [Changelog](CHANGELOG.md) ## Minimum Supported Rust Version (MSRV) This crate is guaranteed to compile on stable Rust 1.51.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. --> <!-- As soon as the MSVR does not compile anymore, just bump it. --> <!-- Don't forget to also adjust the MSVR version in `.github/workflows/ci.yml` --> ## License [0-clause BSD license](LICENSE-0BSD.txt). ## Contributing ### Running Tests Tests are run via the integration test pattern and are executed on a target chip, rather than on a host system. First, install [probe-run](https://crates.io/crates/probe-run) via `cargo install probe-run`. Next, you'll need to modify `.cargo/config` to link defmt and use `probe-run` configured for your chip. See details within the comments in that file. Now, you can execute a test by setting your device, defmt, and any test specific features: ```bash cargo test --test rcc --features=stm32f303xc,defmt,rt ``` The result _always_ shows a backtrace, even in the case of success. Exit code of 0 means that the run was successful.
评论
    相关推荐
    • 一个示例项目,演示了 ESP32-S2 和 ESP32-C3 微控制器与 Rust 的集成。
      如果您已按照入门指南中的说明操作,请使用get_idf别名激活环境:get_idf接下来,为所需的 MCU 配置项目。对于 ESP32:idf.py set-target esp32 idf.py menuconfig对于 ESP32-S2:idf.py set-target esp32s2 idf.p
    • avrd:AVR设备定义
      Rust中定义AVR设备。 此板条箱可显示有关不同AVR微控制器的信息,因此可以实用地使用它。 您可以将此板条箱直接用作AVR裸机或不同体系结构上的依赖。 该库中定义的常量有助于在AVR芯片上进行原始IO端口操作。 ...
    • rubble:(即将成为)嵌入式Rust的BLE堆栈
      Rubble是用于嵌入式Rust的Bluetooth:registered:Low Energy兼容协议栈。 目前,Rubble支持Nordic的nRF52系列MCU。 但是,它的设计独立于硬件,因此始终欢迎其他MCU系列的支持工具。 注意:这些都没有通过蓝牙:...
    • mcu-manager:mcumgr的Rust端口,重点是CLI的可用性
      mcu-manager:mcumgr的Rust端口,重点是CLI的可用性
    • Rust 中实现免费和开放的音频编解码器 Opus。
      去做解码器编码器SIMD 优化重新打包器多流解码器多流编码器不支持 Opus 功能为了降低实现的复杂性,我们不支持以下很少使用的功能:定点运算——这个库只支持浮点运算(只影响没有适当浮点支持的廉价 MCU)。...
    • infrared:嵌入式Rust的红外远程控制库
      用于使用红外硬件解码器(例如Vishay TSOP *解码器)的Rust库,从而实现了对嵌入式项目的远程控制支持。 该库旨在与实现嵌入式Hal特性的任何MCU Hal一起使用,同时提供用于更有效的实现(例如输入捕获)使用它的...
    • hs-probe-firmware:纯Rust中的CMSIS-DAP实现
      hs-probe-firmware 用于CMSIS-DAP固件。 这包括通过高速(480 MBit / s)USB 2.0... turbo ,这会将MCU速度提高到216 MHz,而不是当前默认值72 MHz。 ... 要构建功能部件,请使用以下命令: cargo build --releas
    • keywing-rs:Rust中的Keyboard Featherwing的游乐场
      Rust中的键盘羽翼 这是一个在Rust中使用@ arturo182的Keyboard Featherwing的游乐场。 现在,我使用adafruit nrf52840 Express作为主要MCU
    • rust-lpc1768-examples:在带有应用板的 MBED LPC1768 上运行的 Rust 示例集合
      Rust LPC1768 示例 该项目是一个示例集合,显示 (Rust)[ ] 在 (MBED LPC1768)[ ] 上运行在(锌)[ ] 的帮助下。 一些示例期望 LPC1768 连接到(mbed 应用板...NXP LPC17xx MCU MBED LPC1768 MBED应用板 电路板引出线
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档