File tree Expand file tree Collapse file tree 4 files changed +39
-11
lines changed Expand file tree Collapse file tree 4 files changed +39
-11
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
48
48
0-clause as MIT conditions had to be met anyways. (🧂 IANAL). ([ #309 ] )
49
49
- Renamed ` Serial::raw_read ` to ` Serial::read_data_register ` . ([ #281 ] )
50
50
- Timer error type ` AlreadyCancled ` is no longer public constructable. ([ #281 ] )
51
+ - Seal ` FlashExt ` and ` RccExt ` traits. These are no longer implementable by
52
+ a user of this crate. ([ #281 ] )
51
53
- Move ADC from a macro to a generic implementation, meaning that
52
54
it is possible to obtain an ADC instance via ` Adc::new ` instead of
53
55
` Adc::adc1 ` . ([ #281 ] )
Original file line number Diff line number Diff line change 4
4
5
5
use crate :: pac:: { flash, FLASH } ;
6
6
7
- /// Extension trait to constrain the FLASH peripheral
8
- pub trait FlashExt {
9
- /// Constrains the FLASH peripheral to play nicely with the other abstractions
7
+ impl crate :: private:: Sealed for FLASH { }
8
+
9
+ /// Extension trait to constrain the [`FLASH`] peripheral
10
+ pub trait FlashExt : crate :: private:: Sealed {
11
+ /// Constrains the [`FLASH`] peripheral.
12
+ ///
13
+ /// Consumes the [`pac::FLASH`] peripheral and converts it to a [`HAL`] internal type
14
+ /// constraining it's public access surface to fit the design of the [`HAL`].
15
+ ///
16
+ /// [`pac::FLASH`]: `crate::pac::FLASH`
17
+ /// [`HAL`]: `crate`
10
18
fn constrain ( self ) -> Parts ;
11
19
}
12
20
@@ -31,7 +39,7 @@ pub struct ACR {
31
39
32
40
impl ACR {
33
41
pub ( crate ) fn acr ( & mut self ) -> & flash:: ACR {
34
- // NOTE(unsafe) this proxy grants exclusive access to this register
42
+ // SAFETY: This proxy grants exclusive access to this register
35
43
unsafe { & ( * FLASH :: ptr ( ) ) . acr }
36
44
}
37
45
}
Original file line number Diff line number Diff line change 4
4
`stm32f3xx-hal` contains a multi device hardware abstraction on top of the
5
5
peripheral access API for the STMicro [STM32F3][stm] series microcontrollers.
6
6
7
+ ## Philosophie
8
+
9
+ HAL (meaning **H**ardware **A**bstraction **L**ayer) is a generic term used in many contexts,
10
+ but in the specific context of this crate, it is meant to abstract away the control exposed
11
+ by the devices "[peripheral access crate](`crate::pac`)" to simplify initialization routines,
12
+ with a robust interface avoiding miss-configurations while still not abstracting to much away.
13
+
14
+ Also this crate's goal is to integrate well with the rest of the rust embedded ecosystem,
15
+ for example by implementing the [`embedded_hal`] traits or using crates, like [`embedded_time`],
16
+ or [`rtcc`].
17
+
7
18
[stm]: https://www.st.com/en/microcontrollers-microprocessors/stm32f3-series.html
8
19
9
- ## Basic Usagee
20
+ ## Basic Usage
10
21
11
22
```rust
12
23
#![no_std]
Original file line number Diff line number Diff line change @@ -66,9 +66,17 @@ use core::convert::TryInto;
66
66
use crate :: flash:: ACR ;
67
67
use crate :: time:: rate:: * ;
68
68
69
- /// Extension trait that constrains the `RCC` peripheral
70
- pub trait RccExt {
71
- /// Constrains the `RCC` peripheral so it plays nicely with the other abstractions
69
+ impl crate :: private:: Sealed for RCC { }
70
+
71
+ /// Extension trait that constrains the []`RCC`] peripheral
72
+ pub trait RccExt : crate :: private:: Sealed {
73
+ /// Constrains the [`RCC`] peripheral.
74
+ ///
75
+ /// Consumes the [`pac::RCC`] peripheral and converts it to a [`HAL`] internal type
76
+ /// constraining it's public access surface to fit the design of the `HAL`.
77
+ ///
78
+ /// [`pac::RCC`]: `crate::pac::RCC`
79
+ /// [`HAL`]: `crate`
72
80
fn constrain ( self ) -> Rcc ;
73
81
}
74
82
@@ -88,9 +96,8 @@ impl RccExt for RCC {
88
96
89
97
/// Constrained RCC peripheral
90
98
///
91
- /// An instance of this struct is acquired by calling the
92
- /// [`constrain`](RccExt::constrain) function on the
93
- /// [`RCC`](crate::pac::RCC) struct.
99
+ /// An instance of this struct is acquired by calling the [`constrain`](RccExt::constrain) function
100
+ /// on the [`RCC`](crate::pac::RCC) struct.
94
101
///
95
102
/// ```
96
103
/// let dp = pac::Peripherals::take().unwrap();
You can’t perform that action at this time.
0 commit comments