File tree Expand file tree Collapse file tree 3 files changed +19
-30
lines changed Expand file tree Collapse file tree 3 files changed +19
-30
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,12 @@ impl RxDescriptor {
166
166
167
167
/// Get PTP timestamps if available
168
168
pub ( super ) fn read_timestamp ( & self ) -> Option < Timestamp > {
169
+ #[ cfg( any( feature = "stm32f4xx-hal" , feature = "stm32f7xx-hal" ) ) ]
170
+ let ( high, low) = { ( self . inner_raw . read ( 7 ) , self . inner_raw . read ( 6 ) ) } ;
171
+
172
+ #[ cfg( feature = "stm32f1xx-hal" ) ]
173
+ let ( high, low) = { ( self . inner_raw . read ( 3 ) , self . inner_raw . read ( 2 ) ) } ;
174
+
169
175
#[ cfg( not( feature = "stm32f1xx-hal" ) ) ]
170
176
let is_valid = {
171
177
/// RX timestamp
@@ -174,14 +180,15 @@ impl RxDescriptor {
174
180
} ;
175
181
176
182
#[ cfg( feature = "stm32f1xx-hal" ) ]
177
- // There is no "timestamp valid" indicator bit
178
- // on STM32F1XX
179
- let is_valid = true ;
183
+ // There is no direct "timestamp valid" indicator bit
184
+ // on STM32F1XX, but if it's invalid it will be written
185
+ // as all ones.
186
+ let is_valid = high != 0xFFFF_FFFF || low != 0xFFFF_FFFF ;
180
187
181
- let timestamp = Timestamp :: from_descriptor ( & self . inner_raw ) ;
188
+ let timestamp = Timestamp :: from_parts ( high , low ) ;
182
189
183
190
if is_valid && self . is_last ( ) {
184
- timestamp
191
+ Some ( timestamp)
185
192
} else {
186
193
None
187
194
}
Original file line number Diff line number Diff line change @@ -162,7 +162,13 @@ impl TxDescriptor {
162
162
let contains_timestamp = ( tdes0 & TXDESC_0_TIMESTAMP_STATUS ) == TXDESC_0_TIMESTAMP_STATUS ;
163
163
164
164
if !self . is_owned ( ) && contains_timestamp && Self :: is_last ( tdes0) {
165
- Timestamp :: from_descriptor ( & self . inner_raw )
165
+ #[ cfg( any( feature = "stm32f4xx-hal" , feature = "stm32f7xx-hal" ) ) ]
166
+ let ( high, low) = { ( self . inner_raw . read ( 7 ) , self . inner_raw . read ( 6 ) ) } ;
167
+
168
+ #[ cfg( feature = "stm32f1xx-hal" ) ]
169
+ let ( high, low) = { ( self . inner_raw . read ( 3 ) , self . inner_raw . read ( 2 ) ) } ;
170
+
171
+ Some ( Timestamp :: from_parts ( high, low) )
166
172
} else {
167
173
None
168
174
}
Original file line number Diff line number Diff line change 1
- use crate :: dma:: raw_descriptor:: RawDescriptor ;
2
-
3
1
use super :: Subseconds ;
4
2
5
3
/// A timestamp produced by the PTP periperhal
@@ -96,28 +94,6 @@ impl Timestamp {
96
94
97
95
Timestamp :: new_unchecked ( negative, high, subseconds)
98
96
}
99
-
100
- /// Create a timestamp from the given descriptor
101
- pub fn from_descriptor ( desc : & RawDescriptor ) -> Option < Self > {
102
- #[ cfg( not( feature = "stm32f1xx-hal" ) ) ]
103
- {
104
- let ( high, low) = { ( desc. read ( 7 ) , desc. read ( 6 ) ) } ;
105
- Some ( Self :: from_parts ( high, low) )
106
- }
107
-
108
- #[ cfg( feature = "stm32f1xx-hal" ) ]
109
- {
110
- let ( high, low) = { ( desc. read ( 3 ) , desc. read ( 2 ) ) } ;
111
-
112
- // The timestamp registers are written to all-ones if
113
- // timestamping was no succesfull
114
- if high == 0xFFFF_FFFF && low == 0xFFFF_FFFF {
115
- None
116
- } else {
117
- Some ( Self :: from_parts ( high, low) )
118
- }
119
- }
120
- }
121
97
}
122
98
123
99
impl core:: ops:: Add < Timestamp > for Timestamp {
You can’t perform that action at this time.
0 commit comments