source: ReferenceDesigns/w3_802.11/sysgen/wlan_phy_rx_pmd/util/check_80211_fcs.m

Last change on this file was 3759, checked in by chunter, 10 years ago

v.95 checkin

File size: 995 bytes
Line 
1function no_errors = check_80211_fcs(thePacketBytes)
2%Based on the C code example at:
3%http://www.netrino.com/Embedded-Systems/How-To/CRC-Calculation-C-Code
4%Uses slightly modified version of CRC-32:
5% No output XOR
6% No bit-order swapping on message or digest bytes
7
8%%% Modified from WARP OFDM ref design version, to comply with
9% normal CRC32 (no idea why I changed from CRC32 for the WARP PHY...)
10
11CRCPolynomial = hex2dec('04c11db7');
12CRC_Table = CRC_table_gen(CRCPolynomial, 32);
13
14init_crc = hex2dec('ffffffff');
15myData = thePacketBytes;
16%de2bi(49,'left-msb',8))
17crc_accum = init_crc;
18for n=1:length(myData)
19    x = bitshift(crc_accum,-24,32);
20%CRC32 would swap bit order here:
21    x = bitxor(x, bi2de( de2bi(myData(n),'left-msb',8)));
22%   x = bitxor(x, myData(n));
23    x = bitand(x,hex2dec('ff'));
24    crc_accum = bitxor(bitshift(crc_accum,8,32),CRC_Table(x+1));
25end
26
27CRC32 = crc_accum;
28
29
30if(CRC32 == hex2dec('C704DD7B'))
31    no_errors = 1;
32else
33    no_errors = 0;
34end
Note: See TracBrowser for help on using the repository browser.