2024-07-11 08:56:52 +02:00
|
|
|
#include <kernel/tty.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <strlib.h>
|
|
|
|
|
2024-07-16 22:51:41 +02:00
|
|
|
void print_hex_digit(uint8_t digit)
|
|
|
|
{
|
2024-07-11 08:56:52 +02:00
|
|
|
digit = digit & 0xf;
|
|
|
|
if (digit < 0xA) {
|
|
|
|
terminal_putchar(digit + 0x30);
|
|
|
|
} else {
|
|
|
|
terminal_putchar(digit + 0x41 - 0xA);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-16 22:51:41 +02:00
|
|
|
void print_hex_byte(uint8_t byte)
|
|
|
|
{
|
2024-07-11 08:56:52 +02:00
|
|
|
int upper = byte >> 4;
|
|
|
|
int lower = byte & 0x0F;
|
|
|
|
|
|
|
|
print_hex_digit(upper);
|
|
|
|
print_hex_digit(lower);
|
|
|
|
}
|
2024-07-16 22:51:41 +02:00
|
|
|
|
|
|
|
void print_hex_bytes(void* bytes, size_t len)
|
|
|
|
{
|
|
|
|
uint8_t* value = bytes;
|
|
|
|
for (size_t i = len; i > 0; i--) {
|
|
|
|
print_hex_byte(value[i - 1]);
|
|
|
|
}
|
|
|
|
}
|