Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
pmw3901.c File Reference
#include "pmw3901.h"
#include "mcu_periph/sys_time.h"
#include "mcu_periph/gpio.h"
Include dependency graph for pmw3901.c:

Go to the source code of this file.

Macros

#define PMW3901_RAD_PER_PX   0.002443389
#define PMW3901_SPI_CDIV   SPIDiv32
#define PMW3901_REG_MOTION   0x02
#define PMW3901_REG_DELTA_X_L   0x03
#define PMW3901_REG_DELTA_X_H   0x04
#define PMW3901_REG_DELTA_Y_L   0x05
#define PMW3901_REG_DELTA_Y_H   0x06
#define writeRegister(_addr, _data)
#define readRegister(_addr)
#define wait_ms(_ms)

Functions

static uint8_t readRegister_blocking (struct pmw3901_t *pmw, uint8_t addr)
static void writeRegister_blocking (struct pmw3901_t *pmw, uint8_t addr, uint8_t data)
static void initializeSensor (struct pmw3901_t *pmw)
static void pmw3901_thd (void *arg)
void pmw3901_init (struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx)
bool pmw3901_get_data (struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y)

Macro Definition Documentation

◆ PMW3901_RAD_PER_PX

#define PMW3901_RAD_PER_PX   0.002443389

Definition at line 38 of file pmw3901.c.

Referenced by pmw3901_init().

◆ PMW3901_REG_DELTA_X_H

#define PMW3901_REG_DELTA_X_H   0x04

Definition at line 49 of file pmw3901.c.

Referenced by pmw3901_thd().

◆ PMW3901_REG_DELTA_X_L

#define PMW3901_REG_DELTA_X_L   0x03

Definition at line 48 of file pmw3901.c.

Referenced by pmw3901_thd().

◆ PMW3901_REG_DELTA_Y_H

#define PMW3901_REG_DELTA_Y_H   0x06

Definition at line 51 of file pmw3901.c.

Referenced by pmw3901_thd().

◆ PMW3901_REG_DELTA_Y_L

#define PMW3901_REG_DELTA_Y_L   0x05

Definition at line 50 of file pmw3901.c.

Referenced by pmw3901_thd().

◆ PMW3901_REG_MOTION

#define PMW3901_REG_MOTION   0x02

Definition at line 47 of file pmw3901.c.

Referenced by pmw3901_thd().

◆ PMW3901_SPI_CDIV

#define PMW3901_SPI_CDIV   SPIDiv32

Definition at line 44 of file pmw3901.c.

Referenced by pmw3901_init().

◆ readRegister

#define readRegister ( _addr)
Value:
readRegister_blocking(pmw, (_addr))
static uint8_t readRegister_blocking(struct pmw3901_t *pmw, uint8_t addr)
Definition pmw3901.c:55

Definition at line 100 of file pmw3901.c.

Referenced by initializeSensor().

◆ wait_ms

#define wait_ms ( _ms)
Value:
sys_time_usleep((_ms) * 1000)
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)

Definition at line 101 of file pmw3901.c.

Referenced by initializeSensor().

◆ writeRegister

#define writeRegister ( _addr,
_data )
Value:
writeRegister_blocking(pmw, (_addr), (_data))
static void writeRegister_blocking(struct pmw3901_t *pmw, uint8_t addr, uint8_t data)
Definition pmw3901.c:77

Definition at line 99 of file pmw3901.c.

Referenced by initializeSensor().

Function Documentation

◆ initializeSensor()

void initializeSensor ( struct pmw3901_t * pmw)
static

Definition at line 104 of file pmw3901.c.

References readRegister, spi_slave_select(), spi_slave_unselect(), sys_time_usleep(), wait_ms, and writeRegister.

Referenced by pmw3901_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pmw3901_get_data()

bool pmw3901_get_data ( struct pmw3901_t * pmw,
int16_t * delta_x,
int16_t * delta_y )

Definition at line 261 of file pmw3901.c.

References pmw3901_t::data_available, pmw3901_t::delta_x, and pmw3901_t::delta_y.

Referenced by opticflow_pmw3901_event().

Here is the caller graph for this function:

◆ pmw3901_init()

◆ pmw3901_thd()

void pmw3901_thd ( void * arg)
static

Definition at line 211 of file pmw3901.c.

References pmw3901_t::bsem, pmw3901_t::data_available, pmw3901_t::delta_x, pmw3901_t::delta_y, PMW3901_REG_DELTA_X_H, PMW3901_REG_DELTA_X_L, PMW3901_REG_DELTA_Y_H, PMW3901_REG_DELTA_Y_L, PMW3901_REG_MOTION, pprz_bsem_wait(), and readRegister_blocking().

Referenced by pmw3901_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readRegister_blocking()

uint8_t readRegister_blocking ( struct pmw3901_t * pmw,
uint8_t addr )
static

◆ writeRegister_blocking()

void writeRegister_blocking ( struct pmw3901_t * pmw,
uint8_t addr,
uint8_t data )
static