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 uint8_t SX9500Init( void ); 61 62 /*! 63 * \brief Resets the device 64 * 65 * \retval status [OK, ERROR, UNSUPPORTED] 66 */ 67 uint8_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 * \retval status [OK, ERROR, UNSUPPORTED] 75 */ 76 uint8_t SX9500Write( uint8_t addr, uint8_t data ); 77 78 /*! 79 * \brief Writes a buffer at specified address in the device 80 * 81 * \param [IN]: addr 82 * \param [IN]: data 83 * \param [IN]: size 84 * \retval status [OK, ERROR, UNSUPPORTED] 85 */ 86 uint8_t SX9500WriteBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 87 88 /*! 89 * \brief Reads a byte at specified address in the device 90 * 91 * \param [IN]: addr 92 * \param [OUT]: data 93 * \retval status [OK, ERROR, UNSUPPORTED] 94 */ 95 uint8_t SX9500Read( uint8_t addr, uint8_t *data ); 96 97 /*! 98 * \brief Reads a buffer at specified address in the device 99 * 100 * \param [IN]: addr 101 * \param [OUT]: data 102 * \param [IN]: size 103 * \retval status [OK, ERROR, UNSUPPORTED] 104 */ 105 uint8_t SX9500ReadBuffer( uint8_t addr, uint8_t *data, uint8_t size ); 106 107 /*! 108 * \brief Sets the I2C device slave address 109 * 110 * \param [IN]: addr 111 */ 112 void SX9500SetDeviceAddr( uint8_t addr ); 113 114 /*! 115 * \brief Gets the I2C device slave address 116 * 117 * \retval: addr Current device slave address 118 */ 119 uint8_t SX9500GetDeviceAddr( void ); 120 121 /*! 122 * \brief Goes into a loop until a successful capacitive proximity detection 123 */ 124 void SX9500LockUntilDetection( void ); 125 126 #ifdef __cplusplus 127 } 128 #endif 129 130 #endif // __SX1509_H__ 131