|
3 | 3 | //! # API
|
4 | 4 | //!
|
5 | 5 | //! To use (most of) the peripheral API first you must get an *instance* of the peripheral. All the
|
6 |
| -//! core peripherals are modeled as singletons (there can only ever be, at most, one instance of |
7 |
| -//! them at any given point in time) and the only way to get an instance of them is through the |
8 |
| -//! [`Peripherals::take`](struct.Peripherals.html#method.take) method. |
| 6 | +//! core peripherals are modeled as singletons (there can only ever be, at most, one instance of any |
| 7 | +//! one of them at any given point in time) and the only way to get an instance of them is through |
| 8 | +//! the [`Peripherals::take`](struct.Peripherals.html#method.take) method. |
9 | 9 | //!
|
10 | 10 | //! ``` no_run
|
11 | 11 | //! extern crate cortex_m;
|
|
21 | 21 | //! This method can only be successfully called *once* -- this is why the method returns an
|
22 | 22 | //! `Option`. Subsequent calls to the method will result in a `None` value being returned.
|
23 | 23 | //!
|
| 24 | +//! ``` no_run |
| 25 | +//! extern crate cortex_m; |
| 26 | +//! |
| 27 | +//! use cortex_m::peripheral::Peripherals; |
| 28 | +//! |
| 29 | +//! fn main() { |
| 30 | +//! let ok = Peripherals::take().unwrap(); |
| 31 | +//! let panics = Peripherals::take().unwrap(); |
| 32 | +//! } |
| 33 | +//! ``` |
24 | 34 | //! A part of the peripheral API doesn't require access to a peripheral instance. This part of the
|
25 | 35 | //! API is provided as static methods on the peripheral types. One example is the
|
26 |
| -//! [`DWT::cyccnt`](struct.DWT.html#method.cyccnt) method. |
| 36 | +//! [`DWT::get_cycle_count`](struct.DWT.html#method.get_cycle_count) method. |
27 | 37 | //!
|
28 | 38 | //! ``` no_run
|
29 | 39 | //! extern crate cortex_m;
|
|
43 | 53 | //!
|
44 | 54 | //! The singleton property can be *unsafely* bypassed using the `ptr` static method which is
|
45 | 55 | //! available on all the peripheral types. This method is a useful building block for implementing
|
46 |
| -//! higher level and safe abstractions. |
| 56 | +//! safe higher level abstractions. |
47 | 57 | //!
|
48 | 58 | //! ``` no_run
|
49 | 59 | //! extern crate cortex_m;
|
|
0 commit comments