00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _CMB_H_
00013 #define _CMB_H_
00014
00015
00016 #define VREF 2.455f
00017
00018
00019 #define ADT7486A_address 0x48
00020 #define SST_LINE1 1
00021 #define SST_TIME (unsigned long) 1
00022 #define TEMP_TIME (unsigned long) 2 // in second
00023
00024
00025
00026 #define ON 1
00027 #define DONE 1
00028 #define SET 1
00029 #define OFF 0
00030 #define FAILED 0
00031 #define CLEAR 0
00032
00033
00034 #define IGAIN1 0
00035 #define IGAIN2 1
00036 #define IGAIN4 2
00037 #define IGAIN8 3
00038 #define IGAIN16 4
00039
00040
00041
00042
00043 unsigned int xdata PageAddr[]={0x000, 0x200, 0x400, 0x600};
00044 #define SERIALN_LENGTH 4
00045 #define SERIALN_ADD (PageAddr[3]) // Fixed as sitting at the first byte of the EEPROM
00046
00047
00048 #define EEP_CTRL_KEY 0x3C000000
00049 #define EEP_CTRL_READ 0x00110000
00050 #define EEP_CTRL_WRITE 0x00220000
00051 #define EEP_CTRL_INVAL_REQ 0xff000000
00052 #define EEP_CTRL_INVAL_KEY 0x00ff0000
00053 #define EEP_CTRL_OFF_RANGE 0x0000ff00
00054 #define PAGE_SIZE sizeof(eepage)
00055 #define EEP_RW_IDX 0x02
00056
00057
00058
00059
00060 struct EEPAGE {
00061 unsigned long SerialN;
00062 unsigned int structsze;
00063 unsigned int debug1;
00064
00065 float lVIlimit[8], uVIlimit[8];
00066 float luCTlimit, uuCTlimit;
00067 float lSSTlimit, uSSTlimit;
00068 float ext1offset[4];
00069 };
00070
00071
00072 struct EEPAGE xdata eepage = {
00073
00074 0x00000000
00075
00076 , 110
00077
00078 , 123
00079
00080 , 0.0, 3.0, 3.0, 2.0, 1.2, 1.5, 2.0, 3.0
00081
00082 , 4.0, 4.5, 3.7, 2.7, 1.7, 2.0, 2.7, 3.7
00083
00084 , 10., 50.
00085
00086 , 10. ,50.
00087
00088 , 0.0, 0.0, 0.0, 0.0
00089 };
00090
00091
00092
00093
00094
00095 struct EEPAGE xdata eepage2;
00096
00097
00098 #define IDXEER 1
00099 #define IDXCTL 2
00100 #define IDXEEP_CTL 27
00101
00102
00103 unsigned char bdata rCTL;
00104 sbit CPup = rCTL ^ 0;
00105 sbit CXclk = rCTL ^ 1;
00106 sbit Ccfg = rCTL ^ 2;
00107 sbit Cdeb1 = rCTL ^ 3;
00108 sbit CeeS = rCTL ^ 4;
00109 sbit CeeR = rCTL ^ 5;
00110 sbit CeeClr = rCTL ^ 6;
00111 sbit CmSd = rCTL ^ 7;
00112
00113
00114 unsigned char bdata rCSR;
00115 sbit SPup = rCSR ^ 0;
00116 sbit SXclk = rCSR ^ 1;
00117 sbit SLinkOn = rCSR ^ 2;
00118 sbit Swdog = rCSR ^ 3;
00119 sbit SeeS = rCSR ^ 4;
00120 sbit SeeR = rCSR ^ 5;
00121 sbit SsS = rCSR ^ 6;
00122 sbit SmSd = rCSR ^ 7;
00123
00124
00125
00126
00127
00128 unsigned int bdata rESR;
00129 sbit DI4mon = rESR ^ 8;
00130 sbit DV4mon = rESR ^ 9;
00131 sbit AV33mon = rESR ^ 10;
00132 sbit AV25mon = rESR ^ 11;
00133
00134 sbit DV15mon = rESR ^ 12;
00135 sbit DV18mon = rESR ^ 13;
00136 sbit DV25mon = rESR ^ 14;
00137 sbit DV33mon = rESR ^ 15;
00138
00139 sbit uCT = rESR ^ 0;
00140 sbit FPGAssTT = rESR ^ 1;
00141 sbit Vreg1ssTT = rESR ^ 2;
00142 sbit Vreg2ssTT = rESR ^ 3;
00143
00144 sbit RdssT = rESR ^ 4;
00145 sbit EEPROM = rESR ^ 5;
00146 sbit AsumLock = rESR ^ 6;
00147 sbit V4_OC = rESR ^ 7;
00148
00149
00150
00151
00152 #define UFTEMPERATURE_MASK (unsigned int) 0x0300
00153 #define BTEMPERATURE_MASK (unsigned int) 0x0C00
00154 #define VOLTAGE_MASK (unsigned int) 0x00FE
00155 #define CURRENT_MASK (unsigned int) 0x0001
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 float code coeff[8] = {1.901, 2.000 , 1.426, 1.426, 1.0, 1.0, 1.426, 1.426};
00169 float code offset[8] = {0.000, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0 , 0.0};
00170
00171
00172
00173 struct user_data_type {
00174 unsigned long SerialN;
00175 unsigned int error;
00176 unsigned char control;
00177 unsigned char status;
00178 unsigned char eepage;
00179 unsigned char spare;
00180
00181 float pDI4Mon;
00182 float pDV4Mon;
00183 float pAV33Mon;
00184 float pAV25Mon;
00185 float pDV15Mon;
00186 float pDV18Mon;
00187 float pDV25Mon;
00188 float pDV33Mon;
00189
00190 float uCTemp;
00191 float FPGATemp;
00192 float Vrg1Temp;
00193 float Vrg2Temp;
00194
00195
00196 unsigned int rpDI4Mon;
00197 unsigned int rpDV4Mon;
00198 unsigned int rpAV33Mon;
00199 unsigned int rA25VMon;
00200 unsigned int rpDV15Mon;
00201 unsigned int rpDV18Mon;
00202 unsigned int rpDV25Mon;
00203 unsigned int rpDV33Mon;
00204
00205
00206 float eepValue;
00207 unsigned long eeCtrSet;
00208 };
00209 struct user_data_type xdata user_data;
00210
00211
00212
00213
00214 void user_init(unsigned char init);
00215 void user_loop(void);
00216 void user_write(unsigned char index) reentrant;
00217 unsigned char user_read(unsigned char index);
00218 unsigned char user_func(unsigned char *data_in, unsigned char *data_out);
00219 float read_voltage(unsigned char channel,unsigned int *rvalue, unsigned char gain);
00220
00221 #endif