Browse code

- added crcitt_string_ex to enable computing for multiple strings

Tomas Mandys authored on 16/02/2006 15:51:59
Showing 2 changed files
... ...
@@ -205,12 +205,8 @@ unsigned short int crc_16_tab[] = { /* CRC polynomial 0xA001 */
205 205
 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040,
206 206
 };
207 207
 
208
-unsigned short crcitt_string( char *s, int len )
209
-{
210
-	register unsigned short ccitt;
211
-	
212
-	ccitt = 0xFFFF;
213
-
208
+unsigned short crcitt_string_ex( char *s, int len, register unsigned short ccitt) {
209
+	ccitt = ~ccitt;
214 210
 	while( len ) {
215 211
 		ccitt = UPDCIT(*s, ccitt);
216 212
 		s++; len--;
... ...
@@ -218,6 +214,11 @@ unsigned short crcitt_string( char *s, int len )
218 218
 	return ~ccitt;
219 219
 }
220 220
 
221
+unsigned short crcitt_string( char *s, int len )
222
+{
223
+	return crcitt_string_ex(s, len, 0);
224
+}
225
+
221 226
 void crcitt_string_array( char *dst, str src[], int size )
222 227
 {
223 228
 	register int i;
... ...
@@ -11,6 +11,8 @@ extern unsigned long int crc_32_tab[];
11 11
 extern unsigned short int ccitt_tab[];
12 12
 extern unsigned short int crc_16_tab[];
13 13
 
14
+
15
+unsigned short crcitt_string_ex( char *s, int len, register unsigned short ccitt);
14 16
 unsigned short crcitt_string( char *s, int len );
15 17
 void crcitt_string_array( char *dst, str src[], int size );
16 18