Skip to main content

Tpx3Packet

Struct Tpx3Packet 

Source
pub struct Tpx3Packet(/* private fields */);
Expand description

TPX3 packet wrapper providing efficient field extraction.

Packet format (64-bit):

  • Hit packets (ID 0xB*):

    • Bits 0-15: SPIDR time
    • Bits 16-19: Fine ToA (4-bit)
    • Bits 20-29: ToT (10-bit)
    • Bits 30-43: ToA (14-bit)
    • Bits 44-59: Pixel address (16-bit)
    • Bits 60-63: Packet type ID
  • TDC packets (ID 0x6F):

    • Bits 12-41: 30-bit TDC timestamp
    • Bits 56-63: Packet type ID

Implementations§

Source§

impl Tpx3Packet

Source

pub const TPX3_HEADER_MAGIC: u64 = 0x3358_5054

TPX3 header magic number (“TPX3” in little-endian).

Source

pub const fn new(raw: u64) -> Self

Create from raw 64-bit value.

Source

pub const fn raw(&self) -> u64

Get raw packet value.

Source

pub const fn is_header(&self) -> bool

Check if this is a TPX3 header packet.

Source

pub const fn is_tdc(&self) -> bool

Check if this is a TDC packet (ID 0x6F).

Source

pub const fn is_hit(&self) -> bool

Check if this is a hit packet (ID 0xB*).

Source

pub const fn packet_type(&self) -> u8

Get packet type identifier.

Source

pub const fn chip_id(&self) -> u8

Get chip ID from header packet (bits 32-39).

Source

pub const fn pixel_address(&self) -> u16

Get 16-bit pixel address from hit packet.

Source

pub const fn toa(&self) -> u16

Get 14-bit Time of Arrival.

Source

pub const fn tot(&self) -> u16

Get 10-bit Time over Threshold.

Source

pub const fn fine_toa(&self) -> u8

Get 4-bit fine ToA.

Source

pub const fn spidr_time(&self) -> u16

Get SPIDR time (16-bit).

Source

pub const fn tdc_timestamp(&self) -> u32

Get 30-bit TDC timestamp from TDC packet.

Source

pub const fn pixel_coordinates(&self) -> (u16, u16)

Decode pixel address to local (x, y) coordinates.

  • dcol = (addr >> 8) & 0xFE
  • spix = (addr >> 1) & 0xFC
  • pix = addr & 0x7
  • x = dcol + (pix >> 2)
  • y = spix + (pix & 0x3)
Source§

impl Tpx3Packet

Source

pub fn from_bytes(bytes: [u8; 8]) -> Self

Create from 8-byte array (little-endian).

Source

pub const fn is_pixel_data(&self) -> bool

Alias for is_hit - checks if this is pixel data.

Source

pub fn timestamp_coarse(&self) -> u32

Calculate coarse timestamp in 25ns units from SPIDR time and ToA.

Formula: (spidr_time << 14) | toa Matches C++ reference implementation.

Trait Implementations§

Source§

impl Clone for Tpx3Packet

Source§

fn clone(&self) -> Tpx3Packet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tpx3Packet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<u64> for Tpx3Packet

Source§

fn from(raw: u64) -> Self

Converts to this type from the input type.
Source§

impl Copy for Tpx3Packet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.