|
17 | 17 | //! - stm32f103
|
18 | 18 | //! - stm32f100
|
19 | 19 | //!
|
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 | +//! |
25 | 44 | //!
|
26 | 45 | //! [cortex-m-quickstart]: https://docs.rs/cortex-m-quickstart/0.3.1
|
27 | 46 | //!
|
|
36 | 55 | //! #![no_std]
|
37 | 56 | //! #![no_main]
|
38 | 57 | //!
|
39 |
| -//! extern crate panic_halt; |
| 58 | +//! use panic_halt as _; |
40 | 59 | //!
|
41 | 60 | //! use nb::block;
|
42 | 61 | //!
|
|
46 | 65 | //! timer::Timer,
|
47 | 66 | //! };
|
48 | 67 | //! use cortex_m_rt::entry;
|
| 68 | +//! use embedded_hal::digital::v2::OutputPin; |
49 | 69 | //!
|
50 | 70 | //! #[entry]
|
51 | 71 | //! fn main() -> ! {
|
|
54 | 74 | //! // Get access to the device specific peripherals from the peripheral access crate
|
55 | 75 | //! let dp = pac::Peripherals::take().unwrap();
|
56 | 76 | //!
|
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 |
59 | 79 | //! let mut flash = dp.FLASH.constrain();
|
60 | 80 | //! let mut rcc = dp.RCC.constrain();
|
61 | 81 | //!
|
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` |
64 | 84 | //! let clocks = rcc.cfgr.freeze(&mut flash.acr);
|
65 | 85 | //!
|
66 | 86 | //! // Acquire the GPIOC peripheral
|
67 | 87 | //! let mut gpioc = dp.GPIOC.split(&mut rcc.apb2);
|
68 | 88 | //!
|
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. |
72 | 91 | //! let mut led = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
|
73 | 92 | //! // 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()); |
76 | 94 | //!
|
77 | 95 | //! // Wait for the timer to trigger an update and change the state of the LED
|
78 | 96 | //! loop {
|
|
0 commit comments