#include "parity.h"

void calculate_parity_bits(uint8_t nibble, uint8_t* p0, uint8_t* p1, uint8_t* p2) {
    // Extract each data bit
    uint8_t d0 = (nibble >> 0) & 1;
    uint8_t d1 = (nibble >> 1) & 1;
    uint8_t d2 = (nibble >> 2) & 1;
    uint8_t d3 = (nibble >> 3) & 1;
    
    // Parity bits as per assignment examples
    *p0 = d0 ^ d1 ^ d2;  // Circle with d0,d1,d2
    *p1 = d0 ^ d1 ^ d3;  // Circle with d0,d1,d3
    *p2 = d0 ^ d2 ^ d3;  // Circle with d0,d2,d3
}
