Skip to content

Instantly share code, notes, and snippets.

@jamsesso
Last active August 29, 2015 14:10
Show Gist options
  • Save jamsesso/fb0b2b5b3c535b38687d to your computer and use it in GitHub Desktop.
Save jamsesso/fb0b2b5b3c535b38687d to your computer and use it in GitHub Desktop.
void outchar(char ch) {
volatile int* JTAG_UART = (int*) 0x00008840;
*JTAG_UART = ch; // Write char to display.
}
char bin2hex(char hex) {
hex &= 0x0F; // Mask last 4 bits.
return hex <= 9 ? hex + '0' : hex - 10 + 'A';
}
void outhex(char n) {
char msn = n >> 4; // put first 4 bits into msn (most significant nibble)
outchar(bin2hex(msn));
outchar(bin2hex(n));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment