px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_lis3dh.h
1#ifndef __PX_LIS3DH_H__
2#define __PX_LIS3DH_H__
3/* =============================================================================
4 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
5 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
6 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
7 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
8 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
9
10 Copyright (c) 2020 Pieter Conradie <https://piconomix.com>
11
12 License: MIT
13 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
14
15 Title: px_lis3dh.h : ST LIS3DH accelerometer driver
16 Author(s): Pieter Conradie
17 Creation Date: 2020-11-24
18
19============================================================================= */
20
21/**
22 * @ingroup DEVICES_SENSOR
23 * @defgroup PX_LIS3DH px_lis3dh.h : ST LIS3DH accelerometer driver
24 *
25 * File(s):
26 * - devices/sensor/inc/px_lis3dh.h
27 * - devices/sensor/src/px_lis3dh.c
28 *
29 * Reference:
30 * - [ST LIS3DH accelerometer datasheet](https://www.st.com/resource/en/datasheet/lis3dh.pdf)
31 *
32 * This driver initialises the accelerometer with a High Pass Filter enabled
33 * to detect movement. It tries to filter out the static G-force applied by our
34 * little blue green planet and be orientation agnostic.
35 *
36 * @{
37 */
38
39/* _____STANDARD INCLUDES____________________________________________________ */
40
41/* _____PROJECT INCLUDES_____________________________________________________ */
42#include "px_defs.h"
43#include "px_i2c.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48/* _____DEFINITIONS__________________________________________________________ */
49/// I2C Slave address
50#define PX_LIS3DH_I2C_SLA_ADR 0x18
51
52/* _____TYPE DEFINITIONS_____________________________________________________ */
53/// Acelerometer XYZ data
54typedef struct
55{
56 int16_t x;
57 int16_t y;
58 int16_t z;
60
61/* _____GLOBAL VARIABLES_____________________________________________________ */
62
63/* _____GLOBAL FUNCTION DECLARATIONS_________________________________________ */
64bool px_lis3dh_init (px_i2c_handle_t * handle);
65bool px_lis3dh_enable (void);
66bool px_lis3dh_disable (void);
67
68bool px_lis3dh_xyz_data_ready (void);
69bool px_lis3dh_rd_xyz_data (px_lis3dh_xyz_t * xyz);
70bool px_lis3dh_set_int1_threshold(uint8_t threshold);
71bool px_lis3dh_rd_int1_src (uint8_t * data);
72bool px_lis3dh_rd_int2_src (uint8_t * data);
73
74bool px_lis3dh_rd_who_am_i (uint8_t * data);
75bool px_lis3dh_connected (void);
76
77bool px_lis3dh_test_start (void);
78bool px_lis3dh_test_stop (void);
79bool px_lis3dh_test_active (void);
80
81/* _____MACROS_______________________________________________________________ */
82
83#ifdef __cplusplus
84}
85#endif
86
87/// @}
88#endif
Acelerometer XYZ data.
Definition: px_lis3dh.h:55
Define I2C handle for a slave.
Definition: px_i2c.h:104