c9dof2  2.0.0.0
Main Page

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.

void application_init ( void )
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
C9DOF2_MAP_MIKROBUS( cfg, MIKROBUS_1 );
c9dof2_init( &c9dof2, &cfg );
c9dof2_dev_rst( &c9dof2 );
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 ( ; ; );
}
c9dof2_def_settings( &c9dof2 );
log_printf( &logger, "--- Initialised ---\r\n" );
log_printf( &logger, "--------------------\r\n" );
Delay_ms ( 1000 );
}

Application Task

Reads the angular and acceleration rates and displays the values of X, Y, and Z axis on the USB UART each second.

void application_task ( void )
{
// Task implementation.
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 );
}

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.


c9dof2_cfg_t
Click configuration structure definition.
Definition: c9dof2.h:654
c9dof2_cfg_setup
void c9dof2_cfg_setup(c9dof2_cfg_t *cfg)
Config Object Initialization function.
c9dof2_read_byte
uint8_t c9dof2_read_byte(c9dof2_t *ctx, uint8_t reg)
Read Byte function.
application_task
void application_task(void)
Definition: main.c:94
C9DOF2_MAP_MIKROBUS
#define C9DOF2_MAP_MIKROBUS(cfg, mikrobus)
Definition: c9dof2.h:68
c9dof2_acceleration_rate
void c9dof2_acceleration_rate(c9dof2_t *ctx, float *x_accel_rte, float *y_accel_rte, float *z_accel_rte)
Read acceleration Rate function.
c9dof2_power
void c9dof2_power(c9dof2_t *ctx, uint8_t on_off)
Power up function.
c9dof2_init
C9DOF2_RETVAL c9dof2_init(c9dof2_t *ctx, c9dof2_cfg_t *cfg)
Initialization function.
y_gyro
float y_gyro
Definition: main.c:37
x_gyro
float x_gyro
Definition: main.c:36
id_val
uint8_t id_val
Definition: main.c:32
c9dof2_dev_rst
void c9dof2_dev_rst(c9dof2_t *ctx)
Device Reset function.
z_gyro
float z_gyro
Definition: main.c:38
y_accel
float y_accel
Definition: main.c:34
z_accel
float z_accel
Definition: main.c:35
x_accel
float x_accel
Definition: main.c:33
C9DOF2_WHO_AM_I_ICM20948_VAL
#define C9DOF2_WHO_AM_I_ICM20948_VAL
Definition: c9dof2.h:582
c9dof2_def_settings
void c9dof2_def_settings(c9dof2_t *ctx)
Default settings function.
application_init
void application_init(void)
Definition: main.c:42
C9DOF2_WHO_AM_I_ICM20948
#define C9DOF2_WHO_AM_I_ICM20948
Definition: c9dof2.h:109
c9dof2_angular_rate
void c9dof2_angular_rate(c9dof2_t *ctx, float *x_ang_rte, float *y_ang_rte, float *z_ang_rte)
Read Angular Rate function.
C9DOF2_POWER_ON
#define C9DOF2_POWER_ON
Definition: c9dof2.h:603