accel20 2.0.0.0
Accel 20 Click Driver

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

Topics

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

Functions

void accel20_cfg_setup (accel20_cfg_t *cfg)
 Accel 20 configuration object setup function.
 
void accel20_drv_interface_selection (accel20_cfg_t *cfg, accel20_drv_t drv_sel)
 Accel 20 driver interface setup function.
 
err_t accel20_init (accel20_t *ctx, accel20_cfg_t *cfg)
 Accel 20 initialization function.
 
err_t accel20_default_cfg (accel20_t *ctx)
 Accel 20 default configuration function.
 
err_t accel20_generic_write (accel20_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Accel 20 data writing function.
 
err_t accel20_generic_read (accel20_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Accel 20 data reading function.
 
err_t accel20_soft_reset (accel20_t *ctx)
 Accel 20 soft reset function.
 
err_t accel20_check_id (accel20_t *ctx)
 Accel 20 check ID function.
 
uint8_t accel20_data_ready (accel20_t *ctx)
 Accel 20 check data ready function.
 
err_t accel20_set_operating_mode (accel20_t *ctx, uint8_t op_mode)
 Accel 20 set operating mode function.
 
err_t accel20_enable_int_1_pin (accel20_t *ctx)
 Accel 20 enable INT 1 pin function.
 
err_t accel20_enable_int_2_pin (accel20_t *ctx)
 Accel 20 enable INT 2 pin function.
 
err_t accel20_set_accel_range (accel20_t *ctx, uint8_t range)
 Accel 20 set accel range function.
 
err_t accel20_set_output_data_rate (accel20_t *ctx, uint8_t odr)
 Accel 20 set output data rate function.
 
err_t accel20_get_axis_data (accel20_t *ctx, accel20_axis_t *axis)
 Accel 20 get accelerometer axis function.
 
err_t accel20_set_trigger (accel20_t *ctx, uint8_t en_trg)
 Accel 20 set trigger function.
 
uint8_t accel20_get_int_1 (accel20_t *ctx)
 Accel 20 get Interrupt 1 function.
 
uint8_t accel20_get_int_2 (accel20_t *ctx)
 Accel 20 get Interrupt 2 function.
 

Detailed Description

API for configuring and manipulating Accel 20 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

◆ accel20_cfg_setup()

void accel20_cfg_setup ( accel20_cfg_t * cfg)

Accel 20 configuration object setup function.

This function initializes click configuration structure to initial values.

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

◆ accel20_check_id()

err_t accel20_check_id ( accel20_t * ctx)

Accel 20 check ID function.

This function check device ID and communication of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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

◆ accel20_data_ready()

uint8_t accel20_data_ready ( accel20_t * ctx)

Accel 20 check data ready function.

This function check data ready interrupt reporte of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

Parameters
[in]ctx: Click context object. See accel20_t object definition for detailed explanation.
Returns
  • 0 - Data is ready,
  • -1 - Data is not ready.
See #err_t definition for detailed explanation.
Note
None.

◆ accel20_default_cfg()

err_t accel20_default_cfg ( accel20_t * ctx)

Accel 20 default configuration function.

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

Parameters
[in]ctx: Click context object. See accel20_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.

◆ accel20_drv_interface_selection()

void accel20_drv_interface_selection ( accel20_cfg_t * cfg,
accel20_drv_t drv_sel )

Accel 20 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 accel20_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See accel20_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.

◆ accel20_enable_int_1_pin()

err_t accel20_enable_int_1_pin ( accel20_t * ctx)

Accel 20 enable INT 1 pin function.

This function enable I1 ( INT ) pin data 2 ready interrupt reported of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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

◆ accel20_enable_int_2_pin()

err_t accel20_enable_int_2_pin ( accel20_t * ctx)

Accel 20 enable INT 2 pin function.

This function enable I2 ( AN ) pin data 2 ready interrupt reported of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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

◆ accel20_generic_read()

err_t accel20_generic_read ( accel20_t * ctx,
uint8_t reg,
uint8_t * data_out,
uint8_t len )

Accel 20 data reading function.

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

Parameters
[in]ctx: Click context object. See accel20_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.

◆ accel20_generic_write()

err_t accel20_generic_write ( accel20_t * ctx,
uint8_t reg,
uint8_t * data_in,
uint8_t len )

Accel 20 data writing function.

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

Parameters
[in]ctx: Click context object. See accel20_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.

◆ accel20_get_axis_data()

err_t accel20_get_axis_data ( accel20_t * ctx,
accel20_axis_t * axis )

Accel 20 get accelerometer axis function.

This function get accelerometer data of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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

◆ accel20_get_int_1()

uint8_t accel20_get_int_1 ( accel20_t * ctx)

Accel 20 get Interrupt 1 function.

This function get states of the Interrupt 1 ( INT pin ) of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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

◆ accel20_get_int_2()

uint8_t accel20_get_int_2 ( accel20_t * ctx)

Accel 20 get Interrupt 2 function.

This function get states of the Interrupt 2 ( AN pin ) of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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

◆ accel20_init()

err_t accel20_init ( accel20_t * ctx,
accel20_cfg_t * cfg )

Accel 20 initialization function.

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

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

◆ accel20_set_accel_range()

err_t accel20_set_accel_range ( accel20_t * ctx,
uint8_t range )

Accel 20 set accel range function.

This function sets accel G-range of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

Parameters
[in]ctx: Click context object. See accel20_t object definition for detailed explanation.
[in]range: Acceleration range:
  • 0x00 ( ACCEL20_CNTL1_RANGE_8g ) - G-range +-8g,
  • 0x01 ( ACCEL20_CNTL1_RANGE_16g ) - G-range +-16g,
  • 0x02 ( ACCEL20_CNTL1_RANGE_32g ) - G-range +-32g,
  • 0x03 ( ACCEL20_CNTL1_RANGE_64g ) - G-range +-64g.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ accel20_set_operating_mode()

err_t accel20_set_operating_mode ( accel20_t * ctx,
uint8_t op_mode )

Accel 20 set operating mode function.

This function sets operating mode of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

Parameters
[in]ctx: Click context object. See accel20_t object definition for detailed explanation.
[in]op_mode: Operating mode:
  • 0x00 ( ACCEL20_CNTL1_OP_MODE_STB ) - Stand-by mode,
  • 0x02 ( ACCEL20_CNTL1_OP_MODE_L_PWR ) - Low Power mode,
  • 0x03 ( ACCEL20_CNTL1_OP_MODE_HP ) - High-Performance mode.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ accel20_set_output_data_rate()

err_t accel20_set_output_data_rate ( accel20_t * ctx,
uint8_t odr )

Accel 20 set output data rate function.

This function sets output data rate of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

Parameters
[in]ctx: Click context object. See accel20_t object definition for detailed explanation.
[in]odr: Acceleration odr:
  • 0x00 ( ACCEL20_ODCNTL_ODR_0_781_Hz ) - 0.781 Hz,
  • 0x01 ( ACCEL20_ODCNTL_ODR_1_563_Hz ) - 1.563 Hz,
  • 0x02 ( ACCEL20_ODCNTL_ODR_3_125_Hz ) - 3.125 Hz,
  • 0x03 ( ACCEL20_ODCNTL_ODR_6_25_Hz ) - 6.25 Hz,
  • 0x04 ( ACCEL20_ODCNTL_ODR_12_5_Hz ) - 12.5 Hz,
  • 0x05 ( ACCEL20_ODCNTL_ODR_25_Hz ) - 25 Hz,
  • 0x06 ( ACCEL20_ODCNTL_ODR_50_Hz ) - 50 Hz,
  • 0x07 ( ACCEL20_ODCNTL_ODR_100_Hz ) - 100 Hz,
  • 0x08 ( ACCEL20_ODCNTL_ODR_200_Hz ) - 200 Hz,
  • 0x09 ( ACCEL20_ODCNTL_ODR_400_Hz ) - 400 Hz,
  • 0x0A ( ACCEL20_ODCNTL_ODR_800_Hz ) - 800 Hz,
  • 0x0B ( ACCEL20_ODCNTL_ODR_1600_Hz ) - 1600 Hz,
  • 0x0C ( ACCEL20_ODCNTL_ODR_3200_Hz ) - 3200 Hz,
  • 0x0D ( ACCEL20_ODCNTL_ODR_6400_Hz ) - 6400 Hz,
  • 0x0E ( ACCEL20_ODCNTL_ODR_12800_Hz ) - 12800 Hz,
  • 0x0F ( ACCEL20_ODCNTL_ODR_25600_Hz ) - 25600 Hz.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ accel20_set_trigger()

err_t accel20_set_trigger ( accel20_t * ctx,
uint8_t en_trg )

Accel 20 set trigger function.

This function set trigger, FIFO buffer control of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

Parameters
[in]ctx: Click context object. See accel20_t object definition for detailed explanation.
[in]en_trg:
  • 0x00 ( ACCEL20_TRIGGER_DISABLE ) - Not using external trigger option,
  • 0x01 ( ACCEL20_TRIGGER_ENABLE ) - Using external trigger option.
Returns
  • 0 - Success,
  • -1 - Error.
See #err_t definition for detailed explanation.
Note
None.

◆ accel20_soft_reset()

err_t accel20_soft_reset ( accel20_t * ctx)

Accel 20 soft reset function.

This function executes a software reset of the KX134 tri-axis ±8g, ±16g, ±32g, ±64g silicon micromachined accelerometer on the Accel 20 Click board™.

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