hsppad143a.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __HSPPAD143A_H
  2. #define __HSPPAD143A_H
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "boards.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. //#define HSPPAD143A_USE_IIR 1
  10. #define PRESSURE_ADDRESS 0x48
  11. /* Register for hsppad042 */
  12. #define HSPPAD143A_WIA 0x00 /**< Who I am (R) */
  13. #define HSPPAD143A_INFO 0x01 /**< Information (R) */
  14. #define HSPPAD143A_FFST 0x02 /**< FIFO Status (R) */
  15. #define HSPPAD143A_STAT 0x03 /**< Status (R) */
  16. #define HSPPAD143A_POUTL 0x04 /**< Pressure Output Low */
  17. #define HSPPAD143A_POUTM 0x05 /**< Pressure Output Middle */
  18. #define HSPPAD143A_POUTH 0x06 /**< Pressure Output High */
  19. #define HSPPAD143A_TOUTL 0x09 /**< Temperature Output Low */
  20. #define HSPPAD143A_TOUTH 0x0A /**< Temperature Output High */
  21. #define HSPPAD143A_CTL1 0x0E /**< Contorl 1 (R/W) */
  22. #define HSPPAD143A_CTL2 0x0F /**< Contorl 2 (R/W) */
  23. #define HSPPAD143A_ACTL1 0x10 /**< Action Control 1 (R/W) */
  24. #define HSPPAD143A_ACTL2 0x11 /**< Action Control 2 (R/W) */
  25. #define HSPPAD143A_FCTL 0x12 /**< FIFO Control (R/W) */
  26. #define HSPPAD143A_AVCL 0x13 /**< Average Control (R/W) */
  27. #define HSPPAD143A_PNUM 0x1C /**< Product Number (R) */
  28. /* Comannd for hsppad042 */
  29. #define HSPPAD143A_PDET 0x20 /**< Peform pressure measurement */
  30. #define HSPPAD143A_TDET 0x22 /**< Peform temperature measurement */
  31. #define HSPPAD143A_SRST 0x26 /**< Peform software rest */
  32. #define HSPPAD143A_PTDET 0x29 /**< Peform pressure and temperature measurement */
  33. #define HSPPAD143A_DCTL 0x0D /**< DRDY pin Control (R/W) */
  34. #define HSPPAD143A_AVCL_TFRQ_1ST 0x00 /**< Frequency of temp. meas. (Only first timing) */
  35. #define HSPPAD143A_AVCL_TFRQ_64T 0x08 /**< Frequency of temp. meas. (Once every 64 timies) */
  36. #define HSPPAD143A_AVCL_TFRQ_32T 0x10 /**< Frequency of temp. meas. (Once every 32 timies) */
  37. #define HSPPAD143A_AVCL_TFRQ_16T 0x18 /**< Frequency of temp. meas. (Once every 16 timies) */
  38. #define HSPPAD143A_AVCL_TFRQ_8T 0x20 /**< Frequency of temp. meas. (Once every 8 timies) */
  39. #define HSPPAD143A_AVCL_TFRQ_4T 0x28 /**< Frequency of temp. meas. (Once every 4 timies) */
  40. #define HSPPAD143A_AVCL_TFRQ_2T 0x30 /**< Frequency of temp. meas. (Once every 2 timies) */
  41. #define HSPPAD143A_AVCL_TFRQ_EVY 0x38 /**< Frequency of temp. meas. (Every timies) */
  42. #define HSPPAD143A_AVCL_AVE_NON 0x00 /**< Number of prs average. (No average) */
  43. #define HSPPAD143A_AVCL_AVE_2T 0x01 /**< Number of prs average. (2 times) */
  44. #define HSPPAD143A_AVCL_AVE_4T 0x02 /**< Number of prs average. (4 times) */
  45. #define HSPPAD143A_AVCL_AVE_8T 0x03 /**< Number of prs average. (8 times) */
  46. #define HSPPAD143A_AVCL_AVE_16T 0x04 /**< Number of prs average. (16 times) */
  47. #define HSPPAD143A_AVCL_DEF (HSPPAD143A_AVCL_TFRQ_EVY | HSPPAD143A_AVCL_AVE_2T)
  48. #define HSPPAD143A_CL2_ODR_1HZ 0x00 /**< Output Data Rate (00:1Hz) */
  49. #define HSPPAD143A_CL2_ODR_10HZ 0x04 /**< Output Data Rate (01:10Hz) */
  50. #define HSPPAD143A_CL2_ODR_100HZ 0x08 /**< Output Data Rate (10:100Hz) */
  51. #define HSPPAD143A_CL2_ODR_200HZ 0x0C /**< Output Data Rate (11:200Hz) */
  52. #define HSPPAD143A_CL2_MODE_CM 0x01 /**< Continuous Measurement Mode (01) */
  53. #define HSPPAD143A_CL2_DEF 0xA0 /**< CTRL2 Default setting */
  54. #define HSPPAD143A_FFST_FP 0x1F /**< number of data stored in FIFO (FP=0-16) */
  55. typedef enum
  56. {
  57. HSPPAD143A_QUEUE_TIME=0,
  58. HSPPAD143A_QUEUE_INT=1,
  59. HSPPAD143A_QUEUE_TIMEOUT=2,
  60. }HSPPAD143A_QUEUE_TYPE;
  61. typedef void (*hsppad143a_finish_func)(bool stat);
  62. typedef enum{
  63. HSPPAD143A_NULL,
  64. HSPPAD143A_INIT,
  65. HSPPAD143A_ENABLE,
  66. HSPPAD143A_RD,
  67. HSPPAD143A_DISABLE,
  68. }hsppad143a_work_stat;
  69. #define PRESSURE_SIZE 50
  70. typedef struct{
  71. hsppad143a_finish_func finish_func;
  72. hsppad143a_work_stat hsppad143a_stat;
  73. uint8_t hsppad143a_timeout;
  74. uint8_t idx;
  75. float pressure[PRESSURE_SIZE];
  76. }hsppad143a_work_s;
  77. typedef struct{
  78. bool hsppad143a_stat;
  79. int32_t pressure;
  80. }hsppad143a_data_s;
  81. void Hsppad143A_Start(void);
  82. void Hsppad143A_i2c_init(void);
  83. void Hsppad143A_i2c_uinit(void);
  84. void set_Hsppad143a_finish_func(hsppad143a_finish_func func);
  85. void Set_Hsppad143A_Queue(HSPPAD143A_QUEUE_TYPE type);
  86. void Hsppad143A_Switch_Addr(bool stat);
  87. extern hsppad143a_data_s hsppad143a_data;
  88. int hsppad143A_init(void);
  89. void hsppad143A_enable_setup(int en, int delay_msec);
  90. void hsppad143A_get_data(float *data);
  91. void hsppad143A_get_fifo_data(float data[16][2]);
  92. void hsppad042_selftest(void);
  93. void Set_Hsppad143a_Queue(HSPPAD143A_QUEUE_TYPE type);
  94. void Hsppad143a_Start(void);
  95. void hsppad_timers_init(void);
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif // __HSPPAD143A_H
  100. /** @} */