#ifndef __HSPPAD143A_H #define __HSPPAD143A_H #include #include #include "boards.h" #ifdef __cplusplus extern "C" { #endif //#define HSPPAD143A_USE_IIR 1 #define PRESSURE_ADDRESS 0x48 /* Register for hsppad042 */ #define HSPPAD143A_WIA 0x00 /**< Who I am (R) */ #define HSPPAD143A_INFO 0x01 /**< Information (R) */ #define HSPPAD143A_FFST 0x02 /**< FIFO Status (R) */ #define HSPPAD143A_STAT 0x03 /**< Status (R) */ #define HSPPAD143A_POUTL 0x04 /**< Pressure Output Low */ #define HSPPAD143A_POUTM 0x05 /**< Pressure Output Middle */ #define HSPPAD143A_POUTH 0x06 /**< Pressure Output High */ #define HSPPAD143A_TOUTL 0x09 /**< Temperature Output Low */ #define HSPPAD143A_TOUTH 0x0A /**< Temperature Output High */ #define HSPPAD143A_CTL1 0x0E /**< Contorl 1 (R/W) */ #define HSPPAD143A_CTL2 0x0F /**< Contorl 2 (R/W) */ #define HSPPAD143A_ACTL1 0x10 /**< Action Control 1 (R/W) */ #define HSPPAD143A_ACTL2 0x11 /**< Action Control 2 (R/W) */ #define HSPPAD143A_FCTL 0x12 /**< FIFO Control (R/W) */ #define HSPPAD143A_AVCL 0x13 /**< Average Control (R/W) */ #define HSPPAD143A_PNUM 0x1C /**< Product Number (R) */ /* Comannd for hsppad042 */ #define HSPPAD143A_PDET 0x20 /**< Peform pressure measurement */ #define HSPPAD143A_TDET 0x22 /**< Peform temperature measurement */ #define HSPPAD143A_SRST 0x26 /**< Peform software rest */ #define HSPPAD143A_PTDET 0x29 /**< Peform pressure and temperature measurement */ #define HSPPAD143A_DCTL 0x0D /**< DRDY pin Control (R/W) */ #define HSPPAD143A_AVCL_TFRQ_1ST 0x00 /**< Frequency of temp. meas. (Only first timing) */ #define HSPPAD143A_AVCL_TFRQ_64T 0x08 /**< Frequency of temp. meas. (Once every 64 timies) */ #define HSPPAD143A_AVCL_TFRQ_32T 0x10 /**< Frequency of temp. meas. (Once every 32 timies) */ #define HSPPAD143A_AVCL_TFRQ_16T 0x18 /**< Frequency of temp. meas. (Once every 16 timies) */ #define HSPPAD143A_AVCL_TFRQ_8T 0x20 /**< Frequency of temp. meas. (Once every 8 timies) */ #define HSPPAD143A_AVCL_TFRQ_4T 0x28 /**< Frequency of temp. meas. (Once every 4 timies) */ #define HSPPAD143A_AVCL_TFRQ_2T 0x30 /**< Frequency of temp. meas. (Once every 2 timies) */ #define HSPPAD143A_AVCL_TFRQ_EVY 0x38 /**< Frequency of temp. meas. (Every timies) */ #define HSPPAD143A_AVCL_AVE_NON 0x00 /**< Number of prs average. (No average) */ #define HSPPAD143A_AVCL_AVE_2T 0x01 /**< Number of prs average. (2 times) */ #define HSPPAD143A_AVCL_AVE_4T 0x02 /**< Number of prs average. (4 times) */ #define HSPPAD143A_AVCL_AVE_8T 0x03 /**< Number of prs average. (8 times) */ #define HSPPAD143A_AVCL_AVE_16T 0x04 /**< Number of prs average. (16 times) */ #define HSPPAD143A_AVCL_DEF (HSPPAD143A_AVCL_TFRQ_EVY | HSPPAD143A_AVCL_AVE_2T) #define HSPPAD143A_CL2_ODR_1HZ 0x00 /**< Output Data Rate (00:1Hz) */ #define HSPPAD143A_CL2_ODR_10HZ 0x04 /**< Output Data Rate (01:10Hz) */ #define HSPPAD143A_CL2_ODR_100HZ 0x08 /**< Output Data Rate (10:100Hz) */ #define HSPPAD143A_CL2_ODR_200HZ 0x0C /**< Output Data Rate (11:200Hz) */ #define HSPPAD143A_CL2_MODE_CM 0x01 /**< Continuous Measurement Mode (01) */ #define HSPPAD143A_CL2_DEF 0xA0 /**< CTRL2 Default setting */ #define HSPPAD143A_FFST_FP 0x1F /**< number of data stored in FIFO (FP=0-16) */ typedef enum { HSPPAD143A_QUEUE_TIME=0, HSPPAD143A_QUEUE_INT=1, HSPPAD143A_QUEUE_TIMEOUT=2, }HSPPAD143A_QUEUE_TYPE; typedef void (*hsppad143a_finish_func)(bool stat); typedef enum{ HSPPAD143A_NULL, HSPPAD143A_INIT, HSPPAD143A_ENABLE, HSPPAD143A_RD, HSPPAD143A_DISABLE, }hsppad143a_work_stat; #define PRESSURE_SIZE 50 typedef struct{ hsppad143a_finish_func finish_func; hsppad143a_work_stat hsppad143a_stat; uint8_t hsppad143a_timeout; uint8_t idx; float pressure[PRESSURE_SIZE]; }hsppad143a_work_s; typedef struct{ bool hsppad143a_stat; int32_t pressure; }hsppad143a_data_s; void Hsppad143A_Start(void); void Hsppad143A_i2c_init(void); void Hsppad143A_i2c_uinit(void); void set_Hsppad143a_finish_func(hsppad143a_finish_func func); void Set_Hsppad143A_Queue(HSPPAD143A_QUEUE_TYPE type); void Hsppad143A_Switch_Addr(bool stat); extern hsppad143a_data_s hsppad143a_data; int hsppad143A_init(void); void hsppad143A_enable_setup(int en, int delay_msec); void hsppad143A_get_data(float *data); void hsppad143A_get_fifo_data(float data[16][2]); void hsppad042_selftest(void); void Set_Hsppad143a_Queue(HSPPAD143A_QUEUE_TYPE type); void Hsppad143a_Start(void); void hsppad_timers_init(void); #ifdef __cplusplus } #endif #endif // __HSPPAD143A_H /** @} */