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
This commit is contained in:
Jacob Alexander 2014-07-15 00:28:12 -07:00
parent f9e1600b28
commit 54c11ebd07
12 changed files with 128 additions and 58 deletions

View file

@ -122,6 +122,20 @@ void printHex_op( uint16_t in, uint8_t op )
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 hexToStr_op( uint16_t in, char* out, uint8_t op )
}
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

View file

@ -93,25 +93,28 @@ void printstrs( char* first, ... );
// Printing numbers
#define printHex(hex) printHex_op(hex, 1)
#define printHex(hex) printHex_op(hex, 1)
#define printHex32(hex) printHex32_op(hex, 1)
void printInt8 ( uint8_t in );
void printInt16 ( uint16_t in );
void printInt32 ( uint32_t in );
void printHex_op( uint16_t in, uint8_t op );
void printInt8 ( uint8_t in );
void printInt16 ( uint16_t in );
void printInt32 ( uint32_t in );
void printHex_op ( uint16_t in, uint8_t op );
void printHex32_op( uint32_t in, uint8_t op );
// String Functions
#define hexToStr(hex, out) hexToStr_op(hex, out, 1)
void int8ToStr ( uint8_t in, char* out );
void int16ToStr ( uint16_t in, char* out );
void int32ToStr ( uint32_t in, char* out );
void hexToStr_op( uint16_t in, char* out, uint8_t op );
void revsStr ( char* in );
uint16_t lenStr ( char* in );
int16_t eqStr ( char* str1, char* str2 ); // Returns -1 if identical, last character of str1 comparison (0 if str1 is like str2)
int decToInt ( char* in ); // Returns the int representation of a string
void int8ToStr ( uint8_t in, char* out );
void int16ToStr ( uint16_t in, char* out );
void int32ToStr ( uint32_t in, char* out );
void hexToStr_op ( uint16_t in, char* out, uint8_t op );
void hex32ToStr_op( uint32_t in, char* out, uint8_t op );
void revsStr ( char* in );
uint16_t lenStr ( char* in );
int16_t eqStr ( char* str1, char* str2 ); // Returns -1 if identical, last character of str1 comparison (0 if str1 is like str2)
int decToInt ( char* in ); // Returns the int representation of a string
#endif