All Projects → hepingood → adxl345

hepingood / adxl345

Licence: MIT license
ADXL345 full function driver for general MCU and Linux.

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to adxl345

bmp388
bmp388 full function driver
Stars: ✭ 14 (-91.76%)
Mutual labels:  spi, mcu, iic, full-function-driver
uvis25
uvis25 full function driver
Stars: ✭ 13 (-92.35%)
Mutual labels:  spi, mcu, iic, full-function-driver
sht31
sht31 full function driver
Stars: ✭ 28 (-83.53%)
Mutual labels:  mcu, iic, full-function-driver
at24cxx
at24cxx full function driver
Stars: ✭ 28 (-83.53%)
Mutual labels:  mcu, iic, full-function-driver
fm24clxx
fm24clxx full function driver
Stars: ✭ 0 (-100%)
Mutual labels:  mcu, iic, full-function-driver
bmp180
bmp180 full function driver
Stars: ✭ 57 (-66.47%)
Mutual labels:  mcu, iic, full-function-driver
max7219
MAX7219 full function driver for general MCU and Linux.
Stars: ✭ 86 (-49.41%)
Mutual labels:  spi, mcu, full-function-driver
mlx90614
mlx90614 full function driver
Stars: ✭ 17 (-90%)
Mutual labels:  mcu, iic, full-function-driver
pcf8591
pcf8591 full function driver
Stars: ✭ 32 (-81.18%)
Mutual labels:  mcu, iic, full-function-driver
mcp9600
mcp9600 full function driver
Stars: ✭ 22 (-87.06%)
Mutual labels:  mcu, iic, full-function-driver
max30205
max30205 full function driver
Stars: ✭ 18 (-89.41%)
Mutual labels:  mcu, iic, full-function-driver
ina219
ina219 full function driver
Stars: ✭ 27 (-84.12%)
Mutual labels:  mcu, iic, full-function-driver
sgp30
sgp30 full function driver
Stars: ✭ 24 (-85.88%)
Mutual labels:  mcu, iic, full-function-driver
mcp4725
mcp4725 full function driver
Stars: ✭ 15 (-91.18%)
Mutual labels:  mcu, iic, full-function-driver
ssd1351
ssd1351 full function driver
Stars: ✭ 34 (-80%)
Mutual labels:  spi, mcu, full-function-driver
GY-85
Arduino implementation for GY-85 (ADXL345 accelerometer, ITG3200 gyroscope and HMC5883L magnetometer)
Stars: ✭ 63 (-62.94%)
Mutual labels:  accelerometer, adxl345
hcsr04
hcsr04 full function driver
Stars: ✭ 25 (-85.29%)
Mutual labels:  mcu, full-function-driver
pcf8574
pcf8574 full function driver
Stars: ✭ 106 (-37.65%)
Mutual labels:  mcu, iic
w25qxx
w25qxx full function driver
Stars: ✭ 440 (+158.82%)
Mutual labels:  spi, mcu
IOsonata
IOsonata multi-platform multi-architecture power & performance optimized software library for fast and easy IoT MCU firmware development. Object Oriented design, no board package to define, just pure plug & play any boards
Stars: ✭ 40 (-76.47%)
Mutual labels:  spi, mcu

English | 简体中文 | 繁體中文 | 日本語 | Deutsch | 한국어

LibDriver ADXL345

MISRA API License

The ADXL345 is a small, thin, ultralow power, 3-axis accelerometer launched by Analog Devices. It has high resolution (13-bit) measurement at up to ±16 g. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface.The ADXL345 is well suited for mobile device applications. It measures the static acceleration of gravity in tilt-sensing applications, as well as dynamic acceleration resulting from motion or shock. Its high resolution (3.9 mg/LSB) enables measurement of inclination changes less than 1.0°.Several special sensing functions are provided. Activity and inactivity sensing detect the presence or lack of motion by comparing the acceleration on any axis with user-set thresholds.Tap sensing detects single and double taps in any direction. Freefall sensing detects if the device is falling. These functions can be mapped individually to either of two interrupt output pins.An integrated memory management system with a 32-level first in,first out (FIFO) buffer can be used to store data to minimize host processor activity and lower overall system power consumption.Low power modes enable intelligent motion-based power management with threshold sensing and active acceleration measurement at extremely low power dissipation.

LibDriver ADXL345 is the full function driver of adxl345 launched by LibDriver. It provides acceleration reading, acceleration FIFO mode acquisition, free fall detection, activity /inactivity state detection, tap detection and other functions. LibDriver is MISRA compliant.

Table of Contents

Instruction

/src includes LibDriver ADXL345 source files.

/interface includes LibDriver ADXL345 IIC and SPI platform independent template.

/test includes LibDriver ADXL345 driver test code and this code can test the chip necessary function simply.

/example includes LibDriver ADXL345 sample code.

/doc includes LibDriver ADXL345 offline document.

/datasheet includes ADXL345 datasheet.

/project includes the common Linux and MCU development board sample code. All projects use the shell script to debug the driver and the detail instruction can be found in each project's README.md.

/misra includes the LibDriver MISRA code scanning results.

Install

Reference /interface IIC and SPI platform independent template and finish your platform IIC and SPI driver.

Add /src, /interface and /example to your project.

Usage

example basic

#include "driver_adxl345_basic.h"

uint8_t res;
uint8_t i;
float g[3];

res = adxl345_basic_init(ADXL345_INTERFACE_IIC, ADXL345_ADDRESS_ALT_0);                
if (res != 0)
{
    return 1;
}

...
    
for (i = 0; i < 3; i++)
{
    res = adxl345_basic_read((float *)g);
    if (res != 0)
    {
        (void)adxl345_basic_deinit();
        
        return 1;
    }
    adxl345_interface_debug_print("adxl345: x is %0.3f.\n", g[0]);
    adxl345_interface_debug_print("adxl345: y is %0.3f.\n", g[1]);
    adxl345_interface_debug_print("adxl345: z is %0.3f.\n", g[2]);
    adxl345_interface_delay_ms(1000);
    
    ...
        
}

...
    
(void)adxl345_basic_deinit();

return 0;

example fifo

#include "driver_adxl345_fifo.h"

uint8_t res;
float g[3];

void fifo_callback(float (*g)[3], uint16_t len)
{
    ...
    
    return 0;
}

res = gpio_interrupt_init(adxl345_fifo_irq_handler);
if (res != 0)
{
    return 1;
}
res = adxl345_fifo_init(ADXL345_INTERFACE_IIC, ADXL345_ADDRESS_ALT_0, fifo_callback);
if (res != 0)
{
    (void)gpio_interrupt_deinit();

    return 1;
}

while (1)
{
    adxl345_interface_delay_ms(10);
    
    ...    
}
...
    
(void)gpio_interrupt_deinit();
(void)adxl345_fifo_deinit();

return 0;

example interrupt

#include "driver_adxl345_interrupt.h"

uint8_t res;

void interrupt_callback(uint8_t type)
{
    switch (type)
    {
        case ADXL345_INTERRUPT_DATA_READY :
        {
            ...
                
            break;
        }
        case ADXL345_INTERRUPT_SINGLE_TAP :
        {
            adxl345_interface_debug_print("adxl345: irq single tap.\n");
         
            ...
                
            break;
        }
        case ADXL345_INTERRUPT_DOUBLE_TAP :
        {
            adxl345_interface_debug_print("adxl345: irq double tap.\n");
            
            ...
                
            break;
        }
        case ADXL345_INTERRUPT_ACTIVITY :
        {
            adxl345_interface_debug_print("adxl345: irq activity.\n");
            
            ...
                
            break;
        }
        case ADXL345_INTERRUPT_INACTIVITY :
        {
            adxl345_interface_debug_print("adxl345: irq inactivity.\n");
            
            ...
                
            break;
        }
        case ADXL345_INTERRUPT_FREE_FALL :
        {
            adxl345_interface_debug_print("adxl345: irq free fall.\n");
            
            ...
                
            break;
        }
        case ADXL345_INTERRUPT_OVERRUN :
        {
            ...
                
            break;
        }
        default :
        {
            ...
                
            break;
        }
    }
}

res = gpio_interrupt_init(adxl345_interrupt_irq_handler);
if (res != 0)
{
    return 1;
}
res = adxl345_interrupt_init(ADXL345_INTERFACE_SPI, ADXL345_ADDRESS_ALT_0,
                             interrupt_callback,
                             ADXL345_BOOL_TRUE 
                             ADXL345_BOOL_TRUE,
                             ADXL345_BOOL_TRUE,
                             ADXL345_BOOL_TRUE
                            );
if (res != 0)
{
    (void)gpio_interrupt_deinit();

    return 1;
}

...
    
while (1)
{
    if (adxl345_interrupt_server() != 0)
    {
        return 1;
    }
    adxl345_interface_delay_ms(10);
    
    ...
}

...
    
(void)gpio_interrupt_deinit();
(void)adxl345_interrupt_deinit();

return 0;

Document

Online documents: https://www.libdriver.com/docs/adxl345/index.html.

Offline documents: /doc/html/index.html.

Contributing

Please refer to CONTRIBUTING.md.

License

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all

copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

SOFTWARE.

Contact Us

Please sent an e-mail to [email protected].

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].