DecaDuino
Ranging/synchronisation over UWB - DecaDuino library for Arduino
|
#include <DecaDuino.h>
Public Member Functions | |
DecaDuino (uint8_t slaveSelectPin=DW1000_CS0_PIN, uint8_t interruptPin=DW1000_IRQ0_PIN) | |
DecaDuino Constructor. More... | |
boolean | init () |
Initializes DecaDuino and DWM1000 without addressing fields filtering (Promiscuous mode) More... | |
boolean | init (uint32_t shortAddrAndPanId) |
Initializes DecaDuino and DWM1000 with given Short Address and Pan Id. More... | |
void | resetDW1000 () |
Reset the DW1000 chip. More... | |
void | setPHRMode (uint8_t mode) |
Set PHR Mode. More... | |
uint8_t | getPHRMode (void) |
Returns the PHR Mode. More... | |
void | getSystemTimeCounter (uint64_t *p) |
Stores the System Time Counter value in the variable referenced by the pointer passed as an input parameter. More... | |
uint64_t | getSystemTimeCounter (void) |
Returns the System Time Counter value. More... | |
uint16_t | getPanId () |
Gets the PanId (Personnal Area Network Identifier) stored in the DW1000's RAM. More... | |
uint16_t | getShortAddress () |
Gets the ShortAddress (16-bit network address, aka IEEE short address) stored in the DW1000's RAM. More... | |
uint64_t | getEuid () |
Gets the Euid (Extended Unique IDentifier) stored in the DW1000's ROM. More... | |
void | setPanId (uint16_t panId) |
Sets the PanId (Personnal Area Network Identifier) in the DW1000's RAM. More... | |
void | setShortAddress (uint16_t shortAddress) |
Sets the ShortAddress (16-bit network address, aka IEEE short address) in the DW1000's RAM. More... | |
void | setShortAddressAndPanId (uint16_t shortAddress, uint16_t panId) |
Sets both the ShortAddress and the PanId in the DW1000's RAM. More... | |
int | setShortAddressAndPanId (uint32_t shortAddressPanId) |
Sets both the ShortAddress and the PanId in the DW1000's RAM. More... | |
uint8_t | getChannelRaw (void) |
Returns the currently configured radio channels. More... | |
uint8_t | getChannel (void) |
Returns the currently configured radio channel. More... | |
uint8_t | getRxPrf (void) |
Returns the currently configured Pulse Repetition Frequency. More... | |
uint8_t | getTxPcode (void) |
Returns the currently configured Tx Preamble Code. More... | |
uint8_t | getRxPcode (void) |
Returns the currently configured Rx Preamble Code. More... | |
bool | setChannel (uint8_t channel) |
Sets the radio channels for TX and RX. More... | |
bool | setRxPrf (uint8_t prf) |
Sets the Pulse Repetition Frequency. More... | |
bool | setTxPcode (uint8_t pcode) |
Sets the Tx Preamble Code. More... | |
bool | setRxPcode (uint8_t pcode) |
Sets the Rx Preamble Code. More... | |
int | getPreambleLength (void) |
Returns the preamble length. More... | |
bool | setPreambleLength (int plength) |
Sets the preamble length. More... | |
uint64_t | alignDelayedTransmission (uint64_t wantedDelay) |
Returns an aligned timestamp to use with pdDataRequest() in case of delayed transmissions. More... | |
uint8_t | pdDataRequest (uint8_t *buf, uint16_t len) |
Sends a len-byte frame from buf. More... | |
uint8_t | pdDataRequest (uint8_t *buf, uint16_t len, uint8_t delayed, uint64_t time) |
Sends a len-byte frame from buf with an optionnal delay. More... | |
uint8_t | send (uint8_t *buf, uint16_t len) |
Sends a len-byte frame from buf. More... | |
uint8_t | send (uint8_t *buf, uint16_t len, uint8_t delayed, uint64_t time) |
Sends a len-byte frame from buf with an optionnal delay. More... | |
void | setRxBuffer (uint8_t *buf, uint16_t *len) |
Sets the RX buffer for future frame reception. Received bytes will be stored at the beginning of the buffer. More... | |
void | setRxBuffer (uint8_t *buf, uint16_t *len, uint16_t max) |
Sets the RX buffer for future frame reception. Received bytes will be stored at the end of the buffer of max size. More... | |
void | plmeRxEnableRequest (void) |
Sets transceiver mode to receive mode. More... | |
void | plmeRxEnableRequest (uint16_t max) |
Sets transceiver mode to receive mode. Received bytes will be stored at the end of the buffer of max size. More... | |
void | plmeRxEnableRequest (uint8_t *buf, uint16_t *len) |
Sets transceiver mode to receive mode and set the RX buffer for future frame reception. More... | |
void | plmeRxEnableRequest (uint8_t *buf, uint16_t *len, uint16_t max) |
Sets transceiver mode to receive mode and set the RX buffer for future frame reception. Received bytes will be stored at the end of the buffer of max size. More... | |
void | plmeRxDisableRequest (void) |
Sets transceiver mode to idle mode. More... | |
void | sleepRequest (void) |
Sets transceiver mode to sleep mode. More... | |
uint8_t | rxFrameAvailable (void) |
Returns true if a frame has been received. More... | |
uint8_t | rxFrameAvailable (uint8_t *buf, uint16_t *len) |
Returns true if a frame has been received, copy received bytes in buf and store message length in len. More... | |
uint8_t | rxFrameAvailable (uint8_t *buf, uint16_t *len, uint16_t max) |
Returns true if a frame has been received, copy received bytes in buf and store message length in len. The received bytes shall be copied toward the end of the buffer of size max. More... | |
bool | hasTxSucceeded (void) |
Returns true if the last transmission request has been succefully completed. More... | |
uint8_t | getTrxStatus (void) |
Gets the DecaDuino transceiver status. More... | |
uint8_t | getTemperatureRaw (void) |
Gets the raw value from the DW1000's embedded temperature sensor. More... | |
float | getTemperature (void) |
Gets the temperature value in celsius degrees from the DW1000's embedded temperature sensor. More... | |
uint8_t | getVoltageRaw (void) |
Gets the raw value from the DW1000's embedded voltage sensor. More... | |
float | getVoltage (void) |
Gets the voltage value in volts from the DW1000's embedded voltage sensor. More... | |
uint16_t | decodeUint16 (uint8_t *data) |
Builds an uint16 value from two uint8 values. More... | |
void | encodeUint16 (uint16_t from, uint8_t *to) |
Formats an uint16 value as a list of uint8 values. More... | |
uint32_t | decodeUint32 (uint8_t *data) |
Builds an uint32 value from four uint8 values. More... | |
void | encodeUint32 (uint32_t from, uint8_t *to) |
Formats an uint32 value as a list of uint8 values. More... | |
uint64_t | decodeUint40 (uint8_t *data) |
Builds an uint64 value from five uint8 values. More... | |
void | encodeUint40 (uint64_t from, uint8_t *to) |
Formats an uint64 value with only 5 LSbytes as a list of uint8 values. More... | |
uint64_t | decodeUint64 (uint8_t *data) |
Builds an uint64 value from eight uint8 values. More... | |
void | encodeUint64 (uint64_t from, uint8_t *to) |
Formats an uint64 value as a list of uint8 values. More... | |
float | decodeFloat (uint8_t *data) |
Builds a float value from four uint8 values. More... | |
void | encodeFloat (float from, uint8_t *to) |
Formats an float value as a list of uint8 values. More... | |
void | printUint64 (uint64_t ui64) |
Prints an uint64_t value on console. More... | |
uint64_t | getLastTxTimestamp () |
Returns last transmitted frame timestamp based on the DWM1000 System Time Counter at 64GHz. More... | |
uint64_t | getLastRxTimestamp () |
Returns last received frame timestamp based on the DWM1000 System Time Counter at 64GHz. More... | |
double | getLastRxSkew () |
Returns last received frame's clock skew, also designated as clock offset in the Decawave documentation. More... | |
uint16_t | getAntennaDelay () |
Returns current antenna delay value. More... | |
void | setAntennaDelay (uint16_t newAntennaDelay) |
Sets the current antenna delay value. More... | |
Protected Member Functions | |
void | handleInterrupt () |
The global interrupt function. More... | |
Static Protected Member Functions | |
static void | isr0 () |
The first interrupt function. More... | |
static void | isr1 () |
The second interrupt function. More... | |
static void | isr2 () |
The third interrupt function. More... | |
Protected Attributes | |
SPISettings | currentSPISettings |
Current SPI-bus settings. More... | |
uint64_t | euid |
Current EUID (Extended Unique IDentifier) More... | |
uint8_t * | rxData |
The current (or last) PPDU. More... | |
uint16_t * | rxDataLen |
The current PPDU length. More... | |
uint16_t | rxDataLenMax |
The max PPDU length. More... | |
uint8_t | rxDataAvailable |
Flag indicating if last reception has data. More... | |
uint8_t | trxStatus |
Transceiver status. More... | |
bool | lastTxOK |
Flag indicating if last transmission is done. More... | |
uint64_t | lastTxTimestamp |
Timestamp of last transmitted frame. More... | |
uint64_t | lastRxTimestamp |
Timestamp of last received frame. More... | |
double | clkOffset |
Last clock offset (aka clock skew) More... | |
uint8_t | _slaveSelectPin |
uint8_t | _interruptPin |
Static Protected Attributes | |
static DecaDuino * | _DecaDuinoInterrupt [] = {0, 0, 0} |
DecaDuino::DecaDuino | ( | uint8_t | slaveSelectPin = DW1000_CS0_PIN , |
uint8_t | interruptPin = DW1000_IRQ0_PIN |
||
) |
DecaDuino Constructor.
slaveSelectPin | The slaveSelect pin number |
interruptPin | The interrupt pin number |
uint64_t DecaDuino::alignDelayedTransmission | ( | uint64_t | wantedDelay | ) |
Returns an aligned timestamp to use with pdDataRequest() in case of delayed transmissions.
wantedDelay | The required delay to align the delayed transmission |
float DecaDuino::decodeFloat | ( | uint8_t * | data | ) |
Builds a float value from four uint8 values.
data | The address of the uint8_t buffer |
uint16_t DecaDuino::decodeUint16 | ( | uint8_t * | data | ) |
Builds an uint16 value from two uint8 values.
data | The address of the uint8_t buffer |
uint32_t DecaDuino::decodeUint32 | ( | uint8_t * | data | ) |
Builds an uint32 value from four uint8 values.
data | The address of the uint8_t buffer |
uint64_t DecaDuino::decodeUint40 | ( | uint8_t * | data | ) |
Builds an uint64 value from five uint8 values.
data | The address of the uint8_t buffer |
uint64_t DecaDuino::decodeUint64 | ( | uint8_t * | data | ) |
Builds an uint64 value from eight uint8 values.
data | The address of the uint8_t buffer |
void DecaDuino::encodeFloat | ( | float | from, |
uint8_t * | to | ||
) |
Formats an float value as a list of uint8 values.
from | The float value |
to | The address of the uint8_t buffer |
void DecaDuino::encodeUint16 | ( | uint16_t | from, |
uint8_t * | to | ||
) |
Formats an uint16 value as a list of uint8 values.
from | The uint16_t value |
to | The address of the uint8_t buffer |
void DecaDuino::encodeUint32 | ( | uint32_t | from, |
uint8_t * | to | ||
) |
Formats an uint32 value as a list of uint8 values.
from | The uint32_t value |
to | The address of the uint8_t buffer |
void DecaDuino::encodeUint40 | ( | uint64_t | from, |
uint8_t * | to | ||
) |
Formats an uint64 value with only 5 LSbytes as a list of uint8 values.
from | The uint64_t value |
to | The address of the uint8_t buffer |
void DecaDuino::encodeUint64 | ( | uint64_t | from, |
uint8_t * | to | ||
) |
Formats an uint64 value as a list of uint8 values.
from | The uint64_t value |
to | The address of the uint8_t buffer |
uint16_t DecaDuino::getAntennaDelay | ( | ) |
Returns current antenna delay value.
uint8_t DecaDuino::getChannel | ( | void | ) |
Returns the currently configured radio channel.
uint8_t DecaDuino::getChannelRaw | ( | void | ) |
Returns the currently configured radio channels.
uint64_t DecaDuino::getEuid | ( | ) |
Gets the Euid (Extended Unique IDentifier) stored in the DW1000's ROM.
double DecaDuino::getLastRxSkew | ( | ) |
Returns last received frame's clock skew, also designated as clock offset in the Decawave documentation.
uint64_t DecaDuino::getLastRxTimestamp | ( | ) |
Returns last received frame timestamp based on the DWM1000 System Time Counter at 64GHz.
uint64_t DecaDuino::getLastTxTimestamp | ( | ) |
Returns last transmitted frame timestamp based on the DWM1000 System Time Counter at 64GHz.
uint16_t DecaDuino::getPanId | ( | ) |
Gets the PanId (Personnal Area Network Identifier) stored in the DW1000's RAM.
uint8_t DecaDuino::getPHRMode | ( | void | ) |
Returns the PHR Mode.
int DecaDuino::getPreambleLength | ( | void | ) |
Returns the preamble length.
uint8_t DecaDuino::getRxPcode | ( | void | ) |
Returns the currently configured Rx Preamble Code.
uint8_t DecaDuino::getRxPrf | ( | void | ) |
Returns the currently configured Pulse Repetition Frequency.
uint16_t DecaDuino::getShortAddress | ( | ) |
Gets the ShortAddress (16-bit network address, aka IEEE short address) stored in the DW1000's RAM.
void DecaDuino::getSystemTimeCounter | ( | uint64_t * | p | ) |
Stores the System Time Counter value in the variable referenced by the pointer passed as an input parameter.
p | The address of the uint64_t variable |
uint64_t DecaDuino::getSystemTimeCounter | ( | void | ) |
Returns the System Time Counter value.
float DecaDuino::getTemperature | ( | void | ) |
Gets the temperature value in celsius degrees from the DW1000's embedded temperature sensor.
uint8_t DecaDuino::getTemperatureRaw | ( | void | ) |
Gets the raw value from the DW1000's embedded temperature sensor.
uint8_t DecaDuino::getTrxStatus | ( | void | ) |
uint8_t DecaDuino::getTxPcode | ( | void | ) |
Returns the currently configured Tx Preamble Code.
float DecaDuino::getVoltage | ( | void | ) |
Gets the voltage value in volts from the DW1000's embedded voltage sensor.
uint8_t DecaDuino::getVoltageRaw | ( | void | ) |
Gets the raw value from the DW1000's embedded voltage sensor.
|
protected |
The global interrupt function.
bool DecaDuino::hasTxSucceeded | ( | void | ) |
Returns true if the last transmission request has been succefully completed.
boolean DecaDuino::init | ( | ) |
boolean DecaDuino::init | ( | uint32_t | shortAddrAndPanId | ) |
|
staticprotected |
The first interrupt function.
|
staticprotected |
The second interrupt function.
|
staticprotected |
The third interrupt function.
uint8_t DecaDuino::pdDataRequest | ( | uint8_t * | buf, |
uint16_t | len | ||
) |
Sends a len-byte frame from buf.
buf | The address of the buffer |
len | The message length |
uint8_t DecaDuino::pdDataRequest | ( | uint8_t * | buf, |
uint16_t | len, | ||
uint8_t | delayed, | ||
uint64_t | time | ||
) |
Sends a len-byte frame from buf with an optionnal delay.
buf | The address of the buffer |
len | The message length |
delayed | The delayed flag (true or false) |
time | The time to send, based on the DWM1000 System Time Counter at 64GHz |
void DecaDuino::plmeRxDisableRequest | ( | void | ) |
Sets transceiver mode to idle mode.
void DecaDuino::plmeRxEnableRequest | ( | void | ) |
Sets transceiver mode to receive mode.
void DecaDuino::plmeRxEnableRequest | ( | uint16_t | max | ) |
Sets transceiver mode to receive mode. Received bytes will be stored at the end of the buffer of max size.
max | The buffer size |
void DecaDuino::plmeRxEnableRequest | ( | uint8_t * | buf, |
uint16_t * | len | ||
) |
Sets transceiver mode to receive mode and set the RX buffer for future frame reception.
buf | The address of the buffer |
len | The address of the message length |
void DecaDuino::plmeRxEnableRequest | ( | uint8_t * | buf, |
uint16_t * | len, | ||
uint16_t | max | ||
) |
Sets transceiver mode to receive mode and set the RX buffer for future frame reception. Received bytes will be stored at the end of the buffer of max size.
buf | The address of the buffer |
len | The address of the message length |
max | The buffer size |
void DecaDuino::printUint64 | ( | uint64_t | ui64 | ) |
Prints an uint64_t value on console.
ui64 | The uint64_t value |
void DecaDuino::resetDW1000 | ( | ) |
Reset the DW1000 chip.
uint8_t DecaDuino::rxFrameAvailable | ( | void | ) |
Returns true if a frame has been received.
uint8_t DecaDuino::rxFrameAvailable | ( | uint8_t * | buf, |
uint16_t * | len | ||
) |
Returns true if a frame has been received, copy received bytes in buf and store message length in len.
buf | The address of the buffer |
len | The address of the message length |
uint8_t DecaDuino::rxFrameAvailable | ( | uint8_t * | buf, |
uint16_t * | len, | ||
uint16_t | max | ||
) |
Returns true if a frame has been received, copy received bytes in buf and store message length in len. The received bytes shall be copied toward the end of the buffer of size max.
buf | The address of the buffer |
len | The address of the message length |
max | The buffer size |
uint8_t DecaDuino::send | ( | uint8_t * | buf, |
uint16_t | len | ||
) |
Sends a len-byte frame from buf.
buf | The address of the buffer |
len | The message length |
uint8_t DecaDuino::send | ( | uint8_t * | buf, |
uint16_t | len, | ||
uint8_t | delayed, | ||
uint64_t | time | ||
) |
Sends a len-byte frame from buf with an optionnal delay.
buf | The address of the buffer |
len | The message length |
delayed | The delayed flag (true or false) |
time | The time to send, based on the DWM1000 System Time Counter at 64GHz |
void DecaDuino::setAntennaDelay | ( | uint16_t | newAntennaDelay | ) |
Sets the current antenna delay value.
antennaDelay | The antenna delay value |
bool DecaDuino::setChannel | ( | uint8_t | channel | ) |
Sets the radio channels for TX and RX.
channel | The channel number to set. Valid values are: 1, 2, 3, 4, 5, 7. |
void DecaDuino::setPanId | ( | uint16_t | panId | ) |
Sets the PanId (Personnal Area Network Identifier) in the DW1000's RAM.
panId | The 16-bit PANID (PAN Identifier) |
void DecaDuino::setPHRMode | ( | uint8_t | mode | ) |
Set PHR Mode.
mode | 0 for standard 127 bytes frame, 3 for extended 1023 bytes frame |
bool DecaDuino::setPreambleLength | ( | int | plength | ) |
Sets the preamble length.
plength | The preamble length to set. Valid values are: 64, 128, 256, 512, 1024, 1536, 2048, 4096. |
void DecaDuino::setRxBuffer | ( | uint8_t * | buf, |
uint16_t * | len | ||
) |
Sets the RX buffer for future frame reception. Received bytes will be stored at the beginning of the buffer.
buf | The address of the buffer |
len | The address of the message length |
void DecaDuino::setRxBuffer | ( | uint8_t * | buf, |
uint16_t * | len, | ||
uint16_t | max | ||
) |
Sets the RX buffer for future frame reception. Received bytes will be stored at the end of the buffer of max size.
buf | The address of the buffer |
len | The address of the message length |
max | The buffer size |
bool DecaDuino::setRxPcode | ( | uint8_t | pcode | ) |
Sets the Rx Preamble Code.
pcode | The Preamble Code to set. Valid values are: 1-20. |
bool DecaDuino::setRxPrf | ( | uint8_t | prf | ) |
Sets the Pulse Repetition Frequency.
prf | The PRF value to set. Valid values are: 1, 2. |
void DecaDuino::setShortAddress | ( | uint16_t | shortAddress | ) |
Sets the ShortAddress (16-bit network address, aka IEEE short address) in the DW1000's RAM.
shortAddress | The 16-bit short address |
void DecaDuino::setShortAddressAndPanId | ( | uint16_t | shortAddress, |
uint16_t | panId | ||
) |
Sets both the ShortAddress and the PanId in the DW1000's RAM.
shortAddress | The 16-bit short address |
panId | The 16-bit PANID (PAN Identifier) |
int DecaDuino::setShortAddressAndPanId | ( | uint32_t | shortAddressPanId | ) |
Sets both the ShortAddress and the PanId in the DW1000's RAM.
shortAddressPanId | The 16-bit short address and 16-bit Pan Id as a 32-bit integer where short address in on the LSB. |
bool DecaDuino::setTxPcode | ( | uint8_t | pcode | ) |
Sets the Tx Preamble Code.
pcode | The Preamble Code to set. Valid values are: 1-20. |
void DecaDuino::sleepRequest | ( | void | ) |
Sets transceiver mode to sleep mode.
|
staticprotected |
|
protected |
|
protected |
|
protected |
Last clock offset (aka clock skew)
|
protected |
Current SPI-bus settings.
|
protected |
Current EUID (Extended Unique IDentifier)
|
protected |
Timestamp of last received frame.
|
protected |
Flag indicating if last transmission is done.
|
protected |
Timestamp of last transmitted frame.
|
protected |
The current (or last) PPDU.
|
protected |
Flag indicating if last reception has data.
|
protected |
The current PPDU length.
|
protected |
The max PPDU length.
|
protected |
Transceiver status.