Skip to content

Commit 731e239

Browse files
authored
Merge pull request #435 from stm32-rs/gpio_h
updates
2 parents 8f3f3be + 9e3f1f4 commit 731e239

File tree

10 files changed

+39
-16
lines changed

10 files changed

+39
-16
lines changed

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"rust.all_targets": false,
3+
"rust.target": "thumbv7em-none-eabi",
4+
"rust.all_features": false,
5+
"rust.features": [
6+
"rtic",
7+
"stm32f103",
8+
"medium"
9+
],
10+
"rust-analyzer.checkOnSave.allTargets": false,
11+
"rust-analyzer.checkOnSave.extraArgs": [
12+
"--target",
13+
"thumbv7em-none-eabi"
14+
],
15+
"rust-analyzer.cargo.features": [
16+
"rtic",
17+
"stm32f103",
18+
"medium"
19+
]
20+
}

examples/gpio_input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ fn main() -> ! {
6060
key_up = false;
6161
delay.delay_ms(10u8);
6262
match key_result {
63-
(x, _) if x == true => red_led.toggle(),
64-
(_, y) if y == true => green_led.toggle(),
63+
(true, _) => red_led.toggle(),
64+
(_, true) => green_led.toggle(),
6565
(_, _) => (),
6666
}
6767
} else if !key_result.0 && !key_result.1 {

src/adc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ pub struct Adc<ADC> {
2828
clocks: Clocks,
2929
}
3030

31-
#[derive(Clone, Copy, Debug, PartialEq)]
32-
#[allow(non_camel_case_types)]
3331
/// ADC sampling time
3432
///
3533
/// Options for the sampling time, each is T + 0.5 ADC clock cycles.
34+
#[allow(non_camel_case_types)]
35+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3636
pub enum SampleTime {
3737
/// 1.5 cycles sampling time
3838
T_1,
@@ -75,7 +75,7 @@ impl From<SampleTime> for u8 {
7575
}
7676
}
7777

78-
#[derive(Clone, Copy, Debug, PartialEq)]
78+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
7979
/// ADC data register alignment
8080
pub enum Align {
8181
/// Right alignment of output data
@@ -169,7 +169,7 @@ adc_pins!(pac::ADC3,
169169
);
170170

171171
/// Stored ADC config can be restored using the `Adc::restore_cfg` method
172-
#[derive(Copy, Clone, Debug, PartialEq, Default)]
172+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
173173
pub struct StoredConfig(SampleTime, Align);
174174

175175
macro_rules! adc_hal {

src/bb.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const PERI_BIT_BAND_BASE: usize = 0x4200_0000;
1818
/// # Safety
1919
///
2020
/// Some registers have reserved bits which should not be modified.
21+
#[inline]
2122
pub unsafe fn clear<T>(register: *const T, bit: u8) {
2223
write(register, bit, false);
2324
}
@@ -27,6 +28,7 @@ pub unsafe fn clear<T>(register: *const T, bit: u8) {
2728
/// # Safety
2829
///
2930
/// Some registers have reserved bits which should not be modified.
31+
#[inline]
3032
pub unsafe fn set<T>(register: *const T, bit: u8) {
3133
write(register, bit, true);
3234
}
@@ -36,6 +38,7 @@ pub unsafe fn set<T>(register: *const T, bit: u8) {
3638
/// # Safety
3739
///
3840
/// Some registers have reserved bits which should not be modified.
41+
#[inline]
3942
pub unsafe fn write<T>(register: *const T, bit: u8, set: bool) {
4043
let addr = register as usize;
4144

src/dma.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ pub enum Error {
1313
Overrun,
1414
}
1515

16+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1617
pub enum Event {
1718
HalfTransfer,
1819
TransferComplete,
1920
}
2021

21-
#[derive(Clone, Copy, PartialEq)]
22+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2223
pub enum Half {
2324
First,
2425
Second,

src/gpio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl Default for Dynamic {
312312

313313
impl Active for Dynamic {}
314314

315-
#[derive(Debug, PartialEq)]
315+
#[derive(Debug, PartialEq, Eq)]
316316
pub enum PinModeError {
317317
IncorrectMode,
318318
}

src/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub enum DutyCycle {
4040
Ratio16to9,
4141
}
4242

43-
#[derive(Debug, PartialEq)]
43+
#[derive(Debug, PartialEq, Eq)]
4444
pub enum Mode {
4545
Standard {
4646
frequency: Hertz,

src/rcc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const HSI: u32 = 8_000_000; // Hz
107107
///
108108
/// **NOTE**: Currently, it is not guaranteed that the exact frequencies selected will be
109109
/// used, only frequencies close to it.
110-
#[derive(Debug, Default, PartialEq)]
110+
#[derive(Debug, Default, PartialEq, Eq)]
111111
pub struct CFGR {
112112
hse: Option<u32>,
113113
hclk: Option<u32>,
@@ -334,7 +334,7 @@ impl BKP {
334334
///
335335
/// let clocks = rcc.cfgr.freeze(&mut flash.acr);
336336
/// ```
337-
#[derive(Clone, Copy, Debug, PartialEq)]
337+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
338338
pub struct Clocks {
339339
hclk: Hertz,
340340
pclk1: Hertz,

src/time.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use cortex_m::peripheral::{DCB, DWT};
3535
use crate::rcc::Clocks;
3636

3737
/// Bits per second
38-
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
38+
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Debug)]
3939
pub struct Bps(pub u32);
4040

4141
pub use fugit::{
@@ -134,7 +134,6 @@ impl MonoTimer {
134134
dwt.enable_cycle_counter();
135135

136136
// now the CYCCNT counter can't be stopped or reset
137-
drop(dwt);
138137

139138
MonoTimer {
140139
frequency: clocks.hclk(),

src/timer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub struct Timer<TIM> {
8181
pub(crate) clk: Hertz,
8282
}
8383

84-
#[derive(Clone, Copy, PartialEq)]
84+
#[derive(Clone, Copy, PartialEq, Eq)]
8585
#[repr(u8)]
8686
pub enum Channel {
8787
C1 = 0,
@@ -91,7 +91,7 @@ pub enum Channel {
9191
}
9292

9393
/// Interrupt events
94-
#[derive(Clone, Copy, PartialEq)]
94+
#[derive(Clone, Copy, PartialEq, Eq)]
9595
pub enum SysEvent {
9696
/// [Timer] timed out / count down ended
9797
Update,
@@ -245,7 +245,7 @@ impl Timer<SYST> {
245245
}
246246
}
247247

248-
#[derive(Clone, Copy, Debug, PartialEq)]
248+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
249249
#[repr(u8)]
250250
pub enum Ocm {
251251
Frozen = 0,

0 commit comments

Comments
 (0)