| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- /******************************************************************************
- *Copyright(C),2024-2024,万众一芯生
- *van_BSP_Temp_mts01.h
- *mts01 温度相关驱动接口
- *修改历史
- author 范义东 新建 2024/01/27
- ******************************************************************************/
- #ifndef __VAN_BSP_TEMP_MTS01_H
- #define __VAN_BSP_TEMP_MTS01_H
- #ifndef bool
- typedef enum
- {
- false = 0,
- true = 1,
- False = 0,
- True = 1,
- } bool;
- #endif
- #define ARR_LEN(array)(sizeof(array) / sizeof(array[0]))
- typedef enum
- {
- CONVERT_T = 0xCC44, //Measure temperature
- BREAK = 0x3093, //Abort period measurement
- READ_STATUSCONFIG = 0xf32d, //Read status and configuration registers
- CLEAR_STATUS = 0x3041, //Clear status register
- WRITE_CONFIG = 0x5206, //Write configuration register
- READ_ALERT_HI_SET = 0xe11f, //Read the upper alarm thresholdvalue
- READ_ALERT_LO_SET = 0xe102, //Read the lower alarm threshold value
- WRITE_ALERT_HI_SET = 0x611d, //Set the upper alarm threshold value
- WRITE_ALERT_LO_SET = 0x6100, //Set the lower alarm threshold value
-
- WRITE_ALERT_LO_UNSET = 0x610b, //Set the alarm clear threshold lower threshold
- WRITE_ALERT_HI_UNSET = 0x6116, //Set the alarm clear threshold upper threshold
- READ_ALERT_HI_UNSET = 0xe114, //Read Alarm Clear Threshold Upper Threshold
- READ_ALERT_LO_UNSET = 0xe109, //Read Alarm Clear Threshold Lower Threshold
- COPY_PAGE0 = 0xcc48, //Save page0 to EEPROM
- RECALL_EE = 0xccb8, //Recall EEPROM area
- RECALL_PAGE0_RES = 0xccbb, //Restore the residual area of page0
- SOFT_RST = 0x30a2, //Software reset
- } I2C_CMD;
- /*Bit definition of config register*/
- #define CFG_MPS_Mask (0x1C)
- #define CFG_Repeatbility_Mask (0x03)
- #define CFG_MPS_Single (0x00)
- #define CFG_MPS_Half (0x04)
- #define CFG_MPS_1 (0x08)
- #define CFG_MPS_2 (0x0C)
- #define CFG_MPS_4 (0x10)
- #define CFG_MPS_10 (0x14)
- #define CFG_Repeatbility_Low (0x00)
- #define CFG_Repeatbility_Medium (0x01)
- #define CFG_Repeatbility_High (0x02)
- #define POLYNOMIAL 0x131 // 100110001
- /*Definition of conversion time corresponding to repeatability setting*/
- /*The default low/medium/high repeatability corresponds to the conversion time of 4/6/11ms respectively.
- Considering the delay deviation of different users of the microcontroller, reserve 2ms to ensure sufficient conversion time*/
- #define tConvert_LowRepeat (6) /* ms. */
- #define tConvert_MedRepeat (8) /* ms. */
- #define tConvert_HighRepeat (13) /* ms. */
- #define TEMP_MTS01_MAX_AVG_TIME 10 /*最多10次缓存用于求平均*/
- #define MTS01_ADDR0 (0x44<<1 ) /* Addr */
- #define MTS01_ADDR1 (0x45<<1 ) /* Addr */
- #define TEMP_MTS01NAMEANDID(chanle) .tempID = chanle, .Name = #chanle
- typedef enum
- {
- TEMP_BLOCK,
- } TEMP_MTS01_V1;
-
- typedef enum _EnmFuntionIdType {
- EnmFuntionIdType_IdNull = 0,
- EnmFuntionIdType_Idhost = 1, /* 主机 */
- } EnmFuntionIdType;
-
- typedef struct
- {
- unsigned int tempID; //温区编号
- unsigned char Name[16]; //温区名称
- void *I2C; /*IIC端口 端口*/
- unsigned int addr; /*CS 端口*/
- unsigned int maxlen; /*CS 端口*/
- unsigned int header; /*CS 端口*/
- float temp[TEMP_MTS01_MAX_AVG_TIME];
- unsigned int isload; /*CS 端口*/
- } VAN_TEMP_MTS01_CON_ST_Def, *P_VAN_TEMP_MTS01_CON_ST_Def;
- typedef struct
- {
- unsigned int id; //设备id
- unsigned int feed_channel; //测温通道
- float temp; //温度值
- } VAN_TEMP_CHANNEl_CON_ST_Def, *P_VAN_TEMP_CHANNEl_CON_ST_Def;
- bool MTS01_ReadTemp(unsigned char runMtsId, float *pTemp);
- bool MTS01_Temp_get(uint32_t runMtsId, float *Value);
- unsigned int loadTemp_mts01Cfg(void);
- #endif
|