Skip to content

Commit 5dd8f0d

Browse files
committed
Discuss features in top level docs
1 parent bbc3d79 commit 5dd8f0d

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

src/lib.rs

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,30 @@
1717
//! - stm32f103
1818
//! - stm32f100
1919
//!
20-
//! ```toml
21-
//! [dependencies.stm32f1xx-hal]
22-
//! version = "0.2.1"
23-
//! features = ["stm32f103", "rt"]
24-
//! ```
20+
//! ## Usage
21+
//!
22+
//! This crate supports multiple microcontrollers in the
23+
//! stm32f1 family. Which specific microcontroller you want to build for has to be
24+
//! specified with a feature, for example `stm32f103`.
25+
//!
26+
//! If no microcontroller is specified, the crate will not compile.
27+
//!
28+
//! The currently supported variants are
29+
//!
30+
//! - `stm32f100`
31+
//! - `stm32f101`
32+
//! - `stm32f103`
33+
//!
34+
//! You may also need to specify the density of the device with `medium`, `high` or `xl`
35+
//! to enable certain peripherals. Generally the density can be determined by the 2nd character
36+
//! after the number in the device name (i.e. For STM32F103C6U, the 6 indicates a low-density
37+
//! device) but check the datasheet or CubeMX to be sure.
38+
//! * 4, 6 => low density, no feature required
39+
//! * 8, B => `medium` feature
40+
//! * C, D, E => `high` feature
41+
//! * F, G => `xl` feature
42+
//!
43+
//!
2544
//!
2645
//! [cortex-m-quickstart]: https://docs.rs/cortex-m-quickstart/0.3.1
2746
//!
@@ -36,7 +55,7 @@
3655
//! #![no_std]
3756
//! #![no_main]
3857
//!
39-
//! extern crate panic_halt;
58+
//! use panic_halt as _;
4059
//!
4160
//! use nb::block;
4261
//!
@@ -46,6 +65,7 @@
4665
//! timer::Timer,
4766
//! };
4867
//! use cortex_m_rt::entry;
68+
//! use embedded_hal::digital::v2::OutputPin;
4969
//!
5070
//! #[entry]
5171
//! fn main() -> ! {
@@ -54,25 +74,23 @@
5474
//! // Get access to the device specific peripherals from the peripheral access crate
5575
//! let dp = pac::Peripherals::take().unwrap();
5676
//!
57-
//! // Take ownership over the raw flash and rcc devices and convert them
58-
//! // into the corresponding HAL structs
77+
//! // Take ownership over the raw flash and rcc devices and convert them into the corresponding
78+
//! // HAL structs
5979
//! let mut flash = dp.FLASH.constrain();
6080
//! let mut rcc = dp.RCC.constrain();
6181
//!
62-
//! // Freeze the configuration of all the clocks in the system and store
63-
//! // the frozen frequencies in `clocks`
82+
//! // Freeze the configuration of all the clocks in the system and store the frozen frequencies in
83+
//! // `clocks`
6484
//! let clocks = rcc.cfgr.freeze(&mut flash.acr);
6585
//!
6686
//! // Acquire the GPIOC peripheral
6787
//! let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
6888
//!
69-
//! // Configure gpio C pin 13 as a push-pull output. The `crh` register is
70-
//! // passed to the function in order to configure the port. For pins 0-7,
71-
//! // crl should be passed instead.
89+
//! // Configure gpio C pin 13 as a push-pull output. The `crh` register is passed to the function
90+
//! // in order to configure the port. For pins 0-7, crl should be passed instead.
7291
//! let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
7392
//! // Configure the syst timer to trigger an update every second
74-
//! let mut timer = Timer::syst(cp.SYST, clocks)
75-
//! .start_count_down(1.hz());
93+
//! let mut timer = Timer::syst(cp.SYST, &clocks).start_count_down(1.hz());
7694
//!
7795
//! // Wait for the timer to trigger an update and change the state of the LED
7896
//! loop {

0 commit comments

Comments
 (0)