hal_sc7a20.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef __HAL_SC7A20_H__
  2. #define __HAL_SC7A20_H__
  3. #include "stdint.h"
  4. typedef uint8_t uint8;
  5. typedef uint8 Std_ReturnType;
  6. typedef uint16_t uint16;
  7. typedef int16_t sint16;
  8. //#define E_NOT_OK 0x01
  9. //#define E_OK 0x00
  10. //#define NULL ((void *)0)
  11. void Sensor_Read_Byte(uint8_t RAddr, uint8_t *RData);
  12. void Sensor_Write_Byte(uint8_t RAddr, uint8_t *WData);
  13. void SC7A20_Init(void);
  14. uint8_t SC7A20_GetInfo(int16_t *SL_SC7A20_Data_XYZ_Buf);
  15. void iic_init(void);
  16. //Sensor RW Address
  17. #define Sensor_Wr_Addr1 0x30//8λI2Cַ֘+һλд
  18. #define Sensor_Rd_Addr1 0x31//8λI2Cַ֘+һλׁ
  19. #define CHIP_ID 0x11
  20. #define E_OK 0X01
  21. #define E_ERR 0X00
  22. #define SC7A20_CHIP_ID_ADDRESS (0x0F)
  23. #define SC7A20_CHIP_ID_VALUE (0x11)
  24. #define SL_SC7A20_CTRL_REG1 (0x20)
  25. #define SL_SC7A20_CTRL_REG2 (0x21)
  26. #define SL_SC7A20_CTRL_REG3 (0x22)
  27. #define SL_SC7A20_CTRL_REG4 (0x23)
  28. #define SL_SC7A20_CTRL_REG5 (0x24)
  29. #define SL_SC7A20_CTRL_REG6 (0x25)
  30. #define SL_SC7A20_STATUS_REG (0x27)
  31. #define SL_SC7A20_OUT_X_L (0x28)
  32. #define SL_SC7A20_OUT_X_H (0x29)
  33. #define SL_SC7A20_OUT_Y_L (0x2A)
  34. #define SL_SC7A20_OUT_Y_H (0x2B)
  35. #define SL_SC7A20_OUT_Z_L (0x2C)
  36. #define SL_SC7A20_OUT_Z_H (0x2D)
  37. #define SL_SC7A20_FIFO_CTRL_REG (0x2E)
  38. #define SL_SC7A20_FIFO_SRC_REG (0x2F)
  39. #define SL_SC7A20_INT1_CFG (0x30)
  40. #define SL_SC7A20_INT1_SRC (0x31)
  41. #define SL_SC7A20_INT1_THS (0x32)
  42. #define SL_SC7A20_INT1_DURATION (0x33)
  43. #define SL_SC7A20_INT2_CFG (0x34)
  44. #define SL_SC7A20_INT2_SRC (0x35)
  45. #define SL_SC7A20_INT2_THS (0x36)
  46. #define SL_SC7A20_INT2_DURATION (0x37)
  47. #define SL_SC7A20_CLICK_CFG (0x38)
  48. #define SL_SC7A20_CLICK_SRC (0x39)
  49. #define SL_SC7A20_CLICK_THS (0x3A)
  50. #define SL_SC7A20_TIME_LIMIT (0x3B)
  51. #define SL_SC7A20_TIME_LATENCY (0x3C)
  52. #define SL_SC7A20_TIME_WINDOW (0x3D)
  53. #define SL_SC7A20_ACT_THS (0x3E)
  54. #define SL_SC7A20_ACT_DURATION (0x3F)
  55. #define SL_SC7A20_INT_THS_5PERCENT (0x06)
  56. #define SL_SC7A20_INT_THS_10PERCENT (0x0C)
  57. #define SL_SC7A20_INT_THS_20PERCENT (0x18)
  58. #define SL_SC7A20_INT_THS_40PERCENT (0x32)
  59. #define SL_SC7A20_INT_THS_80PERCENT (0x60)
  60. #define SL_SC7A20_INT_DURATION_2CLK (0x02)
  61. #define SL_SC7A20_INT_DURATION_5CLK (0x05)
  62. #define SL_SC7A20_INT_DURATION_10CLK (0x0A)
  63. #define SL_SC7A20_INT_DURATION_30CLK (0x2E)
  64. #define SL_SC7A20_INT_ACTIVE_LOWER_LEVEL (0x02) //0x02:�ж�ʱINT1����￿ �͵�ƽ
  65. #define SL_SC7A20_INT_ACTIVE_HIGH_LEVEL (0x00) //0x00:�ж�ʱINT1����￿ �ߵ�ƽ
  66. uint8_t SC7A20_GetInfo(int16_t *SL_SC7A20_Data_XYZ_Buf);
  67. void SC7A20_Init(void);
  68. void sc7a20_init(void);
  69. void sc7a20_task(void *argv);
  70. uint8_t read_chip_id(void);
  71. #endif /* __SL_SC7A20_DRIVER_H */