Hi,
I am trying to write the code below in sensor controller studio for MS5837 pressure sensor.
However, I cannot find a way to do BITWISE AND(&) and EXCLUSIVE(^) in sensor controller studio.
Can you help me how to do bitwise and and exclusive in sensor controller studio?
If it is possible to do these operation with bitwise shift, could you be more specific in the explanation?
Thank you!
uint8_t crc4(uint16_t n_prom[]) {
uint16_t n_rem = 0;
n_prom[0] = ((n_prom[0]) & 0x0FFF);
n_prom[7] = 0;
for ( i = 0 ; i < 16; i++ ) {
if ( i%2 == 1 ) {
n_rem ^= (uint16_t)((n_prom[i>>1]) & 0x00FF);
} else {
n_rem ^= (uint16_t)(n_prom[i>>1] >> 8);
}
for ( n_bit = 8 ; n_bit > 0 ; n_bit-- ) {
if ( n_rem & 0x8000 ) {
n_rem = (n_rem << 1) ^ 0x3000;
} else {
n_rem = (n_rem << 1);
}
}
}
n_rem = ((n_rem >> 12) & 0x000F);
return n_rem ^ 0x00;
}