Struct DW3000

Source
pub struct DW3000<SPI, State> { /* private fields */ }
Expand description

Entry point to the DW3000 driver API

Implementations§

Source§

impl<SPI, State> DW3000<SPI, State>
where SPI: SpiDevice<u8>, State: Awake,

Source

pub async fn get_tx_antenna_delay(&mut self) -> Result<Duration, Error<SPI>>

Returns the TX antenna delay

Source

pub async fn get_rx_antenna_delay(&mut self) -> Result<Duration, Error<SPI>>

Returns the RX antenna delay

Source

pub async fn get_address( &mut self, ) -> Result<(Ieee802154Pan, Ieee802154Address), Error<SPI>>

Returns the network id and address used for sending and receiving

Source

pub async fn sys_time(&mut self) -> Result<u32, Error<SPI>>

Returns the current system time (32-bit)

Source

pub async fn state(&mut self) -> Result<u8, Error<SPI>>

Returns the state of the DW3000

Source

pub async fn cmd_status(&mut self) -> Result<u8, Error<SPI>>

Returns the current fast command of the DW3000

Source

pub async fn init_rc_passed(&mut self) -> Result<bool, Error<SPI>>

Returns true if the DW3000 has been in init_rc

Source

pub async fn idle_rc_passed(&mut self) -> Result<bool, Error<SPI>>

Returns true if the DW3000 has been in idle_rc

Source

pub async fn idle_pll_passed(&mut self) -> Result<bool, Error<SPI>>

Returns true if the DW3000 pll is lock

Source

pub fn ll(&mut self) -> &mut DW3000<SPI>

Provides direct access to the register-level API

Be aware that by using the register-level API, you can invalidate various assumptions that the high-level API makes about the operation of the DW3000. Don’t use the register-level and high-level APIs in tandem, unless you know what you’re doing.

Source

pub async fn force_idle(&mut self) -> Result<(), Error<SPI>>

Force the DW3000 into IDLE mode

Any ongoing RX/TX operations will be aborted.

Source

pub async fn fast_cmd(&mut self, fc: FastCommand) -> Result<(), Error<SPI>>

Use fast command ll in hl

Source§

impl<SPI> DW3000<SPI, Ready>
where SPI: SpiDevice<u8>,

Source

pub async fn set_antenna_delay( &mut self, rx_delay: u16, tx_delay: u16, ) -> Result<(), Error<SPI>>

Sets the RX and TX antenna delays

Source

pub async fn set_address( &mut self, pan_id: Ieee802154Pan, addr: Ieee802154Address, ) -> Result<(), Error<SPI>>

Sets the network id and address used for sending and receiving

Source

pub async fn set_full_cia_diagnostics( &mut self, enabled: bool, ) -> Result<(), Error<SPI>>

Enable/disable CIA diagnostics Enabling CIA diagnostics is required for RSSI calculation

Source

pub async fn set_pdoa_mode(&mut self, mode: PdoaMode) -> Result<(), Error<SPI>>

Set the current PDoA mode

Note in order for PDoA to work, the DW3000 must be configured with STS.

The PDoA mode can be set to one of the following: 0: Disabled 1: PDoA mode 1 3: PDoA mode 3

The PDoA mode is set to 0 by default.

NOTE: PDoA mode 3 requires the STS length to be integer multiples of 128.

Source

pub async fn send_raw( self, data: &[u8], send_time: SendTime, config: &Config, ) -> Result<DW3000<SPI, Sending>, Error<SPI>>

Send an raw UWB PHY frame

The data argument is wrapped into an raw UWB PHY frame.

This operation can be delayed to aid in distance measurement, by setting delayed_time to Some(instant). If you want to send the frame as soon as possible, just pass None instead.

The config parameter struct allows for setting the channel, bitrate, and more. This configuration needs to be the same as the configuration used by the receiver, or the message may not be received. The defaults are a sane starting point.

This method starts the transmission and returns immediately thereafter. It consumes this instance of DW3000 and returns another instance which is in the Sending state, and can be used to wait for the transmission to finish and check its result.

Will panic if the delayed TX time is not rounded to top 31 bits.

Source

pub async fn send_frame<T>( self, frame: Ieee802154Frame<T>, send_time: SendTime, config: Config, ) -> Result<DW3000<SPI, Sending>, Error<SPI>>
where T: AsRef<[u8]>,

Send an IEEE 802.15.4 MAC frame

The frame argument is an IEEE 802.15.4 MAC frame and sent to destination.

This operation can be delayed to aid in distance measurement, by setting delayed_time to Some(instant). If you want to send the frame as soon as possible, just pass None instead.

The config parameter struct allows for setting the channel, bitrate, and more. This configuration needs to be the same as the configuration used by the receiver, or the message may not be received. The defaults are a sane starting point.

