#ifndef __HAL_SC7A20_H__
#define __HAL_SC7A20_H__

#include "stdint.h"

typedef uint8_t uint8;
typedef uint8 Std_ReturnType;
typedef uint16_t uint16;
typedef int16_t sint16;

//#define E_NOT_OK    0x01
//#define E_OK        0x00
//#define NULL ((void *)0)




void Sensor_Read_Byte(uint8_t RAddr, uint8_t *RData);
void Sensor_Write_Byte(uint8_t RAddr, uint8_t *WData);

void SC7A20_Init(void);
uint8_t SC7A20_GetInfo(int16_t *SL_SC7A20_Data_XYZ_Buf);

void iic_init(void);


//Sensor RW Address
#define  Sensor_Wr_Addr1	0x30//8λI2Cַ֘+һλд
#define  Sensor_Rd_Addr1	0x31//8λI2Cַ֘+һλׁ
#define  CHIP_ID					0x11
#define  E_OK							0X01
#define  E_ERR						0X00


#define SC7A20_CHIP_ID_ADDRESS    						 (0x0F)
#define SC7A20_CHIP_ID_VALUE      						 (0x11)

#define  SL_SC7A20_CTRL_REG1      						 (0x20)
#define  SL_SC7A20_CTRL_REG2     						   (0x21)
#define  SL_SC7A20_CTRL_REG3     						 	 (0x22)
#define  SL_SC7A20_CTRL_REG4      						 (0x23) 
#define  SL_SC7A20_CTRL_REG5      						 (0x24)
#define  SL_SC7A20_CTRL_REG6     						 	 (0x25)

#define  SL_SC7A20_STATUS_REG     						 (0x27)

#define  SL_SC7A20_OUT_X_L        						 (0x28)
#define  SL_SC7A20_OUT_X_H        						 (0x29)
#define  SL_SC7A20_OUT_Y_L       							 (0x2A)
#define  SL_SC7A20_OUT_Y_H        						 (0x2B)
#define  SL_SC7A20_OUT_Z_L        						 (0x2C)
#define  SL_SC7A20_OUT_Z_H       							 (0x2D)

#define  SL_SC7A20_FIFO_CTRL_REG 						   (0x2E)
#define  SL_SC7A20_FIFO_SRC_REG   						 (0x2F)

#define  SL_SC7A20_INT1_CFG    	 						   (0x30)
#define  SL_SC7A20_INT1_SRC       						 (0x31)
#define  SL_SC7A20_INT1_THS    	  						 (0x32)
#define  SL_SC7A20_INT1_DURATION 						   (0x33)

#define  SL_SC7A20_INT2_CFG    	 						   (0x34)
#define  SL_SC7A20_INT2_SRC      							 (0x35)
#define  SL_SC7A20_INT2_THS    	 						   (0x36)
#define  SL_SC7A20_INT2_DURATION  						 (0x37)
#define  SL_SC7A20_CLICK_CFG   	  						 (0x38)
#define  SL_SC7A20_CLICK_SRC   	 						   (0x39)
#define  SL_SC7A20_CLICK_THS   	 						   (0x3A)
#define  SL_SC7A20_TIME_LIMIT     						 (0x3B)
#define  SL_SC7A20_TIME_LATENCY   						 (0x3C)
#define  SL_SC7A20_TIME_WINDOW    						 (0x3D)
#define  SL_SC7A20_ACT_THS        						 (0x3E)
#define  SL_SC7A20_ACT_DURATION 						   (0x3F)
 
#define SL_SC7A20_INT_THS_5PERCENT  					 (0x06)
#define SL_SC7A20_INT_THS_10PERCENT					   (0x0C)
#define SL_SC7A20_INT_THS_20PERCENT 					 (0x18)
#define SL_SC7A20_INT_THS_40PERCENT 					 (0x32)
#define SL_SC7A20_INT_THS_80PERCENT 					 (0x60)


#define SL_SC7A20_INT_DURATION_2CLK 					 (0x02)
#define SL_SC7A20_INT_DURATION_5CLK 					 (0x05)
#define SL_SC7A20_INT_DURATION_10CLK					 (0x0A)
#define SL_SC7A20_INT_DURATION_30CLK					 (0x2E)


#define SL_SC7A20_INT_ACTIVE_LOWER_LEVEL			 (0x02) //0x02:�ж�ʱINT1���� �͵�ƽ
#define SL_SC7A20_INT_ACTIVE_HIGH_LEVEL				 (0x00) //0x00:�ж�ʱINT1���� �ߵ�ƽ 

 
uint8_t SC7A20_GetInfo(int16_t *SL_SC7A20_Data_XYZ_Buf);
void SC7A20_Init(void);


void sc7a20_init(void);
void sc7a20_task(void *argv);
uint8_t read_chip_id(void);
#endif /* __SL_SC7A20_DRIVER_H */

