BMA423 added accelerometer support

pull/8/head
sqfmi 2020-02-23 13:49:44 -05:00
parent 83167af48c
commit 03ea538e32
10 changed files with 9710 additions and 0 deletions

View File

@ -0,0 +1,33 @@
/*
* Watchy - Accelerometer Example
* Prints out the BMA423 accelerometer data on Serial
*/
#ifndef ESP32
#error Please select ESP32 Wrover Module under Tools > Board
#endif
#include <bma.h>
BMA *bma = nullptr;
I2CBus *i2c = nullptr;
void setup()
{
byte data;
Serial.begin(115200);
i2c = new I2CBus();
bma = new BMA(*i2c);
bma->begin();
bma->enableAccel();
}
void loop(){
Accel acc;
bool res = bma->getAccel(acc);
Serial.print(acc.x);
Serial.print(" , ");
Serial.print(acc.y);
Serial.print(" , ");
Serial.println(acc.z);
}

273
src/bma.cpp Normal file
View File

@ -0,0 +1,273 @@
#include "bma.h"
#include <Arduino.h>
I2CBus *BMA::_bus = nullptr;
BMA::BMA(I2CBus &bus)
{
_bus = &bus;
}
BMA::~BMA()
{
}
uint16_t BMA::read(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len)
{
return _bus->readBytes(addr, reg, data, len);
}
uint16_t BMA::write(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len)
{
return _bus->writeBytes(addr, reg, data, len);
}
bool BMA::begin()
{
_dev.dev_addr = BMA4_I2C_ADDR_PRIMARY;
_dev.interface = BMA4_I2C_INTERFACE;
_dev.bus_read = read;
_dev.bus_write = write;
_dev.delay = delay;
_dev.read_write_len = 8;
_dev.resolution = 12;
_dev.feature_len = BMA423_FEATURE_SIZE;
reset();
delay(20);
if (bma423_init(&_dev) != BMA4_OK) {
Serial.println("bma4 init fail");
return false;
}
config();
return true;
}
void BMA::reset()
{
uint8_t reg = 0xB6;
_bus->writeBytes(BMA4_I2C_ADDR_PRIMARY, 0x7E, &reg, 1);
}
uint16_t BMA::config()
{
return bma423_write_config_file(&_dev);
}
bool BMA::getAccel(Accel &acc)
{
memset(&acc, 0, sizeof(acc));
if (bma4_read_accel_xyz(&acc, &_dev) != BMA4_OK) {
return false;
}
return true;
}
uint8_t BMA::direction()
{
Accel acc;
if (bma4_read_accel_xyz(&acc, &_dev) != BMA4_OK) {
return 0;
}
uint16_t absX = abs(acc.x);
uint16_t absY = abs(acc.y);
uint16_t absZ = abs(acc.z);
if ((absZ > absX) && (absZ > absY)) {
if (acc.z > 0) {
return DIRECTION_DISP_DOWN;
} else {
return DIRECTION_DISP_UP;
}
} else if ((absY > absX) && (absY > absZ)) {
if (acc.y > 0) {
return DIRECTION_BOTTOM_EDGE;
} else {
return DIRECTION_TOP_EDGE;
}
} else {
if (acc.x < 0) {
return DIRECTION_RIGHT_EDGE;
} else {
return DIRECTION_LEFT_EDGE;
}
}
}
float BMA::temperature()
{
int32_t data = 0;
bma4_get_temperature(&data, BMA4_DEG, &_dev);
float res = (float)data / (float)BMA4_SCALE_TEMP;
/* 0x80 - temp read from the register and 23 is the ambient temp added.
* If the temp read from register is 0x80, it means no valid
* information is available */
if (((data - 23) / BMA4_SCALE_TEMP) == 0x80) {
res = 0;
}
return res;
}
void BMA::enableAccel()
{
if (bma4_set_accel_enable(BMA4_ENABLE, &_dev)) {
return;
}
Acfg cfg;
cfg.odr = BMA4_OUTPUT_DATA_RATE_100HZ;
cfg.range = BMA4_ACCEL_RANGE_2G;
cfg.bandwidth = BMA4_ACCEL_NORMAL_AVG4;
cfg.perf_mode = BMA4_CONTINUOUS_MODE;
if (bma4_set_accel_config(&cfg, &_dev)) {
Serial.println("[bma4] set accel config fail");
return;
}
}
void BMA::disalbeIrq()
{
bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT /* |BMA423_WAKEUP_INT*/, BMA4_DISABLE, &_dev);
}
void BMA::enableIrq()
{
bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT /* |BMA423_WAKEUP_INT*/, BMA4_ENABLE, &_dev);
}
//attachInterrupt bma423 int1
void BMA::attachInterrupt()
{
uint16_t rslt = BMA4_OK;
enableAccel();
// rslt |= bma423_reset_step_counter(&_dev);
rslt |= bma423_step_detector_enable(BMA4_ENABLE, &_dev);
rslt |= bma423_feature_enable(BMA423_STEP_CNTR, BMA4_ENABLE, &_dev);
rslt |= bma423_feature_enable(BMA423_WAKEUP, BMA4_ENABLE, &_dev);
rslt |= bma423_feature_enable(BMA423_TILT, BMA4_ENABLE, &_dev);
rslt |= bma423_step_counter_set_watermark(100, &_dev);
// rslt |= bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT | BMA423_WAKEUP_INT, BMA4_ENABLE, &_dev);
rslt |= bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT, BMA4_ENABLE, &_dev);
rslt |= bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_TILT_INT, BMA4_ENABLE, &_dev);
bma423_anymotion_enable_axis(BMA423_ALL_AXIS_DIS, &_dev);
struct bma4_int_pin_config config ;
config.edge_ctrl = BMA4_LEVEL_TRIGGER;
config.lvl = BMA4_ACTIVE_HIGH;
config.od = BMA4_PUSH_PULL;
config.output_en = BMA4_OUTPUT_ENABLE;
config.input_en = BMA4_INPUT_DISABLE;
rslt |= bma4_set_int_pin_config(&config, BMA4_INTR1_MAP, &_dev);
// Serial.printf("[bma4] attachInterrupt %s\n", rslt != 0 ? "fail" : "pass");
struct bma423_axes_remap remap_data;
remap_data.x_axis = 0;
remap_data.x_axis_sign = 1;
remap_data.y_axis = 1;
remap_data.y_axis_sign = 1;
remap_data.z_axis = 2;
remap_data.z_axis_sign = 0;
bma423_set_remap_axes(&remap_data, &_dev);
}
bool BMA::readInterrupt()
{
return bma423_read_int_status(&_irqStatus, &_dev) == BMA4_OK;
}
uint8_t BMA::getIrqStatus()
{
return _irqStatus;
}
uint32_t BMA::getCounter()
{
uint32_t stepCount;
if (bma423_step_counter_output(&stepCount, &_dev) == BMA4_OK) {
return stepCount;
}
return 0;
}
bool BMA::isStepCounter()
{
return (bool)(BMA423_STEP_CNTR_INT & _irqStatus);
}
bool BMA::isDoubleClick()
{
return (bool)(BMA423_WAKEUP_INT & _irqStatus);
}
bool BMA::isTilt()
{
return (bool)(BMA423_TILT_INT & _irqStatus);
}
bool BMA::isActivity()
{
return (bool)(BMA423_ACTIVITY_INT & _irqStatus);
}
bool BMA::isAnyNoMotion()
{
return (bool)(BMA423_ANY_NO_MOTION_INT & _irqStatus);
}
const char *BMA::getActivity()
{
uint8_t activity;
bma423_activity_output(&activity, &_dev);
if (activity & BMA423_USER_STATIONARY) {
return "BMA423_USER_STATIONARY";
} else if (activity & BMA423_USER_WALKING) {
return "BMA423_USER_WALKING";
} else if (activity & BMA423_USER_RUNNING) {
return "BMA423_USER_RUNNING";
} else if (activity & BMA423_STATE_INVALID) {
return "BMA423_STATE_INVALID";
}
return "None";
}
bool BMA::enableStepCountInterrupt(bool en)
{
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT, en, &_dev));
}
bool BMA::enableTiltInterrupt(bool en)
{
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_TILT_INT, en, &_dev));
}
bool BMA::enableWakeupInterrupt(bool en)
{
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_WAKEUP_INT, en, &_dev));
}
bool BMA::enableAnyNoMotionInterrupt(bool en)
{
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ANY_NO_MOTION_INT, en, &_dev));
}
bool BMA::enableActivityInterrupt(bool en)
{
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ACTIVITY_INT, en, &_dev));
}