This method starts the transmission and returns immediately thereafter. It consumes this instance of DW3000 and returns another instance which is in the Sending state, and can be used to wait for the transmission to finish and check its result.

Source

pub async fn send( self, data: &[u8], send_time: SendTime, config: Config, ) -> Result<DW3000<SPI, Sending>, Error<SPI>>

Send an IEEE 802.15.4 MAC frame

The data argument is wrapped into an IEEE 802.15.4 MAC frame and sent to destination.

This operation can be delayed to aid in distance measurement, by setting delayed_time to Some(instant). If you want to send the frame as soon as possible, just pass None instead.

The config parameter struct allows for setting the channel, bitrate, and more. This configuration needs to be the same as the configuration used by the receiver, or the message may not be received. The defaults are a sane starting point.

This method starts the transmission and returns immediately thereafter. It consumes this instance of DW3000 and returns another instance which is in the Sending state, and can be used to wait for the transmission to finish and check its result.

Source

pub async fn receive( self, config: Config, ) -> Result<DW3000<SPI, SingleBufferReceiving>, Error<SPI>>

Attempt to receive a single IEEE 802.15.4 MAC frame

Initializes the receiver. The method consumes this instance of DW3000 and returns another instance which is in the SingleBufferReceiving state, and can be used to wait for a message.

The config parameter allows for the configuration of bitrate, channel and more. Make sure that the values used are the same as of the frames that are transmitted. The default works with the TxConfig’s default and is a sane starting point.

Source

pub async fn receive_delayed( self, recv_time: ReceiveTime, config: Config, ) -> Result<DW3000<SPI, SingleBufferReceiving>, Error<SPI>>

Attempt to receive a single IEEE 802.15.4 MAC frame

Initializes the receiver. The method consumes this instance of DW3000 and returns another instance which is in the SingleBufferReceiving state, and can be used to wait for a message.

This operation can be delayed to aid in distance measurement, by setting recv_time to ReceiveTime::Delayed(instant). If you want to send the frame as soon as possible, just pass ReceiveTime::Now instead.

The config parameter allows for the configuration of bitrate, channel and more. Make sure that the values used are the same as of the frames that are transmitted. The default works with the TxConfig’s default and is a sane starting point.

Source

pub async fn disable_spirdy_interrupt(&mut self) -> Result<(), Error<SPI>>

Disable the SPIRDY interrupt flag

Source

pub async fn enable_tx_interrupts(&mut self) -> Result<(), Error<SPI>>

Enables transmit interrupts for the events that wait checks

Overwrites any interrupt flags that were previously set.

Source

pub async fn enable_rx_interrupts(&mut self) -> Result<(), Error<SPI>>

Enables receive interrupts for the events that wait checks

Overwrites any interrupt flags that were previously set.

Source

pub async fn disable_interrupts(&mut self) -> Result<(), Error<SPI>>

Disables all interrupts

Source

pub async fn gpio_config( &mut self, config: ConfigGPIOs, ) -> Result<(), Error<SPI>>

GPIO SECTION, gpios seems to have a problem with its register. Init GPIO WRT Config

Source

pub async fn gpio_config_clocks(&mut self) -> Result<(), Error<SPI>>

Enable gpios clocks

Source

pub async fn gpio_config_enable( &mut self, pin: u8, enable: u8, ) -> Result<(), Error<SPI>>

Enables single pin

Source

pub async fn gpio_config_mode( &mut self, pin: u8, mode: u8, ) -> Result<(), Error<SPI>>

Configures mode for a single pin

Source

pub async fn gpio_config_dir( &mut self, pin: u8, dir: u8, ) -> Result<(), Error<SPI>>

Configures direction for a single pin

Source

pub async fn gpio_config_out( &mut self, pin: u8, output: u8, ) -> Result<(), Error<SPI>>

Configures output for a single pin

Source

pub async fn get_gpio_config(&mut self) -> Result<ConfigGPIOs, Error<SPI>>

Returns GPIO config

Source

pub async fn get_gpio_enabled(&mut self) -> Result<[u8; 9], Error<SPI>>

Returns current gpio enable state

Source

pub async fn get_gpio_mode(&mut self) -> Result<[u8; 9], Error<SPI>>

Returns current gpio pin mode

Source

pub async fn get_gpio_dir(&mut self) -> Result<[u8; 9], Error<SPI>>

Returns current gpio dir

Source

pub async fn get_gpio_out(&mut self) -> Result<[u8; 9], Error<SPI>>

Returns current output

Source

pub async fn get_gpio_raw_state(&mut self) -> Result<[u8; 9], Error<SPI>>

Returns current raw state / input

Source§

impl<SPI, RECEIVING> DW3000<SPI, RECEIVING>
where SPI: SpiDevice<u8>, RECEIVING: Receiving,

Source

pub async fn rx_state(&mut self) -> Result<u8, Error<SPI>>

Returns the RX state of the DW3000

Source

