Skip to content

DW(M)1000 LED Blink Feature

S edited this page Dec 30, 2017 · 1 revision

LED Blink Feature

This library provides access to DW(M)1000 GPIO pins for led blinking by setting GPIO_MODE registers. The GPIO mode settings has to be called during setup():

  DW1000.setGPIOMode(MSGP0, LED_MODE);

GPIO Mode Selection Options

MSGP0
When operating as the RXOKLED driver, Pin 15 is asserted briefly when the receiver completes the reception of a frame with a good FCS/CRC.

MSGP1
When operating as the driver, Pin 14 is asserted briefly when the receiver detects the SFD sequence in the RX frame.

MSGP2
When operating as the RXLED driver, Pin 13 is asserted when the receiver is on, and stays on for a brief period after the receiver is turned off.

MSGP3
When operating as the TXLED driver, Pin 12 is asserted briefly when the transmitter completes sending a frame.

MSGP6, MSGP5, MSGP4
The pins 9, 10, 11 operates as the EXTRXE, EXTTXE and EXTPA respectively.

MSGP7
The SYNC functionality is unavailable for DWM1000 modules. Pin 4 is only configurable as GPIO.

MSGP8
Pin 22 operates as GPIO instead of IRQ when LED_MODE is set.

Circuit Schematic Example for RXOKLED

GPIO LED Example

#include <SPI.h>
#include "DW1000Ranging.h"

// connection pins
const uint8_t PIN_RST = 9; // reset pin
const uint8_t PIN_IRQ = 2; // irq pin
const uint8_t PIN_SS = SS; // spi select pin

void setup() {
  Serial.begin(115200);
  delay(1000);
  //init the configuration
  DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); //Reset, CS, IRQ pin
  //define the sketch as anchor. It will be great to dynamically change the type of module
  DW1000Ranging.attachNewRange(newRange);
  DW1000Ranging.attachNewDevice(newDevice);
  DW1000Ranging.attachInactiveDevice(inactiveDevice);
  //Enable the filter to smooth the distance
  DW1000Ranging.useRangeFilter(true);

  DW1000.enableDebounceClock();
  DW1000.enableLedBlinking();
  // enables GPIO0/RXOKLED (Pin 15 in DWM1000, Pin 38 in DW1000)
  //for a short duration on reception of a frame with good CRC.
  DW1000.setGPIOMode(MSGP0, LED_MODE);
  
  //we start the module as a tag
  DW1000Ranging.startAsTag("7D:00:22:EA:82:60:3B:9C", DW1000.MODE_LONGDATA_RANGE_ACCURACY);
}

void loop() {
  DW1000Ranging.loop();
}

void newRange() {
  Serial.print("from: "); Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
  Serial.print("\t Range: "); Serial.print(DW1000Ranging.getDistantDevice()->getRange()); Serial.print(" m");
  Serial.print("\t RX power: "); Serial.print(DW1000Ranging.getDistantDevice()->getRXPower()); Serial.println(" dBm");
}

void newDevice(DW1000Device* device) {
  Serial.print("ranging init; 1 device added ! -> ");
  Serial.print(" short:");
  Serial.println(device->getShortAddress(), HEX);
}

void inactiveDevice(DW1000Device* device) {
  Serial.print("delete inactive device: ");
  Serial.println(device->getShortAddress(), HEX);
}

Please check dw1000_user_manual_v2.05 PG 122 for alternate GPIO_Mode registers / settings.