1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
//! # HAL for the STM32F1 family of microcontrollers //! //! This is an implementation of the [`embedded-hal`] traits for the STM32F1 family of //! microcontrollers. //! //! [`embedded-hal`]: https://crates.io/crates/embedded-hal //! //! # Usage //! //! ## Building an application (binary crate) //! //! Follow the [cortex-m-quickstart] instructions, add this crate as a dependency //! and make sure you enable the "rt" Cargo feature of this crate. Also select which //! microcontroller you will be using by using the corresponding feature. The currently //! supported microcontrollers are: //! //! - stm32f103 //! - stm32f100 //! //! ```toml //! [dependencies.stm32f1xx-hal] //! version = "0.2.1" //! features = ["stm32f103", "rt"] //! ``` //! //! [cortex-m-quickstart]: https://docs.rs/cortex-m-quickstart/0.3.1 //! //! ## Usage example //! //! The following example blinks an LED connected to PC13 which is where the LED is connected on the //! [blue_pill] board. If you are testing on a different breakout board, you may need //! to change the pin accordingly. //! //! //! ```rust //! #![no_std] //! #![no_main] //! //! extern crate panic_halt; //! //! use nb::block; //! //! use stm32f1xx_hal::{ //! prelude::*, //! pac, //! timer::Timer, //! }; //! use cortex_m_rt::entry; //! //! #[entry] //! fn main() -> ! { //! // Get access to the core peripherals from the cortex-m crate //! let cp = cortex_m::Peripherals::take().unwrap(); //! // Get access to the device specific peripherals from the peripheral access crate //! let dp = pac::Peripherals::take().unwrap(); //! //! // Take ownership over the raw flash and rcc devices and convert them //! // into the corresponding HAL structs //! let mut flash = dp.FLASH.constrain(); //! let mut rcc = dp.RCC.constrain(); //! //! // Freeze the configuration of all the clocks in the system and store //! // the frozen frequencies in `clocks` //! let clocks = rcc.cfgr.freeze(&mut flash.acr); //! //! // Acquire the GPIOC peripheral //! let mut gpioc = dp.GPIOC.split(&mut rcc.apb2); //! //! // Configure gpio C pin 13 as a push-pull output. The `crh` register is //! // passed to the function in order to configure the port. For pins 0-7, //! // crl should be passed instead. //! let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh); //! // Configure the syst timer to trigger an update every second //! let mut timer = Timer::syst(cp.SYST, 1.hz(), clocks); //! //! // Wait for the timer to trigger an update and change the state of the LED //! loop { //! block!(timer.wait()).unwrap(); //! led.set_high(); //! block!(timer.wait()).unwrap(); //! led.set_low(); //! } //! } //! ``` //! //! [blue_pill]: http://wiki.stm32duino.com/index.php?title=Blue_Pill //! //! # More examples //! //! See the [examples] folder. //! //! [examples]: https://github.com/stm32-rs/stm32f1xx-hal/tree/master/examples #![no_std] #[cfg(feature = "device-selected")] use embedded_hal as hal; #[cfg(feature = "stm32f100")] pub use stm32f1::stm32f100 as pac; #[cfg(feature = "stm32f101")] pub use stm32f1::stm32f101 as pac; #[cfg(feature = "stm32f103")] pub use stm32f1::stm32f103 as pac; #[cfg(feature = "device-selected")] pub use crate::pac as device; #[cfg(feature = "device-selected")] pub use crate::pac as stm32; #[cfg(feature = "device-selected")] pub mod adc; #[cfg(feature = "device-selected")] pub mod afio; #[cfg(feature = "device-selected")] pub mod backup_domain; #[cfg(feature = "device-selected")] pub mod bb; #[cfg(feature = "device-selected")] pub mod delay; #[cfg(feature = "device-selected")] pub mod dma; #[cfg(feature = "device-selected")] pub mod flash; #[cfg(feature = "device-selected")] pub mod gpio; #[cfg(feature = "device-selected")] pub mod i2c; #[cfg(feature = "device-selected")] pub mod prelude; #[cfg(feature = "device-selected")] pub mod pwm; #[cfg(feature = "device-selected")] pub mod pwm_input; #[cfg(feature = "device-selected")] pub mod qei; #[cfg(feature = "device-selected")] pub mod rcc; #[cfg(feature = "device-selected")] pub mod rtc; #[cfg(feature = "device-selected")] pub mod serial; #[cfg(feature = "device-selected")] pub mod spi; #[cfg(feature = "device-selected")] pub mod time; #[cfg(feature = "device-selected")] pub mod timer; #[cfg(feature = "device-selected")] pub mod watchdog;