Code Monkey home page Code Monkey logo

stm32f4xx-hal's Introduction

stm32f4xx-hal

Crates.io Crates.io Released API docs Minimum Supported Rust Version dependency status Continuous integration

stm32f4xx-hal contains a multi device hardware abstraction on top of the peripheral access API for the STMicro STM32F4 series microcontrollers. The selection of the MCU is done by feature gates, typically specified by board support crates. Currently supported configurations are:

  • stm32f401
  • stm32f405
  • stm32f407
  • stm32f410
  • stm32f411
  • stm32f412
  • stm32f413
  • stm32f415
  • stm32f417
  • stm32f423
  • stm32f427
  • stm32f429
  • stm32f437
  • stm32f439
  • stm32f446
  • stm32f469
  • stm32f479

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.

Other optional features

  • rtic — support monotonic timers that can be used by RTIC framework.
  • defmt — implementation of defmt::Format for public enums and structures. See defmt.
  • can — bxCAN peripheral support. See bxcan.
  • i2s — I2S peripheral support. See stm32_i2s_v12x.
  • usb_fs or usb_hs — USB OTG FS/HS peripheral support. See synopsys-usb-otg.
  • fsmc_lcd — LCD support via FMC/FSMC peripheral. See display-interface.
  • sdio-host — SDIO peripheral support. See sdio-host.

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

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

Some of the implementation was shamelessly adapted from the stm32f1xx-hal crate originally started by Jorge Aparicio.

Setting up your project

Check if the BSP for your board exists in the stm32-rs page. If it exists, the stm32f4xx-hal crate should be already included, so you can use the bsp as BSP for your project.

Manually

Otherwise, create a new Rust project as you usually do with cargo init. The "hello world" of embedded development is usually to blink a LED. The code to do so is available in examples/delay-syst-blinky.rs. Copy that file to the main.rs of your project.

You also need to add some dependencies to your Cargo.toml:

[dependencies]
embedded-hal = "0.2"
nb = "1"
cortex-m = "0.7"
cortex-m-rt = "0.7"
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
panic-halt = "0.2"

[dependencies.stm32f4xx-hal]
version = "0.18.0"
features = ["stm32f407"] # replace the model of your microcontroller here
                         # and add other required features

We also need to tell Rust how to link our executable and how to lay out the result in memory. To accomplish all this, copy .cargo/config and memory.x from the stm32f4xx-hal repository to your project and make sure the sizes match up with the datasheet. Also note that there might be different kinds of memory which are not equal; to be on the safe side only specify the size of the first block at the specified address.

Fast start

To create empty project faster you could use cargo generate command. See stm32-template.

$ cargo generate --git https://github.com/burrbull/stm32-template/

Note that you need to know your chip full name.

License

0-clause BSD license.

stm32f4xx-hal's People

Contributors

burrbull avatar bors[bot] avatar therealprof avatar aurelj avatar samcrow avatar speedcrash100 avatar thalesfragoso avatar jkristell avatar disasm avatar psycowithespn avatar arkap avatar ryan-summers avatar alexxy avatar xoviat avatar no111u3 avatar yruamalairba avatar rursprung avatar hacknus avatar timbod7 avatar chemicstry avatar birkenfeld avatar qwerty19106 avatar eziopan avatar theunkn0wn1 avatar jamwaffles avatar texitoi avatar kalkyl avatar imihajlow avatar matoushybl avatar dimpolo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.