Skip to content

Commit 969d634

Browse files
authored
Merge pull request #170 from Sh3Rm4n/doc-n-msvr
Improve documentation and set MSRV
2 parents 403ab19 + 7edffdc commit 969d634

File tree

10 files changed

+189
-61
lines changed

10 files changed

+189
-61
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ jobs:
4949
command: check
5050
args: --features=${{ matrix.mcu }},${{ matrix.features }} --lib --examples
5151

52+
# This is our MSRV. However this is only for documentation
53+
# purposes and should be increased if newer features are used.
54+
# This should not stop anyone from bumping the MSRV.
55+
check-msrv:
56+
name: Check MSRV
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v2
60+
- uses: actions-rs/toolchain@v1
61+
with:
62+
toolchain: 1.48.0
63+
target: thumbv7em-none-eabihf
64+
override: true
65+
profile: minimal
66+
- uses: actions-rs/cargo@v1
67+
with:
68+
command: check
69+
args: --features=stm32f303xc,stm32-usbd,rt,can --lib --examples
70+
5271
clippy:
5372
name: Clippy
5473
runs-on: ubuntu-latest
@@ -65,7 +84,7 @@ jobs:
6584
with:
6685
token: ${{ secrets.GITHUB_TOKEN }}
6786
args: >
68-
--features=stm32f303xc,rt,stm32-usbd --lib --examples
87+
--features=stm32f303xc,rt,stm32-usbd,can --lib --examples
6988
-- -D warnings
7089
7190
rustfmt:

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3131

3232
### Fixed
3333