pub async fn r_wait<'b>( &mut self, buffer: &'b mut [u8], ) -> Result<Message<'b>, Error<SPI>>

Wait for receive operation to finish

This method returns an nb::Result to indicate whether the transmission has finished, or whether it is still ongoing. You can use this to busily wait for the transmission to finish, for example using nb’s block! macro, or you can use it in tandem with DW3000::enable_rx_interrupts and the DW3000 IRQ output to wait in a more energy-efficient manner.

Handling the DW3000’s IRQ output line is out of the scope of this driver, but please note that if you’re using the DWM1001 module or DWM1001-Dev board, that the dwm1001 crate has explicit support for this.

Source

pub async fn r_wait_buf( &mut self, buffer: &mut [u8], ) -> Result<(usize, Instant, RxQuality), Error<SPI>>

Wait for receive operation to finish

This method returns an nb::Result to indicate whether the transmission has finished, or whether it is still ongoing. You can use this to busily wait for the transmission to finish, for example using nb’s block! macro, or you can use it in tandem with DW3000::enable_rx_interrupts and the DW3000 IRQ output to wait in a more energy-efficient manner.

Handling the DW3000’s IRQ output line is out of the scope of this driver, but please note that if you’re using the DWM1001 module or DWM1001-Dev board, that the dwm1001 crate has explicit support for this.

Source

pub async fn finish_receiving( self, ) -> Result<DW3000<SPI, Ready>, (Self, Error<SPI>)>

Finishes receiving and returns to the Ready state

If the receive operation has finished, as indicated by wait, this is a no-op. If the receive operation is still ongoing, it will be aborted.

Source§

impl<SPI> DW3000<SPI, Sending>
where SPI: SpiDevice<u8>,

Source

pub async fn tx_state(&mut self) -> Result<u8, Error<SPI>>

Returns the TX state of the DW3000

Source

pub async fn s_wait(&mut self) -> Result<Instant, Error<SPI>>

Wait for the transmission to finish

This method returns an nb::Result to indicate whether the transmission has finished, or whether it is still ongoing. You can use this to busily wait for the transmission to finish, for example using nb’s block! macro, or you can use it in tandem with DW3000::enable_tx_interrupts and the DW3000 IRQ output to wait in a more energy-efficient manner.

Handling the DW3000’s IRQ output line is out of the scope of this driver, but please note that if you’re using the DWM1001 module or DWM1001-Dev board, that the dwm1001 crate has explicit support for this.

Source

pub async fn finish_sending( self, ) -> Result<DW3000<SPI, Ready>, (Self, Error<SPI>)>

Finishes sending and returns to the Ready state

If the send operation has finished, as indicated by wait, this is a no-op. If the send operation is still ongoing, it will be aborted.

Source§

impl<SPI> DW3000<SPI, Uninitialized>
where SPI: SpiDevice<u8>,

Source

pub fn new(spi: SPI) -> Self

Create a new instance of DW3000

Requires the SPI peripheral and the chip select pin that are connected to the DW3000.

Source

pub async fn read_otp(&mut self, addr: u16) -> Result<u32, Error<SPI>>

Read the OTP memory at the given address

Source

pub async fn init(self) -> Result<DW3000<SPI, Uninitialized>, Error<SPI>>

Initialize the DW3000

Basicaly, this is the pll configuration. We want to have a locked pll in order to provide a constant speed clock. This is important when using th clock to measure distances. At the end of this function, pll is locked and it can be checked by the bit CPLOCK in SYS_STATUS register

Source

pub async fn config<DELAY>( self, config: Config, delay_ns: DELAY, ) -> Result<DW3000<SPI, Ready>, Error<SPI>>
where DELAY: DelayNs,

Configuration of the DW3000, need to be called after an init.

Trait Implementations§

Source§

impl<SPI: Clone, State: Clone> Clone for DW3000<SPI, State>

Source§

fn clone(&self) -> DW3000<SPI, State>

Returns a copy 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<SPI, State> Debug for DW3000<SPI, State>
where State: Debug,

Source§

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

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

impl<SPI: Copy, State: Copy> Copy for DW3000<SPI, State>

Auto Trait Implementations§

§

impl<SPI, State> Freeze for DW3000<SPI, State>
where State: Freeze, SPI: Freeze,

§

impl<SPI, State> RefUnwindSafe for DW3000<SPI, State>
where State: RefUnwindSafe, SPI: RefUnwindSafe,

§

impl<SPI, State> Send for DW3000<SPI, State>
where State: Send, SPI: Send,

§

impl<SPI, State> Sync for DW3000<SPI, State>
where State: Sync, SPI: Sync,

§

impl<SPI, State> Unpin for DW3000<SPI, State>
where State: Unpin, SPI: Unpin,

§

impl<SPI, State> UnwindSafe for DW3000<SPI, State>
where State: UnwindSafe, SPI: UnwindSafe,

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.