9DOF 2 click
9DOF 2 Click is a compact add-on board for applications which require lowest power motion tracking and magnetometer functionality.
click Product page
Click library
- Author : MikroE Team
- Date : May 2020.
- Type : SPI type
Software Support
We provide a library for the 9dof2 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.
Library Description
This library contains API for 9dof2 Click driver.
Standard key functions :
- Config Object Initialization function.
void c9dof2_cfg_setup ( c9dof2_cfg_t *cfg );
- Initialization function.
C9DOF2_RETVAL c9dof2_init ( c9dof2_t *ctx, c9dof2_cfg_t *cfg );
- Click Default Configuration function.
void c9dof2_default_cfg ( c9dof2_t *ctx );
Example key functions :
- Turns the device on or off.
void c9dof2_power ( c9dof2_t *ctx, uint8_t on_off );
- Function is used to read gyroscope data.
void c9dof2_read_gyroscope ( c9dof2_t *ctx, int16_t *gyro_x, int16_t *gyro_y, int16_t *gyro_z );
- Function is used to read accelerometer data.
void c9dof2_read_accelerometer ( c9dof2_t *ctx, int16_t *accel_x, int16_t *accel_y, int16_t *accel_z );
Examples Description
This example demonstrates the use of 9DOF 2 Click board.
The demo application is composed of two sections :
Application Init
Initalizes SPI and device drivers, performs safety check, applies default configuration and writes an initial log.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
Delay_ms ( 1000 );
{
log_printf( &logger, "--------------------\r\n" );
log_printf( &logger, " 9DOF 2 click \r\n" );
log_printf( &logger, "--------------------\r\n" );
}
else
{
log_printf( &logger, "--------------------\r\n" );
log_printf( &logger, " FATAL ERROR!!! \r\n" );
log_printf( &logger, "--------------------\r\n" );
for ( ; ; );
}
log_printf( &logger, "--- Initialised ---\r\n" );
log_printf( &logger, "--------------------\r\n" );
Delay_ms ( 1000 );
}
#define C9DOF2_MAP_MIKROBUS(cfg, mikrobus)
Definition c9dof2.h:68
#define C9DOF2_POWER_ON
Definition c9dof2.h:603
C9DOF2_RETVAL c9dof2_init(c9dof2_t *ctx, c9dof2_cfg_t *cfg)
Initialization function.
void c9dof2_def_settings(c9dof2_t *ctx)
Default settings function.
void c9dof2_cfg_setup(c9dof2_cfg_t *cfg)
Config Object Initialization function.
void c9dof2_dev_rst(c9dof2_t *ctx)
Device Reset function.
void c9dof2_power(c9dof2_t *ctx, uint8_t on_off)
Power up function.
uint8_t c9dof2_read_byte(c9dof2_t *ctx, uint8_t reg)
Read Byte function.
#define C9DOF2_WHO_AM_I_ICM20948
Definition c9dof2.h:109
#define C9DOF2_WHO_AM_I_ICM20948_VAL
Definition c9dof2.h:582
void application_init(void)
Definition main.c:42
uint8_t id_val
Definition main.c:32
Click configuration structure definition.
Definition c9dof2.h:654
Application Task
Reads the angular and acceleration rates and displays the values of X, Y, and Z axis on the USB UART each second.
{
log_printf( &logger, "Angular rate: \r\n" );
log_printf( &logger,
"X-axis: %.2f \r\n",
x_gyro );
log_printf( &logger,
"Y-axis: %.2f \r\n",
y_gyro );
log_printf( &logger,
"Z-axis: %.2f \r\n",
z_gyro );
log_printf( &logger, "---------------------\r\n" );
log_printf( &logger, "Acceleration rate: \r\n" );
log_printf( &logger,
"X-axis: %.2f \r\n",
x_accel );
log_printf( &logger,
"Y-axis: %.2f \r\n",
y_accel );
log_printf( &logger,
"Z-axis: %.2f \r\n",
z_accel );
log_printf( &logger, "---------------------\r\n" );
Delay_ms ( 1000 );
}
void c9dof2_angular_rate(c9dof2_t *ctx, float *x_ang_rte, float *y_ang_rte, float *z_ang_rte)
Read Angular Rate function.
void c9dof2_acceleration_rate(c9dof2_t *ctx, float *x_accel_rte, float *y_accel_rte, float *z_accel_rte)
Read acceleration Rate function.
float y_accel
Definition main.c:34
float x_accel
Definition main.c:33
float z_gyro
Definition main.c:38
void application_task(void)
Definition main.c:94
float x_gyro
Definition main.c:36
float z_accel
Definition main.c:35
float y_gyro
Definition main.c:37
The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.
Other mikroE Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.9dof2
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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.