63
src/bma.h Normal file
View File

@ -0,0 +1,63 @@
#pragma once
#include "bma423.h"
#include "i2c_bus.h"
enum {
DIRECTION_TOP_EDGE = 0,
DIRECTION_BOTTOM_EDGE = 1,
DIRECTION_LEFT_EDGE = 2,
DIRECTION_RIGHT_EDGE = 3,
DIRECTION_DISP_UP = 4,
DIRECTION_DISP_DOWN = 5
} ;
typedef struct bma4_dev Bma;
typedef struct bma4_accel Accel;
typedef struct bma4_accel_config Acfg;
class BMA
{
public:
BMA(I2CBus &bus);
~BMA();
bool begin();
void reset();
uint8_t direction();
float temperature();
void enableAccel();
void disalbeIrq();
void enableIrq();
void attachInterrupt();
uint32_t getCounter();
bool isStepCounter();
bool isDoubleClick();
bool readInterrupt();
bool isTilt();
bool isActivity();
bool isAnyNoMotion();
bool getAccel(Accel &acc);
uint8_t getIrqStatus();
const char * getActivity();
bool enableStepCountInterrupt(bool en = true);
bool enableTiltInterrupt(bool en = true);
bool enableWakeupInterrupt(bool en = true);
bool enableAnyNoMotionInterrupt(bool en = true);
bool enableActivityInterrupt(bool en = true);
private:
static uint16_t read(uint8_t dev_addr, uint8_t reg_addr, uint8_t *read_data, uint16_t len);
static uint16_t write(uint8_t dev_addr, uint8_t reg_addr, uint8_t *read_data, uint16_t len);
uint16_t config();
Bma _dev;
static bma4_com_fptr_t _read;
static bma4_com_fptr_t _write;
static I2CBus *_bus;
bool _irqRead = false;
uint16_t _irqStatus;
};

4204
src/bma4.c Normal file

File diff suppressed because it is too large Load Diff

1574
src/bma4.h Normal file

File diff suppressed because it is too large Load Diff

1695
src/bma423.c Normal file

File diff suppressed because it is too large Load Diff

804
src/bma423.h Normal file
View File

@ -0,0 +1,804 @@
/*
*
****************************************************************************
* Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
*
* File : bma423.h
*
* Date: 12 Oct 2017
*
* Revision : 1.1.4 $
*
* Usage: Sensor Driver for BMA423 sensor
*
****************************************************************************
*
* Disclaimer
*
* Common:
* Bosch Sensortec products are developed for the consumer goods industry.
* They may only be used within the parameters of the respective valid
* product data sheet. Bosch Sensortec products are provided with the
* express understanding that there is no warranty of fitness for a
* particular purpose.They are not fit for use in life-sustaining,
* safety or security sensitive systems or any system or device
* that may lead to bodily harm or property damage if the system
* or device malfunctions. In addition,Bosch Sensortec products are
* not fit for use in products which interact with motor vehicle systems.
* The resale and or use of products are at the purchasers own risk and
* his own responsibility. The examination of fitness for the intended use
* is the sole responsibility of the Purchaser.
*
* The purchaser shall indemnify Bosch Sensortec from all third party
* claims, including any claims for incidental, or consequential damages,
* arising from any product use not covered by the parameters of
* the respective valid product data sheet or not approved by
* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
* connection with such claims.
*
* The purchaser must monitor the market for the purchased products,
* particularly with regard to product safety and inform Bosch Sensortec
* without delay of all security relevant incidents.
*
* Engineering Samples are marked with an asterisk (*) or (e).
* Samples may vary from the valid technical specifications of the product
* series. They are therefore not intended or fit for resale to third
* parties or for use in end products. Their sole purpose is internal
* client testing. The testing of an engineering sample may in no way
* replace the testing of a product series. Bosch Sensortec assumes
* no liability for the use of engineering samples.
* By accepting the engineering samples, the Purchaser agrees to indemnify
* Bosch Sensortec from all claims arising from the use of engineering
* samples.
*
* Special:
* This software module (hereinafter called "Software") and any information
* on application-sheets (hereinafter called "Information") is provided
* free of charge for the sole purpose to support your application work.
* The Software and Information is subject to the following
* terms and conditions:
*
* The Software is specifically designed for the exclusive use for
* Bosch Sensortec products by personnel who have special experience
* and training. Do not use this Software if you do not have the
* proper experience or training.
*
* This Software package is provided `` as is `` and without any expressed
* or implied warranties,including without limitation, the implied warranties
* of merchantability and fitness for a particular purpose.
*
* Bosch Sensortec and their representatives and agents deny any liability
* for the functional impairment
* of this Software in terms of fitness, performance and safety.
* Bosch Sensortec and their representatives and agents shall not be liable
* for any direct or indirect damages or injury, except as
* otherwise stipulated in mandatory applicable law.
*
* The Information provided is believed to be accurate and reliable.
* Bosch Sensortec assumes no responsibility for the consequences of use
* of such Information nor for any infringement of patents or
* other rights of third parties which may result from its use.
* No license is granted by implication or otherwise under any patent or
* patent rights of Bosch. Specifications mentioned in the Information are
* subject to change without notice.
**************************************************************************/
/*! \file bma423.h
\brief Sensor Driver for BMA423 sensor */
#ifndef BMA423_H
#define BMA423_H
#ifdef __cplusplus
extern "C" {
#endif
#include "bma4.h"
/**\name Chip ID of BMA423 sensor */
#define BMA423_CHIP_ID UINT8_C(0x13)
/**\name Sensor feature size */
#define BMA423_FEATURE_SIZE UINT8_C(64)
#define BMA423_ANYMOTION_EN_LEN UINT8_C(2)
#define BMA423_RD_WR_MIN_LEN UINT8_C(2)
/**\name Feature offset address */
#define BMA423_ANY_NO_MOTION_OFFSET UINT8_C(0x00)
#define BMA423_STEP_CNTR_OFFSET UINT8_C(0x36)
#define BMA423_STEP_CNTR_PARAM_OFFSET UINT8_C(0x04)
#define BMA423_WAKEUP_OFFSET UINT8_C(0x38)
#define BMA423_TILT_OFFSET UINT8_C(0x3A)
#define BMA423_CONFIG_ID_OFFSET UINT8_C(0x3C)
#define BMA423_AXES_REMAP_OFFSET UINT8_C(0x3E)
/**************************************************************/
/**\name Remap Axes */
/**************************************************************/
#define BMA423_X_AXIS_MASK UINT8_C(0x03)
#define BMA423_X_AXIS_SIGN_MASK UINT8_C(0x04)
#define BMA423_Y_AXIS_MASK UINT8_C(0x18)
#define BMA423_Y_AXIS_SIGN_MASK UINT8_C(0x20)
#define BMA423_Z_AXIS_MASK UINT8_C(0xC0)
#define BMA423_Z_AXIS_SIGN_MASK UINT8_C(0x01)
/**************************************************************/
/**\name Step Counter & Detector */
/**************************************************************/
/**\name Step counter enable macros */
#define BMA423_STEP_CNTR_EN_POS UINT8_C(4)
#define BMA423_STEP_CNTR_EN_MSK UINT8_C(0x10)
#define BMA423_ACTIVITY_EN_MSK UINT8_C(0x20)
/**\name Step counter watermark macros */
#define BMA423_STEP_CNTR_WM_MSK UINT16_C(0x03FF)
/**\name Step counter reset macros */
#define BMA423_STEP_CNTR_RST_POS UINT8_C(2)
#define BMA423_STEP_CNTR_RST_MSK UINT8_C(0x04)
/**\name Step detector enable macros */
#define BMA423_STEP_DETECTOR_EN_POS UINT8_C(3)
#define BMA423_STEP_DETECTOR_EN_MSK UINT8_C(0x08)
/**\name Tilt enable macros */
#define BMA423_TILT_EN_MSK UINT8_C(0x01)
/**\name Step count output length*/
#define BMA423_STEP_CNTR_DATA_SIZE UINT16_C(4)
/**\name Wakeup enable macros */
#define BMA423_WAKEUP_EN_MSK UINT8_C(0x01)
/**\name Wake up sensitivity macros */
#define BMA423_WAKEUP_SENS_POS UINT8_C(1)
#define BMA423_WAKEUP_SENS_MSK UINT8_C(0x0E)
/**\name Tap selection macro */
#define BMA423_TAP_SEL_POS UINT8_C(4)
#define BMA423_TAP_SEL_MSK UINT8_C(0x10)
/**************************************************************/
/**\name Any Motion */
/**************************************************************/
/**\name Any motion threshold macros */
#define BMA423_ANY_NO_MOTION_THRES_POS UINT8_C(0)
#define BMA423_ANY_NO_MOTION_THRES_MSK UINT16_C(0x07FF)
/**\name Any motion selection macros */
#define BMA423_ANY_NO_MOTION_SEL_POS UINT8_C(3)
#define BMA423_ANY_NO_MOTION_SEL_MSK UINT8_C(0x08)
/**\name Any motion enable macros */
#define BMA423_ANY_NO_MOTION_AXIS_EN_POS UINT8_C(5)
#define BMA423_ANY_NO_MOTION_AXIS_EN_MSK UINT8_C(0xE0)
/**\name Any motion duration macros */
#define BMA423_ANY_NO_MOTION_DUR_MSK UINT16_C(0x1FFF)
/**************************************************************/
/**\name User macros */
/**************************************************************/
/**\name Anymotion/Nomotion axis enable macros */
#define BMA423_X_AXIS_EN UINT8_C(0x01)
#define BMA423_Y_AXIS_EN UINT8_C(0x02)
#define BMA423_Z_AXIS_EN UINT8_C(0x04)
#define BMA423_ALL_AXIS_EN UINT8_C(0x07)
#define BMA423_ALL_AXIS_DIS UINT8_C(0x00)
/**\name Feature enable macros for the sensor */
#define BMA423_STEP_CNTR UINT8_C(0x01)
/**\name Below macros are mutually exclusive */
#define BMA423_ANY_MOTION UINT8_C(0x02)
#define BMA423_NO_MOTION UINT8_C(0x04)
#define BMA423_ACTIVITY UINT8_C(0x08)
#define BMA423_TILT UINT8_C(0x10)
#define BMA423_WAKEUP UINT8_C(0x20)
/**\name Interrupt status macros */
#define BMA423_STEP_CNTR_INT UINT8_C(0x02)
#define BMA423_ACTIVITY_INT UINT8_C(0x04)
#define BMA423_TILT_INT UINT8_C(0x08)
#define BMA423_WAKEUP_INT UINT8_C(0x20)
#define BMA423_ANY_NO_MOTION_INT UINT8_C(0x40)
#define BMA423_ERROR_INT UINT8_C(0x80)
/**\name Activity recognition macros */
#define BMA423_USER_STATIONARY UINT8_C(0x00)
#define BMA423_USER_WALKING UINT8_C(0x01)
#define BMA423_USER_RUNNING UINT8_C(0x02)
#define BMA423_STATE_INVALID UINT8_C(0x03)
/**\name Configuration selection macros */
#define BMA423_PHONE_CONFIG UINT8_C(0x00)
#define BMA423_WRIST_CONFIG UINT8_C(0x01)
/**\name Step counter parameter setting(1-25) for phone */
#define BMA423_PHONE_SC_PARAM_1 UINT16_C(0x132)
#define BMA423_PHONE_SC_PARAM_2 UINT16_C(0x78E6)
#define BMA423_PHONE_SC_PARAM_3 UINT16_C(0x84)
#define BMA423_PHONE_SC_PARAM_4 UINT16_C(0x6C9C)
#define BMA423_PHONE_SC_PARAM_5 UINT8_C(0x07)
#define BMA423_PHONE_SC_PARAM_6 UINT16_C(0x7564)
#define BMA423_PHONE_SC_PARAM_7 UINT16_C(0x7EAA)
#define BMA423_PHONE_SC_PARAM_8 UINT16_C(0x55F)
#define BMA423_PHONE_SC_PARAM_9 UINT16_C(0xABE)
#define BMA423_PHONE_SC_PARAM_10 UINT16_C(0x55F)
#define BMA423_PHONE_SC_PARAM_11 UINT16_C(0xE896)
#define BMA423_PHONE_SC_PARAM_12 UINT16_C(0x41EF)
#define BMA423_PHONE_SC_PARAM_13 UINT8_C(0x01)
#define BMA423_PHONE_SC_PARAM_14 UINT8_C(0x0C)
#define BMA423_PHONE_SC_PARAM_15 UINT8_C(0x0C)
#define BMA423_PHONE_SC_PARAM_16 UINT8_C(0x4A)
#define BMA423_PHONE_SC_PARAM_17 UINT8_C(0xA0)
#define BMA423_PHONE_SC_PARAM_18 UINT8_C(0x00)
#define BMA423_PHONE_SC_PARAM_19 UINT8_C(0x0C)
#define BMA423_PHONE_SC_PARAM_20 UINT16_C(0x3CF0)
#define BMA423_PHONE_SC_PARAM_21 UINT16_C(0x100)
#define BMA423_PHONE_SC_PARAM_22 UINT8_C(0x00)
#define BMA423_PHONE_SC_PARAM_23 UINT8_C(0x00)
#define BMA423_PHONE_SC_PARAM_24 UINT8_C(0x00)
#define BMA423_PHONE_SC_PARAM_25 UINT8_C(0x00)
/**\name Step counter parameter setting(1-25) for wrist (Default) */
#define BMA423_WRIST_SC_PARAM_1 UINT16_C(0x12D)
#define BMA423_WRIST_SC_PARAM_2 UINT16_C(0x7BD4)
#define BMA423_WRIST_SC_PARAM_3 UINT16_C(0x13B)
#define BMA423_WRIST_SC_PARAM_4 UINT16_C(0x7ADB)
#define BMA423_WRIST_SC_PARAM_5 UINT8_C(0x04)
#define BMA423_WRIST_SC_PARAM_6 UINT16_C(0x7B3F)
#define BMA423_WRIST_SC_PARAM_7 UINT16_C(0x6CCD)
#define BMA423_WRIST_SC_PARAM_8 UINT16_C(0x4C3)
#define BMA423_WRIST_SC_PARAM_9 UINT16_C(0x985)
#define BMA423_WRIST_SC_PARAM_10 UINT16_C(0x4C3)
#define BMA423_WRIST_SC_PARAM_11 UINT16_C(0xE6EC)
#define BMA423_WRIST_SC_PARAM_12 UINT16_C(0x460C)
#define BMA423_WRIST_SC_PARAM_13 UINT8_C(0x01)
#define BMA423_WRIST_SC_PARAM_14 UINT8_C(0x27)
#define BMA423_WRIST_SC_PARAM_15 UINT8_C(0x19)
#define BMA423_WRIST_SC_PARAM_16 UINT8_C(0x96)
#define BMA423_WRIST_SC_PARAM_17 UINT8_C(0xA0)
#define BMA423_WRIST_SC_PARAM_18 UINT8_C(0x01)
#define BMA423_WRIST_SC_PARAM_19 UINT8_C(0x0C)
#define BMA423_WRIST_SC_PARAM_20 UINT16_C(0x3CF0)
#define BMA423_WRIST_SC_PARAM_21 UINT16_C(0x100)
#define BMA423_WRIST_SC_PARAM_22 UINT8_C(0x01)
#define BMA423_WRIST_SC_PARAM_23 UINT8_C(0x03)
#define BMA423_WRIST_SC_PARAM_24 UINT8_C(0x01)
#define BMA423_WRIST_SC_PARAM_25 UINT8_C(0x0E)
/*!
* @brief Any motion configuration
*/
struct bma423_anymotion_config {
/*! Expressed in 50 Hz samples (20 ms) */
uint16_t duration;
/*! Threshold value for Any-motion / No-motion detection in
5.11g format */
uint16_t threshold;
/*! Indicates if No-motion or Any-motion is selected */
uint8_t nomotion_sel;
};
/*!
* @brief Axes remapping configuration
*/
struct bma423_axes_remap {
uint8_t x_axis;
uint8_t x_axis_sign;
uint8_t y_axis;
uint8_t y_axis_sign;
uint8_t z_axis;
uint8_t z_axis_sign;
};
/*!
* @brief Step counter param settings
*/
struct bma423_stepcounter_settings {
/*! Step Counter param 1 */
uint16_t param1;
/*! Step Counter param 2 */
uint16_t param2;
/*! Step Counter param 3 */
uint16_t param3;
/*! Step Counter param 4 */
uint16_t param4;
/*! Step Counter param 5 */
uint16_t param5;
/*! Step Counter param 6 */
uint16_t param6;
/*! Step Counter param 7 */
uint16_t param7;
/*! Step Counter param 8 */
uint16_t param8;
/*! Step Counter param 9 */
uint16_t param9;
/*! Step Counter param 10 */
uint16_t param10;
/*! Step Counter param 11 */
uint16_t param11;
/*! Step Counter param 12 */
uint16_t param12;
/*! Step Counter param 13 */
uint16_t param13;
/*! Step Counter param 14 */
uint16_t param14;
/*! Step Counter param 15 */
uint16_t param15;
/*! Step Counter param 16 */
uint16_t param16;
/*! Step Counter param 17 */
uint16_t param17;
/*! Step Counter param 18 */
uint16_t param18;
/*! Step Counter param 19 */
uint16_t param19;
/*! Step Counter param 20 */
uint16_t param20;
/*! Step Counter param 21 */
uint16_t param21;
/*! Step Counter param 22 */
uint16_t param22;
/*! Step Counter param 23 */
uint16_t param23;
/*! Step Counter param 24 */
uint16_t param24;
/*! Step Counter param 25 */
uint16_t param25;
};
/*!
* @brief This API is the entry point.
* Call this API before using all other APIs.
* This API reads the chip-id of the sensor and sets the resolution.
*
* @param[in,out] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_init(struct bma4_dev *dev);
/*!
* @brief This API is used to upload the config file to enable
* the features of the sensor.
*
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_write_config_file(struct bma4_dev *dev);
/*!
* @brief This API is used to get the configuration id of the sensor.
*
* @param[out] config_id : Pointer variable used to store
* the configuration id.
* @param[in] dev : Structure instance of bma4_dev.
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_get_config_id(uint16_t *config_id, struct bma4_dev *dev);
/*!
* @brief This API sets/unsets the user provided interrupt to either
* interrupt pin1 or pin2 in the sensor.
*
* @param[in] int_line: Variable to select either interrupt pin1 or pin2.
* int_line | Macros
* ------------|-------------------
* 0 | BMA4_INTR1_MAP
* 1 | BMA4_INTR2_MAP
* @param[in] int_map : Variable to specify the interrupts.
* @param[in] enable : Variable to specify mapping or unmapping of
* interrupts.
* enable | Macros
* --------------------|-------------------
* 0x00 | BMA4_DISABLE
* 0x01 | BMA4_ENABLE
* @param[in] dev : Structure instance of bma4_dev.
*
* @note Below macros specify the interrupts.
* Feature Interrupts
* - BMA423_STEP_CNTR_INT
* - BMA423_ACTIVITY_INT
* - BMA423_TILT_INT
* - BMA423_WAKEUP_INT
* - BMA423_ANY_NO_MOTION_INT
* - BMA423_ERROR_INT
*
* Hardware Interrupts
* - BMA4_FIFO_FULL_INT
* - BMA4_FIFO_WM_INT
* - BMA4_DATA_RDY_INT
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_map_interrupt(uint8_t int_line, uint16_t int_map, uint8_t enable, struct bma4_dev *dev);
/*!
* @brief This API reads the bma423 interrupt status from the sensor.
*
* @param[out] int_status : Variable to store the interrupt status
* read from the sensor.
* @param[in] dev : Structure instance of bma4_dev.
*
* @note Below macros are used to check the interrupt status.
* Feature Interrupts
*
* - BMA423_STEP_CNTR_INT
* - BMA423_ACTIVITY_INT
* - BMA423_TILT_INT
* - BMA423_WAKEUP_INT
* - BMA423_ANY_NO_MOTION_INT
* - BMA423_ERROR_INT
*
*
* Hardware Interrupts
* - BMA4_FIFO_FULL_INT
* - BMA4_FIFO_WM_INT
* - BMA4_MAG_DATA_RDY_INT
* - BMA4_ACCEL_DATA_RDY_INT
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_read_int_status(uint16_t *int_status, struct bma4_dev *dev);
/*!
* @brief This API enables/disables the features of the sensor.
*
* @param[in] feature : Variable to specify the features
* which are to be set in bma423 sensor.
* @param[in] enable : Variable which specifies whether to enable or
* disable the features in the bma423 sensor
* enable | Macros
* --------------------|-------------------
* 0x00 | BMA4_DISABLE
* 0x01 | BMA4_ENABLE
* @param[in] dev : Structure instance of bma4_dev.
*
* @note User should use the below macros to enable or disable the
* features of bma423 sensor
* - BMA423_STEP_CNTR
* - BMA423_ANY_MOTION (or) BMA423_NO_MOTION
* - BMA423_ACTIVITY
* - BMA423_WAKEUP
* - BMA423_TILT
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_feature_enable(uint8_t feature, uint8_t enable, struct bma4_dev *dev);
/*!
* @brief This API performs x, y and z axis remapping in the sensor.
*
* @param[in] remap_data : Pointer to store axes remapping data.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_set_remap_axes(const struct bma423_axes_remap *remap_data, struct bma4_dev *dev);
/*!
* @brief This API reads the x, y and z axis remap data from the sensor.
*
* @param[out] remap_data : Pointer to store axis remap data which is read
* from the bma423 sensor.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_get_remap_axes(struct bma423_axes_remap *remap_data, struct bma4_dev *dev);
/*!
* @brief This API sets the watermark level for step counter
* interrupt in the sensor.
*
* @param[in] step_counter_wm : Variable which specifies watermark level
* count
* @note Valid values are from 1 to 1023
* @note Value 0 is used for step detector interrupt
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_step_counter_set_watermark(uint16_t step_counter_wm, struct bma4_dev *dev);
/*!
* @brief This API gets the water mark level set for step counter interrupt
* in the sensor
*
* @param[out] step_counter_wm : Pointer variable which stores
* the water mark level read from the sensor.
* @note valid values are from 1 to 1023
* @note value 0 is used for step detector interrupt
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_step_counter_get_watermark(uint16_t *step_counter_wm, struct bma4_dev *dev);
/*!
* @brief This API resets the counted steps of step counter.
*
* @param[in] dev : structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_reset_step_counter(struct bma4_dev *dev);
/*!
* @brief This API gets the number of counted steps of the step counter
* feature from the sensor.
*
* @param[out] step_count : Pointer variable which stores counted steps
* read from the sensor.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_step_counter_output(uint32_t *step_count, struct bma4_dev *dev);
/*!
* @brief This API gets the output for activity feature.
*
* @param[out] activity : Pointer variable which stores activity output
* read from the sensor.
* activity | State
* --------------|------------------------
* 0x00 | BMA423_USER_STATIONARY
* 0x01 | BMA423_USER_WALKING
* 0x02 | BMA423_USER_RUNNING
* 0x03 | BMA423_STATE_INVALID
*
* @param[in] dev : Structure instance of bma4_dev
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_activity_output(uint8_t *activity, struct bma4_dev *dev);
/*!
* @brief This API select the platform configuration wrist(default) or phone.
*
* @param[in] platform : Variable to select wrist/phone
*
* platform | Macros
* -------------|------------------------
* 0x00 | BMA423_PHONE_CONFIG
* 0x01 | BMA423_WRIST_CONFIG
*
* @param[in] dev : Structure instance of bma4_dev
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_select_platform(uint8_t platform, struct bma4_dev *dev);
/*!
* @brief This API gets the parameter1 to parameter7 settings of the
* step counter feature.
*
* @param[out] setting : Pointer to structure variable which stores the
* parameter1 to parameter7 read from the sensor.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_stepcounter_get_parameter(struct bma423_stepcounter_settings *setting, struct bma4_dev *dev);
/*!
* @brief This API sets the parameter1 to parameter7 settings of the
* step counter feature in the sensor.
*
* @param[in] setting : Pointer to structure variable which stores the
* parameter1 to parameter7 settings read from the sensor.
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_stepcounter_set_parameter(const struct bma423_stepcounter_settings *setting, struct bma4_dev *dev);
/*!
* @brief This API enables or disables the step detector feature in the
* sensor.
*
* @param[in] enable : Variable used to enable or disable step detector
* enable | Macros
* --------------------|-------------------
* 0x00 | BMA4_DISABLE
* 0x01 | BMA4_ENABLE
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_step_detector_enable(uint8_t enable, struct bma4_dev *dev);
/*!
* @brief This API enables the any motion feature according to the axis
* set by the user in the sensor.
*
* @param[in] axis : Variable to specify the axis of the any motion feature
* to be enabled in the sensor.
* Value | Axis
* ---------|-------------------------
* 0x00 | BMA423_ALL_AXIS_DIS
* 0x01 | BMA423_X_AXIS_EN
* 0x02 | BMA423_Y_AXIS_EN
* 0x04 | BMA423_Z_AXIS_EN
* 0x07 | BMA423_ALL_AXIS_EN
* @param[in] dev : Structure instance of bma4_dev
*
* @return result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_anymotion_enable_axis(uint8_t axis, struct bma4_dev *dev);
/*! @brief This API sets the configuration of Any motion feature in
* the sensor.
*
* @param[in] any_motion : Pointer to structure variable to specify
* the any motion feature settings.
* Structure members are provided in the table below
*@verbatim
* -------------------------------------------------------------------------
* Structure parameters | Description
* --------------------------------|----------------------------------------
* | Defines the number of
* | consecutive data points for
* | which the threshold condition
* duration | must be respected, for interrupt
* | assertion. It is expressed in
* | 50 Hz samples (20 ms).
* | Range is 0 to 163sec.
* | Default value is 5 = 100ms.
* --------------------------------|----------------------------------------
* | Slope threshold value for
* | Any-motion / No-motion detection
* threshold | in 5.11g format.
* | Range is 0 to 1g.
* | Default value is 0xAA = 83mg.
* --------------------------------|----------------------------------------
* | Indicates if No motion (1) or
* nomotion_sel | Any-motion (0) is selected;
* | default value is 0 Any-motion.
* -------------------------------------------------------------------------
*@endverbatim
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_set_any_motion_config(const struct bma423_anymotion_config *any_motion, struct bma4_dev *dev);
/*! @brief This API gets the configuration of any motion feature from
* the sensor.
*
* @param[out] any_motion : Pointer to structure variable used to store
* the any motion feature settings read from the sensor.
* Structure members are provided in the table below
*@verbatim
* -------------------------------------------------------------------------
* Structure parameters | Description
* --------------------------------|----------------------------------------
* | Defines the number of
* | consecutive data points for
* | which the threshold condition
* duration | must be respected, for interrupt
* | assertion. It is expressed in
* | 50 Hz samples (20 ms).
* | Range is 0 to 163sec.
* | Default value is 5 = 100ms.
* --------------------------------|----------------------------------------
* | Slope threshold value for
* | Any-motion / No-motion detection
* threshold | in 5.11g format.
* | Range is 0 to 1g.
* | Default value is 0xAA = 83mg.
* --------------------------------|----------------------------------------
* | Indicates if No motion (1) or
* nomotion_sel | Any-motion (0) is selected;
* | default value is 0 Any-motion.
* -------------------------------------------------------------------------
*@endverbatim
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_get_any_motion_config(struct bma423_anymotion_config *any_motion, struct bma4_dev *dev);
/*!
* @brief This API sets the sensitivity of wake up feature in the sensor
*
* @param[in] sensitivity : Variable used to specify the sensitivity of the
* Wake up feature.
* Value | Sensitivity
* --------|-------------------------
* 0x00 | MOST SENSITIVE
* 0x07 | LEAST SENSITIVE
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_wakeup_set_sensitivity(uint8_t sensitivity, struct bma4_dev *dev);
/*!
* @brief This API gets the sensitivity of wake up feature in the sensor
*
* @param[out] sensitivity : Pointer variable which stores the sensitivity
* value read from the sensor.
* Value | Sensitivity
* --------|-------------------------
* 0x00 | MOST SENSITIVE
* 0x07 | LEAST SENSITIVE
* @param[in] dev : Structure instance of bma4_dev
*
* @return Result of API execution status
* @retval 0 -> Success
* @retval Any non zero value -> Fail
*/
uint16_t bma423_wakeup_get_sensitivity(uint8_t *sensitivity, struct bma4_dev *dev);
/*!
* @brief This API is used to select single/double tap
* feature in the sensor
*
* @param tap_select : Variable used to specify the single or
* double tap selection in the sensor
* tap_select | description
* ------------|------------------------
* 0x00 | Double tap selected
* 0x01 | single tap selected
*
* @param dev : Structure instance of bma4_dev
*
* @return results of stream_transfer operation
* @retval 0 -> Success
* @retval Any positive value mentioned in ERROR CODES -> Fail
*
*/
uint16_t bma423_tap_selection(const uint8_t tap_select, struct bma4_dev *dev);
#ifdef __cplusplus
}
#endif /*End of CPP guard */
#endif /*End of header guard macro */

