accel19 2.2.0
Loading...
Searching...
No Matches
accel19


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

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.

void application_init ( void )
{
log_cfg_t log_cfg;
accel19_cfg_t accel19_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
accel19_cfg_setup( &accel19_cfg );
ACCEL19_MAP_MIKROBUS( accel19_cfg, MIKROBUS_1 );
err_t init_flag = accel19_init( &accel19, &accel19_cfg );
if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
Delay_ms ( 1000 );
if ( ACCEL19_ERROR == accel19_default_cfg ( &accel19 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
if ( ACCEL19_ERROR == accel19_check_device_id( &accel19 ) )
{
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.

void application_task ( void )
{
static accel19_axis_t axis;
{
accel19_get_axis_data( &accel19, &axis );
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.