Air Motion click
Air Motion Click is a compact add-on board that contains a 6-axis inertial measurement unit. This board features TDK InvenSense’s ICM-40627, a 6-axis MEMS MotionTracking™ device that combines a 3-axis user-selectable gyroscope accelerometer.
click Product page
Click library
- Author : Stefan Ilic
- Date : Dec 2022.
- Type : I2C/SPI type
Software Support
We provide a library for the Air Motion Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Air Motion Click driver.
Standard key functions :
airmotion_cfg_setup
Config Object Initialization function.
void airmotion_cfg_setup(airmotion_cfg_t *cfg)
Air Motion configuration object setup function.
Air Motion Click configuration object.
Definition airmotion.h:806
airmotion_init
Initialization function.
err_t airmotion_init(airmotion_t *ctx, airmotion_cfg_t *cfg)
Air Motion initialization function.
Air Motion Click context object.
Definition airmotion.h:783
airmotion_default_cfg
Click Default Configuration function.
err_t airmotion_default_cfg(airmotion_t *ctx)
Air Motion default configuration function.
Example key functions :
airmotion_set_reg_bank
Air Motion set register bank function.
err_t airmotion_set_reg_bank(airmotion_t *ctx, uint8_t bank)
Air Motion set register bank function.
airmotion_sw_reset
Air Motion software reset function.
err_t airmotion_sw_reset(airmotion_t *ctx)
Air Motion software reset function.
airmotion_get_data_from_register
Air Motion read data function.
err_t airmotion_get_data_from_register(airmotion_t *ctx, float *temperature_data, airmotion_data_t *accel_data, airmotion_data_t *gyro_data, uint32_t *tmst_data)
Air Motion read data function.
Definition airmotion.h:828
Example Description
This example demonstrates the use of Air Motion Click board.
The demo application is composed of two sections :
Application Init
Initializes the driver after that resets the device and performs default configuration and reads the device id.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
uint8_t id = 0;
log_printf( &logger, " WHO AM I = 0X%.2X\r\n", (uint16_t)id );
#if defined TAP_DETECTION_MODE
log_printf( &logger, " Tap Detection Mode \r\n" );
#endif
}
@ AIRMOTION_OK
Definition airmotion.h:842
#define AIRMOTION_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition airmotion.h:748
#define AIRMOTION_WHO_AM_I
Definition airmotion.h:137
#define AIRMOTION_BANK0_SEL
Air Motion description setting.
Definition airmotion.h:220
err_t airmotion_set_basic_tap_detection(airmotion_t *ctx)
Air Motion basic tap detection configuration function.
err_t airmotion_reg_read(airmotion_t *ctx, uint8_t reg_bank, uint8_t reg, uint8_t *data_out, uint8_t len)
Air Motion data reading function.
void application_init(void)
Definition main.c:32
Application Task
When the device is in Tap Detection Mode, Air Motion Click board will read and display the direction, axis, and number of taps that it detected. If Tap Detection mode is disabled, the device will read accel, gyro, and temperature data.
{
{
#if defined TAP_DETECTION_MODE
uint8_t tap_num;
uint8_t tap_axis;
uint8_t tap_dir;
{
log_printf( &logger, " SINGLE TAP" );
}
else
{
log_printf( &logger, " DOUBLE TAP" );
}
{
log_printf( &logger, " IN POSITIVE" );
}
else
{
log_printf( &logger, " IN NEGATIVE" );
}
{
log_printf( &logger, " X AXIS DIRECTION \r\n" );
}
{
log_printf( &logger, " Y AXIS DIRECTION \r\n" );
}
else
{
log_printf( &logger, " Z AXIS DIRECTION \r\n" );
}
#else
float temp_data;
uint32_t tmst_data;
log_printf( &logger, " TEMP: %.2f \r\n", temp_data );
log_printf( &logger,
" GYRO: x:%d y:%d z:%d \r\n", gyro_data.
data_x,gyro_data.
data_y,gyro_data.
data_z );
log_printf( &logger,
" ACCEL: x:%d y:%d z:%d \r\n", accel_data.
data_x,accel_data.
data_y,accel_data.
data_z );
log_printf( &logger, "========================== \r\n" );
Delay_ms ( 1000 );
#endif
}
}
#define AIRMOTION_TAP_SINGLE
Definition airmotion.h:257
#define AIRMOTION_TAP_DIR_POSITIVE
Definition airmotion.h:264
#define AIRMOTION_TAP_AXIS_Y
Definition airmotion.h:261
#define AIRMOTION_TAP_AXIS_X
Definition airmotion.h:260
uint8_t airmotion_get_int1_state(airmotion_t *ctx)
Air Motion read INT1 pin state function.
err_t airmotion_get_tap_detection(airmotion_t *ctx, uint8_t *tap_num, uint8_t *tap_axis, uint8_t *tap_dir)
Air Motion get tap detection data function.
void application_task(void)
Definition main.c:79
int16_t data_y
Definition airmotion.h:830
int16_t data_z
Definition airmotion.h:831
int16_t data_x
Definition airmotion.h:829
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.AirMotion
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.