[][src]Struct dw1000::hl::DW1000

pub struct DW1000<SPI, CS, State> { /* fields omitted */ }

Entry point to the DW1000 driver API

Methods

impl<SPI, CS> DW1000<SPI, CS, Uninitialized> where
    SPI: Transfer<u8> + Write<u8>,
    CS: OutputPin
[src]

pub fn new(spi: SPI, chip_select: CS) -> Self[src]

Create a new instance of DW1000

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

pub fn init(self) -> Result<DW1000<SPI, CS, Ready>, Error<SPI, CS>>[src]

Initialize the DW1000

The DW1000's default configuration is somewhat inconsistent, and the user manual (section 2.5.5) has a long list of default configuration values that should be changed to guarantee everything works correctly. This method does just that.

Please note that this method assumes that you kept the default configuration. It is generally recommended not to change configuration before calling this method.

impl<SPI, CS> DW1000<SPI, CS, Ready> where
    SPI: Transfer<u8> + Write<u8>,
    CS: OutputPin
[src]

pub fn set_antenna_delay(
    &mut self,
    rx_delay: u16,
    tx_delay: u16
) -> Result<(), Error<SPI, CS>>
[src]

Sets the RX and TX antenna delays

pub fn set_address(
    &mut self,
    pan_id: PanId,
    addr: ShortAddress
) -> Result<(), Error<SPI, CS>>
[src]

Sets the network id and address used for sending and receiving

pub fn send(
    self,
    data: &[u8],
    destination: Address,
    delayed_time: Option<Instant>,
    config: TxConfig
) -> Result<DW1000<SPI, CS, Sending>, Error<SPI, CS>>
[src]

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 DW1000 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.

pub fn receive(
    self,
    config: RxConfig
) -> Result<DW1000<SPI, CS, Receiving>, Error<SPI, CS>>
[src]

Attempt to receive an IEEE 802.15.4 MAC frame

Initializes the receiver. The method consumes this instance of DW1000 and returns another instance which is in the Receiving 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.

pub fn enable_tx_interrupts(&mut self) -> Result<(), Error<SPI, CS>>[src]

Enables transmit interrupts for the events that wait checks

Overwrites any interrupt flags that were previously set.

pub fn enable_rx_interrupts(&mut self) -> Result<(), Error<SPI, CS>>[src]

Enables receive interrupts for the events that wait checks

Overwrites any interrupt flags that were previously set.

pub fn disable_interrupts(&mut self) -> Result<(), Error<SPI, CS>>[src]

Disables all interrupts

pub fn configure_leds(
    &mut self,
    enable_rx_ok: bool,
    enable_sfd: bool,
    enable_rx: bool,
    enable_tx: bool,
    blink_time: u8
) -> Result<(), Error<SPI, CS>>
[src]

Configures the gpio pins to operate as LED output.

  • Note: This means that the function of the gpio pins change
  • Note: Both the kilohertz and debounce clock will be turned on or off

  • RXOKLED will change GPIO0
  • SFDLED will change GPIO1
  • RXLED will change GPIO2
  • TXLED will change GPIO3

blink_time is in units of 14 ms

impl<SPI, CS> DW1000<SPI, CS, Sending> where
    SPI: Transfer<u8> + Write<u8>,
    CS: OutputPin
[src]

pub fn wait(&mut self) -> Result<(), Error<SPI, CS>>[src]

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 DW1000::enable_tx_interrupts and the DW1000 IRQ output to wait in a more energy-efficient manner.

Handling the DW1000'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.

pub fn finish_sending(
    self
) -> Result<DW1000<SPI, CS, Ready>, (Self, Error<SPI, CS>)>
[src]

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.

impl<SPI, CS> DW1000<SPI, CS, Receiving> where
    SPI: Transfer<u8> + Write<u8>,
    CS: OutputPin
[src]

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

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 DW1000::enable_rx_interrupts and the DW1000 IRQ output to wait in a more energy-efficient manner.

Handling the DW1000'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.

pub fn finish_receiving(
    self
) -> Result<DW1000<SPI, CS, Ready>, (Self, Error<SPI, CS>)>
[src]

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.

impl<SPI, CS, State> DW1000<SPI, CS, State> where
    SPI: Transfer<u8> + Write<u8>,
    CS: OutputPin
[src]

pub fn get_tx_antenna_delay(&mut self) -> Result<Duration, Error<SPI, CS>>[src]

Returns the TX antenna delay

pub fn get_address(&mut self) -> Result<Address, Error<SPI, CS>>[src]

Returns the network id and address used for sending and receiving

pub fn sys_time(&mut self) -> Result<Instant, Error<SPI, CS>>[src]

Returns the current system time

pub fn ll(&mut self) -> &mut DW1000<SPI, CS>[src]

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 DW1000. Don't use the register-level and high-level APIs in tandem, unless you know what you're doing.

Trait Implementations

impl<SPI, CS, State> Debug for DW1000<SPI, CS, State> where
    State: Debug
[src]

Auto Trait Implementations

impl<SPI, CS, State> Send for DW1000<SPI, CS, State> where
    CS: Send,
    SPI: Send,
    State: Send

impl<SPI, CS, State> Sync for DW1000<SPI, CS, State> where
    CS: Sync,
    SPI: Sync,
    State: Sync

impl<SPI, CS, State> Unpin for DW1000<SPI, CS, State> where
    CS: Unpin,
    SPI: Unpin,
    State: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.