|
7 | 7 | //! them at any given point in time) and the only way to get an instance of them is through the
|
8 | 8 | //! [`Peripherals::take`](struct.Peripherals.html#method.take) method.
|
9 | 9 | //!
|
10 |
| -//! ``` ignore |
| 10 | +//! ``` no_run |
| 11 | +//! extern crate cortex_m; |
| 12 | +//! |
| 13 | +//! use cortex_m::peripheral::Peripherals; |
| 14 | +//! |
11 | 15 | //! fn main() {
|
12 |
| -//! let peripherals = Peripherals::take(); |
13 |
| -//! peripherals.dwt.enable_cycle_counter(); |
| 16 | +//! let mut peripherals = Peripherals::take().unwrap(); |
| 17 | +//! peripherals.DWT.enable_cycle_counter(); |
14 | 18 | //! }
|
15 | 19 | //! ```
|
16 | 20 | //!
|
|
21 | 25 | //! API is provided as static methods on the peripheral types. One example is the
|
22 | 26 | //! [`DWT::cyccnt`](struct.DWT.html#method.cyccnt) method.
|
23 | 27 | //!
|
24 |
| -//! ``` ignore |
| 28 | +//! ``` no_run |
| 29 | +//! extern crate cortex_m; |
| 30 | +//! |
| 31 | +//! use cortex_m::peripheral::{DWT, Peripherals}; |
| 32 | +//! |
25 | 33 | //! fn main() {
|
26 | 34 | //! {
|
27 |
| -//! let peripherals = Peripherals::take().unwrap(); |
| 35 | +//! let mut peripherals = Peripherals::take().unwrap(); |
28 | 36 | //! peripherals.DWT.enable_cycle_counter();
|
29 | 37 | //! } // all the peripheral singletons are destroyed here
|
30 | 38 | //!
|
31 | 39 | //! // but this method can be called without a DWT instance
|
32 |
| -//! let cyccnt = DWT::cyccnt(); |
| 40 | +//! let cyccnt = DWT::get_cycle_count(); |
33 | 41 | //! }
|
34 | 42 | //! ```
|
35 | 43 | //!
|
36 | 44 | //! The singleton property can be *unsafely* bypassed using the `ptr` static method which is
|
37 | 45 | //! available on all the peripheral types. This method is a useful building block for implementing
|
38 | 46 | //! higher level and safe abstractions.
|
39 | 47 | //!
|
40 |
| -//! ``` ignore |
| 48 | +//! ``` no_run |
| 49 | +//! extern crate cortex_m; |
| 50 | +//! |
| 51 | +//! use cortex_m::peripheral::{DWT, Peripherals}; |
| 52 | +//! |
41 | 53 | //! fn main() {
|
42 | 54 | //! {
|
43 |
| -//! let peripherals = Peripherals::take().unwrap(); |
| 55 | +//! let mut peripherals = Peripherals::take().unwrap(); |
44 | 56 | //! peripherals.DWT.enable_cycle_counter();
|
45 | 57 | //! } // all the peripheral singletons are destroyed here
|
46 | 58 | //!
|
|
0 commit comments