Skip to content

Commit 87982ab

Browse files
davidv1992rnijveld
authored andcommitted
Updated stm32 example to use the new filter.
1 parent 6c7a476 commit 87982ab

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

statime-stm32/src/ethernet.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use core::task::Poll;
22

3-
use super::{Monotonic, Systick};
43
use defmt::unwrap;
54
use futures::future::poll_fn;
65
use ieee802_3_miim::{
@@ -21,6 +20,8 @@ use stm32_eth::{
2120
};
2221
use stm32f7xx_hal::signature::Uid;
2322

23+
use super::{Monotonic, Systick};
24+
2425
pub struct DmaResources {
2526
pub rx_ring: [RxRingEntry; 2],
2627
pub tx_ring: [TxRingEntry; 2],
@@ -127,12 +128,8 @@ pub fn setup_smoltcp(
127128
unwrap!(a.push(IpCidr::new(IpAddress::v4(10, 0, 0, 2), 24)));
128129
});
129130

130-
unwrap!(interface.join_multicast_group(
131-
Ipv4Address::new(224, 0, 1, 129)
132-
));
133-
unwrap!(interface.join_multicast_group(
134-
Ipv4Address::new(224, 0, 0, 107)
135-
));
131+
unwrap!(interface.join_multicast_group(Ipv4Address::new(224, 0, 1, 129)));
132+
unwrap!(interface.join_multicast_group(Ipv4Address::new(224, 0, 0, 107)));
136133

137134
defmt::info!("Set IPs to: {}", interface.ip_addrs());
138135

statime-stm32/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use smoltcp::{
1717
socket::dhcpv4,
1818
wire::{IpCidr, Ipv4Address, Ipv4Cidr},
1919
};
20-
use statime::{filters::BasicFilter, port::TimestampContext, PtpInstance};
20+
use statime::{filters::KalmanFilter, port::TimestampContext, PtpInstance};
2121
use stm32_eth::{dma::PacketId, EthPins, Parts, PartsIn};
2222
use stm32f7xx_hal::{
2323
gpio::{Output, Pin, Speed},
@@ -37,7 +37,7 @@ mod port;
3737
mod ptp_clock;
3838
mod ptp_state_mutex;
3939

40-
type StmPtpInstance = PtpInstance<BasicFilter, PtpStateMutex>;
40+
type StmPtpInstance = PtpInstance<KalmanFilter, PtpStateMutex>;
4141

4242
defmt::timestamp!("{=u64:iso8601ms}", {
4343
let time = stm32_eth::ptp::EthernetPTP::get_time();
@@ -220,8 +220,9 @@ mod app {
220220
.unwrap_or_else(|_| defmt::panic!("Failed to start instance bmca"));
221221

222222
// Poll network interfaces and run DHCP
223-
// poll_smoltcp::spawn().unwrap_or_else(|_| defmt::panic!("Failed to start poll_smoltcp"));
224-
// dhcp::spawn(dhcp_socket).unwrap_or_else(|_| defmt::panic!("Failed to start dhcp"));
223+
// poll_smoltcp::spawn().unwrap_or_else(|_| defmt::panic!("Failed to
224+
// start poll_smoltcp")); dhcp::spawn(dhcp_socket).
225+
// unwrap_or_else(|_| defmt::panic!("Failed to start dhcp"));
225226
}
226227

227228
(

statime-stm32/src/port.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use statime::{
1212
AcceptAnyMaster, ClockIdentity, ClockQuality, DelayMechanism, InstanceConfig, PortConfig,
1313
PtpMinorVersion, SdoId, TimePropertiesDS, TimeSource,
1414
},
15-
filters::BasicFilter,
15+
filters::KalmanFilter,
1616
port::{InBmca, NoForwardedTLVs, PortAction, PortActionIterator, Running, TimestampContext},
1717
time::{Duration, Interval, Time},
1818
PtpInstance,
@@ -30,7 +30,7 @@ type StmPort<State> = statime::port::Port<
3030
AcceptAnyMaster,
3131
Rng,
3232
&'static PtpClock,
33-
BasicFilter,
33+
KalmanFilter,
3434
PtpStateMutex,
3535
>;
3636

@@ -307,9 +307,7 @@ pub fn setup_statime(
307307
minor_ptp_version: PtpMinorVersion::One,
308308
};
309309

310-
let filter_config = 0.1;
311-
312-
let ptp_port = ptp_instance.add_port(port_config, filter_config, ptp_clock, rng);
310+
let ptp_port = ptp_instance.add_port(port_config, Default::default(), ptp_clock, rng);
313311

314312
(ptp_instance, ptp_port)
315313
}

0 commit comments

Comments
 (0)