#ifndef _TEMPERATURE_H_ #define _TEMPERATURE_H_ #include "MAIN.H" #define DQ P3_5 ///*Bit definition of config register*/ #define CFG_CLKSTRETCH_Mask 0x20 #define CFG_MPS_Mask 0x1C #define CFG_Repeatbility_Mask 0x03 #define CFG_ClkStreatch_Disable (0x00 << 5) #define CFG_ClkStreatch_Enable (0x01 << 5) #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 MAXNUM 5 /*总线级联最大芯片数量*/ typedef enum { FALSE = 0, TRUE = !FALSE } BOOL; typedef struct { char Tha_set_lsb; char Tla_set_lsb; ubyte Cfg; /*系统配置寄存器, RW*/ } M601_SCRATCHPAD_WRITE; /* M601/01 ow Commands-------------------------------------------------------*/ typedef enum { //ROM command SKIP_ROM = 0xcc, READ_ROM = 0x33, MATCH_ROM = 0x55, SEARCH_ROM = 0xf0, ALARM_SEARCH = 0xec, //Function command CONVERT_T = 0x44, READ_SCRATCHPAD = 0xbe, WRITE_SCRATCHPAD = 0x4e, } M601_OW_CMD; /****************** Scratchpad/SRAM ******************/ /*SRAM scratchpad*/ typedef struct { ubyte T_lsb; /*The LSB of 温度结果, RO*/ ubyte T_msb; /*The MSB of 温度结果, RO*/ ubyte C1_lsb; /*The LSB of 电容通道C1, RO*/ ubyte C1_msb; /*The MSB of 电容通道C1, Ro*/ ubyte Tha_set_lsb; ubyte Tla_set_lsb; ubyte Cfg; /*系统配置寄存器, RW*/ ubyte Status; /*系统状态寄存器, RO*/ ubyte crc_scr; /*CRC for byte0-7, RO*/ } M601_SCRATCHPAD_READ; //20250116 增加温度采集字节 typedef struct _StrSwSample { unsigned int emergency_stop_switch : 1; // 通道1,急停开关 unsigned int High_voltage_switch : 1; // 通道2,高压开关 unsigned int CH03 : 1; // 通道3 unsigned int CH04 : 1; // 通道4 unsigned int CH05 : 1; // 通道5 unsigned int CH06 : 1; // 通道6 unsigned int CH07 : 1; // 通道7 unsigned int CH08 : 1; // 通道8 unsigned int CH09 : 1; // 通道9 unsigned int CH10 : 1; // 通道10 unsigned int CH11 : 1; // 通道11 unsigned int CH12 : 1; // 通道12 unsigned int CH13 : 1; // 通道13 unsigned int CH14 : 1; // 通道14 unsigned int CH15 : 1; // 通道15 unsigned int CH16 : 1; // 通道16 unsigned int CH17 : 1; // 通道17 unsigned int CH18 : 1; // 通道18 unsigned int CH19 : 1; // 通道19 unsigned int CH20 : 1; // 通道20 unsigned int CH21 : 1; // 通道21 unsigned int CH22 : 1; // 通道22 unsigned int CH23 : 1; // 通道23 unsigned int CH24 : 1; // 通道24 unsigned int CH25 : 1; // 通道25 unsigned int CH26 : 1; // 通道26 unsigned int CH27 : 1; // 通道27 unsigned int CH28 : 1; // 通道28 unsigned int CH29 : 1; // 通道29 unsigned int CH30 : 1; // 通道30 unsigned int CH31 : 1; // 通道31 unsigned int CH32 : 1; // 通道32 // unsigned int CH33 : 1; // 通道33 // unsigned int CH34 : 1; // 通道34 // unsigned int CH35 : 1; // 通道35 // unsigned int CH36 : 1; // 通道36 // unsigned int CH37 : 1; // 通道37 // unsigned int CH38 : 1; // 通道38 // unsigned int CH39 : 1; // 通道39 // unsigned int CH40 : 1; // 通道40 // unsigned int CH41 : 1; // 通道41 // unsigned int CH42 : 1; // 通道42 // unsigned int CH43 : 1; // 通道43 // unsigned int CH44 : 1; // 通道44 // unsigned int reserve : 4; unsigned int temperature[2]; // 温度 } StrSwSample; typedef union _UnSwSample { StrSwSample bit_data; // 使用定义的结构体变量名 unsigned char arr[sizeof(StrSwSample)]; // 通过结构体类型确定大小 } UnSwSample; extern UnSwSample UnSwSample_1 ; BOOL GetTemp(void); BOOL SetConfig(ubyte mps, ubyte repeatability); int Search_ROM(unsigned char(*romID)[8]); extern unsigned char romid[MAXNUM][8]; extern int RomNum; #endif // _TEMPERATURE_H_