1616#error MIDIUSB can only be used with an USB MCU.
1717#endif
1818
19- #if defined(USBCON)
20-
2119typedef struct
2220{
2321 uint8_t header;
@@ -29,52 +27,56 @@ typedef struct
2927#if defined(ARDUINO_ARCH_AVR)
3028
3129#include " PluggableUSB.h"
30+
3231#define EPTYPE_DESCRIPTOR_SIZE uint8_t
33- #define EP_TYPE_BULK_OUT_MIDI EP_TYPE_BULK_OUT
34- #define EP_TYPE_BULK_IN_MIDI EP_TYPE_BULK_IN
35- #define MIDI_BUFFER_SIZE 64
32+ #define EP_TYPE_BULK_IN_MIDI USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_IN( 0 );
33+ #define EP_TYPE_BULK_OUT_MIDI USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_OUT( 0 );
34+ #define MIDI_BUFFER_SIZE USB_EP_SIZE
3635#define is_write_enabled (x ) (1 )
3736
38- #else
37+ #elif defined(ARDUINO_ARCH_SAM)
3938
4039#include " USB/PluggableUSB.h"
41- #define EPTYPE_DESCRIPTOR_SIZE uint32_t
42- #define MIDI_BUFFER_SIZE 512
43-
44- #if defined(ARDUINO_ARCH_SAM)
45- #define USB_SendControl USBD_SendControl
46- #define USB_Available USBD_Available
47- #define USB_Recv USBD_Recv
48- #define USB_Send USBD_Send
49- #define USB_Flush USBD_Flush
50- #define is_write_enabled (x ) Is_udd_write_enabled(x)
5140
41+ #define EPTYPE_DESCRIPTOR_SIZE uint32_t
5242#define EP_TYPE_BULK_IN_MIDI (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \
5343 UOTGHS_DEVEPTCFG_EPDIR_IN | \
5444 UOTGHS_DEVEPTCFG_EPTYPE_BLK | \
5545 UOTGHS_DEVEPTCFG_EPBK_1_BANK | \
5646 UOTGHS_DEVEPTCFG_NBTRANS_1_TRANS | \
5747 UOTGHS_DEVEPTCFG_ALLOC)
58-
5948#define EP_TYPE_BULK_OUT_MIDI (UOTGHS_DEVEPTCFG_EPSIZE_512_BYTE | \
6049 UOTGHS_DEVEPTCFG_EPTYPE_BLK | \
6150 UOTGHS_DEVEPTCFG_EPBK_1_BANK | \
6251 UOTGHS_DEVEPTCFG_NBTRANS_1_TRANS | \
6352 UOTGHS_DEVEPTCFG_ALLOC)
64- #endif
53+ #define MIDI_BUFFER_SIZE EPX_SIZE
54+ #define USB_SendControl USBD_SendControl
55+ #define USB_Available USBD_Available
56+ #define USB_Recv USBD_Recv
57+ #define USB_Send USBD_Send
58+ #define USB_Flush USBD_Flush
59+ #define is_write_enabled (x ) Is_udd_write_enabled(x)
60+
61+ #elif defined(ARDUINO_ARCH_SAMD)
6562
66- #if defined(__SAMD21G18A__)
67- #define USB_SendControl USBDevice.sendControl
68- #define USB_Available USBDevice.available
69- #define USB_Recv USBDevice.recv
70- #define USB_Send USBDevice.send
71- #define USB_Flush USBDevice.flush
72- #define is_write_enabled (x ) (1 )
63+ #include " USB/PluggableUSB.h"
7364
65+ #define EPTYPE_DESCRIPTOR_SIZE uint32_t
7466#define EP_TYPE_BULK_IN_MIDI USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_IN(0 );
7567#define EP_TYPE_BULK_OUT_MIDI USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_OUT(0 );
68+ #define MIDI_BUFFER_SIZE EPX_SIZE
69+ #define USB_SendControl USBDevice.sendControl
70+ #define USB_Available USBDevice.available
71+ #define USB_Recv USBDevice.recv
72+ #define USB_Send USBDevice.send
73+ #define USB_Flush USBDevice.flush
74+ #define is_write_enabled (x ) (1 )
75+
76+ #else
77+
78+ #error "Unsupported architecture"
7679
77- #endif
7880#endif
7981
8082#define MIDI_AUDIO 0x01
@@ -220,5 +222,4 @@ class MIDI_ : public PluggableUSBModule
220222};
221223extern MIDI_ MidiUSB;
222224
223- #endif /* USBCON */
224- #endif /* MIDIUSB_h */
225+ #endif /* MIDIUSB_h */
0 commit comments