smartdof2 2.1.0.0
smartdof2.h File Reference

This file contains API for Smart DOF 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  smartdof2_s
 Smart DOF 2 Click context object. More...
 
struct  smartdof2_cfg_t
 Smart DOF 2 Click configuration object. More...
 
struct  smartdof2_axis_data_t
 Smart DOF 2 Click axis raw data structure object. More...
 
struct  smartdof2_axis_t
 Smart DOF 2 Click sensor axes structure object. More...
 

Macros

#define SMARTDOF2_REG_FUNC_CFG_ACCESS   0x01
 Smart DOF 2 description register.
 
#define SMARTDOF2_REG_PIN_CTRL   0x02
 
#define SMARTDOF2_REG_IF_CFG   0x03
 
#define SMARTDOF2_REG_S4S_TPH_L   0x04
 
#define SMARTDOF2_REG_S4S_TPH_H   0x05
 
#define SMARTDOF2_REG_S4S_RR   0x06
 
#define SMARTDOF2_REG_FIFO_CTRL1   0x07
 
#define SMARTDOF2_REG_FIFO_CTRL2   0x08
 
#define SMARTDOF2_REG_FIFO_CTRL3   0x09
 
#define SMARTDOF2_REG_FIFO_CTRL4   0x0A
 
#define SMARTDOF2_REG_COUNTER_BDR_REG1   0x0B
 
#define SMARTDOF2_REG_COUNTER_BDR_REG2   0x0C
 
#define SMARTDOF2_REG_INT1_CTRL   0x0D
 
#define SMARTDOF2_REG_INT2_CTRL   0x0E
 
#define SMARTDOF2_REG_WHO_AM_I   0x0F
 
#define SMARTDOF2_REG_CTRL1   0x10
 
#define SMARTDOF2_REG_CTRL2   0x11
 
#define SMARTDOF2_REG_CTRL3   0x12
 
#define SMARTDOF2_REG_CTRL4   0x13
 
#define SMARTDOF2_REG_CTRL5   0x14
 
#define SMARTDOF2_REG_CTRL6   0x15
 
#define SMARTDOF2_REG_CTRL7   0x16
 
#define SMARTDOF2_REG_CTRL8   0x17
 
#define SMARTDOF2_REG_CTRL9   0x18
 
#define SMARTDOF2_REG_CTRL10   0x19
 
#define SMARTDOF2_REG_CTRL_STATUS   0x1A
 
#define SMARTDOF2_REG_FIFO_STATUS1   0x1B
 
#define SMARTDOF2_REG_FIFO_STATUS2   0x1C
 
#define SMARTDOF2_REG_ALL_INT_SRC   0x1D
 
#define SMARTDOF2_REG_STATUS_REG   0x1E
 
#define SMARTDOF2_REG_OUT_TEMP_L   0x20
 
#define SMARTDOF2_REG_OUT_TEMP_H   0x21
 
#define SMARTDOF2_REG_OUTX_L_G   0x22
 
#define SMARTDOF2_REG_OUTX_H_G   0x23
 
#define SMARTDOF2_REG_OUTY_L_G   0x24
 
#define SMARTDOF2_REG_OUTY_H_G   0x25
 
#define SMARTDOF2_REG_OUTZ_L_G   0x26
 
#define SMARTDOF2_REG_OUTZ_H_G   0x27
 
#define SMARTDOF2_REG_OUTX_L_A   0x28
 
#define SMARTDOF2_REG_OUTX_H_A   0x29
 
#define SMARTDOF2_REG_OUTY_L_A   0x2A
 
#define SMARTDOF2_REG_OUTY_H_A   0x2B
 
#define SMARTDOF2_REG_OUTZ_L_A   0x2C
 
#define SMARTDOF2_REG_OUTZ_H_A   0x2D
 
#define SMARTDOF2_REG_UI_OUTX_L_G_OIS_EIS   0x2E
 
#define SMARTDOF2_REG_UI_OUTX_H_G_OIS_EIS   0x2F
 
#define SMARTDOF2_REG_UI_OUTY_L_G_OIS_EIS   0x30
 
#define SMARTDOF2_REG_UI_OUTY_H_G_OIS_EIS   0x31
 
#define SMARTDOF2_REG_UI_OUTZ_L_G_OIS_EIS   0x32
 
#define SMARTDOF2_REG_UI_OUTZ_H_G_OIS_EIS   0x33
 
#define SMARTDOF2_REG_UI_OUTX_L_A_OIS_DUALC   0x34
 
#define SMARTDOF2_REG_UI_OUTX_H_A_OIS_DUALC   0x35
 
#define SMARTDOF2_REG_UI_OUTY_L_A_OIS_DUALC   0x36
 
#define SMARTDOF2_REG_UI_OUTY_H_A_OIS_DUALC   0x37
 
#define SMARTDOF2_REG_UI_OUTZ_L_A_OIS_DUALC   0x38
 
#define SMARTDOF2_REG_UI_OUTZ_H_A_OIS_DUALC   0x39
 
#define SMARTDOF2_REG_AH_QVAR_OUT_L   0x3A
 
#define SMARTDOF2_REG_AH_QVAR_OUT_H   0x3B
 
#define SMARTDOF2_REG_TIMESTAMP0   0x40
 
#define SMARTDOF2_REG_TIMESTAMP1   0x41
 
#define SMARTDOF2_REG_TIMESTAMP2   0x42
 
#define SMARTDOF2_REG_TIMESTAMP3   0x43
 
#define SMARTDOF2_REG_UI_STATUS_REG_OIS   0x44
 
#define SMARTDOF2_REG_WAKE_UP_SRC   0x45
 
#define SMARTDOF2_REG_TAP_SRC   0x46
 
#define SMARTDOF2_REG_D6D_SRC   0x47
 
#define SMARTDOF2_REG_STATUS_MASTER_MAINPAGE   0x48
 
#define SMARTDOF2_REG_EMB_FUNC_STATUS_MAINPAGE   0x49
 
#define SMARTDOF2_REG_FSM_STATUS_MAINPAGE   0x4A
 
#define SMARTDOF2_REG_MLC_STATUS_MAINPAGE   0x4B
 
#define SMARTDOF2_REG_INTERNAL_FREQ   0x4F
 
#define SMARTDOF2_REG_FUNCTIONS_ENABLE   0x50
 
#define SMARTDOF2_REG_DEN   0x51
 
#define SMARTDOF2_REG_INACTIVITY_DUR   0x54
 
#define SMARTDOF2_REG_INACTIVITY_THS   0x55
 
#define SMARTDOF2_REG_TAP_CFG0   0x56
 
#define SMARTDOF2_REG_TAP_CFG1   0x57
 
#define SMARTDOF2_REG_TAP_CFG2   0x58
 
#define SMARTDOF2_REG_TAP_THS_6D   0x59
 
#define SMARTDOF2_REG_INT_DUR2   0x5A
 
#define SMARTDOF2_REG_WAKE_UP_THS   0x5B
 
#define SMARTDOF2_REG_WAKE_UP_DUR   0x5C
 
#define SMARTDOF2_REG_FREE_FALL   0x5D
 
#define SMARTDOF2_REG_MD1_CFG   0x5E
 
#define SMARTDOF2_REG_MD2_CFG   0x5F
 
#define SMARTDOF2_REG_S4S_ST_CMD_CODE   0x60
 
#define SMARTDOF2_REG_S4S_DT_REG   0x61
 
#define SMARTDOF2_REG_EMB_FUNC_CFG   0x63
 
#define SMARTDOF2_REG_UI_HANDSHAKE_CTRL   0x64
 
#define SMARTDOF2_REG_UI_SPI2_SHARED_0   0x65
 
#define SMARTDOF2_REG_UI_SPI2_SHARED_1   0x66
 
#define SMARTDOF2_REG_UI_SPI2_SHARED_2   0x67
 
#define SMARTDOF2_REG_UI_SPI2_SHARED_3   0x68
 
#define SMARTDOF2_REG_UI_SPI2_SHARED_4   0x69
 
#define SMARTDOF2_REG_UI_SPI2_SHARED_5   0x6A
 
#define SMARTDOF2_REG_CTRL_EIS   0x6B
 
#define SMARTDOF2_REG_UI_INT_OIS   0x6F
 
#define SMARTDOF2_REG_UI_CTRL1_OIS   0x70
 
#define SMARTDOF2_REG_UI_CTRL2_OIS   0x71
 
#define SMARTDOF2_REG_UI_CTRL3_OIS   0x72
 
#define SMARTDOF2_REG_X_OFS_USR   0x73
 
#define SMARTDOF2_REG_Y_OFS_USR   0x74
 
#define SMARTDOF2_REG_Z_OFS_USR   0x75
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_TAG   0x78
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_X_L   0x79
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_X_H   0x7A
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_Y_L   0x7B
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_Y_H   0x7C
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_Z_L   0x7D
 
#define SMARTDOF2_REG_FIFO_DATA_OUT_Z_H   0x7E
 
#define SMARTDOF2_DEVICE_ID   0x70
 Smart DOF 2 SMARTDOF2_REG_WHO_AM_I register value.
 
#define SMARTDOF2_IF_INC_DISABLE   0x00
 Smart DOF 2 SMARTDOF2_REG_CTRL3 register value.
 
#define SMARTDOF2_IF_INC_ENABLE   0x04
 
#define SMARTDOF2_IF_INC_BIT_MASK   0xFB
 
#define SMARTDOF2_BDU_DISABLE   0x00
 
#define SMARTDOF2_BDU_ENABLE   0x40
 
#define SMARTDOF2_BDU_BIT_MASK   0xBF
 
#define SMARTDOF2_FIFO_MODE_BYPASS   0x00
 Smart DOF 2 SMARTDOF2_REG_FIFO_CTRL4 register value.
 
#define SMARTDOF2_FIFO_MODE_FIFO   0x01
 
#define SMARTDOF2_FIFO_MODE_STREAM_WTM_TO_FULL   0x02
 
#define SMARTDOF2_FIFO_MODE_STREAM_TO_FIFO   0x03
 
#define SMARTDOF2_FIFO_MODE_BYPASS_TO_STREAM   0x04
 
#define SMARTDOF2_FIFO_MODE_STREAM   0x06
 
#define SMARTDOF2_FIFO_MODE_BYPASS_TO_FIFO   0x07
 
#define SMARTDOF2_FIFO_MODE_BIT_MASK   0xF8
 
#define SMARTDOF2_ODR_OFF   0x00
 Smart DOF 2 SMARTDOF2_REG_CTRL1 register value.
 
#define SMARTDOF2_ODR_AT_1Hz875   0x01
 
#define SMARTDOF2_ODR_AT_7Hz5   0x02
 
#define SMARTDOF2_ODR_AT_15Hz   0x03
 
#define SMARTDOF2_ODR_AT_30Hz   0x04
 
#define SMARTDOF2_ODR_AT_60Hz   0x05
 
#define SMARTDOF2_ODR_AT_120Hz   0x06
 
#define SMARTDOF2_ODR_AT_240Hz   0x07
 
#define SMARTDOF2_ODR_AT_480Hz   0x08
 
#define SMARTDOF2_ODR_AT_960Hz   0x09
 
#define SMARTDOF2_ODR_AT_1920Hz   0x0A
 
#define SMARTDOF2_ODR_AT_3840Hz   0x0B
 
#define SMARTDOF2_ODR_AT_7680Hz   0x0C
 
#define SMARTDOF2_ODR_BIT_MASK   0xF0
 
#define SMARTDOF2_XL_FULL_SCALE_2g   0x00
 Smart DOF 2 SMARTDOF2_REG_CTRL2/8 register value.
 
