+// BSD shift checksum 8bit version
+static uint16_t calcBSDchecksum8( uint8_t* bytes, uint8_t len, uint32_t mask){
+ uint16_t sum = 0;
+ for(uint8_t i = 0; i < len; i++){
+ sum = ((sum & 0xFF) >> 1) | ((sum & 0x1) << 7); // rotate accumulator
+ sum += bytes[i]; // add next byte
+ sum &= 0xFF; //
+ }
+ sum &= mask;
+ return sum;
+}
+// BSD shift checksum 4bit version
+static uint16_t calcBSDchecksum4( uint8_t* bytes, uint8_t len, uint32_t mask){
+ uint16_t sum = 0;
+ for(uint8_t i = 0; i < len; i++){
+ sum = ((sum & 0xF) >> 1) | ((sum & 0x1) << 3); // rotate accumulator
+ sum += NIBBLE_HIGH(bytes[i]); // add high nibble
+ sum &= 0xF; //
+ sum = ((sum & 0xF) >> 1) | ((sum & 0x1) << 3); // rotate accumulator
+ sum += NIBBLE_LOW(bytes[i]); // add low nibble
+ sum &= 0xF; //
+ }
+ sum &= mask;
+ return sum;
+}
+
+
+