PAA5100JE/PMW3901 Driver

Driver for the PAA5100JE/PMW3901 Optical Flow Sensor. More...

Detailed Description

Driver for the PAA5100JE/PMW3901 Optical Flow Sensor.

Description

The PAA5100JE and PMW3901 sensors are accessed in the same way over SPI but require slightly different initialization code. Since the datasheets are not very detailed, I created this driver based on a reference implementation by Pimoroni, who designed a breakout board for the PMW3901.

The motion data read represents the relative motion since the last readout. It depends on the surface, lighting conditions, and the sensor’s distance from the ground.

The readings are scaled according to the configuration parameter PAA5100JE_SCALE_DENOMINATOR. The readings are multiplied by 100 and divided by the denominator.

The scaling factor, the quality threshold, and the timeout can be configured via Kconfig.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Datasheets:

Reference Implementation:

Files

file  paa5100je.h
 
file  paa5100je_constants.h
 Internal addresses, registers and constants.
 
file  paa5100je_params.h
 Default configuration.
 

Data Structures

struct  paa5100je_params_t
 Device initialization parameters. More...
 
struct  paa5100je_t
 Device descriptor for the driver. More...
 

Enumerations

enum  paa5100je_variant_t { PAA5100JE = 0 , PMW3901 = 1 }
 Variant of the sensor.
 
enum  paa5100je_led_brightness_t { PAA5100JE_LED_OFF = 0 , PAA5100JE_LED_MEDIUM = 1 , PAA5100JE_LED_MAX = 2 }
 PAA5100JE LED brightness levels.
 

Functions

int paa5100je_init (paa5100je_t *dev, const paa5100je_params_t *params)
 Initialize the given device. More...
 
int paa5100je_get_motion_burst (const paa5100je_t *dev, int16_t *x, int16_t *y)
 Reads the relative motition vector from the device using burst read. More...
 
int paa5100je_set_led_brightness (const paa5100je_t *dev, const paa5100je_led_brightness_t level)
 Sets the LED brightness level. More...
 

Function Documentation

◆ paa5100je_get_motion_burst()

int paa5100je_get_motion_burst ( const paa5100je_t dev,
int16_t *  x,
int16_t *  y 
)

Reads the relative motition vector from the device using burst read.

Reads twelve bytes from the burst register. Repeats the read when the data is not ready, the quality is too low or the shutter values is too high. The data being read from the sensor represents the relative motion since the last readout. It depends on the surface, lighting conditions, and the sensor’s distance from the ground. The quality threshold, the timeout, and a scaling factor can be configured via Kconfig.

Parameters
[in]devdevice descriptor
[out]xx component in millimeters
[out]yy component in millimeters
Return values
0on success
-ETIMEdata was not ready in time, the quality was not good enough, or the shutter to high

◆ paa5100je_init()

int paa5100je_init ( paa5100je_t dev,
const paa5100je_params_t params 
)

Initialize the given device.

Parameters
[in,out]devDevice descriptor of the driver
[in]paramsInitialization parameters
Return values
0on success
-ENXIOinvalid SPI device
-ENODEVinvalid SPI CS pin/line or wrong device id or revision

◆ paa5100je_set_led_brightness()

int paa5100je_set_led_brightness ( const paa5100je_t dev,
const paa5100je_led_brightness_t  level 
)

Sets the LED brightness level.

Parameters
[in]devdevice descriptor
[in]levelbrightness level
Return values
0on success
-EINVALinvalid brightness level