annotate network/test_avr.h @ 108:b523761181f5 avr-http

Add some replacement functions for testing
author Matt Johnston <matt@ucc.asn.au>
date Sat, 15 Sep 2012 21:43:15 +0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
108
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 #ifndef _TEST_AVR_H
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 #define _TEST_AVR_H
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 #include <stdint.h>
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 #include <unistd.h>
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 static uint16_t _crc_ccitt_update (uint16_t crc, uint8_t data)
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 {
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 data ^= crc & 0xff;
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 data ^= data << 4;
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 return ((((uint16_t)data << 8) | ((crc >> 8) & 0xff)) ^ (uint8_t)(data >> 4)
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 ^ ((uint16_t)data << 3));
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 }
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 static void _delay_ms (double __ms)
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 {
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 usleep(__ms*1000);
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 }
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 static
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23
b523761181f5 Add some replacement functions for testing
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 #endif // _TEST_AVR_H