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 {
166166
167167 /// Get PTP timestamps if available
168168 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+
169175 #[ cfg( not( feature = "stm32f1xx-hal" ) ) ]
170176 let is_valid = {
171177 /// RX timestamp
@@ -174,14 +180,15 @@ impl RxDescriptor {
174180 } ;
175181
176182 #[ 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 ;
180187
181- let timestamp = Timestamp :: from_descriptor ( & self . inner_raw ) ;
188+ let timestamp = Timestamp :: from_parts ( high , low ) ;
182189
183190 if is_valid && self . is_last ( ) {
184- timestamp
191+ Some ( timestamp)
185192 } else {
186193 None
187194 }
Original file line number Diff line number Diff line change @@ -162,7 +162,13 @@ impl TxDescriptor {
162162 let contains_timestamp = ( tdes0 & TXDESC_0_TIMESTAMP_STATUS ) == TXDESC_0_TIMESTAMP_STATUS ;
163163
164164 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) )
166172 } else {
167173 None
168174 }
Original file line number Diff line number Diff line change 1- use crate :: dma:: raw_descriptor:: RawDescriptor ;
2-
31use super :: Subseconds ;
42
53/// A timestamp produced by the PTP periperhal
@@ -96,28 +94,6 @@ impl Timestamp {
9694
9795 Timestamp :: new_unchecked ( negative, high, subseconds)
9896 }
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- }
12197}
12298
12399impl core:: ops:: Add < Timestamp > for Timestamp {
You can’t perform that action at this time.
0 commit comments