3 Copyright (c) 2015 Arduino LLC
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 class PluggableUSBModule {
30 PluggableUSBModule(uint8_t numEps, uint8_t numIfs, uint8_t *epType) :
31 numEndpoints(numEps), numInterfaces(numIfs), endpointType(epType)
35 virtual bool setup(USBSetup& setup) = 0;
36 virtual int getInterface(uint8_t* interfaceCount) = 0;
37 virtual int getDescriptor(USBSetup& setup) = 0;
38 virtual uint8_t getShortName(char *name) { name[0] = 'A'+pluggedInterface; return 1; }
40 uint8_t pluggedInterface;
41 uint8_t pluggedEndpoint;
43 const uint8_t numEndpoints;
44 const uint8_t numInterfaces;
45 const uint8_t *endpointType;
47 PluggableUSBModule *next = NULL;
49 friend class PluggableUSB_;
55 bool plug(PluggableUSBModule *node);
56 int getInterface(uint8_t* interfaceCount);
57 int getDescriptor(USBSetup& setup);
58 bool setup(USBSetup& setup);
59 void getShortName(char *iSerialNum);
64 PluggableUSBModule* rootNode;
67 // Replacement for global singleton.
68 // This function prevents static-initialization-order-fiasco
69 // https://isocpp.org/wiki/faq/ctors#static-init-order-on-first-use
70 PluggableUSB_& PluggableUSB();