pub struct Counter {
pub free: Tracked,
pub pulse: Tracked,
}Expand description
Both counters a concentrator keeps.
Fields§
§free: TrackedThe one that free runs, which packets are stamped against.
pulse: TrackedThe one a pulse per second line latches, which disciplines the other.
Implementations§
Source§impl Counter
impl Counter
Sourcepub const fn read(&mut self, bytes: &[u8; 8]) -> (u32, u32)
pub const fn read(&mut self, bytes: &[u8; 8]) -> (u32, u32)
Takes a reading from the eight bytes the chip answers with.
The pulse counter comes first and the free running one after it, each most significant byte first, and both are scaled from the 32 MHz they count at.
§Arguments
bytes- what the burst read answered with.
§Returns
The free running counter and then the pulse one, both in microseconds and both widened past any rollover seen so far.
§Examples
use pamoja_radios::sx1302::timestamp::Counter;
let mut counter = Counter::new();
// The free running counter reads 64 ticks, which is two microseconds.
let (free, pulse) = counter.read(&[0, 0, 0, 32, 0, 0, 0, 64]);
assert_eq!((free, pulse), (2, 1));Sourcepub const fn widened_packet(&self, packet: u32) -> u32
pub const fn widened_packet(&self, packet: u32) -> u32
Widens the counter value a packet was stamped with.
A packet reading above the last counter reading was heard before the most recent rollover, not after it, so it belongs to the wrap count before this one.
§Arguments
packet- what the packet carried, in microseconds.
§Returns
The value widened past the rollovers seen so far.
§Examples
use pamoja_radios::sx1302::timestamp::Counter;
let mut counter = Counter::new();
counter.read(&[0, 0, 0, 0, 0, 0, 0, 32]);
// A packet heard just before the counter reading sits in the same stretch.
assert_eq!(counter.widened_packet(1), 1);Trait Implementations§
impl Copy for Counter
impl Eq for Counter
impl StructuralPartialEq for Counter
Auto Trait Implementations§
impl Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnsafeUnpin for Counter
impl UnwindSafe for Counter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more