sensor.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #ifndef _SC7A20_H
  2. #define _SC7A20_H
  3. #include "commontypedef.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /***ʹ������ǰ�����ʵ�ʽ����������******/
  8. /**SC7A20��SDO �Žӵأ� 0****************/
  9. /**SC7A20��SDO �Žӵ�Դ��1****************/
  10. #define SC7A20_SDO_VDD_GND 0
  11. /*****************************************/
  12. /***ʹ������ǰ�����ʵ��IIC�����������***/
  13. /**SC7A20��IIC �ӿڵ�ַ���� 7bits�� 0****/
  14. /**SC7A20��IIC �ӿڵ�ַ���� 8bits�� 1****/
  15. #define SC7A20_IIC_7BITS_8BITS 0
  16. /*****************************************/
  17. #define SL_SC7A20_16BIT_8BIT 1
  18. /**SC7A20������λ��ѡ�� 16bits�� 1****/
  19. /**SC7A20������λ��ѡ�� 8bits�� 0****/
  20. /*****************************************/
  21. #define SL_6D4D2D1D_SEL 6
  22. #if SC7A20_SDO_VDD_GND==0
  23. #define SC7A20_IIC_7BITS_ADDR 0x18
  24. #define SC7A20_IIC_8BITS_ADDR 0x30
  25. #else
  26. #define SC7A20_IIC_7BITS_ADDR 0x19
  27. #define SC7A20_IIC_8BITS_ADDR 0x32
  28. #endif
  29. #if SC7A20_IIC_7BITS_8BITS==0
  30. #define SC7A20_IIC_ADDRESS SC7A20_IIC_7BITS_ADDR
  31. #else
  32. #define SC7A20_IIC_ADDRESS SC7A20_IIC_8BITS_ADDR
  33. #endif
  34. #define SC7A20_CHIP_ID_ADDRESS (UINT8)(0x0F)
  35. #define SC7A20_CHIP_ID_VALUE (UINT8)(0x11)
  36. #define SL_SC7A20_CTRL_REG1 (UINT8)(0x20)
  37. #define SL_SC7A20_CTRL_REG2 (UINT8)(0x21)
  38. #define SL_SC7A20_CTRL_REG3 (UINT8)(0x22)
  39. #define SL_SC7A20_CTRL_REG4 (UINT8)(0x23)
  40. #define SL_SC7A20_CTRL_REG5 (UINT8)(0x24)
  41. #define SL_SC7A20_CTRL_REG6 (UINT8)(0x25)
  42. #define SL_SC7A20_STATUS_REG (UINT8)(0x27)
  43. #define SL_SC7A20_OUT_X_L (UINT8)(0x28)
  44. #define SL_SC7A20_OUT_X_H (UINT8)(0x29)
  45. #define SL_SC7A20_OUT_Y_L (UINT8)(0x2A)
  46. #define SL_SC7A20_OUT_Y_H (UINT8)(0x2B)
  47. #define SL_SC7A20_OUT_Z_L (UINT8)(0x2C)
  48. #define SL_SC7A20_OUT_Z_H (UINT8)(0x2D)
  49. #define SL_SC7A20_FIFO_CTRL_REG (UINT8)(0x2E)
  50. #define SL_SC7A20_FIFO_SRC_REG (UINT8)(0x2F)
  51. #define SL_SC7A20_INT1_CFG (UINT8)(0x30)
  52. #define SL_SC7A20_INT1_SRC (UINT8)(0x31)
  53. #define SL_SC7A20_INT1_THS (UINT8)(0x32)
  54. #define SL_SC7A20_INT1_DURATION (UINT8)(0x33)
  55. #define SL_SC7A20_INT2_CFG (UINT8)(0x34)
  56. #define SL_SC7A20_INT2_SRC (UINT8)(0x35)
  57. #define SL_SC7A20_INT2_THS (UINT8)(0x36)
  58. #define SL_SC7A20_INT2_DURATION (UINT8)(0x37)
  59. #define SL_SC7A20_CLICK_CFG (UINT8)(0x38)
  60. #define SL_SC7A20_CLICK_SRC (UINT8)(0x39)
  61. #define SL_SC7A20_CLICK_THS (UINT8)(0x3A)
  62. #define SL_SC7A20_TIME_LIMIT (UINT8)(0x3B)
  63. #define SL_SC7A20_TIME_LATENCY (UINT8)(0x3C)
  64. #define SL_SC7A20_TIME_WINDOW (UINT8)(0x3D)
  65. #define SL_SC7A20_ACT_THS (UINT8)(0x3E)
  66. #define SL_SC7A20_ACT_DURATION (UINT8)(0x3F)
  67. /*������ȡ����ʱ�����ݼĴ�����ַ*/
  68. #define SL_SC7A20_DATA_OUT (UINT8)(SL_SC7A20_OUT_X_L)
  69. /**********���⹦�ܼĴ���**********/
  70. /*��ԭ��������Ա�����޸�*/
  71. #define SL_SC7A20_MTP_ENABLE (0x00)
  72. #define SL_SC7A20_MTP_CFG (UINT8)(0x1E)
  73. #define SL_SC7A20_MTP_VALUE (UINT8)(0x05)
  74. #define SL_SC7A20_SDOI2C_PU_CFG (UINT8)(0x57)
  75. #define SL_SC7A20_SDO_PU_MSK (UINT8)(0x08)
  76. #define SL_SC7A20_I2C_PU_MSK (UINT8)(0x04)
  77. #define SL_SC7A20_HR_ENABLE (UINT8)(0X08)
  78. #define SL_SC7A20_BOOT_ENABLE (UINT8)(0X80)
  79. /*��ԭ��������Ա�����޸�*/
  80. /***************���ݸ�������**���ٶȼ�ʹ��**********/
  81. #define SL_SC7A20_ODR_POWER_DOWN (UINT8)(0x00)
  82. #define SL_SC7A20_ODR_1HZ (UINT8)(0x17)
  83. #define SL_SC7A20_ODR_10HZ (UINT8)(0x27)
  84. #define SL_SC7A20_ODR_25HZ (UINT8)(0x37)
  85. #define SL_SC7A20_ODR_50HZ (UINT8)(0x47)
  86. #define SL_SC7A20_ODR_100HZ (UINT8)(0x57)
  87. #define SL_SC7A20_ODR_200HZ (UINT8)(0x67)
  88. #define SL_SC7A20_ODR_400HZ (UINT8)(0x77)
  89. #define SL_SC7A20_ODR_1600HZ (UINT8)(0x87)
  90. #define SL_SC7A20_ODR_1250HZ (UINT8)(0x97)
  91. #define SL_SC7A20_ODR_5000HZ (UINT8)(0x9F)
  92. #define SL_SC7A20_LOWER_POWER_ODR_1HZ (UINT8)(0x1F)
  93. #define SL_SC7A20_LOWER_POWER_ODR_10HZ (UINT8)(0x2F)
  94. #define SL_SC7A20_LOWER_POWER_ODR_25HZ (UINT8)(0x3F)
  95. #define SL_SC7A20_LOWER_POWER_ODR_50HZ (UINT8)(0x4F)
  96. #define SL_SC7A20_LOWER_POWER_ODR_100HZ (UINT8)(0x5F)
  97. #define SL_SC7A20_LOWER_POWER_ODR_200HZ (UINT8)(0x6F)
  98. #define SL_SC7A20_LOWER_POWER_ODR_400HZ (UINT8)(0x7F)
  99. /***************���ݸ�������**���ٶȼ�ʹ��**********/
  100. /***************��������������**********************/
  101. #define SL_SC7A20_FS_2G (UINT8)(0x00)
  102. #define SL_SC7A20_FS_4G (UINT8)(0x10)
  103. #define SL_SC7A20_FS_8G (UINT8)(0x20)
  104. #define SL_SC7A20_FS_16G (UINT8)(0x30)
  105. /***************��������������**********************/
  106. /***ȡֵ��0-127֮�䣬�˴�������****/
  107. #define SL_SC7A20_INT_THS_5PERCENT (UINT8)(0x06)
  108. #define SL_SC7A20_INT_THS_10PERCENT (UINT8)(0x0C)
  109. #define SL_SC7A20_INT_THS_20PERCENT (UINT8)(0x18)
  110. #define SL_SC7A20_INT_THS_40PERCENT (UINT8)(0x32)
  111. #define SL_SC7A20_INT_THS_80PERCENT (UINT8)(0x60)
  112. /***ȡֵ��0-127֮�䣬�˴������� ����ODR��λʱ��****/
  113. #define SL_SC7A20_INT_DURATION_2CLK (UINT8)(0x02)
  114. #define SL_SC7A20_INT_DURATION_5CLK (UINT8)(0x05)
  115. #define SL_SC7A20_INT_DURATION_10CLK (UINT8)(0x0A)
  116. #define SL_SC7A20_INT_DURATION_30CLK (UINT8)(0x2E)
  117. /***�ж���Чʱ�ĵ�ƽ���ã��ߵ�ƽ�൱�������أ��͵�ƽ�൱���½���****/
  118. #define SL_SC7A20_INT_ACTIVE_LOWER_LEVEL (UINT8)(0x02) //0x02:�ж�ʱINT1����� �͵�ƽ
  119. #define SL_SC7A20_INT_ACTIVE_HIGH_LEVEL (UINT8)(0x00) //0x00:�ж�ʱINT1����� �ߵ�ƽ
  120. /***�ж���Чʱ�ĵ�ƽ���ã��ߵ�ƽ�൱�������أ��͵�ƽ�൱���½���****/
  121. #define SL_SC7A20_INT_AOI1_INT1 (UINT8)(0x40) //AOI1 TO INT1
  122. #define SL_SC7A20_INT_AOI2_INT1 (UINT8)(0x20) //AOI2 TO INT1
  123. extern INT32 GSENSOR_WriteReg(UINT8 addr, UINT8 value);
  124. extern INT32 GSENSOR_ReadReg(UINT8 reg, UINT8 len, UINT8 *buf);
  125. INT8 SL_SC7A20_Online_Test(void);
  126. INT8 SL_SC7A20_BOOT(void);
  127. INT8 SL_SC7A20_FS_Config(UINT8 Sc7a20_FS_Reg);
  128. INT8 SL_SC7A20_INT_Config(void);
  129. INT8 SL_SC7A20_INT_RESET(void);
  130. INT8 SL_SC7A20_Power_Config(UINT8 Power_Config_Reg);
  131. #if SL_SC7A20_16BIT_8BIT==0
  132. INT8 SL_SC7A20_Read_XYZ_Data(INT8 *SL_SC7A20_Data_XYZ_Buf);
  133. #elif SL_SC7A20_16BIT_8BIT==1
  134. INT8 SL_SC7A20_Read_XYZ_Data(INT16 *SL_SC7A20_Data_XYZ_Buf);
  135. #endif
  136. void GsensorInit(void);
  137. #ifdef __cplusplus
  138. }
  139. #endif
  140. #endif /* _SC7A20_H */