accel21 2.1.0.0
Accel 21 Click Driver

API for configuring and manipulating Accel 21 Click driver. More...

Topics

 Accel 21 Registers List
 List of registers of Accel 21 Click driver.
 
 Accel 21 Registers Settings
 Settings for registers of Accel 21 Click driver.
 
 Accel 21 MikroBUS Map
 MikroBUS pin mapping of Accel 21 Click driver.
 

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

API for configuring and manipulating Accel 21 Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ accel21_cfg_setup()

void accel21_cfg_setup ( accel21_cfg_t * cfg)

Accel 21 configuration object setup function.

This function initializes click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See accel21_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ accel21_check_data_overrun()

err_t accel21_check_data_overrun ( accel21_t * ctx,
uint8_t * data_overrun )

Accel 21 check accel overrun function.

This function check if new accel data has overwritten the previous data of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]data_overrun: X-, Y- and Z-axis data overrun.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_check_id()

err_t accel21_check_id ( accel21_t * ctx)

Accel 21 check device ID function.

This function checking the device ID of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
Returns
  • 0 - OK,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_check_new_data()

err_t accel21_check_new_data ( accel21_t * ctx,
uint8_t * new_data_avl )

Accel 21 check accel data ready function.

This function check if accel data ready of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[out]new_data_avl: Temperature new data available:
  • 0 - a new set of data is not yet available,
  • 1 - a new set of data is available.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_check_temp_data_ovr()

err_t accel21_check_temp_data_ovr ( accel21_t * ctx,
uint8_t * temp_data_ovr )

Accel 21 check temperature overrun function.

This function check if new temperature data has overwritten the previous data of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]temp_data_ovr: Temperature new data available:
  • 0 - no overrun has occurred,
  • 1 - new temperature data has overwritten the previous data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_check_temp_data_ready()

err_t accel21_check_temp_data_ready ( accel21_t * ctx,
uint8_t * temp_data_ready )

Accel 21 check temperature data ready function.

This function check if temperature data ready of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[out]temp_data_ready: Temperature new data available:
  • 0 - new temperature data is not yet available,
  • 1 - new temperature data is available.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_default_cfg()

err_t accel21_default_cfg ( accel21_t * ctx)

Accel 21 default configuration function.

This function executes a default configuration of Accel 21 click board.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function can consist any necessary configuration or setting to put device into operating mode.

◆ accel21_drv_interface_selection()

void accel21_drv_interface_selection ( accel21_cfg_t * cfg,
accel21_drv_t drv_sel )

Accel 21 driver interface setup function.

This function sets a serial driver interface which will be used further in the click driver.

Parameters
[out]cfg: Click configuration structure. See accel21_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See accel21_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be call before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ accel21_enable_temp_data()

err_t accel21_enable_temp_data ( accel21_t * ctx)

Accel 21 enable temperature data function.

This function enables the temperature sensor of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_generic_read()

err_t accel21_generic_read ( accel21_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Accel 21 data reading function.

This function reads a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[in]reg: Start register address.
[out]data_out: Output read data.
[in]len: Number of bytes to be read.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_generic_write()

err_t accel21_generic_write ( accel21_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Accel 21 data writing function.

This function writes a desired number of data bytes starting from the selected register.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[in]reg: Start register address.
[in]data_in: Data to be written.
[in]len: Number of bytes to be written.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_axis()

err_t accel21_get_axis ( accel21_t * ctx,
accel21_axis_t * acc_axis )

Accel 21 get accel data function.

This function reads accel data for all three axis of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[out]acc_axis: Accel axis output.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_device_id()

err_t accel21_get_device_id ( accel21_t * ctx,
uint8_t * device_id )

Accel 21 get device ID function.

This function reads the device ID of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]device_id: Device ID.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_in1_pin()

uint8_t accel21_get_in1_pin ( accel21_t * ctx)

Accel 21 get interrupt 1 function.

This function get states of the Interrupt 1 ( PWM pin ) of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
Returns
  • 0 - Low pin state,
  • -1 - High pin state. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_in2_pin()

uint8_t accel21_get_in2_pin ( accel21_t * ctx)

Accel 21 get interrupt 2 function.

This function get states of the Interrupt 2 ( INT pin ) of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
Returns
  • 0 - Low pin state,
  • -1 - High pin state. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_op_mode()

err_t accel21_get_op_mode ( accel21_t * ctx,
uint8_t * op_mode )

Accel 21 get operating mode function.

This function reads the operating mode of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]op_mode: Operating mode:
  • 0 - normal,
  • 1 - highresolution mode,
  • 2 - low-power.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_status()

err_t accel21_get_status ( accel21_t * ctx,
uint8_t * status )

Accel 21 get status function.

This function reads the status data of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]status: Status data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_temp_data()

err_t accel21_get_temp_data ( accel21_t * ctx,
int16_t * temp_data )

Accel 21 get temperature data function.

This function reads the raw temperature data of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]temp_data: Temperature sensor data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Temperature data can be enabled by setting the TEMP_EN[1:0] bits to ‘1’ in the ACCEL21_REG_TEMP_CFG (1Fh) register. To retrieve the temperature sensor data the BDU bit in CTRL_REG4 (23h) must be set to ‘1’. Both the OUT_TEMP_L (0Ch), OUT_TEMP_H (0Dh) registers must be read.

◆ accel21_get_temp_status()

err_t accel21_get_temp_status ( accel21_t * ctx,
uint8_t * temp_status )

Accel 21 get temperature status function.

This function reads a temperature status of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[out]temp_status: Output temperature status data.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_get_temperature()

err_t accel21_get_temperature ( accel21_t * ctx,
float * temperature )

Accel 21 get temperature function.

This function reads the raw temperature data and converts it to Celsius of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[out]temperature: Temperature in Celsius.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
Temperature data can be enabled by setting the TEMP_EN[1:0] bits to ‘1’ in the ACCEL21_REG_TEMP_CFG (1Fh) register. To retrieve the temperature sensor data the BDU bit in CTRL_REG4 (23h) must be set to ‘1’. Both the OUT_TEMP_L (0Ch), OUT_TEMP_H (0Dh) registers must be read.

◆ accel21_init()

err_t accel21_init ( accel21_t * ctx,
accel21_cfg_t * cfg )

Accel 21 initialization function.

This function initializes all necessary pins and peripherals used for this click board.

Parameters
[out]ctx: Click context object. See accel21_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See accel21_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_set_config()

err_t accel21_set_config ( accel21_t * ctx,
accel21_config_t config )

Accel 21 set config function.

This function set sensor configuration of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object. See accel21_t object definition for detailed explanation.
[out]config: Configuration structure object.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ accel21_set_op_mode()

err_t accel21_set_op_mode ( accel21_t * ctx,
uint8_t op_mode )

Accel 21 set operating mode function.

This function set the desired operating mode of the the MEMS digital output motion sensor ultra-low-power high-performance 3-axis accelerometer on the Accel 21 Click board™.

Parameters
[in]ctx: Click context object.
[in]op_mode: Operating mode:
  • 0 - normal,
  • 1 - highresolution mode,
  • 2 - low-power.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.