Commit 5113d83c by triazo

Give printing functions to half word, byte

parent 3e410fcd
Showing with 18 additions and 0 deletions
...@@ -39,6 +39,22 @@ void serial_writestring(char* s) ...@@ -39,6 +39,22 @@ void serial_writestring(char* s)
} }
const char* hexchars = "0123456789abcdef"; const char* hexchars = "0123456789abcdef";
void serial_hexbyte(uint8_t x)
{
for (int i = 1; i >= 0; i--)
{
serial_writechar(hexchars[x>>i*4&0xf]);
}
}
void serial_hexhword(uint16_t x)
{
for (int i = 3; i >= 0; i--)
{
serial_writechar(hexchars[x>>i*4&0xf]);
}
}
void serial_hexword(uint32_t x) void serial_hexword(uint32_t x)
{ {
for (int i = 7; i >= 0; i--) for (int i = 7; i >= 0; i--)
......
...@@ -21,6 +21,8 @@ void serial_writechar(char a); ...@@ -21,6 +21,8 @@ void serial_writechar(char a);
void serial_writestring(char* s); void serial_writestring(char* s);
// Function to write a 4 byte word toserial in hex // Function to write a 4 byte word toserial in hex
void serial_hexbyte(uint8_t x);
void serial_hexhword(uint16_t x);
void serial_hexword(uint32_t x); void serial_hexword(uint32_t x);
void serial_hexqword(uint64_t x); void serial_hexqword(uint64_t x);
void serial_hexstring(void* s, uint32_t n); void serial_hexstring(void* s, uint32_t n);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment