Skip to content

Commit

Permalink
PMW3901 add register write delay (TIME_us_TSWW)
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar committed Sep 1, 2019
1 parent ab92f3a commit 9aad996
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/drivers/optical_flow/pmw3901/PMW3901.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#include "PMW3901.hpp"

static constexpr uint32_t TIME_us_TSWW = 11; // - actually 10.5us

PMW3901::PMW3901(int bus, enum Rotation yaw_rotation) :
SPI("PMW3901", PMW3901_DEVICE_PATH, bus, PMW3901_SPIDEV, SPIDEV_MODE0, PMW3901_SPI_BUS_SPEED),
ScheduledWorkItem(px4::device_bus_to_wq(get_device_id())),
Expand Down Expand Up @@ -71,6 +73,7 @@ PMW3901::sensorInit()
usleep(1000);

// set performance optimization registers
// from PixArt PMW3901MB Optical Motion Tracking chip demo kit V3.20 (21 Aug 2018)
unsigned char v = 0;
unsigned char c1 = 0;
unsigned char c2 = 0;
Expand Down Expand Up @@ -287,6 +290,8 @@ PMW3901::writeRegister(unsigned reg, uint8_t data)
return ret;
}

px4_usleep(TIME_us_TSWW);

return ret;
}

Expand Down
2 changes: 1 addition & 1 deletion src/drivers/optical_flow/pmw3901/PMW3901.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include <px4_config.h>
#include <px4_defines.h>
#include <px4_getopt.h>
#include <px4_work_queue/ScheduledWorkItem.hpp>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <drivers/device/spi.h>
#include <conversion/rotation.h>
#include <lib/perf/perf_counter.h>
Expand Down

0 comments on commit 9aad996

Please sign in to comment.