Smart DOF 5 Click
Smart DOF 5 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jul 2024.
- Type : I2C/SPI type
Software Support
Example Description
This example demonstrates the use of Smart DOF 5 Click board by reading and displaying the accelerometer and gyroscope data (X, Y, and Z axis) as well as a temperature measurement in degrees Celsius.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.SmartDOF5
Example Key Functions
- smartdof5_cfg_setup Config Object Initialization function.
void smartdof5_cfg_setup(smartdof5_cfg_t *cfg)
Smart DOF 5 configuration object setup function.
Smart DOF 5 Click configuration object.
Definition smartdof5.h:516
- smartdof5_init Initialization function.
err_t smartdof5_init(smartdof5_t *ctx, smartdof5_cfg_t *cfg)
Smart DOF 5 initialization function.
struct smartdof5_s smartdof5_t
Smart DOF 5 Click context object.
- smartdof5_default_cfg Click Default Configuration function.
err_t smartdof5_default_cfg(smartdof5_t *ctx)
Smart DOF 5 default configuration function.
- smartdof5_get_int_pin This function returns the interrupt 1 pin logic state.
uint8_t smartdof5_get_int_pin(smartdof5_t *ctx)
Smart DOF 5 get int pin function.
- smartdof5_get_data This function reads the accelerometer, gyroscope, and temperature measurement data.
err_t smartdof5_get_data(smartdof5_t *ctx, smartdof5_data_t *data_out)
Smart DOF 5 get data function.
Smart DOF 5 Click data structure.
Definition smartdof5.h:553
- smartdof5_set_accel_fsr This function sets the accel measurement full scale range.
err_t smartdof5_set_accel_fsr(smartdof5_t *ctx, uint8_t fsr)
Smart DOF 5 set accel fsr function.
Application Init
Initializes the driver and performs the Click default configuration.
{
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 " );
}
#define SMARTDOF5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition smartdof5.h:458
void application_init(void)
Definition main.c:30
@ SMARTDOF5_ERROR
Definition smartdof5.h:567
Application Task
Waits for a data ready indication and then reads the accelerometer, gyroscope, and temperature measurements. The results are displayed on the USB UART at 12.5 Hz output data rate.
{
{
{
log_printf( &logger,
" Accel X: %.3f g\r\n", meas_data.
accel.
x );
log_printf( &logger,
" Accel Y: %.3f g\r\n", meas_data.
accel.
y );
log_printf( &logger,
" Accel Z: %.3f g\r\n", meas_data.
accel.
z );
log_printf( &logger,
" Gyro X: %.1f dps\r\n", meas_data.
gyro.
x );
log_printf( &logger,
" Gyro Y: %.1f dps\r\n", meas_data.
gyro.
y );
log_printf( &logger,
" Gyro Z: %.1f dps\r\n", meas_data.
gyro.
z );
log_printf( &logger,
" Temperature: %.2f degC\r\n\n", meas_data.
temperature );
}
}
}
void application_task(void)
Definition main.c:67
@ SMARTDOF5_OK
Definition smartdof5.h:566
float y
Definition smartdof5.h:543
float x
Definition smartdof5.h:542
float z
Definition smartdof5.h:544
smartdof5_axes_t accel
Definition smartdof5.h:554
smartdof5_axes_t gyro
Definition smartdof5.h:555
float temperature
Definition smartdof5.h:556
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.