PX4 Firmware
PX4 Autopilot Software http://px4.io
bma180.cpp File Reference

Driver for the Bosch BMA 180 MEMS accelerometer connected via SPI. More...

#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <ecl/geo/geo.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <semaphore.h>
#include <string.h>
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
#include <stdio.h>
#include <math.h>
#include <unistd.h>
#include <perf/perf_counter.h>
#include <systemlib/err.h>
#include <nuttx/arch.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <nuttx/clock.h>
#include <drivers/drv_hrt.h>
#include <board_config.h>
#include <drivers/device/spi.h>
#include <drivers/drv_accel.h>
#include <drivers/device/ringbuffer.h>
Include dependency graph for bma180.cpp:

Go to the source code of this file.

Classes

class  BMA180
 

Namespaces

 bma180
 Local functions in support of the shell command.
 

Macros

#define ACCEL_DEVICE_PATH   "/dev/bma180"
 
#define DIR_READ   (1<<7)
 
#define DIR_WRITE   (0<<7)
 
#define ADDR_CHIP_ID   0x00
 
#define CHIP_ID   0x03
 
#define ADDR_ACC_X_LSB   0x02
 
#define ADDR_ACC_Y_LSB   0x04
 
#define ADDR_ACC_Z_LSB   0x06
 
#define ADDR_TEMPERATURE   0x08
 
#define ADDR_CTRL_REG0   0x0D
 
#define REG0_WRITE_ENABLE   0x10
 
#define ADDR_RESET   0x10
 
#define SOFT_RESET   0xB6
 
#define ADDR_BW_TCS   0x20
 
#define BW_TCS_BW_MASK   (0xf<<4)
 
#define BW_TCS_BW_10HZ   (0<<4)
 
#define BW_TCS_BW_20HZ   (1<<4)
 
#define BW_TCS_BW_40HZ   (2<<4)
 
#define BW_TCS_BW_75HZ   (3<<4)
 
#define BW_TCS_BW_150HZ   (4<<4)
 
#define BW_TCS_BW_300HZ   (5<<4)
 
#define BW_TCS_BW_600HZ   (6<<4)
 
#define BW_TCS_BW_1200HZ   (7<<4)
 
#define ADDR_HIGH_DUR   0x27
 
#define HIGH_DUR_DIS_I2C   (1<<0)
 
#define ADDR_TCO_Z   0x30
 
#define TCO_Z_MODE_MASK   0x3
 
#define ADDR_GAIN_Y   0x33
 
#define GAIN_Y_SHADOW_DIS   (1<<0)
 
#define ADDR_OFFSET_LSB1   0x35
 
#define OFFSET_LSB1_RANGE_MASK   (7<<1)
 
#define OFFSET_LSB1_RANGE_1G   (0<<1)
 
#define OFFSET_LSB1_RANGE_2G   (2<<1)
 
#define OFFSET_LSB1_RANGE_3G   (3<<1)
 
#define OFFSET_LSB1_RANGE_4G   (4<<1)
 
#define OFFSET_LSB1_RANGE_8G   (5<<1)
 
#define OFFSET_LSB1_RANGE_16G   (6<<1)
 
#define ADDR_OFFSET_T   0x37
 
#define OFFSET_T_READOUT_12BIT   (1<<0)
 

Functions

__EXPORT int bma180_main (int argc, char *argv[])
 
void bma180::start ()
 Start the driver. More...
 
void bma180::test ()
 Perform some basic functional tests on the driver; make sure we can collect data from the sensor in polled and automatic modes. More...
 
void bma180::reset ()
 Reset the driver. More...
 
void bma180::info ()
 Print a little info about the driver. More...
 

Variables

BMA180bma180::g_dev
 

Detailed Description

Driver for the Bosch BMA 180 MEMS accelerometer connected via SPI.

Definition in file bma180.cpp.

Macro Definition Documentation

◆ ACCEL_DEVICE_PATH

#define ACCEL_DEVICE_PATH   "/dev/bma180"

Definition at line 71 of file bma180.cpp.

Referenced by BMA180::init(), bma180::reset(), bma180::start(), and bma180::test().

◆ ADDR_ACC_X_LSB

#define ADDR_ACC_X_LSB   0x02

Definition at line 80 of file bma180.cpp.

Referenced by BMA180::measure().

◆ ADDR_ACC_Y_LSB

#define ADDR_ACC_Y_LSB   0x04

Definition at line 81 of file bma180.cpp.

◆ ADDR_ACC_Z_LSB

#define ADDR_ACC_Z_LSB   0x06

Definition at line 82 of file bma180.cpp.

◆ ADDR_BW_TCS

#define ADDR_BW_TCS   0x20

Definition at line 91 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ ADDR_CHIP_ID

#define ADDR_CHIP_ID   0x00

Definition at line 77 of file bma180.cpp.

Referenced by BMA180::init(), and BMA180::probe().

◆ ADDR_CTRL_REG0

#define ADDR_CTRL_REG0   0x0D

Definition at line 85 of file bma180.cpp.

Referenced by BMA180::init(), BMA180::set_lowpass(), and BMA180::set_range().

