mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Fixed formatting
No new code added
This commit is contained in:
parent
5053e8dfae
commit
cbea36f76f
2 changed files with 192 additions and 192 deletions
|
@ -39,13 +39,13 @@ void PrintAddress(uint8_t addr)
|
|||
UsbDeviceAddress adr;
|
||||
adr.devAddress = addr;
|
||||
Serial.print("\r\nADDR:\t");
|
||||
Serial.println(adr.devAddress,HEX);
|
||||
Serial.println(adr.devAddress, HEX);
|
||||
Serial.print("DEV:\t");
|
||||
Serial.println(adr.bmAddress,HEX);
|
||||
Serial.println(adr.bmAddress, HEX);
|
||||
Serial.print("PRNT:\t");
|
||||
Serial.println(adr.bmParent,HEX);
|
||||
Serial.println(adr.bmParent, HEX);
|
||||
Serial.print("HUB:\t");
|
||||
Serial.println(adr.bmHub,HEX);
|
||||
Serial.println(adr.bmHub, HEX);
|
||||
}
|
||||
|
||||
void setup()
|
||||
|
@ -72,17 +72,17 @@ void PrintDescriptors(uint8_t addr)
|
|||
byte num_conf = 0;
|
||||
|
||||
rcode = getdevdescr( (byte)addr, num_conf );
|
||||
if( rcode )
|
||||
if ( rcode )
|
||||
{
|
||||
printProgStr(Gen_Error_str);
|
||||
print_hex( rcode, 8 );
|
||||
}
|
||||
Serial.print("\r\n");
|
||||
|
||||
for (int i=0; i<num_conf; i++)
|
||||
for (int i = 0; i < num_conf; i++)
|
||||
{
|
||||
rcode = getconfdescr( addr, i ); // get configuration descriptor
|
||||
if( rcode )
|
||||
if ( rcode )
|
||||
{
|
||||
printProgStr(Gen_Error_str);
|
||||
print_hex(rcode, 8);
|
||||
|
@ -103,14 +103,14 @@ void loop()
|
|||
{
|
||||
Usb.Task();
|
||||
|
||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||
{
|
||||
//if (millis() >= next_time)
|
||||
{
|
||||
Usb.ForEachUsbDevice(&PrintAllDescriptors);
|
||||
Usb.ForEachUsbDevice(&PrintAllAddresses);
|
||||
|
||||
while( 1 ); //stop
|
||||
while ( 1 ); //stop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,8 +120,8 @@ byte getdevdescr( byte addr, byte &num_conf )
|
|||
USB_DEVICE_DESCRIPTOR buf;
|
||||
byte rcode;
|
||||
rcode = Usb.getDevDescr( addr, 0, 0x12, ( uint8_t *)&buf );
|
||||
if( rcode ) {
|
||||
return( rcode );
|
||||
if ( rcode ) {
|
||||
return ( rcode );
|
||||
}
|
||||
printProgStr(Dev_Header_str);
|
||||
printProgStr(Dev_Length_str);
|
||||
|
@ -153,7 +153,7 @@ byte getdevdescr( byte addr, byte &num_conf )
|
|||
printProgStr(Dev_Nconf_str);
|
||||
print_hex( buf.bNumConfigurations, 8 );
|
||||
num_conf = buf.bNumConfigurations;
|
||||
return( 0 );
|
||||
return ( 0 );
|
||||
}
|
||||
|
||||
void printhubdescr(uint8_t *descrptr, uint8_t addr)
|
||||
|
@ -195,7 +195,7 @@ void printhubdescr(uint8_t *descrptr, uint8_t addr)
|
|||
printProgStr(PSTR("bHubContrCurrent:\t"));
|
||||
Serial.println(pHub->bHubContrCurrent, HEX);
|
||||
|
||||
for (uint8_t i=7; i<len; i++)
|
||||
for (uint8_t i = 7; i < len; i++)
|
||||
print_hex(descrptr[i], 8);
|
||||
|
||||
//for (uint8_t i=1; i<=pHub->bNbrPorts; i++)
|
||||
|
@ -213,22 +213,22 @@ byte getconfdescr( byte addr, byte conf )
|
|||
rcode = Usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length
|
||||
LOBYTE( total_length ) = buf[ 2 ];
|
||||
HIBYTE( total_length ) = buf[ 3 ];
|
||||
if( total_length > 256 ) { //check if total length is larger than buffer
|
||||
if ( total_length > 256 ) { //check if total length is larger than buffer
|
||||
printProgStr(Conf_Trunc_str);
|
||||
total_length = 256;
|
||||
}
|
||||
rcode = Usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor
|
||||
while( buf_ptr < buf + total_length ) { //parsing descriptors
|
||||
while ( buf_ptr < buf + total_length ) { //parsing descriptors
|
||||
descr_length = *( buf_ptr );
|
||||
descr_type = *( buf_ptr + 1 );
|
||||
switch( descr_type ) {
|
||||
case( USB_DESCRIPTOR_CONFIGURATION ):
|
||||
switch ( descr_type ) {
|
||||
case ( USB_DESCRIPTOR_CONFIGURATION ):
|
||||
printconfdescr( buf_ptr );
|
||||
break;
|
||||
case( USB_DESCRIPTOR_INTERFACE ):
|
||||
case ( USB_DESCRIPTOR_INTERFACE ):
|
||||
printintfdescr( buf_ptr );
|
||||
break;
|
||||
case( USB_DESCRIPTOR_ENDPOINT ):
|
||||
case ( USB_DESCRIPTOR_ENDPOINT ):
|
||||
printepdescr( buf_ptr );
|
||||
break;
|
||||
case 0x29:
|
||||
|
@ -247,9 +247,9 @@ byte getconfdescr( byte addr, byte conf )
|
|||
// source: http://www.phanderson.com/arduino/arduino_display.html
|
||||
void print_hex(int v, int num_places)
|
||||
{
|
||||
int mask=0, n, num_nibbles, digit;
|
||||
int mask = 0, n, num_nibbles, digit;
|
||||
|
||||
for (n=1; n<=num_places; n++) {
|
||||
for (n = 1; n <= num_places; n++) {
|
||||
mask = (mask << 1) | 0x0001;
|
||||
}
|
||||
v = v & mask; // truncate v to specified number of places
|
||||
|
@ -259,10 +259,10 @@ void print_hex(int v, int num_places)
|
|||
++num_nibbles;
|
||||
}
|
||||
do {
|
||||
digit = ((v >> (num_nibbles-1) * 4)) & 0x0f;
|
||||
digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f;
|
||||
Serial.print(digit, HEX);
|
||||
}
|
||||
while(--num_nibbles);
|
||||
while (--num_nibbles);
|
||||
}
|
||||
/* function to print configuration descriptor */
|
||||
void printconfdescr( uint8_t* descr_ptr )
|
||||
|
@ -332,7 +332,7 @@ void printunkdescr( uint8_t* descr_ptr )
|
|||
print_hex( *(descr_ptr + 1 ), 8 );
|
||||
printProgStr(Unk_Contents_str);
|
||||
descr_ptr += 2;
|
||||
for( i = 0; i < length; i++ ) {
|
||||
for ( i = 0; i < length; i++ ) {
|
||||
print_hex( *descr_ptr, 8 );
|
||||
descr_ptr++;
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ void printunkdescr( uint8_t* descr_ptr )
|
|||
void printProgStr(const char* str)
|
||||
{
|
||||
char c;
|
||||
if(!str) return;
|
||||
while((c = pgm_read_byte(str++)))
|
||||
if (!str) return;
|
||||
while ((c = pgm_read_byte(str++)))
|
||||
Serial.print(c);
|
||||
}
|
||||
|
|
|
@ -35,13 +35,13 @@ void PrintAddress(uint8_t addr)
|
|||
UsbDeviceAddress adr;
|
||||
adr.devAddress = addr;
|
||||
Serial.print("\r\nADDR:\t");
|
||||
Serial.println(adr.devAddress,HEX);
|
||||
Serial.println(adr.devAddress, HEX);
|
||||
Serial.print("DEV:\t");
|
||||
Serial.println(adr.bmAddress,HEX);
|
||||
Serial.println(adr.bmAddress, HEX);
|
||||
Serial.print("PRNT:\t");
|
||||
Serial.println(adr.bmParent,HEX);
|
||||
Serial.println(adr.bmParent, HEX);
|
||||
Serial.print("HUB:\t");
|
||||
Serial.println(adr.bmHub,HEX);
|
||||
Serial.println(adr.bmHub, HEX);
|
||||
}
|
||||
|
||||
void setup()
|
||||
|
@ -68,17 +68,17 @@ void PrintDescriptors(uint8_t addr)
|
|||
byte num_conf = 0;
|
||||
|
||||
rcode = getdevdescr( (byte)addr, num_conf );
|
||||
if( rcode )
|
||||
if ( rcode )
|
||||
{
|
||||
printProgStr(Gen_Error_str);
|
||||
print_hex( rcode, 8 );
|
||||
}
|
||||
Serial.print("\r\n");
|
||||
|
||||
for (int i=0; i<num_conf; i++)
|
||||
for (int i = 0; i < num_conf; i++)
|
||||
{
|
||||
rcode = getconfdescr( addr, i ); // get configuration descriptor
|
||||
if( rcode )
|
||||
if ( rcode )
|
||||
{
|
||||
printProgStr(Gen_Error_str);
|
||||
print_hex(rcode, 8);
|
||||
|
@ -99,14 +99,14 @@ void loop()
|
|||
{
|
||||
Usb.Task();
|
||||
|
||||
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
|
||||
{
|
||||
if ((millis() - next_time) >= 0L)
|
||||
{
|
||||
Usb.ForEachUsbDevice(&PrintAllDescriptors);
|
||||
Usb.ForEachUsbDevice(&PrintAllAddresses);
|
||||
|
||||
while( 1 ); //stop
|
||||
while ( 1 ); //stop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ byte getdevdescr( byte addr, byte &num_conf )
|
|||
USB_DEVICE_DESCRIPTOR buf;
|
||||
byte rcode;
|
||||
rcode = Usb.getDevDescr( addr, 0, 0x12, ( uint8_t *)&buf );
|
||||
if( rcode ) {
|
||||
return( rcode );
|
||||
if ( rcode ) {
|
||||
return ( rcode );
|
||||
}
|
||||
printProgStr(Dev_Header_str);
|
||||
printProgStr(Dev_Length_str);
|
||||
|
@ -149,7 +149,7 @@ byte getdevdescr( byte addr, byte &num_conf )
|
|||
printProgStr(Dev_Nconf_str);
|
||||
print_hex( buf.bNumConfigurations, 8 );
|
||||
num_conf = buf.bNumConfigurations;
|
||||
return( 0 );
|
||||
return ( 0 );
|
||||
}
|
||||
|
||||
void printhubdescr(uint8_t *descrptr, uint8_t addr)
|
||||
|
@ -191,7 +191,7 @@ void printhubdescr(uint8_t *descrptr, uint8_t addr)
|
|||
printProgStr(PSTR("bHubContrCurrent:\t"));
|
||||
Serial.println(pHub->bHubContrCurrent, HEX);
|
||||
|
||||
for (uint8_t i=7; i<len; i++)
|
||||
for (uint8_t i = 7; i < len; i++)
|
||||
print_hex(descrptr[i], 8);
|
||||
|
||||
//for (uint8_t i=1; i<=pHub->bNbrPorts; i++)
|
||||
|
@ -209,22 +209,22 @@ byte getconfdescr( byte addr, byte conf )
|
|||
rcode = Usb.getConfDescr( addr, 0, 4, conf, buf ); //get total length
|
||||
LOBYTE( total_length ) = buf[ 2 ];
|
||||
HIBYTE( total_length ) = buf[ 3 ];
|
||||
if( total_length > 256 ) { //check if total length is larger than buffer
|
||||
if ( total_length > 256 ) { //check if total length is larger than buffer
|
||||
printProgStr(Conf_Trunc_str);
|
||||
total_length = 256;
|
||||
}
|
||||
rcode = Usb.getConfDescr( addr, 0, total_length, conf, buf ); //get the whole descriptor
|
||||
while( buf_ptr < buf + total_length ) { //parsing descriptors
|
||||
while ( buf_ptr < buf + total_length ) { //parsing descriptors
|
||||
descr_length = *( buf_ptr );
|
||||
descr_type = *( buf_ptr + 1 );
|
||||
switch( descr_type ) {
|
||||
case( USB_DESCRIPTOR_CONFIGURATION ):
|
||||
switch ( descr_type ) {
|
||||
case ( USB_DESCRIPTOR_CONFIGURATION ):
|
||||
printconfdescr( buf_ptr );
|
||||
break;
|
||||
case( USB_DESCRIPTOR_INTERFACE ):
|
||||
case ( USB_DESCRIPTOR_INTERFACE ):
|
||||
printintfdescr( buf_ptr );
|
||||
break;
|
||||
case( USB_DESCRIPTOR_ENDPOINT ):
|
||||
case ( USB_DESCRIPTOR_ENDPOINT ):
|
||||
printepdescr( buf_ptr );
|
||||
break;
|
||||
case 0x29:
|
||||
|
@ -243,9 +243,9 @@ byte getconfdescr( byte addr, byte conf )
|
|||
// source: http://www.phanderson.com/arduino/arduino_display.html
|
||||
void print_hex(int v, int num_places)
|
||||
{
|
||||
int mask=0, n, num_nibbles, digit;
|
||||
int mask = 0, n, num_nibbles, digit;
|
||||
|
||||
for (n=1; n<=num_places; n++) {
|
||||
for (n = 1; n <= num_places; n++) {
|
||||
mask = (mask << 1) | 0x0001;
|
||||
}
|
||||
v = v & mask; // truncate v to specified number of places
|
||||
|
@ -255,10 +255,10 @@ void print_hex(int v, int num_places)
|
|||
++num_nibbles;
|
||||
}
|
||||
do {
|
||||
digit = ((v >> (num_nibbles-1) * 4)) & 0x0f;
|
||||
digit = ((v >> (num_nibbles - 1) * 4)) & 0x0f;
|
||||
Serial.print(digit, HEX);
|
||||
}
|
||||
while(--num_nibbles);
|
||||
while (--num_nibbles);
|
||||
}
|
||||
/* function to print configuration descriptor */
|
||||
void printconfdescr( uint8_t* descr_ptr )
|
||||
|
@ -328,7 +328,7 @@ void printunkdescr( uint8_t* descr_ptr )
|
|||
print_hex( *(descr_ptr + 1 ), 8 );
|
||||
printProgStr(Unk_Contents_str);
|
||||
descr_ptr += 2;
|
||||
for( i = 0; i < length; i++ ) {
|
||||
for ( i = 0; i < length; i++ ) {
|
||||
print_hex( *descr_ptr, 8 );
|
||||
descr_ptr++;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ void printunkdescr( uint8_t* descr_ptr )
|
|||
void printProgStr(const char* str)
|
||||
{
|
||||
char c;
|
||||
if(!str) return;
|
||||
while((c = pgm_read_byte(str++)))
|
||||
if (!str) return;
|
||||
while ((c = pgm_read_byte(str++)))
|
||||
Serial.print(c);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue