accel21 2.1.0.0
accel21.h File Reference

This file contains API for Accel 21 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  accel21_s
 Accel 21 Click context object. More...
 
struct  accel21_cfg_t
 Accel 21 Click configuration object. More...
 
struct  accel21_axis_t
 Accel 21 Click Axis structure object. More...
 
struct  accel21_config_t
 Accel 21 Click configuration structure object. More...
 

Macros

#define ACCEL21_REG_STATUS_AUX   0x07
 Accel 21 description register.
 
#define ACCEL21_REG_OUT_TEMP_L   0x0C
 
#define ACCEL21_REG_OUT_TEMP_H   0x0D
 
#define ACCEL21_REG_INT_COUNTER   0x0E
 
#define ACCEL21_REG_WHO_AM_I   0x0F
 
#define ACCEL21_REG_TEMP_CFG   0x1F
 
#define ACCEL21_REG_CTRL_REG1   0x20
 
#define ACCEL21_REG_CTRL_REG2   0x21
 
#define ACCEL21_REG_CTRL_REG3   0x22
 
#define ACCEL21_REG_CTRL_REG4   0x23
 
#define ACCEL21_REG_CTRL_REG5   0x24
 
#define ACCEL21_REG_CTRL_REG6   0x25
 
#define ACCEL21_REG_REFERENCE_DATACAPTURE   0x26
 
#define ACCEL21_REG_STATUS   0x27
 
#define ACCEL21_REG_OUT_X_L   0x28
 
#define ACCEL21_REG_OUT_X_H   0x29
 
#define ACCEL21_REG_OUT_Y_L   0x2A
 
#define ACCEL21_REG_OUT_Y_H   0x2B
 
#define ACCEL21_REG_OUT_Z_L   0x2C
 
#define ACCEL21_REG_OUT_Z_H   0x2D
 
#define ACCEL21_REG_FIFO_CTRL   0x2E
 
#define ACCEL21_REG_FIFO_SRC   0x2F
 
#define ACCEL21_REG_INT1_CFG   0x30
 
#define ACCEL21_REG_INT1_SRC   0x31
 
#define ACCEL21_REG_INT1_THS   0x32
 
#define ACCEL21_REG_INT1_DURATION   0x33
 
#define ACCEL21_REG_INT2_CFG   0x34
 
#define ACCEL21_REG_INT2_SRC   0x35
 
#define ACCEL21_REG_INT2_THS   0x36
 
#define ACCEL21_REG_INT2_DURATION   0x37
 
#define ACCEL21_REG_CLICK_CFG   0x38
 
#define ACCEL21_REG_CLICK_SRC   0x39
 
#define ACCEL21_REG_CLICK_THS   0x3A
 
#define ACCEL21_REG_TIME_LIMIT   0x3B
 
#define ACCEL21_REG_TIME_LATENCY   0x3C
 
#define ACCEL21_REG_ACT_THS   0x3E
 
#define ACCEL21_REG_ACT_DUR   0x3F
 
#define ACCEL21_STATUS_AUX_TDA_BIT_MASK   0x04
 Accel 21 description setting.
 
#define ACCEL21_STATUS_AUX_TOR_BIT_MASK   0x40
 
#define ACCEL21_TEMP_CFG_TEMP_EN_BIT_MASK   0xC0
 
#define ACCEL21_WHO_AM_I   0x33
 
#define ACCEL21_OP_MODE_NORMAL   0x00
 
#define ACCEL21_OP_MODE_HIGH_RESOLUTION   0x01
 
#define ACCEL21_OP_MODE_LOW_POWER   0x02
 
#define ACCEL21_OP_MODE_NOT_ALLOWED   0x02
 
#define ACCEL21_CTRL_OP_MODE_BIT_MASK   0x08
 
#define ACCEL21_STATUS_NEW_DATA_AVL_BIT_MASK   0x08
 
#define ACCEL21_STATUS_DATA_OVERRUN_BIT_MASK   0x80
 
#define ACCEL21_CTRL_REG1_ODR_PWR_DOWN_MODE   0x00
 
#define ACCEL21_CTRL_REG1_ODR_1_Hz   0x01
 
#define ACCEL21_CTRL_REG1_ODR_10_Hz   0x02
 
#define ACCEL21_CTRL_REG1_ODR_25_Hz   0x03
 
#define ACCEL21_CTRL_REG1_ODR_50_Hz   0x04
 
#define ACCEL21_CTRL_REG1_ODR_100_Hz   0x05
 
#define ACCEL21_CTRL_REG1_ODR_200_Hz   0x06
 
#define ACCEL21_CTRL_REG1_ODR_400_Hz   0x07
 
#define ACCEL21_CTRL_REG1_ODR_1_62_kHz   0x08
 
#define ACCEL21_CTRL_REG1_ODR_1_344_kHz   0x09
 
#define ACCEL21_CTRL_REG1_ODR_BIT_MASK   0xF0
 
#define ACCEL21_CTRL_REG1_LPEN_DISABLE   0x00
 
#define ACCEL21_CTRL_REG1_LPEN_ENABLE   0x01
 
#define ACCEL21_CTRL_REG1_LPEN_BIT_MASK   0x08
 
#define ACCEL21_CTRL_REG1_XYZEN_DISABLE   0x00
 
#define ACCEL21_CTRL_REG1_XYZEN_ENABLE   0x01
 
#define ACCEL21_CTRL_REG1_ZEN_BIT_MASK   0x04
 
#define ACCEL21_CTRL_REG1_YEN_BIT_MASK   0x02
 
#define ACCEL21_CTRL_REG1_XEN_BIT_MASK   0x01
 