34-
- Fixed [#151][] not being able to generate 72 MHz HCLK for stm32f303xc devices
34+
- Fixed [#151][] not being able to generate 72 MHz HCLK for stm32f303xc devices
3535
([#152](https://github.com/stm32-rs/stm32f3xx-hal/pull/152))
3636

3737
[#151]: https://github.com/stm32-rs/stm32f3xx-hal/issues/151
@@ -42,6 +42,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4242
`stm32f378` targets. ([#99](https://github.com/stm32-rs/stm32f3xx-hal/pull/99))
4343
- Removed SPI1 support for `stm32f302x6` and `stm32f302x8` sub-targets
4444
and `stm32f318` target. ([#99](https://github.com/stm32-rs/stm32f3xx-hal/pull/99))
45+
- This release requires 1.48, as intra-doc-links are now used internally.
46+
Until now, no MSRV was tracked. This has changed now. This however does
47+
not mean, that we guarantee any MSRV policy. It is rather for documentation
48+
purposes and if a new useful feature arises, we will increase the MSRV.
49+
([#170](https://github.com/stm32-rs/stm32f3xx-hal/pull/170))
4550

4651
## [v0.5.0] - 2020-07-21
4752

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ exclude = [
1919
]
2020

2121
[package.metadata.docs.rs]
22-
features = ["stm32f303xc", "rt", "stm32-usbd"]
22+
features = ["stm32f303xc", "rt", "stm32-usbd", "can"]
2323
targets = ["thumbv7em-none-eabihf"]
2424

2525
[dependencies]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# stm32f3xx-hal
1+
# `stm32f3xx-hal`
22

33
[![Build Status](https://github.com/stm32-rs/stm32f3xx-hal/workflows/CI/badge.svg)](https://github.com/stm32-rs/stm32f3xx-hal/actions)
44
[![Crate](https://img.shields.io/crates/v/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal)
@@ -38,6 +38,8 @@ Almost all of the implementation was shamelessly adapted from the
3838
[`stm32f30x-hal`]: https://github.com/japaric/stm32f30x-hal
3939
[`embedded-hal`]: https://github.com/japaric/embedded-hal
4040

41+
## [Changelog](CHANGELOG.md)
42+
4143
## Selecting the right chip
4244

4345
This crate requires you to specify your target chip as a feature.

examples/can.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn main() -> ! {
8181
}
8282

8383
let data: [u8; 1] = [counter];
84-
let frame = CanFrame::data_frame(CanId::BaseId(ID.into()), &data);
84+
let frame = CanFrame::data_frame(CanId::BaseId(ID), &data);
8585

8686
block!(can_tx.transmit(&frame)).expect("Cannot send CAN frame");
8787
}

src/can.rs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
//! Controller Area Network
2+
//!
3+
//! CAN is currently not enabled by default, and
4+
//! can be enabled by the `can` feature.
5+
//!
6+
//! It is a implementation of the [`embedded_hal_can`][can] traits.
7+
//!
8+
//! [can]: embedded_hal_can
29
pub use embedded_hal_can::{self, Filter, Frame, Id, Receiver, Transmitter};
310

411
use crate::gpio::gpioa;
@@ -10,10 +17,11 @@ use nb::{self, Error};
1017

1118
use core::sync::atomic::{AtomicU8, Ordering};
1219

13-
const EXID_MASK: u32 = 0b11111_11111100_00000000_00000000;
20+
const EXID_MASK: u32 = 0b1_1111_1111_1100_0000_0000_0000_0000;
1421
const MAX_EXTENDED_ID: u32 = 0x1FFF_FFFF;
1522

16-
/// A CAN identifier, which can be either 11 or 27 (extended) bits. u16 and u32 respectively are used here despite the fact that the upper bits are unused.
23+
/// A CAN identifier, which can be either 11 or 27 (extended) bits.
24+
/// u16 and u32 respectively are used here despite the fact that the upper bits are unused.
1725
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
1826
pub enum CanId {
1927
BaseId(u16),
@@ -22,14 +30,16 @@ pub enum CanId {
2230

2331
/// A CAN frame consisting of a destination ID and up to 8 bytes of data.
2432
///
25-
/// Currently, we always allocate a fixed size array for each frame regardless of actual size, but this could be improved in the future using const-generics.
33+
/// Currently, we always allocate a fixed size array for each frame regardless
34+
/// of actual size, but this could be improved in the future using const-generics.
2635
#[derive(Debug, Clone, Eq, PartialEq)]
2736
pub struct CanFrame {
2837
pub id: CanId,
2938
pub data: Vec<u8, U8>,
3039
}
3140

32-
/// Represents the operating mode of a CAN filter, which can either contain a list of identifiers, or a mask to match on.
41+
/// Represents the operating mode of a CAN filter, which can either contain a
42+
/// list of identifiers, or a mask to match on.
3343
pub enum FilterMode {
3444
Mask,
3545
List,
@@ -58,7 +68,8 @@ pub struct Can {
5868
_tx: gpioa::PA12<AF9>,
5969
}
6070

61-
/// A CAN FIFO which is used to receive and buffer messages from the CAN network that match on of the assigned filters.
71+
/// A CAN FIFO which is used to receive and buffer messages from the CAN
72+
/// network that match on of the assigned filters.
6273
pub struct CanFifo {
6374
idx: usize,
6475
}
@@ -140,9 +151,12 @@ impl embedded_hal_can::Filter for CanFilter {
140151
CanFilter::new(CanFilterData::AcceptAll)
141152
}
142153

143-
// TODO: Constructing filters like this is fairly limiting because ideally we would have the full "filter state" available, so for non-extended filters this could be 2 masks and filters or 4 ids for id lists
154+
// TODO: Constructing filters like this is fairly limiting because ideally
155+
// we would have the full "filter state" available, so for non-extended
156+
// filters this could be 2 masks and filters or 4 ids for id lists
144157

145-
/// Constuct a mask filter. This method accepts two parameters, the mask which designates which bits are actually matched againts and the filter, with the actual bits to match.
158+
/// Constuct a mask filter. This method accepts two parameters, the mask which designates which
159+
/// bits are actually matched againts and the filter, with the actual bits to match.
146160
fn from_mask(mask: u32, filter: u32) -> Self {
147161
assert!(
148162
mask < MAX_EXTENDED_ID,
@@ -159,7 +173,8 @@ impl embedded_hal_can::Filter for CanFilter {
159173
}
160174

161175
impl CanFilter {
162-
/// Create a new filter with no assigned index. To actually active the filter call `Receiver::set_filter`, which will assign an index.
176+
/// Create a new filter with no assigned index. To actually active the filter call
177+
/// [`Receiver::set_filter`], which will assign an index.
163178
pub fn new(data: CanFilterData) -> CanFilter {
164179
CanFilter { data, index: None }
165180
}
@@ -179,7 +194,8 @@ impl CanFilterData {
179194
CanFilterData::AcceptAll => 0,
180195
CanFilterData::ExtendedMaskFilter(filter, _) => filter << 3,
181196
CanFilterData::MaskFilter(filter, mask) => {
182-
let shifted_filter = ((*filter as u32) << 5) & (u16::max_value() as u32); // Only use lower 16 bits
197+
// Only use lower 16 bits
198+
let shifted_filter = ((*filter as u32) << 5) & (u16::max_value() as u32);
183199
let shifted_mask = ((*mask as u32) << 5) << 16;
184200

185201
shifted_filter | shifted_mask
@@ -195,8 +211,10 @@ impl CanFilterData {
195211
match self {
196212
CanFilterData::AcceptAll => Some(0),
197213
CanFilterData::ExtendedMaskFilter(_, mask) => Some(mask << 3),
198-
CanFilterData::MaskFilter(_, _mask) => None, // TODO: We should be able to fill this register with a second filter/mask pair
199-
CanFilterData::IdFilter(_id) => None, // TODO: This sucks, we need more info here to figure out the correct value of fr2
214+
// TODO: We should be able to fill this register with a second filter/mask pair
215+
CanFilterData::MaskFilter(_, _mask) => None,
216+
// TODO: This sucks, we need more info here to figure out the correct value of fr2
217+
CanFilterData::IdFilter(_id) => None,
200218
}
201219
}
202220
}
@@ -284,7 +302,7 @@ impl Can {
284302
_tx: self._tx,
285303
};
286304

287-
return (transmitter, fifo0, fifo1);
305+
(transmitter, fifo0, fifo1)
288306
}
289307

290308
pub fn free(self) -> (stm32::CAN, gpioa::PA11<AF9>, gpioa::PA12<AF9>) {
@@ -335,7 +353,7 @@ impl embedded_hal_can::Transmitter for CanTransmitter {
335353
}),
336354
}
337355

338-
if let Some(_) = frame.data() {
356+
if frame.data().is_some() {
339357
for j in 0..frame.data.len() {
340358
let val = &frame.data[j];
341359

src/gpio.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! General Purpose Input / Output
22
//!
33
//! To use the GPIO pins, you first need to configure the GPIO bank (GPIOA, GPIOB, ...) that you
4-
//! are interested in. This is done using the [GpioExt::split](trait.GpioExt.html#tymethod.split) function.
4+
//! are interested in. This is done using the [`GpioExt::split`] function.
55
//!
66
//! ```
77
//! let dp = pac::Peripherals::take().unwrap();
@@ -10,10 +10,10 @@
1010
//! let mut gpioa = dp.GPIOA.split(&mut rcc.ahb);
1111
//! ```
1212
//!
13-
//! The resulting [Parts](gpioa/struct.Parts.html) struct contains one field for each
13+
//! The resulting [Parts](gpioa::Parts) struct contains one field for each
1414
//! pin, as well as some shared registers.
1515
//!
16-
//! To use a pin, first use the relevant `into_...` method of the [pin](gpioa/struct.PA0.html).
16+
//! To use a pin, first use the relevant `into_...` method of the [pin](gpioa::PA0).
1717
//!
1818
//! ```rust
1919
//! let pa0 = gpioa.pa0.into_push_pull_output(&mut gpioa.moder, &mut gpioa.otyper);
@@ -24,8 +24,8 @@
2424
//!
2525
//! For a complete example, see [examples/toggle.rs]
2626
//!
27-
//! [InputPin]: ../prelude/trait._embedded_hal_digital_InputPin.html
28-
//! [OutputPin]: ../prelude/trait._embedded_hal_digital_OutputPin.html
27+
//! [InputPin]: embedded_hal::digital::v2::InputPin
28+
//! [OutputPin]: embedded_hal::digital::v2::OutputPin
2929
//! [examples/toggle.rs]: https://github.com/stm32-rs/stm32f3xx-hal/blob/v0.4.3/examples/toggle.rs
3030
3131
use core::convert::Infallible;
@@ -43,7 +43,7 @@ use crate::rcc::AHB;
4343

4444
/// Extension trait to split a GPIO peripheral in independent pins and registers
4545
pub trait GpioExt {
46-
/// The to split the GPIO into
46+
/// The Parts to split the GPIO peripheral into
4747
type Parts;
4848

4949
/// Splits the GPIO block into independent pins and registers

src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
/*!
2+
# stm32f3xx-hal
3+
4+
`stm32f3xx-hal` contains a multi device hardware abstraction on top of the
5+
peripheral access API for the STMicro [STM32F3][stm] series microcontrollers. The
6+
selection of the MCU is done by [feature][f] gates
7+
8+
[f]: #selecting-the-right-chip
9+
[stm]: https://www.st.com/en/microcontrollers-microprocessors/stm32f3-series.html
10+
211
# Selecting the right chip
312
413
This crate requires you to specify your target chip as a feature.
@@ -87,25 +96,32 @@ pub use nb;
8796
pub use nb::block;
8897

8998
#[cfg(any(feature = "stm32f301", feature = "stm32f318"))]
99+
/// Peripheral access
90100
pub use stm32f3::stm32f301 as pac;
91101

92102
#[cfg(feature = "stm32f302")]
103+
/// Peripheral access
93104
pub use stm32f3::stm32f302 as pac;
94105

95106
#[cfg(feature = "stm32f303")]
107+
/// Peripheral access
96108
pub use stm32f3::stm32f303 as pac;
97109

98110
#[cfg(any(feature = "stm32f373", feature = "stm32f378"))]
111+
/// Peripheral access
99112
pub use stm32f3::stm32f373 as pac;
100113

101114
#[cfg(feature = "stm32f334")]
115+
/// Peripheral access
102116
pub use stm32f3::stm32f3x4 as pac;
103117

104118
#[cfg(any(feature = "stm32f328", feature = "stm32f358", feature = "stm32f398"))]
119+
/// Peripheral access
105120
pub use stm32f3::stm32f3x8 as pac;
106121

107122
#[cfg(feature = "device-selected")]
108123
#[deprecated(since = "0.5.0", note = "please use `pac` instead")]
124+
/// Peripheral access
109125
pub use crate::pac as stm32;
110126

111127
// Enable use of interrupt macro

0 commit comments

Comments
 (0)