00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _LPB_H_
00014 #define _LPB_H_
00015
00016
00017 #define VREF 2.50f
00018
00019
00020 #define ADT7486A_ADDR0 0x4C
00021 #define NCHANNEL_ADT7486A 1
00022 #define SST_LINE1 1
00023
00024
00025 #define CLEAR 0
00026 #define SET 1
00027 #define DONE 1
00028 #define FAILED 0
00029 #define ON 1
00030 #define OFF 0
00031
00032 #define IntGAIN1 0
00033 #define IntGAIN2 1
00034 #define IntGAIN4 2
00035 #define IntGAIN8 3
00036 #define IntGAIN16 4
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 float code coeff[8] = {4.615, 3.136, 0.1, 3.136, 0.4, 0.4, 0.2, 0.01};
00051 float code offset[8] = { 0, 0, 0, 0, 0, 0, 0, 0};
00052 unsigned int xdata ltc2620mirror[16];
00053
00054
00055
00056
00057 unsigned int xdata PageAddr[]={0x000, 0x200, 0x400, 0x600};
00058 #define SERIALN_LENGTH 4
00059 #define SERIALN_ADD (PageAddr[3]) // Fixed as sitting at the first byte of the EEPROM
00060
00061
00062
00063 struct EEPAGE {
00064 unsigned long SerialN;
00065 unsigned int structsze;
00066 unsigned int delay;
00067 unsigned int rdac[16];
00068 float lVIlimit[8];
00069 float uVIlimit[8];
00070 float luCTlimit, uuCTlimit;
00071 float lSSTlimit, uSSTlimit;
00072 };
00073
00074
00075
00076 struct EEPAGE xdata eepage={
00077
00078 0x00000000
00079
00080 , 0x0000, 0x0000
00081
00082 , 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
00083 , 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
00084
00085
00086 , 0.0, 3.5, 0.1, 5.5, 0.0, 0.0, 0.0, 0.0
00087
00088
00089 , 6.0, 5.5, 0.3, 6.5, 1.8, 0.1, 0.5, 0.2
00090
00091 , 10., 50.
00092
00093 , 10., 50.
00094 };
00095
00096 #define PAGE_SIZE (unsigned int) sizeof(eepage)
00097
00098
00099 #define EEP_CTRL_KEY 0x3C000000
00100 #define EEP_CTRL_READ 0x00110000
00101 #define EEP_CTRL_WRITE 0x00220000
00102 #define EEP_CTRL_INVAL_REQ 0xff000000
00103 #define EEP_CTRL_INVAL_KEY 0x00ff0000
00104 #define EEP_CTRL_OFF_RANGE 0x0000ff00
00105 #define EEP_RW_IDX 0x0a // (I*4)
00106
00107
00108 struct user_data_type {
00109 unsigned long SerialN;
00110 unsigned int error;
00111 unsigned char control;
00112 unsigned char status;
00113 unsigned char eepage;
00114 unsigned char spare;
00115 unsigned int delay;
00116 float iadc[8];
00117 float uCTemp;
00118 float IntTemp;
00119 float Temp58;
00120 float Temp33;
00121 float SHTtemp;
00122 float SHThumid;
00123 unsigned int rdac[16];
00124 unsigned int riadc[8];
00125 unsigned int rSHTemp;
00126 unsigned int rSHhumid;
00127 float eepValue;
00128 unsigned long eeCtrSet;
00129 };
00130 struct user_data_type xdata user_data;
00131
00132 #define IDXDAC 21
00133 #define IDXCTL 2
00134 #define IDXEEP_CTL 48
00135 #define IDXDELAY 6
00136
00137 unsigned char bdata rCTL;
00138 sbit CPup = rCTL ^ 0;
00139 sbit Cmode = rCTL ^ 3;
00140 sbit CeeS = rCTL ^ 4;
00141 sbit CeeR = rCTL ^ 5;
00142 sbit CeeClr = rCTL ^ 6;
00143 sbit CmSd = rCTL ^ 7;
00144
00145 unsigned char bdata rCSR;
00146 sbit SPup = rCSR ^ 0;
00147 sbit S6dd = rCSR ^ 1;
00148 sbit Smode = rCSR ^ 3;
00149 sbit SeeS = rCSR ^ 4;
00150 sbit SeeR = rCSR ^ 5;
00151 sbit SsS = rCSR ^ 6;
00152 sbit SmSd = rCSR ^ 7;
00153
00154
00155
00156
00157
00158
00159
00160 unsigned int bdata rESR;
00161 sbit Vss = rESR ^ 8;
00162 sbit Iss = rESR ^ 9;
00163 sbit Vdd = rESR ^ 10;
00164 sbit Idd = rESR ^ 11;
00165
00166 sbit I5 = rESR ^ 12;
00167 sbit I33 = rESR ^ 13;
00168 sbit I18 = rESR ^ 14;
00169 sbit uCT = rESR ^ 15;
00170
00171 sbit IntssTT = rESR ^ 0;
00172 sbit Ext1ssTT = rESR ^ 1;
00173 sbit Ext2ssTT = rESR ^ 2;
00174 sbit EEPROM = rESR ^ 3;
00175
00176 sbit pcbssTT = rESR ^ 4;
00177 sbit RdssT = rESR ^ 5;
00178
00179 sbit V6Fault = rESR ^ 7;
00180
00181
00182
00183
00184
00185
00186 #define UCTEMPERATURE_MASK 0x0080
00187 #define BTEMPERATURE_MASK 0x0600
00188 #define VOLTAGE_MASK 0x0005
00189 #define CURRENT_MASK 0x0008
00190 #define MAIN_CURRENT_MASK 0x8000
00191
00192
00193
00194
00195
00196 sbit VCC_EN = P1 ^ 3;
00197 sbit VREG_5 = P2 ^ 5;
00198 sbit VREG_3 = P2 ^ 6;
00199
00200 sbit V6ddFlag = P1 ^ 6;
00201
00202 sbit DELAY_0 = P0 ^ 6;
00203 sbit DELAY_1 = P0 ^ 7;
00204
00205
00206 #define humsense 1
00207
00208
00209
00210
00211 float read_voltage(unsigned char channel,unsigned int *rvalue, unsigned char gain);
00212 #endif