Last change
on this file was
1714,
checked in by murphpo, 12 years ago
|
cleaning up PHY directory; coded PHY is now primary OFDM_MIMO model
|
File size:
800 bytes
|
Line | |
---|
1 | function crcOut = calcCRC16(thePacketBytes) |
---|
2 | %Based on the C code example at: |
---|
3 | %http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code |
---|
4 | %Uses CRC-CCIT standard checksum polynomial/formatting |
---|
5 | |
---|
6 | CRCPolynomial = hex2dec('1021'); |
---|
7 | CRC_Table = CRC_table_gen(CRCPolynomial, 16); |
---|
8 | |
---|
9 | %init_crc = hex2dec('FFFF'); |
---|
10 | init_crc = 0; |
---|
11 | myData = thePacketBytes; |
---|
12 | |
---|
13 | crc_accum = init_crc; |
---|
14 | for n=1:length(myData) |
---|
15 | x = bitshift(crc_accum,-8,16); |
---|
16 | x = bitxor(x, myData(n)); |
---|
17 | x = bitand(x,hex2dec('ff')); |
---|
18 | crc_accum = bitxor(bitshift(crc_accum,8,16),CRC_Table(x+1)); |
---|
19 | crc_tracking(n) = crc_accum; |
---|
20 | end |
---|
21 | |
---|
22 | TxCRC16 = bitand(crc_accum, hex2dec('ffff')); |
---|
23 | |
---|
24 | TxCRC16_b1 = bitand(bitshift(TxCRC16,-8,32),hex2dec('ff')); |
---|
25 | TxCRC16_b0 = bitand(TxCRC16,hex2dec('ff')); |
---|
26 | |
---|
27 | crcOut = [TxCRC16_b1 TxCRC16_b0]; |
---|
Note: See
TracBrowser
for help on using the repository browser.