+ if (rowP != pType) return FALSE;
+ }
+ return TRUE;
+}
+
+// EM word parity test.
+// 9*5 = 45 bits in total
+// 012345678|r1
+// 012345678|r2
+// 012345678|r3
+// 012345678|r4
+// ------------
+//c012345678| 0
+// |- must be zero
+
+bool EMwordparitytest(uint8_t *bits){
+
+ // last row/col parity must be 0
+ if (bits[44] != 0 ) return FALSE;
+
+ // col parity check
+ uint8_t c1 = bytebits_to_byte(bits, 8) ^ bytebits_to_byte(bits+9, 8) ^ bytebits_to_byte(bits+18, 8) ^ bytebits_to_byte(bits+27, 8);
+ uint8_t c2 = bytebits_to_byte(bits+36, 8);
+ if ( c1 != c2 ) return FALSE;
+
+ // row parity check
+ uint8_t rowP = 0;
+ for ( uint8_t i = 0; i < 36; ++i ) {
+
+ rowP ^= bits[i];
+ if ( i>0 && (i % 9) == 0) {
+
+ if ( rowP != EVEN )
+ return FALSE;
+
+ rowP = 0;
+ }