Mercurial > louis > kiibohd-controller
diff Debug/print/print.c @ 175:c70f641581b5
McHCK USB WORKS!!
- McHCK uses FLL instead of the PLL for USB (startup, not usb init)
- Added optional debug for the pjrc USB module
- Cleaned up compiler flags
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Tue, 15 Jul 2014 00:28:12 -0700 |
parents | 85d74e5e1a95 |
children | 58cfcb7bac88 |
line wrap: on
line diff
--- a/Debug/print/print.c Mon Jun 30 23:52:24 2014 -0700 +++ b/Debug/print/print.c Tue Jul 15 00:28:12 2014 -0700 @@ -122,6 +122,20 @@ dPrintStr( tmpStr ); } +void printHex32_op( uint32_t in, uint8_t op ) +{ + // With an op of 1, the max number of characters is 6 + 1 for null + // e.g. "0xFFFF\0" + // op 2 and 4 require fewer characters (2+1 and 4+1 respectively) + char tmpStr[7]; + + // Convert number + hex32ToStr_op( in, tmpStr, op ); + + // Print number + dPrintStr( tmpStr ); +} + // String Functions @@ -223,6 +237,41 @@ } +void hex32ToStr_op( uint32_t in, char* out, uint8_t op ) +{ + // Position container + uint32_t pos = 0; + + // Evaluate through digits as hex + do + { + uint32_t cur = in % 16; + out[pos++] = cur + (( cur < 10 ) ? '0' : 'A' - 10); + } + while ( (in /= 16) > 0 ); + + // Output formatting options + switch ( op ) + { + case 1: // Add 0x + out[pos++] = 'x'; + out[pos++] = '0'; + break; + case 2: // 8-bit padding + case 4: // 16-bit padding + while ( pos < op ) + out[pos++] = '0'; + break; + } + + // Append null + out[pos] = '\0'; + + // Reverse the string to the correct order + revsStr(out); +} + + void revsStr( char* in ) { // Iterators