#define SMARTDOF2_XL_FULL_SCALE_4g   0x01
 
#define SMARTDOF2_XL_FULL_SCALE_8g   0x02
 
#define SMARTDOF2_XL_FULL_SCALE_16g   0x03
 
#define SMARTDOF2_XL_FULL_SCALE_BIT_MASK   0xF8
 
#define SMARTDOF2_GY_FULL_SCALE_125dps   0x00
 Smart DOF 2 SMARTDOF2_REG_CTRL6 register value.
 
#define SMARTDOF2_GY_FULL_SCALE_250dps   0x01
 
#define SMARTDOF2_GY_FULL_SCALE_500dps   0x02
 
#define SMARTDOF2_GY_FULL_SCALE_1000dps   0x03
 
#define SMARTDOF2_GY_FULL_SCALE_2000dps   0x04
 
#define SMARTDOF2_GY_FULL_SCALE_4000dps   0x0C
 
#define SMARTDOF2_GY_FULL_SCALE_BIT_MASK   0xF0
 
#define SMARTDOF2_ACC_SENSITIVITY_FS_2g   0.061
 Smart DOF 2 accel sensitivity data value.
 
#define SMARTDOF2_ACC_SENSITIVITY_FS_4g   0.122
 
#define SMARTDOF2_ACC_SENSITIVITY_FS_8g   0.244
 
#define SMARTDOF2_ACC_SENSITIVITY_FS_16g   0.488
 
#define SMARTDOF2_GYRO_SENSITIVITY_FS_125dps   4.375
 Smart DOF 2 gyro sensitivity data value.
 
#define SMARTDOF2_GYRO_SENSITIVITY_FS_250dps   8.750
 
#define SMARTDOF2_GYRO_SENSITIVITY_FS_500dps   17.500
 
#define SMARTDOF2_GYRO_SENSITIVITY_FS_1000dps   35.000
 
#define SMARTDOF2_GYRO_SENSITIVITY_FS_2000dps   70.000
 
#define SMARTDOF2_GYRO_SENSITIVITY_FS_4000dps   140.000
 
#define SMARTDOF2_DEVICE_ADDRESS_GND   0x6A
 Smart DOF 2 device address setting.
 
#define SMARTDOF2_DEVICE_ADDRESS_VCC   0x6B
 
#define SMARTDOF2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define SMARTDOF2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define SMARTDOF2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Typedefs

typedef err_t(* smartdof2_master_io_t) (struct smartdof2_s *, uint8_t, uint8_t *, uint8_t)
 Smart DOF 2 Click driver interface.
 
typedef struct smartdof2_s smartdof2_t
 Smart DOF 2 Click context object.
 

Enumerations

enum  smartdof2_drv_t { SMARTDOF2_DRV_SEL_SPI , SMARTDOF2_DRV_SEL_I2C }
 Smart DOF 2 Click driver selector. More...
 
enum  smartdof2_return_value_t { SMARTDOF2_OK = 0 , SMARTDOF2_ERROR = -1 }
 Smart DOF 2 Click return value data. More...
 

Functions

void smartdof2_cfg_setup (smartdof2_cfg_t *cfg)
 Smart DOF 2 configuration object setup function.
 
void smartdof2_drv_interface_selection (smartdof2_cfg_t *cfg, smartdof2_drv_t drv_sel)
 Smart DOF 2 driver interface setup function.
 
err_t smartdof2_init (smartdof2_t *ctx, smartdof2_cfg_t *cfg)
 Smart DOF 2 initialization function.
 
err_t smartdof2_default_cfg (smartdof2_t *ctx)
 Smart DOF 2 default configuration function.
 
