Accel 16 Click
Accel 16 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 : Luka Filipovic
- Date : Sep 2021.
- Type : SPI type
Software Support
Example Description
This showcases ability of the Click board to read x, y, and z axes data in different resolution, read IC temperature and also have additional functionality to read ADC data. Device also has ability to store data in internal fifo buffer.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Accel16
Example Key Functions
- accel16_cfg_setup Config Object Initialization function.
void accel16_cfg_setup(accel16_cfg_t *cfg)
Accel 16 configuration object setup function.
Accel 16 Click configuration object.
Definition accel16.h:210
- accel16_init Initialization function.
err_t accel16_init(accel16_t *ctx, accel16_cfg_t *cfg)
Accel 16 initialization function.
Accel 16 Click context object.
Definition accel16.h:190
- accel16_default_cfg Click Default Configuration function.
err_t accel16_default_cfg(accel16_t *ctx)
Accel 16 default configuration function.
- accel16_get_axes Get axes data.
err_t accel16_get_axes(accel16_t *ctx, accel16_axes_t *axes)
Get axes data.
Accel 16 Click axes data.
Definition accel16.h:233
- accel16_filter_configuration Filter configuration.
accel16_gain_t
Accel 16 Click gain.
Definition accel16.h:256
accel16_output_rate_t
Accel 16 Click output data rate.
Definition accel16.h:268
err_t accel16_filter_configuration(accel16_t *ctx, accel16_gain_t gain, accel16_output_rate_t odr)
Filter configuration.
- accel16_get_temperature Get temperature data.
err_t accel16_get_temperature(accel16_t *ctx, float *temperature)
Get temperature data.
Application Init
Initialization of communication modules(SPI, UART) and additional interrupt pins. Reads device ID's and revision. Then configures device to work in FIFO mode or to read data from the registers, sets 2g resolution, 12.5Hz output data rate, sets interrupt 1 active low, powers on device, and calibrates temperature.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( SPI_MASTER_ERROR ==
accel16_init( &accel16, &accel16_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
uint8_t temp_buf[ 4 ] = { 0 };
log_printf( &logger, " > ID0: 0x%.2X\r\n > ID1: 0x%.2X\r\n > ID2: 0x%.2X\r\n > REV: 0x%.2X\r\n",
( uint16_t ) temp_buf[ 0 ], ( uint16_t ) temp_buf[ 1 ],
( uint16_t ) temp_buf[ 2 ], ( uint16_t ) temp_buf[ 3 ] );
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ ACCEL16_ERROR
Definition accel16.h:247
#define ACCEL16_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition accel16.h:174
#define ACCEL16_REG_DEVID_AD
Accel 16 description register.
Definition accel16.h:82
#define ACCEL16_APPLICATION_REG
Definition accel16.h:136
err_t accel16_multiple_reg_read(accel16_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Read multiple registers.
void application_init(void)
Definition main.c:60
Application Task
Depending of the application mode selects example.
- If fifo example is selected waits for the interrupt to indicate that data is ready in fifo buffer and reads number of fifo entries. Data that should be read are X, Y, Z axes and temperature.
- If register example is selected also waits for interrupt to indicate that data is ready to read. Then reads X, Y, Z axes, temperature, and ADC data.
{
{
accel16_read_fifo_data( );
}
{
accel16_read_reg_data( );
}
log_printf( &logger, "********************************************************\r\n" );
Delay_ms ( 300 );
}
#define ACCEL16_APPLICATION_FIFO
Accel 16 description setting.
Definition accel16.h:135
void application_task(void)
Definition main.c:105
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.