GithubHelp home page GithubHelp logo

libdw1000's Introduction

Libdw1000 CI

Open source driver implementation for the Decawave DW1000 UWB radio chip

This driver is mainly a port of the Arduino DW1000 driver. As such is is licensed under the same license, Apache2.

Usage

Initialize

All functions of the lib takes a dwDevice_t * as first argument. The struct contains the state of the driver, and the purpose is to enable the driver could be used to control more than one dw1000 radio in the same system.

Example of libdw initialization:

dwDevice_t dwm_device;
dwDevice_t *dwm = &dwm_device;

// (...)

printf("TEST\t: Initialize DWM1000 ... ");
dwInit(dwm, &dwOps);       // Init libdw
dwOpsInit(dwm);
result = dwConfigure(dwm); // Configure the dw1000 chip
if (result == 0) {
  printf("[OK]\r\n");
  dwEnableAllLeds(dwm);
} else {
  printf("[ERROR]: %s\r\n", dwStrError(result));
  selftestPasses = false;
}

// (...)

dwTime_t delay = {.full = ANTENNA_DELAY/2};
dwSetAntenaDelay(dwm, delay);

dwAttachSentHandler(dwm, txcallback);
dwAttachReceivedHandler(dwm, rxcallback);

dwNewConfiguration(dwm);
dwSetDefaults(dwm);
dwEnableMode(dwm, MODE_SHORTDATA_FAST_ACCURACY);
dwSetChannel(dwm, CHANNEL_2);
dwSetPreambleCode(dwm, PREAMBLE_CODE_64MHZ_9);

dwCommitConfiguration(dwm);

The txcallback and rxcallback function are defined that way:

void txcallback(dwDevice_t *dev);
void rxcallback(dwDevice_t *dev);

They are called when a packet has been received or sent.

Ops

The driver is platform independent and so you need to provide platform-specific function. This is done by instanciating a dwOps_t structure:

/**
 * DW operation type. Constains function pointer to all hardware-dependent
 * operation required to access the DW1000 device.
 */
typedef struct dwOps_s {
  /**
   * Function that activates the chip-select, sends header, read data and
   * disable the chip-select.
   */
  void (*spiRead)(dwDevice_t* dev, const void *header, size_t headerLength,
                                   void* data, size_t dataLength);

  /**
   * Function that activates the chip-select, sends header, sends data and
   * disable the chip-select.
   */
  void (*spiWrite)(dwDevice_t* dev, const void *header, size_t headerLength,
                                    const void* data, size_t dataLength);

  /**
   * Sets the SPI bus speed. Take as argument:
   *   - dwSpiSpeedLow: <= 4MHz
   *   - dwSpiSpeedHigh: <= 20MHz
   */
  void (*spiSetSpeed)(dwDevice_t* dev, dwSpiSpeed_t speed);

  /**
   * Waits at least 'delay' miliseconds.
   */
  void (*delayms)(dwDevice_t* dev, unsigned int delay);

  /**
   * Resets the DW1000 by pulling the reset pin low and then releasing it.
   * This function is optional, if not set softreset via SPI will be used.
   */
   void (*reset)(dwDevice_t *dev);
} dwOps_t;

Send and receive

To send a packet:

dwNewTransmit(dev);
dwSetDefaults(dev);
dwSetData(dev, (uint8_t*)&txPacket, MAC802154_HEADER_LENGTH+2);

dwStartTransmit(dev);

To receive a packet:

dwNewReceive(dev);
dwSetDefaults(dev);
dwStartReceive(dev);

To put the radio in IDLE mode (cancel current send/receive)

dwIdle(dev);

Testing

Dependencies

Frameworks for unit testing are pulled in as git submodules. To get them when cloning

git clone --recursive https://github.com/bitcraze/lps-node-firmware.git

or if you already have a cloned repo and want the submodules

git submodule init        
git submodule update        

The testing framework uses ruby and rake to generate and run code.

To minimize the need for installations and configuration, use the docker builder image (bitcraze/builder) that contains all tools needed. All scripts in the tools/build directory are intended to be run in the image. You may use the utility script tools/do to start the docker container. For instance

    tools/do build

Running unit tests

With the environment set up locally

    rake

with the docker builder image

    tools/do test

Contribute

Go to the contribute page on our website to learn more.

Test code for contribution

Run the automated build locally to test your code

./tools/build/build

libdw1000's People

Contributors

acecilia avatar ataffanel avatar knmcguire avatar krichardsson avatar stephanbro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libdw1000's Issues

Add more useful modes

There are a few modes defined for bitrates and preamble length. Add two more modes for mid bitrate and short + mid preamble

Hardware instructions

Hello there.

We have the MDEK1001 kit of DecaWave and we realized that it's API doesn't allow us to control the transmission in any way we want or run our own custom code, and we were wondering about how exactly can we do just that. Do we have to purchase DW1000 devices on their own and make our own boards? Can we use the MDEK1001 kit at all? Any info you might have, instructions, hardware tips, etc, would be really helpful.

Thank you in advance!

Use Github actions for CI

We have decided to move from Travis to GitHub actions for CI. The CI configuration needs to be converted.

Unable to Communicate via SPI with Flow Deck also attached

Hello, I am experiencing issues in which the DW1000 is not able to properly communicate via the SPI bus when a flow deck and AI deck are attached at the same time.

In the past, I have had the flow deck and the DW1000 in the loco positioning deck work together seamlessly when those were the only decks attached. I have modified the AI deck to work with the DW1000 by disabling the GPIO1 pin from its deck driver object, but when I attach all three of these decks together on the same drone, I get an error that the DW1000 is not able to initialize properly,. Upon further investigation, it seems that the DW1000 is not communicating properly via SPI.

I am perplexed as to why this is the case because each of these 3 chips should have different GPIO pins as chip selects. From my understanding, the current configuration is that the flow deck CS is on GPIO3, the loco deck CS is on GPIO1, and the AI deck CS is on GPIO4. What could be causing the conflict that prevents SPI from initializing properly for the DW1000 in the loco, but works perfectly for the flow deck?

Implement API to force TXPower register value

There should be an API to force the TXPower. Currently TXPower is set depending of the other radio settings using reference values. The user should be able to force any value that makes sensor for its design.

lose config when weak up from sleep

Hi, we lost the config of dw1000 when weak up from sleep, any suggestion?
It turned out that we send data failed when weak up, but successed using original dw lib.

difference

Hello
How is this project is different from arduino dw100 project by thotro?

setDelay() AntennaDelay isn't updated.

Hi ,
When using SetDelay library use dev->antennaDelay to calculate futureTime. But dev->antennaDelay set to 0 in uwbInit.So it doesn't add antennaDelay to futureTime calculation.

  dwTime_t delay = {.full = 0};
  dwSetAntenaDelay(dwm, delay);

But in dwInit()
writeValueToBytes(dev->antennaDelay.raw, 16384, LEN_STAMP);

ANTENNA_DELAY/2 value in twr_tag & anchor ~16475. I guess in uwbInit() if antennaDelay set correctly it could be used for calculations and


#define ANTENNA_OFFSET 154.6   // In meter
#define ANTENNA_DELAY  (ANTENNA_OFFSET*499.2e6*128)/299792458.0 // In radio tick 

part of the code can be moved to uwb.h . dev->antennaDelay can bu used for adding & subtracting from departure & arrival times.

Sending data through UWB

Hi,

Using this code can you send custom data (other than position) using UWB from tag to the listener?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.