Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
pmw3901.c File Reference
#include "pmw3901.h"
#include "mcu_periph/sys_time.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   SPIDiv256
 
#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)   writeRegister_blocking(pmw, (_addr), (_data))
 
#define readRegister(_addr)   readRegister_blocking(pmw, (_addr))
 
#define wait_ms(_ms)   sys_time_usleep((_ms) * 1000)
 

Functions

static bool readRegister_nonblocking (struct pmw3901_t *pmw, uint8_t addr, uint8_t *value)
 
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)
 
void pmw3901_init (struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx)
 
void pmw3901_event (struct pmw3901_t *pmw)
 
bool pmw3901_is_idle (struct pmw3901_t *pmw)
 
void pmw3901_start_read (struct pmw3901_t *pmw)
 
bool pmw3901_data_available (struct pmw3901_t *pmw)
 
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 37 of file pmw3901.c.

◆ PMW3901_REG_DELTA_X_H

#define PMW3901_REG_DELTA_X_H   0x04

Definition at line 48 of file pmw3901.c.

◆ PMW3901_REG_DELTA_X_L

#define PMW3901_REG_DELTA_X_L   0x03

Definition at line 47 of file pmw3901.c.

◆ PMW3901_REG_DELTA_Y_H

#define PMW3901_REG_DELTA_Y_H   0x06

Definition at line 50 of file pmw3901.c.

◆ PMW3901_REG_DELTA_Y_L

#define PMW3901_REG_DELTA_Y_L   0x05

Definition at line 49 of file pmw3901.c.

◆ PMW3901_REG_MOTION

#define PMW3901_REG_MOTION   0x02

Definition at line 46 of file pmw3901.c.

◆ PMW3901_SPI_CDIV

#define PMW3901_SPI_CDIV   SPIDiv256

Definition at line 43 of file pmw3901.c.

◆ readRegister

#define readRegister (   _addr)    readRegister_blocking(pmw, (_addr))

Definition at line 120 of file pmw3901.c.

◆ wait_ms

#define wait_ms (   _ms)    sys_time_usleep((_ms) * 1000)

Definition at line 121 of file pmw3901.c.

◆ writeRegister

#define writeRegister (   _addr,
  _data 
)    writeRegister_blocking(pmw, (_addr), (_data))

Definition at line 119 of file pmw3901.c.

Function Documentation

◆ initializeSensor()

static void initializeSensor ( struct pmw3901_t pmw)
static

Definition at line 124 of file pmw3901.c.

References readRegister, 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_data_available()

bool pmw3901_data_available ( struct pmw3901_t pmw)

Definition at line 322 of file pmw3901.c.

References pmw3901_t::data_available.

Referenced by opticflow_pmw3901_event().

+ Here is the caller graph for this function:

◆ pmw3901_event()

◆ pmw3901_get_data()

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

Definition at line 326 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_is_idle()

bool pmw3901_is_idle ( struct pmw3901_t pmw)

Definition at line 312 of file pmw3901.c.

References PMW3901_IDLE, and pmw3901_t::state.

Referenced by opticflow_pmw3901_periodic(), and pmw3901_start_read().

+ Here is the caller graph for this function:

◆ pmw3901_start_read()

void pmw3901_start_read ( struct pmw3901_t pmw)

Definition at line 316 of file pmw3901.c.

References pmw3901_is_idle(), PMW3901_READ_MOTION, and pmw3901_t::state.

Referenced by opticflow_pmw3901_periodic().

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

◆ readRegister_blocking()

◆ readRegister_nonblocking()

static bool readRegister_nonblocking ( struct pmw3901_t pmw,
uint8_t  addr,
uint8_t value 
)
static

◆ writeRegister_blocking()

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