◆ ADDR_GAIN_Y

#define ADDR_GAIN_Y   0x33

Definition at line 108 of file bma180.cpp.

Referenced by BMA180::init().

◆ ADDR_HIGH_DUR

#define ADDR_HIGH_DUR   0x27

Definition at line 102 of file bma180.cpp.

Referenced by BMA180::init().

◆ ADDR_OFFSET_LSB1

#define ADDR_OFFSET_LSB1   0x35

Definition at line 111 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ ADDR_OFFSET_T

#define ADDR_OFFSET_T   0x37

Definition at line 120 of file bma180.cpp.

Referenced by BMA180::init().

◆ ADDR_RESET

#define ADDR_RESET   0x10

Definition at line 88 of file bma180.cpp.

Referenced by BMA180::init().

◆ ADDR_TCO_Z

#define ADDR_TCO_Z   0x30

Definition at line 105 of file bma180.cpp.

Referenced by BMA180::init().

◆ ADDR_TEMPERATURE

#define ADDR_TEMPERATURE   0x08

Definition at line 83 of file bma180.cpp.

◆ BW_TCS_BW_10HZ

#define BW_TCS_BW_10HZ   (0<<4)

Definition at line 93 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_1200HZ

#define BW_TCS_BW_1200HZ   (7<<4)

Definition at line 100 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_150HZ

#define BW_TCS_BW_150HZ   (4<<4)

Definition at line 97 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_20HZ

#define BW_TCS_BW_20HZ   (1<<4)

Definition at line 94 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_300HZ

#define BW_TCS_BW_300HZ   (5<<4)

Definition at line 98 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_40HZ

#define BW_TCS_BW_40HZ   (2<<4)

Definition at line 95 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_600HZ

#define BW_TCS_BW_600HZ   (6<<4)

Definition at line 99 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_75HZ

#define BW_TCS_BW_75HZ   (3<<4)

Definition at line 96 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ BW_TCS_BW_MASK

#define BW_TCS_BW_MASK   (0xf<<4)

Definition at line 92 of file bma180.cpp.

Referenced by BMA180::set_lowpass().

◆ CHIP_ID

#define CHIP_ID   0x03

Definition at line 78 of file bma180.cpp.

Referenced by BMA180::init(), and BMA180::probe().

◆ DIR_READ

#define DIR_READ   (1<<7)

Definition at line 74 of file bma180.cpp.

Referenced by BMA180::read_reg().

◆ DIR_WRITE

#define DIR_WRITE   (0<<7)

Definition at line 75 of file bma180.cpp.

Referenced by BMA180::write_reg().

◆ GAIN_Y_SHADOW_DIS

#define GAIN_Y_SHADOW_DIS   (1<<0)

Definition at line 109 of file bma180.cpp.

Referenced by BMA180::init().

◆ HIGH_DUR_DIS_I2C

#define HIGH_DUR_DIS_I2C   (1<<0)

Definition at line 103 of file bma180.cpp.

Referenced by BMA180::init().

◆ OFFSET_LSB1_RANGE_16G

#define OFFSET_LSB1_RANGE_16G   (6<<1)

Definition at line 118 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ OFFSET_LSB1_RANGE_1G

#define OFFSET_LSB1_RANGE_1G   (0<<1)

Definition at line 113 of file bma180.cpp.

◆ OFFSET_LSB1_RANGE_2G

#define OFFSET_LSB1_RANGE_2G   (2<<1)

Definition at line 114 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ OFFSET_LSB1_RANGE_3G

#define OFFSET_LSB1_RANGE_3G   (3<<1)

Definition at line 115 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ OFFSET_LSB1_RANGE_4G

#define OFFSET_LSB1_RANGE_4G   (4<<1)

Definition at line 116 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ OFFSET_LSB1_RANGE_8G

#define OFFSET_LSB1_RANGE_8G   (5<<1)

Definition at line 117 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ OFFSET_LSB1_RANGE_MASK

#define OFFSET_LSB1_RANGE_MASK   (7<<1)

Definition at line 112 of file bma180.cpp.

Referenced by BMA180::set_range().

◆ OFFSET_T_READOUT_12BIT

#define OFFSET_T_READOUT_12BIT   (1<<0)

Definition at line 121 of file bma180.cpp.

Referenced by BMA180::init().

◆ REG0_WRITE_ENABLE

#define REG0_WRITE_ENABLE   0x10

Definition at line 86 of file bma180.cpp.

Referenced by BMA180::init(), BMA180::set_lowpass(), and BMA180::set_range().

◆ SOFT_RESET

#define SOFT_RESET   0xB6

Definition at line 89 of file bma180.cpp.

Referenced by BMA180::init().

◆ TCO_Z_MODE_MASK

#define TCO_Z_MODE_MASK   0x3

Definition at line 106 of file bma180.cpp.

Referenced by BMA180::init().

Function Documentation

◆ bma180_main()

int bma180_main ( int  argc,
char *  argv[] 
)

Definition at line 821 of file bma180.cpp.

References errx, bma180::info(), bma180::reset(), bma180::start(), and bma180::test().

Here is the call graph for this function: