gyro8  2.1.0.0
Main Page

Gyro 8 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Nov 2022.
  • Type : SPI type

Software Support

We provide a library for the Gyro 8 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 Gyro 8 Click driver.

Standard key functions :

Example key functions :

  • gyro8_read_serial_id This function reads the serial ID which is laser marked on the sensor lid.
    err_t gyro8_read_serial_id ( gyro8_t *ctx, uint32_t *serial_id );
  • gyro8_read_temperature This function reads the temperature measurement in Celsius.
    err_t gyro8_read_temperature ( gyro8_t *ctx, float *temperature );
  • gyro8_read_angular_rate This function reads the angular rate of X-axis in dps.
    err_t gyro8_read_angular_rate ( gyro8_t *ctx, float *rate );

Example Description

This example demonstrates the use of Gyro 8 click board by reading and displaying the temperature and angular rate measurements.

The demo application is composed of two sections :

Application Init

Initializes the driver and the click board, and reads the serial ID number which is marked on the sensor lid.

void application_init ( void )
{
log_cfg_t log_cfg;
gyro8_cfg_t gyro8_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
gyro8_cfg_setup( &gyro8_cfg );
GYRO8_MAP_MIKROBUS( gyro8_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == gyro8_init( &gyro8, &gyro8_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( GYRO8_ERROR == gyro8_default_cfg ( &gyro8 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
uint32_t serial_id;
if ( GYRO8_OK == gyro8_read_serial_id ( &gyro8, &serial_id ) )
{
log_printf ( &logger, " Serial ID: %lu\r\n", serial_id );
}
log_info( &logger, " Application Task " );
}

Application Task

Reads the temperature and angular rate measurements every 100ms and displays the results on the USB UART.

void application_task ( void )
{
float temperature, angular_rate;
if ( GYRO8_OK == gyro8_read_temperature ( &gyro8, &temperature ) )
{
log_printf ( &logger, " Temperature: %.2f degC\r\n", temperature );
}
if ( GYRO8_OK == gyro8_read_angular_rate ( &gyro8, &angular_rate ) )
{
log_printf ( &logger, " Angular rate: %.2f dps\r\n\n", angular_rate );
}
Delay_ms ( 100 );
}

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.Gyro8

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.


gyro8_cfg_setup
void gyro8_cfg_setup(gyro8_cfg_t *cfg)
Gyro 8 configuration object setup function.
gyro8_read_serial_id
err_t gyro8_read_serial_id(gyro8_t *ctx, uint32_t *serial_id)
Gyro 8 read serial id function.
gyro8_read_temperature
err_t gyro8_read_temperature(gyro8_t *ctx, float *temperature)
Gyro 8 read temperature function.
gyro8_init
err_t gyro8_init(gyro8_t *ctx, gyro8_cfg_t *cfg)
Gyro 8 initialization function.
application_task
void application_task(void)
Definition: main.c:72
GYRO8_OK
@ GYRO8_OK
Definition: gyro8.h:180
gyro8_t
Gyro 8 Click context object.
Definition: gyro8.h:141
GYRO8_ERROR
@ GYRO8_ERROR
Definition: gyro8.h:181
gyro8_default_cfg
err_t gyro8_default_cfg(gyro8_t *ctx)
Gyro 8 default configuration function.
application_init
void application_init(void)
Definition: main.c:30
GYRO8_MAP_MIKROBUS
#define GYRO8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: gyro8.h:126
gyro8_read_angular_rate
err_t gyro8_read_angular_rate(gyro8_t *ctx, float *rate)
Gyro 8 read angular rate function.
gyro8_cfg_t
Gyro 8 Click configuration object.
Definition: gyro8.h:157