Skip to content

Commit e40b2db

Browse files
authored
Merge pull request #49 from stm32-rs/debug-partial-eq-impls
Debug partial eq impls and pac compatability
2 parents 8d0a123 + dc1c497 commit e40b2db

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

src/datetime.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
//! Date and timer units & helper functions
22
33
/// Seconds
4-
#[derive(Clone, Copy, Debug)]
4+
#[derive(Clone, Copy, Debug, PartialEq)]
55
pub struct Second(pub u32);
66

77
/// Minutes
8-
#[derive(Clone, Copy, Debug)]
8+
#[derive(Clone, Copy, Debug, PartialEq)]
99
pub struct Minute(pub u32);
1010

1111
/// Hours
12-
#[derive(Clone, Copy, Debug)]
12+
#[derive(Clone, Copy, Debug, PartialEq)]
1313
pub struct Hour(pub u32);
1414

1515
/// Day (1-7)
16-
#[derive(Clone, Copy, Debug)]
16+
#[derive(Clone, Copy, Debug, PartialEq)]
1717
pub struct Day(pub u32);
1818

1919
/// Date (1-31)
20-
#[derive(Clone, Copy, Debug)]
20+
#[derive(Clone, Copy, Debug, PartialEq)]
2121
pub struct DateInMonth(pub u32);
2222

2323
/// Week (1-52)
24-
#[derive(Clone, Copy, Debug)]
24+
#[derive(Clone, Copy, Debug, PartialEq)]
2525
pub struct Week(pub u32);
2626

2727
/// Month (1-12)
28-
#[derive(Clone, Copy, Debug)]
28+
#[derive(Clone, Copy, Debug, PartialEq)]
2929
pub struct Month(pub u32);
3030

3131
/// Year
32-
#[derive(Clone, Copy, Debug)]
32+
#[derive(Clone, Copy, Debug, PartialEq)]
3333
pub struct Year(pub u32);
3434

3535
/// Extension trait that adds convenience methods to the `u32` type
@@ -80,7 +80,7 @@ impl U32Ext for u32 {
8080
}
8181
}
8282

83-
#[derive(Clone,Copy,Debug)]
83+
#[derive(Clone, Copy, Debug, PartialEq)]
8484
pub struct Time {
8585
pub hours: u32,
8686
pub minutes: u32,
@@ -99,7 +99,7 @@ impl Time {
9999
}
100100
}
101101

102-
#[derive(Clone,Copy, Debug)]
102+
#[derive(Clone, Copy, Debug, PartialEq)]
103103
pub struct Date {
104104
pub day: u32,
105105
pub date: u32,

src/gpio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! General Purpose Input / Output
22
3-
// Based on (ripped)
3+
// Based on
44
// https://github.com/japaric/stm32f30x-hal/blob/master/src/gpio.rs
55

66
use core::marker::PhantomData;

src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@ pub use embedded_hal as hal;
2424

2525
pub use stm32l4;
2626
#[cfg(feature = "stm32l4x1")]
27-
pub use stm32l4::stm32l4x1 as stm32;
27+
pub use stm32l4::stm32l4x1 as pac;
2828

2929
#[cfg(feature = "stm32l4x2")]
30-
pub use stm32l4::stm32l4x2 as stm32;
30+
pub use stm32l4::stm32l4x2 as pac;
3131

3232
#[cfg(feature = "stm32l4x3")]
33-
pub use stm32l4::stm32l4x3 as stm32;
33+
pub use stm32l4::stm32l4x3 as pac;
3434

3535
#[cfg(feature = "stm32l4x5")]
36-
pub use stm32l4::stm32l4x5 as stm32;
36+
pub use stm32l4::stm32l4x5 as pac;
3737

3838
#[cfg(feature = "stm32l4x6")]
39-
pub use stm32l4::stm32l4x6 as stm32;
39+
pub use stm32l4::stm32l4x6 as pac;
4040

4141
#[cfg(feature = "rt")]
42-
pub use self::stm32::interrupt;
42+
pub use self::pac::interrupt;
43+
44+
pub use crate::pac as device;
45+
pub use crate::pac as stm32;
4346

4447
pub mod datetime;
4548
#[cfg(any(

src/tsc.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ use crate::stm32::{TSC};
1212
use crate::gpio::gpiob::{PB4, PB5, PB6, PB7};
1313
use crate::gpio::{AF9, Alternate, Output, OpenDrain, PushPull};
1414

15-
#[derive(Debug, Copy, Clone)]
15+
#[derive(Clone, Copy, Debug, PartialEq)]
1616
pub enum Event {
1717
/// Max count error
1818
MaxCountError,
1919
/// End of acquisition
2020
EndOfAcquisition
2121
}
2222

23-
#[derive(Debug, Copy, Clone)]
23+
#[derive(Clone, Copy, Debug, PartialEq)]
2424
pub enum Error {
2525
/// Max count error
2626
MaxCountError,
@@ -70,21 +70,20 @@ impl ChannelPin<TSC> for PB7<Alternate<AF9, Output<PushPull>>> {
7070
const OFFSET: u32 = 3;
7171
}
7272

73-
7473
pub struct Tsc<SPIN> {
7574
sample_pin: SPIN,
7675
tsc: TSC
7776
}
7877

79-
#[derive(Debug, Copy, Clone)]
78+
#[derive(Clone, Copy, Debug, PartialEq)]
8079
pub struct Config {
8180
pub clock_prescale: Option<ClockPrescaler>,
8281
pub max_count_error: Option<MaxCountError>,
8382
pub charge_transfer_high: Option<ChargeDischargeTime>,
8483
pub charge_transfer_low: Option<ChargeDischargeTime>,
8584
}
8685

87-
#[derive(Debug, Copy, Clone)]
86+
#[derive(Clone, Copy, Debug, PartialEq)]
8887
pub enum ClockPrescaler {
8988
Hclk = 0b000,
9089
HclkDiv2 = 0b001,
@@ -96,7 +95,7 @@ pub enum ClockPrescaler {
9695
HclkDiv128 = 0b111,
9796
}
9897

99-
#[derive(Debug, Copy, Clone)]
98+
#[derive(Clone, Copy, Debug, PartialEq)]
10099
pub enum MaxCountError {
101100
/// 000: 255
102101
U255 = 000,
@@ -114,7 +113,7 @@ pub enum MaxCountError {
114113
U16383 = 110
115114
}
116115

117-
#[derive(Debug, Copy, Clone)]
116+
#[derive(Clone, Copy, Debug, PartialEq)]
118117
/// How many tsc cycles are spent charging / discharging
119118
pub enum ChargeDischargeTime {
120119
C1 = 0b0000,

0 commit comments

Comments
 (0)