Question : Convert C into vb

Im trying to convert a CRC into a vb algorithm. There are a couple of syntax thats i ahve not seen or used before " ^=" if anyone has ideas please let me know.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
* Update the CRC for transmitted and received data using the CCITT 16bit
 * algorithm (X^16 + X^12 + X^5 + 1).
 *
 * \returns updated crc16
 * \param crc currrent crc value
 * \param data next byte that should be included into the crc16
 */
uint16_t crc_ccitt_update( uint16_t crc, uint8_t data )
{
    data ^= crc & 0xFF;
    data ^= data << 4;
    
    uint16_t ret_val = ((((uint16_t)data << 8) | ((crc & 0xFF00) >> 8))
                        ^ (uint8_t)(data >> 4)
                        ^ ((uint16_t)data << 3));
    return ret_val;
}

Answer : Convert C into vb

cmdolcet:

This should work for you.

AielloJ
1:
2:
3:
4:
5:
6:
7:
Private Function crc_ccitt_update(crc As uint16_t, data As uint8_t) As uint16_t
	data = data Xor crc And &Hff
	data = data Xor data << 4

	Dim ret_val As uint16_t = (((DirectCast(data, uint16_t) << 8) Or ((crc And &Hff00) >> 8)) Xor DirectCast(data >> 4, uint8_t) Xor (DirectCast(data, uint16_t) << 3))
	Return ret_val
End Function
Random Solutions  
 
programming4us programming4us