TOP Contributors

  1. MIKROE (2779 codes)
  2. Alcides Ramos (376 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139560 times)
  2. FAT32 Library (72041 times)
  3. Network Ethernet Library (57254 times)
  4. USB Device Library (47607 times)
  5. Network WiFi Library (43219 times)
  6. FT800 Library (42551 times)
  7. GSM click (29930 times)
  8. mikroSDK (28292 times)
  9. PID Library (26930 times)
  10. microSD click (26309 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Accel 4 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.18

mikroSDK Library: 2.0.0.0

Category: Motion

Downloaded: 255 times

Not followed.

License: MIT license  

Accel 4 Click is a compact add-on board that contains an acceleration sensor. This board features the FXLS8964AF, a 12-bit three-axis accelerometer from NXP Semiconductors. It allows selectable full-scale acceleration measurements in ranges of �2g, �4g, �8g, or �16g in three axes with a configurable host interface that supports both SPI and I2C serial communication. The FXLS8964AF supports both high-performance and low-power operating modes, allowing maximum flexibility to meet the resolution and power needs for various unique use cases.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Accel 4 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Accel 4 Click" changes.

Do you want to report abuse regarding "Accel 4 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Accel 4 Click

Accel 4 Click is a compact add-on board that contains an acceleration sensor. This board features the FXLS8964AF, a 12-bit three-axis accelerometer from NXP Semiconductors. It allows selectable full-scale acceleration measurements in ranges of �2g, �4g, �8g, or �16g in three axes with a configurable host interface that supports both SPI and I2C serial communication. The FXLS8964AF supports both high-performance and low-power operating modes, allowing maximum flexibility to meet the resolution and power needs for various unique use cases.

accel4_click.png

Click Product page


Click library

  • Author : Luka Filipovic
  • Date : Jul 2021.
  • Type : I2C/SPI type

Software Support

We provide a library for the Accel4 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 Accel4 Click driver.

Standard key functions :

  • accel4_cfg_setup Config Object Initialization function.

    void accel4_cfg_setup ( accel4_cfg_t *cfg );
  • accel4_init Initialization function.

    err_t accel4_init ( accel4_t *ctx, accel4_cfg_t *cfg );
  • accel4_default_cfg Click Default Configuration function.

    err_t accel4_default_cfg ( accel4_t *ctx );

Example key functions :

  • accel4_get_int1 Get interrupt 1 pin state.

    uint8_t accel4_get_int1 ( accel4_t *ctx );
  • accel4_axes_get_resolution Reads current resolution of output data.

    float accel4_axes_get_resolution ( accel4_t *ctx );
  • accel4_get_axes_data Accel data reading.

    err_t accel4_get_axes_data ( accel4_t *ctx, accel4_axes_t *axes );

Example Description

This example is a showcase of the ability of the device to read 3 axis data in varity of 3 resolutions, ability to configure 2 interrput pins for user needs etc..

The demo application is composed of two sections :

Application Init

Initializion of communication modules (I2C/SPI, UART) and additional interrupt pins. Reading status register in loop until power up bit is set to 1. Then reads device ID and checks if it's valid, and in the end configures device to get interrupt on new data received, set device in active mode and sets currently configured resolution to context object.


void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    accel4_cfg_t accel4_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    accel4_cfg_setup( &accel4_cfg );
    ACCEL4_MAP_MIKROBUS( accel4_cfg, MIKROBUS_1 );
    err_t init_flag  = accel4_init( &accel4, &accel4_cfg );
    if ( ( I2C_MASTER_ERROR == init_flag ) || ( SPI_MASTER_ERROR == init_flag ) )
    {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    uint8_t temp_data = 0;

    // Wait for the powerup status
    do {
        accel4_generic_read( &accel4, ACCEL4_REG_INT_STATUS, &temp_data, 1 );
        Delay_ms ( 1 );
    }while ( ( temp_data & 1 ) != 1 );

    //Read device ID
    accel4_generic_read( &accel4, ACCEL4_REG_WHO_AM_I, &temp_data, 1 );
    log_printf( &logger, " > WHO AM I: 0x%.2X\r\n", ( uint16_t )temp_data );
    if ( ACCEL4_DEVICE_ID != temp_data )
    {
        log_error( &logger, " ID" );
        for( ; ; );
    }

    accel4_default_cfg ( &accel4 );

    Delay_ms ( 1000 );
    log_info( &logger, " Application Task " );
}

Application Task

Reads data of all 3 axes whenever interrupt is received and logs it.


void application_task ( void )
{
    if ( accel4_get_int1( &accel4 ) )
    {
        accel4_axes_t axes;
        accel4_get_axes_data( &accel4, &axes );

        log_printf( &logger, " > X: %.2f\r\n", axes.x );
        log_printf( &logger, " > Y: %.2f\r\n", axes.y );
        log_printf( &logger, " > Z: %.2f\r\n", axes.z );
        log_printf( &logger, "*****************************************\r\n" );
        Delay_ms ( 300 );
    }
}

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.Accel4

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.


ALSO FROM THIS AUTHOR

Rotary Switch Click

0

Rotary Switch Click is a compact add-on board for applications requiring precise rotary input. This board is based on the RDS6-16S-1065-1-SMT, a 16-position notched cap surface-mount rotary DIP switch from Same Sky. This switch features continuous 360-degree actuator rotation, a 2.54mm pin pitch, and robust construction with a contact resistance of 80mΩ and a maximum operating torque of 700gf*cm, ensuring reliable operation for up to 10,000 steps. The board supports the innovative Click Snap feature, allowing the rotary switch to operate autonomously when detached, providing flexibility in various implementations.

[Learn More]

Mikromedia 5 for Kinetis Capacitive FPI

0

This project contains example for testing modules on Mikromedia 5 for Kinetis Capacitive FPI.

[Learn More]

Clock Gen 5 Click

0

Clock Gen 5 Click is a compact add-on board that contains a digital programmable oscillator solution. This board features the LTC6903, a low-power self-contained digital frequency source providing a precision frequency from 1kHz to 68MHz set through a 3-wire SPI digital interface from Analog Devices.

[Learn More]