1 /*!
2  * \file      mma8451.h
3  *
4  * \brief     MMA8451 Accelerometer driver implementation
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013-2017 Semtech
16  *
17  * \endcode
18  *
19  * \author    Miguel Luis ( Semtech )
20  *
21  * \author    Gregory Cristian ( Semtech )
22  */
23 #ifndef __MMA8451_H__
24 #define __MMA8451_H__
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 #include <stdint.h>
32 #include "utilities.h"
33 
34 /*
35  * MMA8451 I2C address
36  */
37 #define MMA8451_I2C_ADDRESS                          0x1C
38 
39 /*
40  * MMA8451 Registers
41  */
42 #define MMA8451_STATUS                               0x00 //
43 #define MMA8451_OUT_X_MSB                            0x01 //
44 #define MMA8451_SYSMOD                               0x0B //
45 #define MMA8451_INT_SOURCE                           0x0C //
46 #define MMA8451_ID                                   0x0D //
47 #define MMA8451_PL_STATUS                            0x10 //
48 #define MMA8451_PL_CFG                               0x11 //
49 #define MMA8451_PL_COUNT                             0x12 // Orientation debounce
50 #define MMA8451_PL_BF_ZCOMP                          0x13 //
51 #define MMA8451_PL_THS_REG                           0x14 //
52 #define MMA8451_FF_MT_SRC                            0x16 //
53 #define MMA8451_TRANSIENT_CFG                        0x1D // Transient enable
54 #define MMA8451_TRANSIENT_SRC                        0x1E // Transient read/clear interrupt
55 #define MMA8451_TRANSIENT_THS                        0x1F // Transient threshold
56 #define MMA8451_TRANSIENT_COUNT                      0x20 // Transient debounce
57 #define MMA8451_PULSE_SRC                            0x22 //
58 #define MMA8451_CTRL_REG1                            0x2A //
59 #define MMA8451_CTRL_REG2                            0x2B //
60 #define MMA8451_CTRL_REG3                            0x2C // Interrupt control
61 #define MMA8451_CTRL_REG4                            0x2D // Interrupt enable
62 #define MMA8451_CTRL_REG5                            0x2E // Interrupt pin selection
63 
64 /*!
65  * \brief Initializes the device
66  *
67  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
68  */
69 LmnStatus_t MMA8451Init( void );
70 
71 /*!
72  * \brief Resets the device
73  *
74  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
75  */
76 LmnStatus_t MMA8451Reset( void );
77 
78 /*!
79  * \brief Initializes the orientation detection
80  */
81 void MMA8451OrientDetect( void );
82 
83 /*!
84  * \brief Gets the orientation state.
85  *
86  * \retval orientation Bit 6 [1: Horizontal, 0: Vertical]
87  *                     Bit 0 [1: Face down, 0: Face up]
88  *                     Other bits don't care.
89  */
90 uint8_t MMA8451GetOrientation( void );
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif // __MMA8451_H__
97