arduino-libraries / Arduino_USBHostMbed5

Apache License 2.0
4 stars 11 forks source link

Add parseConfigEntry to IUSBEnumerator, call from parseConfDescr() #44

Closed AndrewCapon closed 1 year ago

AndrewCapon commented 1 year ago

Extend IUSBEnumerator to allow driver to get at configuration data whilst enumerating.

github-actions[bot] commented 1 year ago

Memory usage change @ 16be69ec348c2fe59cf1754f524ada214e65dba6

Board flash % RAM for global variables %
arduino:mbed_giga:giga :small_red_triangle: +8 - +72 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_opta:opta :small_red_triangle: +8 - +72 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
Click for full report table Board|`examples/DirList`
flash|%|`examples/DirList`
RAM for global variables|%|`examples/FileRead`
flash|%|`examples/FileRead`
RAM for global variables|%|`examples/FileWrite`
flash|%|`examples/FileWrite`
RAM for global variables|%|`examples/OptaDirList`
flash|%|`examples/OptaDirList`
RAM for global variables|%|`examples/PortentaOTA`
flash|%|`examples/PortentaOTA`
RAM for global variables|% -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|- `arduino:mbed_giga:giga`|72|0.0|0|0.0|8|0.0|0|0.0|72|0.0|0|0.0|72|0.0|0|0.0|8|0.0|0|0.0 `arduino:mbed_opta:opta`|72|0.0|0|0.0|8|0.0|0|0.0|72|0.0|0|0.0|8|0.0|0|0.0|72|0.0|0|0.0 `arduino:mbed_portenta:envie_m7`|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A
Click for full report CSV ``` Board,examples/DirList
flash,%,examples/DirList
RAM for global variables,%,examples/FileRead
flash,%,examples/FileRead
RAM for global variables,%,examples/FileWrite
flash,%,examples/FileWrite
RAM for global variables,%,examples/OptaDirList
flash,%,examples/OptaDirList
RAM for global variables,%,examples/PortentaOTA
flash,%,examples/PortentaOTA
RAM for global variables,% arduino:mbed_giga:giga,72,0.0,0,0.0,8,0.0,0,0.0,72,0.0,0,0.0,72,0.0,0,0.0,8,0.0,0,0.0 arduino:mbed_opta:opta,72,0.0,0,0.0,8,0.0,0,0.0,72,0.0,0,0.0,8,0.0,0,0.0,72,0.0,0,0.0 arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A ```
facchinm commented 1 year ago

The patch looks good, can you also provide an example on how to use parseConfigEntry() in a derived class?

AndrewCapon commented 1 year ago

Hi,

This is basically just logging code at the moment:

void USBHostMultiMidi::parseConfigEntry(uint8_t type, uint8_t sub_type, uint8_t *data, uint32_t len)
{
  if(type == 0x24) // class-specific interface descriptor
  {
    // Midi jack
    switch (sub_type)
    {
      case 0x01: // Header
        USB_DBG("Midi Header V%u.%u", data[1], data[0]);
      break;

      case 0x02: // Midi in jack
      {
        uint8_t uJackType = data[0];
        uint8_t uJackId   = data[1];

        USB_DBG("%s Midi in jack [%u]", uJackType == 1 ? "Embedded" : "External", uJackId);
      }
      break;

      case 0x03: // Midi out jack
      {
        uint8_t uJackType = data[0];
        uint8_t uJackId   = data[1];

        USB_DBG("%s Midi out jack [%u]", uJackType== 1 ? "Embedded" : "External", uJackId);
        uint8_t uNumPins = data[2];
        for(uint uPin = 0; uPin < uNumPins; uPin++)
        {
          uint8_t *uP = &data[3];
          uint8_t uSource = *uP++;
          uint8_t uSourcePin = *uP++;
          USB_DBG("  Pin[%u] source = (%u, %u)", uPin, uSource, uSourcePin);
        }
      }
      break;
    }
  }  
}

so it will enable me to look at the jack definition for a midi device and link them all together while it is being enumerated:

[USB_DBG: src/USBHostMultiMidi.cpp:105]Midi Header V1.0
[USB_DBG: src/USBHostMultiMidi.cpp:113]Embedded Midi in jack [1]
[USB_DBG: src/USBHostMultiMidi.cpp:113]External Midi in jack [2]
[USB_DBG: src/USBHostMultiMidi.cpp:122]Embedded Midi out jack [3]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (2, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:122]External Midi out jack [4]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (1, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:113]Embedded Midi in jack [5]
[USB_DBG: src/USBHostMultiMidi.cpp:113]External Midi in jack [6]
[USB_DBG: src/USBHostMultiMidi.cpp:122]Embedded Midi out jack [7]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (6, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:122]External Midi out jack [8]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (5, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:113]Embedded Midi in jack [9]
[USB_DBG: src/USBHostMultiMidi.cpp:113]External Midi in jack [10]
[USB_DBG: src/USBHostMultiMidi.cpp:122]Embedded Midi out jack [11]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (10, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:122]External Midi out jack [12]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (9, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:113]Embedded Midi in jack [13]
[USB_DBG: src/USBHostMultiMidi.cpp:113]External Midi in jack [14]
[USB_DBG: src/USBHostMultiMidi.cpp:122]Embedded Midi out jack [15]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (14, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:122]External Midi out jack [16]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (13, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:113]Embedded Midi in jack [17]
[USB_DBG: src/USBHostMultiMidi.cpp:113]External Midi in jack [18]
[USB_DBG: src/USBHostMultiMidi.cpp:122]Embedded Midi out jack [19]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (18, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:122]External Midi out jack [20]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (17, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:113]Embedded Midi in jack [21]
[USB_DBG: src/USBHostMultiMidi.cpp:113]External Midi in jack [22]
[USB_DBG: src/USBHostMultiMidi.cpp:122]Embedded Midi out jack [23]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (22, 1)
[USB_DBG: src/USBHostMultiMidi.cpp:122]External Midi out jack [24]
[USB_DBG: src/USBHostMultiMidi.cpp:129]  Pin[0] source = (21, 1)
AndrewCapon commented 1 year ago

parseConfigEntry() can be undeclared?

Yes I did it like that so it would not effect any existing code.