Compass 6 click
Compass 6 Click is a compact add-on board perfect for implementation in applications such as an electronic compass. This board features the HSCDTD008A, a high-sensitivity geomagnetic sensor from ALPS Alpine.
click Product page
Click library
- Author : Luka Filipovic
- Date : Aug 2021.
- Type : I2C type
Software Support
We provide a library for the Compass6 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 Compass6 Click driver.
Standard key functions :
compass6_cfg_setup
Config Object Initialization function.
void compass6_cfg_setup(compass6_cfg_t *cfg)
Compass 6 configuration object setup function.
Compass 6 Click configuration object.
Definition compass6.h:172
compass6_init
Initialization function.
err_t compass6_init(compass6_t *ctx, compass6_cfg_t *cfg)
Compass 6 initialization function.
Compass 6 Click context object.
Definition compass6.h:155
compass6_default_cfg
Click Default Configuration function.
err_t compass6_default_cfg(compass6_t *ctx)
Compass 6 default configuration function.
Example key functions :
compass6_get_axes_data
Magnetic axes data reading.
err_t compass6_get_axes_data(compass6_t *ctx, compass6_axes_t *axes_data)
Magnetic axes data reading.
Compass 6 Click axes data.
Definition compass6.h:199
compass6_data_ready
Get data ready pin state.
uint8_t compass6_data_ready(compass6_t *ctx)
Get data ready pin state.
compass6_generic_read
Reading function.
err_t compass6_generic_read(compass6_t *ctx, uint8_t reg, uint8_t *rx_data)
Compass 6 I2C reading function.
Example Description
This example is a showcase the ability of the device
to read 3 axis data of magnetic raw value when data is ready.
The demo application is composed of two sections :
Application Init
Initialization of communication modules (I2C, UART) and data
ready pin as input. Then reads identification data and checks if some of them have wrong value, and configures device for reading.
{
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 )
{
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
uint8_t temp_data = 0;
log_printf( &logger, " > Who am I: 0x%.2X\r\n", ( uint16_t )temp_data );
{
log_error( &logger, " Who am I. " );
}
log_printf( &logger, " > Version: 0x%.2X\r\n", ( uint16_t )temp_data );
{
log_error( &logger, " Version. " );
}
log_printf( &logger, " > ALPS: 0x%.2X\r\n", ( uint16_t )temp_data );
{
log_error( &logger, " ALPS. " );
}
log_info( &logger, " Application Task " );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
#define COMPASS6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition compass6.h:142
#define COMPASS6_REG_WHO_I_AM
Definition compass6.h:76
#define COMPASS6_REG_INFO_VERSION
Definition compass6.h:74
#define COMPASS6_REG_INFO_ALPS
Definition compass6.h:75
#define COMPASS6_VERSION
Definition compass6.h:116
#define COMPASS6_ALPS
Definition compass6.h:117
#define COMPASS6_WHO_AM_I
Compass 6 identification value.
Definition compass6.h:115
void application_init(void)
Definition main.c:31
Application Task
Checks Data ready pin and if asserted high it will read data of all
3 axes(x, y, z) and log data to Terminal.
{
{
log_printf( &logger,
" > X: %d\r\n", axes_data.
x );
log_printf( &logger,
" > Y: %d\r\n", axes_data.
y );
log_printf( &logger,
" > Z: %d\r\n", axes_data.
z );
log_printf( &logger, "*********************\r\n" );
}
}
void application_task(void)
Definition main.c:90
int16_t z
Definition compass6.h:202
int16_t x
Definition compass6.h:200
int16_t y
Definition compass6.h:201
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.Compass6
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.