Driver for the PAA5100JE/PMW3901 Optical Flow Sensor. More...
Driver for the PAA5100JE/PMW3901 Optical Flow Sensor.
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... | |
| 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.
| [in] | dev | device descriptor |
| [out] | x | x component in millimeters |
| [out] | y | y component in millimeters |
| 0 | on success |
| -ETIME | data was not ready in time, the quality was not good enough, or the shutter to high |
| int paa5100je_init | ( | paa5100je_t * | dev, |
| const paa5100je_params_t * | params | ||
| ) |
Initialize the given device.
| [in,out] | dev | Device descriptor of the driver |
| [in] | params | Initialization parameters |
| 0 | on success |
| -ENXIO | invalid SPI device |
| -ENODEV | invalid SPI CS pin/line or wrong device id or revision |
| int paa5100je_set_led_brightness | ( | const paa5100je_t * | dev, |
| const paa5100je_led_brightness_t | level | ||
| ) |
Sets the LED brightness level.
| [in] | dev | device descriptor |
| [in] | level | brightness level |
| 0 | on success |
| -EINVAL | invalid brightness level |