960
src/bma4_defs.h Normal file
View File

@ -0,0 +1,960 @@
/*
*
****************************************************************************
* Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
*
* File : bma4_defs.h
*
* Date: 12 Oct 2017
*
* Revision: 2.1.9 $
*
* Usage: Sensor Driver for BMA4 family of sensors
*
****************************************************************************
*
* Disclaimer
*
* Common:
* Bosch Sensortec products are developed for the consumer goods industry.
* They may only be used within the parameters of the respective valid
* product data sheet. Bosch Sensortec products are provided with the
* express understanding that there is no warranty of fitness for a
* particular purpose.They are not fit for use in life-sustaining,
* safety or security sensitive systems or any system or device
* that may lead to bodily harm or property damage if the system
* or device malfunctions. In addition,Bosch Sensortec products are
* not fit for use in products which interact with motor vehicle systems.
* The resale and or use of products are at the purchasers own risk and
* his own responsibility. The examination of fitness for the intended use
* is the sole responsibility of the Purchaser.
*
* The purchaser shall indemnify Bosch Sensortec from all third party
* claims, including any claims for incidental, or consequential damages,
* arising from any product use not covered by the parameters of
* the respective valid product data sheet or not approved by
* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
* connection with such claims.
*
* The purchaser must monitor the market for the purchased products,
* particularly with regard to product safety and inform Bosch Sensortec
* without delay of all security relevant incidents.
*
* Engineering Samples are marked with an asterisk (*) or (e).
* Samples may vary from the valid technical specifications of the product
* series. They are therefore not intended or fit for resale to third
* parties or for use in end products. Their sole purpose is internal
* client testing. The testing of an engineering sample may in no way
* replace the testing of a product series. Bosch Sensortec assumes
* no liability for the use of engineering samples.
* By accepting the engineering samples, the Purchaser agrees to indemnify
* Bosch Sensortec from all claims arising from the use of engineering
* samples.
*
* Special:
* This software module (hereinafter called "Software") and any information
* on application-sheets (hereinafter called "Information") is provided
* free of charge for the sole purpose to support your application work.
* The Software and Information is subject to the following
* terms and conditions:
*
* The Software is specifically designed for the exclusive use for
* Bosch Sensortec products by personnel who have special experience
* and training. Do not use this Software if you do not have the
* proper experience or training.
*
* This Software package is provided `` as is `` and without any expressed
* or implied warranties,including without limitation, the implied warranties
* of merchantability and fitness for a particular purpose.
*
* Bosch Sensortec and their representatives and agents deny any liability
* for the functional impairment
* of this Software in terms of fitness, performance and safety.
* Bosch Sensortec and their representatives and agents shall not be liable
* for any direct or indirect damages or injury, except as
* otherwise stipulated in mandatory applicable law.
*
* The Information provided is believed to be accurate and reliable.
* Bosch Sensortec assumes no responsibility for the consequences of use
* of such Information nor for any infringement of patents or
* other rights of third parties which may result from its use.
* No license is granted by implication or otherwise under any patent or
* patent rights of Bosch. Specifications mentioned in the Information are
* subject to change without notice.
**************************************************************************/
/*! \file bma4_defs.h
\brief Sensor Driver for BMA4 family of sensors */
#ifndef BMA4_DEFS_H__
#define BMA4_DEFS_H__
/*********************************************************************/
/**\ header files */
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#include <stddef.h>
#include <math.h>
#endif
/*********************************************************************/
/* macro definitions */
/*
#if (LONG_MAX) > 0x7fffffff
#define __have_long64 1
#elif (LONG_MAX) == 0x7fffffff
#define __have_long32 1
#endif
*/
#if !defined(UINT8_C)
#define INT8_C(x) x
#if (INT_MAX) > 0x7f
#define UINT8_C(x) x
#else
#define UINT8_C(x) x##U
#endif
#endif
#if !defined(UINT16_C)
#define INT16_C(x) x
#if (INT_MAX) > 0x7fff
#define UINT16_C(x) x
#else
#define UINT16_C(x) x##U
#endif
#endif
#if !defined(INT32_C) && !defined(UINT32_C)
#if __have_long32
#define INT32_C(x) x##L
#define UINT32_C(x) x##UL
#else
#define INT32_C(x) x
#define UINT32_C(x) x##U
#endif
#endif
#if !defined(INT64_C) && !defined(UINT64_C)
#if __have_long64
#define INT64_C(x) x##L
#define UINT64_C(x) x##UL
#else
#define INT64_C(x) x##LL
#define UINT64_C(x) x##ULL
#endif
#endif
/**\name CHIP ID ADDRESS*/
#define BMA4_CHIP_ID_ADDR UINT8_C(0x00)
/**\name ERROR STATUS*/
#define BMA4_ERROR_ADDR UINT8_C(0X02)
/**\name STATUS REGISTER FOR SENSOR STATUS FLAG*/
#define BMA4_STATUS_ADDR UINT8_C(0X03)
/**\name AUX/ACCEL DATA BASE ADDRESS REGISTERS*/
#define BMA4_DATA_0_ADDR UINT8_C(0X0A)
#define BMA4_DATA_8_ADDR UINT8_C(0X12)
/**\name SENSOR TIME REGISTERS*/
#define BMA4_SENSORTIME_0_ADDR UINT8_C(0X18)
/**\name INTERRUPT/FEATURE STATUS REGISTERS*/
#define BMA4_INT_STAT_0_ADDR UINT8_C(0X1C)
/**\name INTERRUPT/FEATURE STATUS REGISTERS*/
#define BMA4_INT_STAT_1_ADDR UINT8_C(0X1D)
/**\name TEMPERATURE REGISTERS*/
#define BMA4_TEMPERATURE_ADDR UINT8_C(0X22)
/**\name FIFO REGISTERS*/
#define BMA4_FIFO_LENGTH_0_ADDR UINT8_C(0X24)
#define BMA4_FIFO_DATA_ADDR UINT8_C(0X26)
/**\name ACCEL CONFIG REGISTERS*/
#define BMA4_ACCEL_CONFIG_ADDR UINT8_C(0X40)
/**\name ACCEL RANGE ADDRESS*/
#define BMA4_ACCEL_RANGE_ADDR UINT8_C(0X41)
/**\name AUX CONFIG REGISTERS*/
#define BMA4_AUX_CONFIG_ADDR UINT8_C(0X44)
/**\name FIFO DOWN SAMPLING REGISTER ADDRESS FOR ACCEL*/
#define BMA4_FIFO_DOWN_ADDR UINT8_C(0X45)
/**\name FIFO WATERMARK REGISTER ADDRESS*/
#define BMA4_FIFO_WTM_0_ADDR UINT8_C(0X46)
/**\name FIFO CONFIG REGISTERS*/
#define BMA4_FIFO_CONFIG_0_ADDR UINT8_C(0X48)
#define BMA4_FIFO_CONFIG_1_ADDR UINT8_C(0X49)
/**\name MAG INTERFACE REGISTERS*/
#define BMA4_AUX_DEV_ID_ADDR UINT8_C(0X4B)
#define BMA4_AUX_IF_CONF_ADDR UINT8_C(0X4C)
#define BMA4_AUX_RD_ADDR UINT8_C(0X4D)
#define BMA4_AUX_WR_ADDR UINT8_C(0X4E)
#define BMA4_AUX_WR_DATA_ADDR UINT8_C(0X4F)
/**\name INTERRUPT ENABLE REGISTERS*/
#define BMA4_INT1_IO_CTRL_ADDR UINT8_C(0X53)
#define BMA4_INT2_IO_CTRL_ADDR UINT8_C(0X54)
/**\name LATCH DURATION REGISTERS*/
#define BMA4_INTR_LATCH_ADDR UINT8_C(0X55)
/**\name MAP INTERRUPT 1 and 2 REGISTERS*/
#define BMA4_INT_MAP_1_ADDR UINT8_C(0X56)
#define BMA4_INT_MAP_2_ADDR UINT8_C(0X57)
#define BMA4_INT_MAP_DATA_ADDR UINT8_C(0x58)
#define BMA4_INIT_CTRL_ADDR UINT8_C(0x59)
/**\name FEATURE CONFIG RELATED */
#define BMA4_RESERVED_REG_5B_ADDR UINT8_C(0x5B)
#define BMA4_RESERVED_REG_5C_ADDR UINT8_C(0x5C)
#define BMA4_FEATURE_CONFIG_ADDR UINT8_C(0x5E)
#define BMA4_INTERNAL_ERROR UINT8_C(0x5F)
/**\name SERIAL INTERFACE SETTINGS REGISTER*/
#define BMA4_IF_CONFIG_ADDR UINT8_C(0X6B)
/**\name SELF_TEST REGISTER*/
#define BMA4_ACC_SELF_TEST_ADDR UINT8_C(0X6D)
/**\name SPI,I2C SELECTION REGISTER*/
#define BMA4_NV_CONFIG_ADDR UINT8_C(0x70)
/**\name ACCEL OFFSET REGISTERS*/
#define BMA4_OFFSET_0_ADDR UINT8_C(0X71)
#define BMA4_OFFSET_1_ADDR UINT8_C(0X72)
#define BMA4_OFFSET_2_ADDR UINT8_C(0X73)
/**\name POWER_CTRL REGISTER*/
#define BMA4_POWER_CONF_ADDR UINT8_C(0x7C)
#define BMA4_POWER_CTRL_ADDR UINT8_C(0x7D)
/**\name COMMAND REGISTER*/
#define BMA4_CMD_ADDR UINT8_C(0X7E)
/**\name GPIO REGISTERS*/
#define BMA4_STEP_CNT_OUT_0_ADDR UINT8_C(0x1E)
#define BMA4_HIGH_G_OUT_ADDR UINT8_C(0x1F)
#define BMA4_ACTIVITY_OUT_ADDR UINT8_C(0x27)
#define BMA4_ORIENTATION_OUT_ADDR UINT8_C(0x28)
#define BMA4_INTERNAL_STAT UINT8_C(0x2A)
/*!
* @brief Block size for config write */
#define BMA4_BLOCK_SIZE UINT8_C(32)
/**\name I2C slave address */
#define BMA4_I2C_ADDR_PRIMARY UINT8_C(0x18)
#define BMA4_I2C_ADDR_SECONDARY UINT8_C(0x19)
#define BMA4_I2C_BMM150_ADDR UINT8_C(0x10)
/**\name Interface selection macro */
#define BMA4_SPI_INTERFACE UINT8_C(1)
#define BMA4_I2C_INTERFACE UINT8_C(2)
/**\name Interface selection macro */
#define BMA4_SPI_WR_MASK UINT8_C(0x7F)
#define BMA4_SPI_RD_MASK UINT8_C(0x80)
/**\name Chip ID macros */
#define BMA4_CHIP_ID_MIN UINT8_C(0x10)
#define BMA4_CHIP_ID_MAX UINT8_C(0x15)
/**\name Auxiliary sensor selection macro */
#define BMM150_SENSOR UINT8_C(1)
#define AKM9916_SENSOR UINT8_C(2)
#define BMA4_ASIC_INITIALIZED UINT8_C(0x01)
/**\name Auxiliary sensor chip id macros */
#define BMM150_CHIP_ID UINT8_C(0x32)
/**\name Auxiliary sensor other macros */
#define BMM150_POWER_CONTROL_REG UINT8_C(0x4B)
#define BMM150_POWER_MODE_REG UINT8_C(0x4C)
/**\name CONSTANTS */
#define BMA4_FIFO_CONFIG_LENGTH UINT8_C(2)
#define BMA4_ACCEL_CONFIG_LENGTH UINT8_C(2)
#define BMA4_FIFO_WM_LENGTH UINT8_C(2)
#define BMA4_CONFIG_STREAM_SIZE UINT16_C(6144)
#define BMA4_NON_LATCH_MODE UINT8_C(0)
#define BMA4_LATCH_MODE UINT8_C(1)
#define BMA4_OPEN_DRAIN UINT8_C(1)
#define BMA4_PUSH_PULL UINT8_C(0)
#define BMA4_ACTIVE_HIGH UINT8_C(1)
#define BMA4_ACTIVE_LOW UINT8_C(0)
#define BMA4_EDGE_TRIGGER UINT8_C(1)
#define BMA4_LEVEL_TRIGGER UINT8_C(0)
#define BMA4_OUTPUT_ENABLE UINT8_C(1)
#define BMA4_OUTPUT_DISABLE UINT8_C(0)
#define BMA4_INPUT_ENABLE UINT8_C(1)
#define BMA4_INPUT_DISABLE UINT8_C(0)
/**\name ACCEL RANGE CHECK*/
#define BMA4_ACCEL_RANGE_2G UINT8_C(0)
#define BMA4_ACCEL_RANGE_4G UINT8_C(1)
#define BMA4_ACCEL_RANGE_8G UINT8_C(2)
#define BMA4_ACCEL_RANGE_16G UINT8_C(3)
/**\name CONDITION CHECK FOR READING AND WRTING DATA*/
#define BMA4_MAX_VALUE_FIFO_FILTER UINT8_C(1)
#define BMA4_MAX_VALUE_SPI3 UINT8_C(1)
#define BMA4_MAX_VALUE_SELFTEST_AMP UINT8_C(1)
#define BMA4_MAX_IF_MODE UINT8_C(3)
#define BMA4_MAX_VALUE_SELFTEST_SIGN UINT8_C(1)
/**\name BUS READ AND WRITE LENGTH FOR MAG & ACCEL*/
#define BMA4_MAG_TRIM_DATA_SIZE UINT8_C(16)
#define BMA4_MAG_XYZ_DATA_LENGTH UINT8_C(6)
#define BMA4_MAG_XYZR_DATA_LENGTH UINT8_C(8)
#define BMA4_ACCEL_DATA_LENGTH UINT8_C(6)
#define BMA4_FIFO_DATA_LENGTH UINT8_C(2)
#define BMA4_TEMP_DATA_SIZE UINT8_C(1)
/**\name TEMPERATURE CONSTANT */
#define BMA4_OFFSET_TEMP UINT8_C(23)
#define BMA4_DEG UINT8_C(1)
#define BMA4_FAHREN UINT8_C(2)
#define BMA4_KELVIN UINT8_C(3)
/**\name DELAY DEF