modm API documentation
|
#include <modm/driver/radio/dw3110/dw3110_phy.hpp>
Public Member Functions | |
modm::ResumableResult< void > | setChannel (Dw3110::Channel channel) |
Set the UWB channel used. | |
modm::ResumableResult< void > | setEnableLongFrames (bool value) |
modm::ResumableResult< void > | setSendHeaderFast (bool value) |
modm::ResumableResult< void > | setReceiveWaitTimeout (modm::chrono::micro_clock::duration duration) |
modm::ResumableResult< void > | setReenableOnRxFailure (bool value) |
Set whether to stay in receive mode after receive failure. | |
modm::ResumableResult< void > | setCCATimeout (uint16_t timeout) |
modm::ResumableResult< void > | setEnableFastTurnaround (bool value) |
modm::ResumableResult< uint32_t > | readChipTime () |
Read the value of the internal chip clock. | |
modm::ResumableResult< void > | setPreambleLength (Dw3110::PreambleLength len) |
modm::ResumableResult< uint64_t > | getReceiveTimestamp () |
modm::ResumableResult< uint64_t > | getTransmitTimestamp () |
Analogous to getReceiveTimestamp. | |
modm::ResumableResult< void > | setAcknowledgeTurnaround (uint8_t time) |
modm::ResumableResult< void > | setWaitForResponseTime (modm::PreciseClock::duration time) |
modm::ResumableResult< void > | setSFD (Dw3110::StartFrameDelimiter sfd) |
Set the start frame delimiter used by the chip. | |
modm::ResumableResult< void > | setPreambleCode (Dw3110::PreambleCode rx, Dw3110::PreambleCode tx) |
modm::ResumableResult< uint64_t > | getDeviceUID () |
Get devices unique id. | |
modm::ResumableResult< void > | setDeviceUID (uint64_t uid) |
Set devices unique id. | |
modm::ResumableResult< uint16_t > | getPanUID () |
Get devices pan id. | |
modm::ResumableResult< uint16_t > | getShortUID () |
Get devices short id. | |
modm::ResumableResult< void > | setPanUID (uint16_t pid) |
Set devices pan id. | |
modm::ResumableResult< void > | setShortUID (uint16_t pid) |
Set devices short id. | |
modm::ResumableResult< void > | setFrameFilterEnabled (bool value) |
Enable or disable the frame filtering. | |
modm::ResumableResult< Dw3110::FilterConfig_t > | getFilterConfig () |
Get current filtering config. | |
modm::ResumableResult< void > | setFilterConfig (Dw3110::FilterConfig_t fc) |
Set frame filtering config. | |
modm::ResumableResult< void > | setAutoAckEnabled (bool value) |
modm::ResumableResult< Dw3110::SystemState > | getChipState () |
Read the reported state of the chip. | |
modm::ResumableResult< void > | setAntennaDelay (uint16_t delay) |
modm::ResumableResult< uint16_t > | getRXAntennaDelay () |
modm::ResumableResult< uint16_t > | getTXAntennaDelay () |
modm::ResumableResult< float > | getReceiverClockOffset () |
modm::ResumableResult< bool > | calibrate () |
modm::ResumableResult< bool > | initialize (Dw3110::Channel channel=Dw3110::Channel::Channel5, Dw3110::PreambleCode pcode=Dw3110::PreambleCode::Code_64Mhz_9, Dw3110::PreambleLength plen=Dw3110::PreambleLength::Preamble_64, Dw3110::StartFrameDelimiter sfd=Dw3110::StartFrameDelimiter::IEEE802_15_4z_8) |
modm::ResumableResult< bool > | startReceive () |
Set the chip into receive mode. | |
modm::ResumableResult< bool > | packetReady () |
Check if a packet has been successfully received. | |
modm::ResumableResult< bool > | isReceiving () |
Check if the chip is currently in RX mode. | |
modm::ResumableResult< bool > | fetchPacket (std::span< uint8_t > payload, size_t &payload_len) |
template<TXMode tmode = TXMode::Default> | |
modm::ResumableResult< Error > | transmit (const std::span< const uint8_t > payload, bool ranging=true, bool fast=true) |
modm::ResumableResult< void > | setReferenceTime (uint32_t time) |
template<DelayTXMode dmode = DelayTXMode::AtTime> | |
modm::ResumableResult< Error > | transmitDelayed (uint32_t time, const std::span< const uint8_t > payload, bool ranging=true, bool fast=true) |
modm::ResumableResult< Dw3110::SystemStatus_t > | getStatus () |
Read the current system status register. | |
modm::ResumableResult< void > | clearStatusBits (Dw3110::SystemStatus_t mask) |
Clear the given bits in the status register. | |
modm::ResumableResult< void > | setInterruptsEnabled (Dw3110::SystemStatus_t mask) |
modm::ResumableResult< void > | setIRQPolarity (bool high) |
modm::ResumableResult< bool > | setSTSLength (uint8_t len) |
modm::ResumableResult< void > | setSTSMode (Dw3110::STSMode mode, bool sdc) |
modm::ResumableResult< uint16_t > | getSTSQuality () |
Return the 12-bit quality assessment of the last received STS. | |
modm::ResumableResult< bool > | getSTSGood () |
Return whether or not the STS quality is in an acceptable range. | |
modm::ResumableResult< void > | setSTSKey (std::span< const uint8_t, 16 > key) |
modm::ResumableResult< void > | setSTSIV (std::span< const uint8_t, 16 > iv) |
modm::ResumableResult< void > | getSTSKey (std::span< uint8_t, 16 > key) |
Get the Key to use for AES generation of the STS. | |
modm::ResumableResult< void > | getSTSIV (std::span< uint8_t, 16 > iv) |
modm::ResumableResult< uint32_t > | getCurrentCounter () |
Get lower 32 bits of the currently used STS IV. | |
modm::ResumableResult< void > | reloadSTSIV () |
Reload the STS IV from the STSIV registers. | |
modm::ResumableResult< void > | reuseLastSTSIV () |
Don't increment the STS IV for the next RX/TX. | |
void | attachConfigurationHandler (Spi::ConfigurationHandler handler) |
Protected Member Functions | |
template<modm::Dw3110::FastCommand Cmd> | |
modm::ResumableResult< Error > | transmitGeneric (std::span< const uint8_t > payload, bool ranging, bool fast) |
modm::ResumableResult< void > | loadOTP () |
modm::ResumableResult< bool > | checkDevID () |
Check the device ID over SPI. | |
template<Dw3110::FastCommand Cmd> | |
modm::ResumableResult< void > | sendCommand () |
Send a command to the chip. | |
modm::ResumableResult< void > | setRX_SFD_TOC () |
Recompute the SFD TOC. | |
modm::ResumableResult< void > | fetchSystemStatus () |
Update the local system_status variable. | |
modm::ResumableResult< void > | fetchChipState () |
Update the local chip_state variable. | |
modm::ResumableResult< Error > | checkTXFailed () |
template<Dw3110::OTPAddr Addr> | |
modm::ResumableResult< void > | readOTPMemory (std::span< uint8_t, 4 > out) |
Read a variable from the OTP memory. | |
template<Dw3110::Register Reg, size_t Len, size_t Offset = 0> | |
modm::ResumableResult< void > | readRegister (std::span< uint8_t, Len > out) |
Read a variable from a register. | |
template<Dw3110::RegisterBank Reg> | |
modm::ResumableResult< void > | readRegisterBank (std::span< uint8_t > out, size_t len) |
template<Dw3110::Register Reg, size_t Len, size_t Offset = 0> | |
modm::ResumableResult< void > | writeRegister (std::span< const uint8_t, Len > val) |
Write a variable to a register. | |
template<Dw3110::Register Reg, size_t Len, size_t Offset = 0> | |
modm::ResumableResult< void > | readModifyWriteRegister (std::span< const uint8_t, Len > or_mask, std::span< const uint8_t, Len > and_mask) |
template<Dw3110::Register Reg, size_t Len, size_t Offset = 0> | |
modm::ResumableResult< void > | writeRegisterMasked (std::span< const uint8_t, Len > or_mask, std::span< const uint8_t, Len > and_mask) |
Do not use to clear "write 1 to clear" bits (2.3.1.2 Table 3) | |
template<Dw3110::RegisterBank Reg> | |
modm::ResumableResult< void > | writeRegisterBank (std::span< const uint8_t > val, size_t len) |
bool | acquireMaster () |
bool | releaseMaster () |
int8_t | getResumableDepth () const |
bool | isResumableRunning () const |
void | stopResumable () |
Hardware abstraction layer for DW3110
Unsupported Features: AES encryption, Double buffering, GPIO, Temperature and Voltage, Pulse Generator calibration, RX antenna delay temp compensation, Soft reset, Sleep, Sniff mode
modm::ResumableResult<bool> modm::Dw3110Phy< SpiMaster, Cs >::calibrate | ( | ) |
Runs the RX calibration.
Needs to be done after startup, wake and after 20C temperature change
Needs to be run when chip is in IDLE_PLL state
Automatically run by initialize()
|
protected |
Due to an errata the check is a bit more complicated
Relies on system_status and chip_state being up to date
modm::ResumableResult<bool> modm::Dw3110Phy< SpiMaster, Cs >::fetchPacket | ( | std::span< uint8_t > | payload, |
size_t & | payload_len | ||
) |
Copy received packet into the provided payload buffer, clear packet received flags
payload | Region of memory the payload will be written to |
payload_len | Contains the length of the received payload |
modm::ResumableResult<float> modm::Dw3110Phy< SpiMaster, Cs >::getReceiverClockOffset | ( | ) |
Get the Clock offset multiplier for the received packet
Can be used to recover the clock drift compared to a packets sender
Unit is in parts per million (ppm)
modm::ResumableResult<uint64_t> modm::Dw3110Phy< SpiMaster, Cs >::getReceiveTimestamp | ( | ) |
Get the timestamp of the last arrived packet.
This timestamp already has various correction factors applied to it.
It is given in ~15.65 picoseconds per unit
modm::ResumableResult<uint16_t> modm::Dw3110Phy< SpiMaster, Cs >::getRXAntennaDelay | ( | ) |
Get the currently programmed RX antenna delay
Unit is approx 15.65ps
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::getSTSIV | ( | std::span< uint8_t, 16 > | iv | ) |
Get the IV to use for AES generation of the STS
modm::ResumableResult<uint16_t> modm::Dw3110Phy< SpiMaster, Cs >::getTXAntennaDelay | ( | ) |
Get the currently programmed TX antenna delay
Unit is approx 15.65ps
modm::ResumableResult<bool> modm::Dw3110Phy< SpiMaster, Cs >::initialize | ( | Dw3110::Channel | channel = Dw3110::Channel::Channel5 , |
Dw3110::PreambleCode | pcode = Dw3110::PreambleCode::Code_64Mhz_9 , |
||
Dw3110::PreambleLength | plen = Dw3110::PreambleLength::Preamble_64 , |
||
Dw3110::StartFrameDelimiter | sfd = Dw3110::StartFrameDelimiter::IEEE802_15_4z_8 |
||
) |
Initialize the DW3000, make ready to receive/transmit
Call ideally after the IRQ Pin has gone high, signalling SPIRDY
|
protected |
Only load configuration independent stuff, everything else should be initialized when changing those parts
|
protected |
Simple implementation of read modify write using and and or masks
Use on registers that do not support native write register masked
|
protected |
Read a number of bytes from a register bank, useful for RX buffers and other large read transfers
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setAcknowledgeTurnaround | ( | uint8_t | time | ) |
Set the time between RX of a packet and the TX of the acknowledgement
Specified in number of preamble symbols, so time depends on the PRF
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setAntennaDelay | ( | uint16_t | delay | ) |
Set both the RX and TX antenna delay
Unit is approx 15.65ps
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setAutoAckEnabled | ( | bool | value | ) |
Enable auto acknowledgment
Will automatically respond to valid 802.5.14 Frames with the ACK request bit set
Only active when Frame filtering is enabled
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setCCATimeout | ( | uint16_t | timeout | ) |
Set the time spent listening for competing transmissions on CCA commands
Unit is in counts of PAC symbols
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setEnableFastTurnaround | ( | bool | value | ) |
Enable a faster TX/RX turnaround.
The Frame will be set ready before computation of ToA data has finished and any ACKs will be sent.
Time of Arrival may not be ready when the frame is made available
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setEnableLongFrames | ( | bool | value | ) |
Change Header format to non-standard to allow 1021 Byte payloads instead of default 125
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setInterruptsEnabled | ( | Dw3110::SystemStatus_t | mask | ) |
Set interrupt bits
Set on which status events the IRQ Pin of the chip should be pulled high
Interrupt condition can be cleared by clearing the corresponding status bit using clearStatusBits()
Polarity of the line can be changed with setIRQPolarity()
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setIRQPolarity | ( | bool | high | ) |
Set the polarity of the interrupt line
Default is active high
high | If true sets the line to active high |
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setPreambleCode | ( | Dw3110::PreambleCode | rx, |
Dw3110::PreambleCode | tx | ||
) |
Set the preamble code used and looked for.
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setPreambleLength | ( | Dw3110::PreambleLength | len | ) |
Set the number of preamble symbols sent with each transmission
Each symbol takes ~1µs to send
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setReceiveWaitTimeout | ( | modm::chrono::micro_clock::duration | duration | ) |
Set the timeout to wait on arriving packets after startReceive()
0 = No Timeout
Register resolution is ~1µs
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setReferenceTime | ( | uint32_t | time | ) |
Set the reference time value
Used as the reference in transmitDelayed() when using DelayTXMode::DelayWRTRef and DelayTXMode::DelayWRTRefAndReceive
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setSendHeaderFast | ( | bool | value | ) |
Send the PHR at 6.8Mbps.
By default the PHR is always sent at 850kb/s
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setSTSIV | ( | std::span< const uint8_t, 16 > | iv | ) |
Set the IV to use for AES generation of the STS
Ignored if SDC is set in setSTSMode()
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setSTSKey | ( | std::span< const uint8_t, 16 > | key | ) |
Set the Key to use for AES generation of the STS
Ignored if SDC is set in setSTSMode()
modm::ResumableResult<bool> modm::Dw3110Phy< SpiMaster, Cs >::setSTSLength | ( | uint8_t | len | ) |
Set the length of the generated Secure timestamp
len | Length in units of 8 chips (~1µs), minimum supported is 32 chips(e.g a value of 3) |
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setSTSMode | ( | Dw3110::STSMode | mode, |
bool | sdc | ||
) |
Set the STS mode
mode | Defines where to place the STS inside the packet |
sdc | If true IV and Key are ignored and a deterministic code is used |
modm::ResumableResult<void> modm::Dw3110Phy< SpiMaster, Cs >::setWaitForResponseTime | ( | modm::PreciseClock::duration | time | ) |
Set the time between a transmission and the start of RX on any of the RX after TX commands
This can be used to delay turning on of the receiver after transmission to save on power.
modm::ResumableResult<Error> modm::Dw3110Phy< SpiMaster, Cs >::transmit | ( | const std::span< const uint8_t > | payload, |
bool | ranging = true , |
||
bool | fast = true |
||
) |
Transmit a given package using the current configuration using a given transmission mode
payload | Span to the desired payload |
ranging | Decides whether or not to set the ranging bit in the header |
fast | Decides if the data portion is sent at 850kbps or 6.8Mbps |
modm::ResumableResult<Error> modm::Dw3110Phy< SpiMaster, Cs >::transmitDelayed | ( | uint32_t | time, |
const std::span< const uint8_t > | payload, | ||
bool | ranging = true , |
||
bool | fast = true |
||
) |
Transmit a given package using the current configuration using a given delayed transmission mode
payload | Span to the desired payload |
ranging | Decides whether or not to set the ranging bit in the header |
fast | Decides if the data portion is sent at 850kbps or 6.8Mbps |
time | Either the transmission time or a delay in units of 4ns dependent on the DelayTXMode provided |
|
protected |
Transmit a given package using the current configuration and a specific command
payload | Span to the desired payload |
ranging | Decides whether or not to set the ranging bit in the header |
fast | Decides if the data portion is sent at 850kbps or 6.8Mbps command |
|
protected |
Write a number of bytes to a register bank, useful for TX buffers and other large write transfers