Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dw1000/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Unreleased

- Add TX continuation (into RX state) for fast tx-rx turnaround time
- Add auto ack functionality
- Add support for 'raw' messages (aka it's up to the user to encode them as valid ieee 802.15.4 frames)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot to add this in the last PR, so added it here


### v0.6.0 (2021-12-14)

- Add support for double-buffering RX ([#134])
Expand Down
76 changes: 76 additions & 0 deletions dw1000/src/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub struct TxConfig {
pub sfd_sequence: SfdSequence,
/// When true, a CRC will be appended to the message
pub append_crc: bool,
/// Setting for how the transmission should be continued
pub continuation: TxContinuation,
}

impl Default for TxConfig {
Expand All @@ -38,10 +40,33 @@ impl Default for TxConfig {
channel: Default::default(),
sfd_sequence: Default::default(),
append_crc: true,
continuation: TxContinuation::Ready,
}
}
}

/// Setting for how the transmission should be continued
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default)]
pub enum TxContinuation {
#[default]
/// After the transmission the radio should go back to ready
Ready,
/// After the transmission the radio should go to the receiving state
Rx {
/// Enable frame filtering. See [RxConfig::frame_filtering]
frame_filtering: bool,
/// Used as the [RxConfig::auto_ack] value
auto_ack: AutoAck,
},
/// After the transmission the radio should go to the double buffered receiving state
RxDoubleBuffered {
/// Enable frame filtering. See [RxConfig::frame_filtering]
frame_filtering: bool,
/// Used as the [RxConfig::auto_ack] value
auto_ack: AutoAck,
},
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
/// Receive configuration
pub struct RxConfig {
Expand All @@ -68,6 +93,35 @@ pub struct RxConfig {
pub sfd_sequence: SfdSequence,
/// When true, a CRC will be expected to be appended to the message
pub append_crc: bool,
/// When enabled, the radio itself will send acks to messages with the ack bit enabled.
pub auto_ack: AutoAck,
}

impl RxConfig {
/// Create an [RxConfig] by copying the properties from a [TxConfig] and adding missing properties
pub const fn from_tx_config(tx_config: TxConfig, frame_filtering: bool, auto_ack: AutoAck) -> Self {
let TxConfig {
bitrate,
ranging_enable: _,
pulse_repetition_frequency,
preamble_length,
channel,
sfd_sequence,
append_crc,
continuation: _,
} = tx_config;

RxConfig {
bitrate,
frame_filtering,
pulse_repetition_frequency,
expected_preamble_length: preamble_length,
channel,
sfd_sequence,
append_crc,
auto_ack,
}
}
}

impl Default for RxConfig {
Expand All @@ -80,10 +134,32 @@ impl Default for RxConfig {
channel: Default::default(),
sfd_sequence: Default::default(),
append_crc: true,
auto_ack: Default::default(),
}
}
}

/// The auto acknowledge behavior
#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default)]
pub enum AutoAck {
#[default]
/// No automatic acks are sent
Disabled,
/// An automatic Ack will be sent if:
/// - Frame filtering is on
/// - The received frame passes through the filter
/// - The frame has the ack bit set
Enabled {
/// The turnaround time in number of symbols.
///
/// Recommended minimal value:
/// - 110 kbps: 0
/// - 850 kbps: 2
/// - 6.8 Mbps: 3
turnaround_time: u8,
},
}

#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, TryFromPrimitive)]
#[repr(u8)]
/// The bitrate at which a message is transmitted
Expand Down
6 changes: 6 additions & 0 deletions dw1000/src/hl/awake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ where
Ok(Instant::new(sys_time).unwrap())
}

/// Set the value of the pending bit used by the auto acks
pub fn set_pending_bit(&mut self, value: bool) -> Result<(), Error<SPI>> {
self.ll.sys_cfg().modify(|_, w| w.aackpend(value as u8))?;
Ok(())
}

/// Provides direct access to the register-level API
///
/// Be aware that by using the register-level API, you can invalidate
Expand Down
12 changes: 12 additions & 0 deletions dw1000/src/hl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ where
/// There are issues with frame filtering in double buffer mode.
/// So it's not supported now.
RxConfigFrameFilteringUnsupported,

/// The wrong continuation was called on the radio
WrongTxContinuation,

/// The transmission has not yet finished
TxNotFinishedyet,
}

impl<SPI> From<ll::Error<SPI>> for Error<SPI>
Expand Down Expand Up @@ -131,6 +137,12 @@ where
Error::RxConfigFrameFilteringUnsupported => {
write!(f, "RxConfigFrameFilteringUnsupported")
}
Error::WrongTxContinuation => {
write!(f, "WrongTxContinuation")
}
Error::TxNotFinishedyet => {
write!(f, "TxNotFinishedyet")
}
}
}
}
Loading