This commit is contained in:
Rens Pastoor
2025-05-27 22:41:46 +02:00
parent d141296aea
commit 11b391b8a1
416 changed files with 25232 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#include "encode.h"
#include "parity.h"
#include <stdint.h>
#include <stddef.h>
void encode_get_nibbles(uint8_t value, uint8_t* high, uint8_t* low) {
if (high == NULL || low == NULL) {
return;
}
*high = (value >> 4) & 0x0F; // bits 7-4
*low = value & 0x0F; // bits 3-0
}
void encode_value(uint8_t input, uint8_t* high, uint8_t* low) {
if (high == NULL || low == NULL) {
return;
}
uint8_t nibble_high, nibble_low;
// Splits input-byte in twee nibbles
encode_get_nibbles(input, &nibble_high, &nibble_low);
// Voeg pariteitsbits toe
*high = add_parity(nibble_high);
*low = add_parity(nibble_low);
}