#define ACCEL21_CTRL_REG4_BDU_CONTIN_UPDATE   0x00
 
#define ACCEL21_CTRL_REG4_BDU_NOT_UPDATE   0x01
 
#define ACCEL21_CTRL_REG4_BDU_BIT_MASK   0x80
 
#define ACCEL21_CTRL_REG4_FS_2_g   0x00
 
#define ACCEL21_CTRL_REG4_FS_4_g   0x01
 
#define ACCEL21_CTRL_REG4_FS_10_g   0x02
 
#define ACCEL21_CTRL_REG4_FS_16_g   0x03
 
#define ACCEL21_CTRL_REG4_FS_BIT_MASK   0x30
 
#define ACCEL21_CTRL_REG4_HR_DISABLE   0x00
 
#define ACCEL21_CTRL_REG4_HR_ENABLE   0x01
 
#define ACCEL21_CTRL_REG1_HR_BIT_MASK   0x08
 
#define ACCEL21_DEVICE_ADDRESS_GND   0x18
 Accel 21 device address setting.
 
#define ACCEL21_DEVICE_ADDRESS_VCC   0x19
 
#define ACCEL21_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define ACCEL21_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define ACCEL21_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Typedefs

typedef err_t(* accel21_master_io_t) (struct accel21_s *, uint8_t, uint8_t *, uint8_t)
 Accel 21 Click driver interface.
 
typedef struct accel21_s accel21_t
 Accel 21 Click context object.
 

Enumerations

enum  accel21_drv_t { ACCEL21_DRV_SEL_SPI , ACCEL21_DRV_SEL_I2C }
 Accel 21 Click driver selector. More...
 
enum  accel21_return_value_t { ACCEL21_OK = 0 , ACCEL21_ERROR = -1 }
 Accel 21 Click return value data. More...
 

Functions

void accel21_cfg_setup (accel21_cfg_t *cfg)
 Accel 21 configuration object setup function.
 
void accel21_drv_interface_selection (accel21_cfg_t *cfg, accel21_drv_t drv_sel)
 Accel 21 driver interface setup function.
 
err_t accel21_init (accel21_t *ctx, accel21_cfg_t *cfg)
 Accel 21 initialization function.
 
err_t accel21_default_cfg (accel21_t *ctx)
 Accel 21 default configuration function.
 
err_t accel21_generic_write (accel21_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Accel 21 data writing function.
 
err_t accel21_generic_read (accel21_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Accel 21 data reading function.
 
err_t accel21_get_temp_status (accel21_t *ctx, uint8_t *temp_status)
 Accel 21 get temperature status function.
 
err_t accel21_check_temp_data_ready (accel21_t *ctx, uint8_t *temp_data_ready)
 Accel 21 check temperature data ready function.
 
err_t accel21_enable_temp_data (accel21_t *ctx)
 Accel 21 enable temperature data function.
 
err_t accel21_check_temp_data_ovr (accel21_t *ctx, uint8_t *temp_data_ovr)
 Accel 21 check temperature overrun function.
 
err_t accel21_get_temp_data (accel21_t *ctx, int16_t *temp_data)
 Accel 21 get temperature data function.
 
err_t accel21_get_temperature (accel21_t *ctx, float *temperature)
 Accel 21 get temperature function.
 
err_t accel21_set_op_mode (accel21_t *ctx, uint8_t op_mode)
 Accel 21 set operating mode function.
 
err_t accel21_get_op_mode (accel21_t *ctx, uint8_t *op_mode)
 Accel 21 get operating mode function.
 
err_t accel21_get_device_id (accel21_t *ctx, uint8_t *device_id)
 Accel 21 get device ID function.
 
err_t accel21_check_id (accel21_t *ctx)
 Accel 21 check device ID function.
 
err_t accel21_get_status (accel21_t *ctx, uint8_t *status)
 Accel 21 get status function.
 
err_t accel21_check_data_overrun (accel21_t *ctx, uint8_t *data_overrun)
 Accel 21 check accel overrun function.
 
err_t accel21_check_new_data (accel21_t *ctx, uint8_t *new_data_avl)
 Accel 21 check accel data ready function.
 
err_t accel21_set_config (accel21_t *ctx, accel21_config_t config)
 Accel 21 set config function.
 
err_t accel21_get_axis (accel21_t *ctx, accel21_axis_t *acc_axis)
 Accel 21 get accel data function.
 
uint8_t accel21_get_in1_pin (accel21_t *ctx)
 Accel 21 get interrupt 1 function.
 
uint8_t accel21_get_in2_pin (accel21_t *ctx)
 Accel 21 get interrupt 2 function.
 

Detailed Description

This file contains API for Accel 21 Click Driver.

Typedef Documentation

◆ accel21_master_io_t

typedef err_t(* accel21_master_io_t) (struct accel21_s *, uint8_t, uint8_t *, uint8_t)

Accel 21 Click driver interface.

Definition of driver interface of Accel 21 Click driver. Driver serial interface.

◆ accel21_t

typedef struct accel21_s accel21_t

Accel 21 Click context object.

Context object definition of Accel 21 Click driver.

Enumeration Type Documentation

◆ accel21_drv_t

Accel 21 Click driver selector.

Selects target driver interface of Accel 21 Click driver.

Enumerator
ACCEL21_DRV_SEL_SPI 

SPI driver descriptor.

ACCEL21_DRV_SEL_I2C 

I2C driver descriptor.

◆ accel21_return_value_t

Accel 21 Click return value data.

Predefined enum values for driver return values.

Enumerator
ACCEL21_OK 
ACCEL21_ERROR