Accel 19 Click
Accel 19 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 : Nenad Filipovic
- Date : Nov 2021.
- Type : I2C/SPI type
Software Support
Example Description
This library contains API for Accel 19 Click driver. The library initializes and defines the I2C or SPI bus drivers to write and read data from registers. The library also includes a function for reading X-axis, Y-axis, and Z-axis data.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Accel19
Example Key Functions
- accel19_cfg_setup Config Object Initialization function.
void accel19_cfg_setup(accel19_cfg_t *cfg)
Accel 19 configuration object setup function.
Accel 19 Click configuration object.
Definition accel19.h:289
- accel19_init Initialization function.
struct accel19_s accel19_t
Accel 19 Click context object.
err_t accel19_init(accel19_t *ctx, accel19_cfg_t *cfg)
Accel 19 initialization function.
- accel19_default_cfg Click Default Configuration function.
err_t accel19_default_cfg(accel19_t *ctx)
Accel 19 default configuration function.
- accel19_get_axis_data Accel 19 get accelerometer axis function.
err_t accel19_get_axis_data(accel19_t *ctx, accel19_axis_t *axis)
Accel 19 get accelerometer axis function.
Accel 19 axis data structure.
Definition accel19.h:316
- accel19_data_ready Accel 19 data ready function.
uint8_t accel19_data_ready(accel19_t *ctx)
Accel 19 data ready function.
- accel19_set_control Accel 19 set control function.
err_t accel19_set_control(accel19_t *ctx, uint8_t odr, uint8_t op_mode, uint8_t lp_mode)
Accel 19 set control function.
Application Init
The initialization of I2C or SPI module, log UART, and additional pins. After the driver init, the app executes a default configuration and checks communication and device ID.
{
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 ( ; ; );
}
Delay_ms ( 1000 );
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
{
log_printf( &logger, " Communication ERROR \r\n" );
log_printf( &logger, " Reset the device \r\n" );
log_printf( &logger, "-------------------------\r\n" );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, "-------------------------\r\n" );
Delay_ms ( 1000 );
}
@ ACCEL19_ERROR
Definition accel19.h:330
#define ACCEL19_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition accel19.h:233
err_t accel19_check_device_id(accel19_t *ctx)
Accel 19 check device ID function.
void application_init(void)
Definition main.c:35
Application Task
This is an example that demonstrates the use of the Accel 19 Click board™. Measures and displays acceleration data for X-axis, Y-axis, and Z-axis. Results are being sent to the USART terminal where the user can track their changes. This task repeats every 1 sec.
{
{
log_printf( &logger,
"\tX : %5d \r\n\tY : %5d \r\n\tZ : %5d \r\n", axis.
x, axis.
y, axis.
z );
log_printf( &logger, "-------------------------\r\n" );
Delay_ms ( 1000 );
}
Delay_ms ( 1 );
}
#define ACCEL19_STATUS_DRDY
Definition accel19.h:176
void application_task(void)
Definition main.c:84
int16_t z
Definition accel19.h:319
int16_t x
Definition accel19.h:317
int16_t y
Definition accel19.h:318
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.