Defines | |
| #define | T_BIT 16 |
| #define | T_H1 T_BIT * 0.75 |
| #define | T_H0 T_BIT * 0.25 |
| #define | SST_CLEAR_DELAY 2 |
Functions | |
| void | SST_Clear (int SST_LINE) |
| void | SST_WriteByte (unsigned char datByte, int SST_LINE) |
| unsigned char | SST_ReadByte (int SST_LINE) |
| void | SST_Init (int SST_LINE) |
| unsigned char | FCS_Step (unsigned int msg, unsigned char fcs) reentrant |
| void | SST_DrvHigh (int SST_LINE) |
| void | SST_DrvLow (int SST_LINE) |
| unsigned char | SST_DrvClientResponse (int SST_LINE) |
| #define SST_CLEAR_DELAY 2 |
| #define T_BIT 16 |
| #define T_H0 T_BIT * 0.25 |
| #define T_H1 T_BIT * 0.75 |
| unsigned char FCS_Step | ( | unsigned int | msg, | |
| unsigned char | fcs | |||
| ) |
Single calculation for 8-bit cyclic redundancy checksum usually used in FORWARD recursive format (to save code-space) Reentrant function /code
/endcode
| msg | ||
| fcs |
00074 { 00075 return FCS_data[(msg ^ fcs)]; 00076 }
| void SST_Clear | ( | int | SST_LINE | ) |
Drives SST line to low for a reasonably long time which gives enough time for the SST to go idle.
00094 { 00095 // Test this, high low high low 00096 if(SST_LINE==1) 00097 SST1 = 0; 00098 #ifdef MORE_THAN_ONE_LINE 00099 else if(SST_LINE==2) 00100 SST2 = 0; 00101 #endif 00102 delay_ms(SST_CLEAR_DELAY); //clear to 0's 00103 }
| unsigned char SST_DrvClientResponse | ( | int | SST_LINE | ) |
Get the comparator bit value (Client response)
00159 { 00160 00161 // Drive SST to logic "0" (high 1/4, low 3/4) to let Client 00162 // drive SST to its desired state 00163 if(SST_LINE==1) { 00164 SST1 = 1; //Drv high (originator drives SST bus high to toggle client's response 00165 delay_us (1); 00166 SST1 = 0; 00167 00168 delay_us(T_BIT / 2.0); //delay for half of T_BIT time 00169 00170 #if defined(CPU_C8051F120) 00171 #ifdef CMB 00172 SFRPAGE = CPT1_PAGE; 00173 #elif defined(FEB64) 00174 SFRPAGE = CPT1_PAGE; 00175 #elif defined(LPB) 00176 SFRPAGE = CPT1_PAGE; 00177 #else 00178 SFRPAGE = CPT0_PAGE; 00179 #endif 00180 #endif 00181 if(SST_ClientResponse1 == 1) { 00182 //if the comparator output is high, then return 1 00183 delay_us(2 * T_H0); 00184 return 1; 00185 } else { 00186 //if the comparator output is low, then return 0 00187 delay_us(2 * T_H0); 00188 return 0; 00189 } 00190 } 00191 #ifdef MORE_THAN_ONE_LINE 00192 else if(SST_LINE==2) { 00193 SST2 = 1; //Drv high (originator drives SST bus high to toggle client's response 00194 delay_us (1); 00195 SST2 = 0; 00196 00197 delay_us(T_BIT / 2.0); //delay for half of T_BIT time 00198 00199 #if defined(CPU_C8051F120) 00200 #ifdef FEB64 00201 SFRPAGE = CPT0_PAGE; 00202 #elif defined(TEMP36) 00203 SFRPAGE = CPT1_PAGE; 00204 #endif 00205 #endif 00206 if(SST_ClientResponse2 == 1) { 00207 //if the comparator output is high, then return 1 00208 delay_us(2 * T_H0); 00209 return 1; 00210 } else { 00211 //if the comparator output is low, then return 0 00212 delay_us(2 * T_H0); 00213 return 0; 00214 } 00215 } // Client1 00216 #endif 00217 }
| void SST_DrvHigh | ( | int | SST_LINE | ) |
Drives SST line to a logic "high" or "1", which is defined as driving SST high 3/4 cycle of t_Bit and the rest of it low
00111 { 00112 // Drive high for 0.75 * T_BIT 00113 if(SST_LINE==1) { 00114 SST1 = 1; 00115 delay_us(T_H1); 00116 SST1 = 0; //drive the rest of T_BIT low 00117 delay_us(T_BIT - T_H1); 00118 } 00119 #ifdef MORE_THAN_ONE_LINE 00120 else if(SST_LINE==2) { 00121 SST2 = 1; 00122 delay_us(T_H1); 00123 SST2 = 0; //drive the rest of T_BIT low 00124 delay_us(T_BIT - T_H1); 00125 } 00126 #endif 00127 }
| void SST_DrvLow | ( | int | SST_LINE | ) |
To drive SST line to a logic "low" or "0", which is defined as driving SST high for 1/4 cycle of t_Bit and the rest of it low.
00135 { 00136 // Drive high for 0.25 * T_BIT 00137 if(SST_LINE==1) { 00138 SST1 = 1; 00139 delay_us(T_H0); 00140 SST1 = 0; //drive the rest of T_BIT low 00141 delay_us(T_BIT - T_H0); 00142 } 00143 #ifdef MORE_THAN_ONE_LINE 00144 else if(SST_LINE==2) { 00145 SST2 = 1; 00146 delay_us(T_H0); 00147 SST2 = 0; //drive the rest of T_BIT low 00148 delay_us(T_BIT - T_H0); 00149 } 00150 #endif 00151 }
| void SST_Init | ( | int | SST_LINE | ) |
| unsigned char SST_ReadByte | ( | int | SST_LINE | ) |
Read a single byte from the SST device.
00254 { 00255 unsigned char xdata din = 0; 00256 unsigned char xdata dataReceived = 0; 00257 signed char xdata j = 0; 00258 00259 for(j = 7; j >= 0; j--) { 00260 // Get single bit from comparator 00261 din = SST_DrvClientResponse(SST_LINE); 00262 dataReceived |= (din << j); 00263 } 00264 return dataReceived; 00265 }
| void SST_WriteByte | ( | unsigned char | datByte, | |
| int | SST_LINE | |||
| ) |
Write a single byte to the SST device.
| datByte |
00225 { 00226 //declare local variables 00227 unsigned char xdata toBeDrv = 0; 00228 int xdata i = 0; 00229 00230 for(i = 7; i >= 0; i--) //8bits in 1 byte 00231 { 00232 toBeDrv = (datByte >> i) & 0x1; 00233 if(toBeDrv == 0) //if the bit to be driven is logic 0 00234 { 00235 SST_DrvLow(SST_LINE); 00236 } 00237 else if(toBeDrv == 1) //if the bit to be driven is logic 1 00238 { 00239 SST_DrvHigh(SST_LINE); 00240 } 00241 else //if the bit to be driven is neither 0 nor 1 00242 { 00243 return; //error 00244 } 00245 } 00246 }
1.4.7