err_t smartdof2_generic_write (smartdof2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Smart DOF 2 data writing function.
 
err_t smartdof2_generic_read (smartdof2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Smart DOF 2 data reading function.
 
err_t smartdof2_get_device_id (smartdof2_t *ctx, uint8_t *device_id)
 Smart DOF 2 get device ID function.
 
err_t smartdof2_enable_auto_increment (smartdof2_t *ctx)
 Smart DOF 2 enable auto increment function.
 
err_t smartdof2_enable_block_data_update (smartdof2_t *ctx)
 Smart DOF 2 enable block data update function.
 
err_t smartdof2_set_fifo_mode (smartdof2_t *ctx, uint8_t fifo_mode)
 Smart DOF 2 set FIFO mode function.
 
err_t smartdof2_set_acc_data_rate (smartdof2_t *ctx, uint8_t data_rate)
 Smart DOF 2 set accel data rate function.
 
err_t smartdof2_get_acc_full_scale (smartdof2_t *ctx, uint8_t *data_scale)
 Smart DOF 2 get full-scale accel range function.
 
err_t smartdof2_set_acc_full_scale (smartdof2_t *ctx, uint8_t data_scale)
 Smart DOF 2 set full-scale accel range function.
 
err_t smartdof2_set_gyro_data_rate (smartdof2_t *ctx, uint8_t data_rate)
 Smart DOF 2 set gyro data rate function.
 
err_t smartdof2_get_gyro_full_scale (smartdof2_t *ctx, uint8_t *data_scale)
 Smart DOF 2 get full-scale gyro range function.
 
err_t smartdof2_set_gyro_full_scale (smartdof2_t *ctx, uint8_t data_scale)
 Smart DOF 2 set full-scale gyro range function.
 
err_t smartdof2_get_acc_axis_data (smartdof2_t *ctx, smartdof2_axis_data_t *acc_axis)
 Smart DOF 2 get accel data function.
 
err_t smartdof2_get_gyro_axis_data (smartdof2_t *ctx, smartdof2_axis_data_t *gyro_axis)
 Smart DOF 2 get gyro data function.
 
err_t smartdof2_get_acc_sensitivity (smartdof2_t *ctx, float *sensitivity)
 Smart DOF 2 get accel sensitivity function.
 
err_t smartdof2_get_gyro_sensitivity (smartdof2_t *ctx, float *sensitivity)
 Smart DOF 2 get gyro sensitivity function.
 
err_t smartdof2_get_acc_axis (smartdof2_t *ctx, smartdof2_axis_t *acc_axis)
 Smart DOF 2 get accel sensor axes function.
 
err_t smartdof2_get_gyro_axis (smartdof2_t *ctx, smartdof2_axis_t *gyro_axis)
 Smart DOF 2 get gyro sensor axes function.
 
err_t smartdof2_get_temperature_raw (smartdof2_t *ctx, int16_t *temp_raw)
 Smart DOF 2 get temperature data function.
 
err_t smartdof2_get_temperature (smartdof2_t *ctx, float *temperature)
 Smart DOF 2 get temperature function.
 
uint8_t smartdof2_get_int_pin (smartdof2_t *ctx)
 Smart DOF 2 get interrupt function.
 

Detailed Description

This file contains API for Smart DOF 2 Click Driver.

Typedef Documentation

◆ smartdof2_master_io_t

typedef err_t(* smartdof2_master_io_t) (struct smartdof2_s *, uint8_t, uint8_t *, uint8_t)

Smart DOF 2 Click driver interface.

Definition of driver interface of Smart DOF 2 Click driver. Driver serial interface.

◆ smartdof2_t

typedef struct smartdof2_s smartdof2_t

Smart DOF 2 Click context object.

Context object definition of Smart DOF 2 Click driver.

Enumeration Type Documentation

◆ smartdof2_drv_t

Smart DOF 2 Click driver selector.

Selects target driver interface of Smart DOF 2 Click driver.

Enumerator
SMARTDOF2_DRV_SEL_SPI 

SPI driver descriptor.

SMARTDOF2_DRV_SEL_I2C 

I2C driver descriptor.

◆ smartdof2_return_value_t

Smart DOF 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
SMARTDOF2_OK 
SMARTDOF2_ERROR