1 /*!
2  * \file      sx9500.h
3  *
4  * \brief     SX9500 proximity sensor 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 __SX9500_H__
24 #define __SX9500_H__
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 #include <stdint.h>
32 
33 #define SX9500_I2C_ADDRESS                          0x28
34 
35 #define SX9500_REG_IRQSRC                           0x00
36 #define SX9500_REG_STAT                             0x01
37 #define SX9500_REG_IRQMSK                           0x03
38 #define SX9500_REG_PROXCTRL0                        0x06
39 #define SX9500_REG_PROXCTRL1                        0x07
40 #define SX9500_REG_PROXCTRL2                        0x08
41 #define SX9500_REG_PROXCTRL3                        0x09
42 #define SX9500_REG_PROXCTRL4                        0x0A
43 #define SX9500_REG_PROXCTRL5                        0x0B
44 #define SX9500_REG_PROXCTRL6                        0x0C
45 #define SX9500_REG_PROXCTRL7                        0x0D
46 #define SX9500_REG_PROXCTRL8                        0x0E
47 #define SX9500_REG_SENSORSEL                        0x20
48 #define SX9500_REG_USEMSB                           0x21
49 #define SX9500_REG_USELSB                           0x22
50 #define SX9500_REG_AVGMSB                           0x23
51 #define SX9500_REG_AVGLSB                           0x24
52 #define SX9500_REG_DIFFMSB                          0x25
53 #define SX9500_REG_DIFFLSB                          0x26
54 #define SX9500_REG_OFFSETMSB                        0x27
55 #define SX9500_REG_OFFSETLSB                        0x28
56 #define SX9500_REG_RESET                            0x7F
57 
58 #define SX9500_RESET_CMD                            0xDE
59 
60 LmnStatus_t SX9500Init( void );
61 
62 /*!
63  * \brief Resets the device
64  *
65  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
66  */
67 LmnStatus_t SX9500Reset( void );
68 
69 /*!
70  * \brief Writes a byte at specified address in the device
71  *
72  * \param [IN]: addr
73  * \param [IN]: data
74  *
75  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
76  */
77 LmnStatus_t SX9500Write( uint8_t addr, uint8_t data );
78 
79 /*!
80  * \brief Writes a buffer at specified address in the device
81  *
82  * \param [IN]: addr
83  * \param [IN]: data
84  * \param [IN]: size
85  *
86  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
87  */
88 LmnStatus_t SX9500WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size );
89 
90 /*!
91  * \brief Reads a byte at specified address in the device
92  *
93  * \param [IN]: addr
94  * \param [OUT]: data
95  *
96  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
97  */
98 LmnStatus_t SX9500Read( uint8_t addr, uint8_t *data );
99 
100 /*!
101  * \brief Reads a buffer at specified address in the device
102  *
103  * \param [IN]: addr
104  * \param [OUT]: data
105  * \param [IN]: size
106  *
107  * \retval status [LMN_STATUS_OK, LMN_STATUS_ERROR]
108  */
109 LmnStatus_t SX9500ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size );
110 
111 /*!
112  * \brief Sets the I2C device slave address
113  *
114  * \param [IN]: addr
115  */
116 void SX9500SetDeviceAddr( uint8_t addr );
117 
118 /*!
119  * \brief Gets the I2C device slave address
120  *
121  * \retval: addr Current device slave address
122  */
123 uint8_t SX9500GetDeviceAddr( void );
124 
125 /*!
126  * \brief Goes into a loop until a successful capacitive proximity detection
127  */
128 void SX9500LockUntilDetection( void );
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif // __SX1509_H__
135