Changeset 72 for webserver/example/EnergyMeters/Source
- Timestamp:
- 10/23/10 12:36:15 (14 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
r71 r72 929 929 { 930 930 931 unsigned int baud = 57600;931 unsigned int baud = 2400; 932 932 unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud); 933 933 … … 1203 1203 ) 1204 1204 { 1205 unsigned char currentChar; 1206 unsigned char conversionError = 0; 1205 1207 1206 1208 unsigned char x; 1207 1209 int resultValue = 0; /* initial value */ 1208 1210 unsigned char round = 0; /* which digit? 0 = LSB */ 1209 unsigned charcurrentCharValue;1211 int currentCharValue; 1210 1212 1211 1213 /* go through the bytes backwards (least significant to most significant) */ 1212 1214 for (x = lastSrcByte; x >= firstSrcByte; x--) 1213 1215 { 1214 1215 currentCharValue = (srcDataStart[x]) - 0x30; 1216 currentChar = srcDataStart[x]; 1217 if ((currentChar < 0x30) || (currentChar > 0x46)) 1218 { 1219 conversionError = 1; 1220 } 1221 else if (currentChar <= 0x39) 1222 { 1223 // 0x0 to 0x9 1224 currentCharValue = (srcDataStart[x]) - 0x30; 1225 } 1226 else 1227 { 1228 // 0xA to 0xF 1229 currentCharValue = 0xA + ((srcDataStart[x]) - 0x41); 1230 } 1216 1231 resultValue = resultValue + (currentCharValue << (4 * round)); 1217 1232 1218 1233 round++; 1219 1234 } /* for */ 1235 1236 /* if a conversion error occurred, nullify the result */ 1237 if (conversionError == 1) 1238 { 1239 resultValue = 0xFFFF; 1240 } 1220 1241 1221 1242 return resultValue; webserver/example/EnergyMeters/Source/serial.c
r37 r72 224 224 225 225 226 unsigned int baud = 57600;226 unsigned int baud = 2400; 227 227 unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud); 228 228