pub struct DW3000<SPI, State> { /* private fields */ }
Expand description
Entry point to the DW3000 driver API
Implementations§
Source§impl<SPI, State> DW3000<SPI, State>
impl<SPI, State> DW3000<SPI, State>
Sourcepub async fn get_tx_antenna_delay(&mut self) -> Result<Duration, Error<SPI>>
pub async fn get_tx_antenna_delay(&mut self) -> Result<Duration, Error<SPI>>
Returns the TX antenna delay
Sourcepub async fn get_rx_antenna_delay(&mut self) -> Result<Duration, Error<SPI>>
pub async fn get_rx_antenna_delay(&mut self) -> Result<Duration, Error<SPI>>
Returns the RX antenna delay
Sourcepub async fn get_address(
&mut self,
) -> Result<(Ieee802154Pan, Ieee802154Address), Error<SPI>>
pub async fn get_address( &mut self, ) -> Result<(Ieee802154Pan, Ieee802154Address), Error<SPI>>
Returns the network id and address used for sending and receiving
Sourcepub async fn sys_time(&mut self) -> Result<u32, Error<SPI>>
pub async fn sys_time(&mut self) -> Result<u32, Error<SPI>>
Returns the current system time (32-bit)
Sourcepub async fn cmd_status(&mut self) -> Result<u8, Error<SPI>>
pub async fn cmd_status(&mut self) -> Result<u8, Error<SPI>>
Returns the current fast command of the DW3000
Sourcepub async fn init_rc_passed(&mut self) -> Result<bool, Error<SPI>>
pub async fn init_rc_passed(&mut self) -> Result<bool, Error<SPI>>
Returns true if the DW3000 has been in init_rc
Sourcepub async fn idle_rc_passed(&mut self) -> Result<bool, Error<SPI>>
pub async fn idle_rc_passed(&mut self) -> Result<bool, Error<SPI>>
Returns true if the DW3000 has been in idle_rc
Sourcepub async fn idle_pll_passed(&mut self) -> Result<bool, Error<SPI>>
pub async fn idle_pll_passed(&mut self) -> Result<bool, Error<SPI>>
Returns true if the DW3000 pll is lock
Sourcepub fn ll(&mut self) -> &mut DW3000<SPI>
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.
Sourcepub async fn force_idle(&mut self) -> Result<(), Error<SPI>>
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§impl<SPI> DW3000<SPI, Ready>
impl<SPI> DW3000<SPI, Ready>
Sourcepub async fn set_antenna_delay(
&mut self,
rx_delay: u16,
tx_delay: u16,
) -> Result<(), Error<SPI>>
pub async fn set_antenna_delay( &mut self, rx_delay: u16, tx_delay: u16, ) -> Result<(), Error<SPI>>
Sets the RX and TX antenna delays
Sourcepub async fn set_address(
&mut self,
pan_id: Ieee802154Pan,
addr: Ieee802154Address,
) -> Result<(), Error<SPI>>
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
Sourcepub async fn set_full_cia_diagnostics(
&mut self,
enabled: bool,
) -> Result<(), Error<SPI>>
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
Sourcepub async fn set_pdoa_mode(&mut self, mode: PdoaMode) -> Result<(), Error<SPI>>
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.
Sourcepub async fn send_raw(
self,
data: &[u8],
send_time: SendTime,
config: &Config,
) -> Result<DW3000<SPI, Sending>, Error<SPI>>
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.
Sourcepub async fn send_frame<T>(
self,
frame: Ieee802154Frame<T>,
send_time: SendTime,
config: Config,
) -> Result<DW3000<SPI, Sending>, Error<SPI>>
pub async fn send_frame<T>( self, frame: Ieee802154Frame<T>, send_time: SendTime, config: Config, ) -> Result<DW3000<SPI, Sending>, Error<SPI>>
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.
Sourcepub async fn send(
self,
data: &[u8],
send_time: SendTime,
config: Config,
) -> Result<DW3000<SPI, Sending>, Error<SPI>>
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.
Sourcepub async fn receive(
self,
config: Config,
) -> Result<DW3000<SPI, SingleBufferReceiving>, Error<SPI>>
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.
Sourcepub async fn receive_delayed(
self,
recv_time: ReceiveTime,
config: Config,
) -> Result<DW3000<SPI, SingleBufferReceiving>, Error<SPI>>
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.
Sourcepub async fn disable_spirdy_interrupt(&mut self) -> Result<(), Error<SPI>>
pub async fn disable_spirdy_interrupt(&mut self) -> Result<(), Error<SPI>>
Disable the SPIRDY interrupt flag
Sourcepub async fn enable_tx_interrupts(&mut self) -> Result<(), Error<SPI>>
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.
Sourcepub async fn enable_rx_interrupts(&mut self) -> Result<(), Error<SPI>>
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.
Sourcepub async fn disable_interrupts(&mut self) -> Result<(), Error<SPI>>
pub async fn disable_interrupts(&mut self) -> Result<(), Error<SPI>>
Disables all interrupts
Sourcepub async fn gpio_config(
&mut self,
config: ConfigGPIOs,
) -> Result<(), Error<SPI>>
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
Sourcepub async fn gpio_config_clocks(&mut self) -> Result<(), Error<SPI>>
pub async fn gpio_config_clocks(&mut self) -> Result<(), Error<SPI>>
Enable gpios clocks
Sourcepub async fn gpio_config_enable(
&mut self,
pin: u8,
enable: u8,
) -> Result<(), Error<SPI>>
pub async fn gpio_config_enable( &mut self, pin: u8, enable: u8, ) -> Result<(), Error<SPI>>
Enables single pin
Sourcepub async fn gpio_config_mode(
&mut self,
pin: u8,
mode: u8,
) -> Result<(), Error<SPI>>
pub async fn gpio_config_mode( &mut self, pin: u8, mode: u8, ) -> Result<(), Error<SPI>>
Configures mode for a single pin
Sourcepub async fn gpio_config_dir(
&mut self,
pin: u8,
dir: u8,
) -> Result<(), Error<SPI>>
pub async fn gpio_config_dir( &mut self, pin: u8, dir: u8, ) -> Result<(), Error<SPI>>
Configures direction for a single pin
Sourcepub async fn gpio_config_out(
&mut self,
pin: u8,
output: u8,
) -> Result<(), Error<SPI>>
pub async fn gpio_config_out( &mut self, pin: u8, output: u8, ) -> Result<(), Error<SPI>>
Configures output for a single pin
Sourcepub async fn get_gpio_config(&mut self) -> Result<ConfigGPIOs, Error<SPI>>
pub async fn get_gpio_config(&mut self) -> Result<ConfigGPIOs, Error<SPI>>
Returns GPIO config
Sourcepub async fn get_gpio_enabled(&mut self) -> Result<[u8; 9], Error<SPI>>
pub async fn get_gpio_enabled(&mut self) -> Result<[u8; 9], Error<SPI>>
Returns current gpio enable state
Source§impl<SPI, RECEIVING> DW3000<SPI, RECEIVING>
impl<SPI, RECEIVING> DW3000<SPI, RECEIVING>
Sourcepub async fn r_wait<'b>(
&mut self,
buffer: &'b mut [u8],
) -> Result<Message<'b>, Error<SPI>>
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.
Sourcepub async fn r_wait_buf(
&mut self,
buffer: &mut [u8],
) -> Result<(usize, Instant, RxQuality), Error<SPI>>
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§impl<SPI> DW3000<SPI, Sending>
impl<SPI> DW3000<SPI, Sending>
Sourcepub async fn s_wait(&mut self) -> Result<Instant, Error<SPI>>
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§impl<SPI> DW3000<SPI, Uninitialized>
impl<SPI> DW3000<SPI, Uninitialized>
Sourcepub fn new(spi: SPI) -> Self
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.
Sourcepub async fn read_otp(&mut self, addr: u16) -> Result<u32, Error<SPI>>
pub async fn read_otp(&mut self, addr: u16) -> Result<u32, Error<SPI>>
Read the OTP memory at the given address
Sourcepub async fn init(self) -> Result<DW3000<SPI, Uninitialized>, Error<SPI>>
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