Go Down

Topic: Arduino Due libraries (official and 3rd party) (Read 258371 times) previous topic - next topic

ZackT86

Im using get.modifiers with a keyboard and everytime I press a key the output is 0 and not the proper value. Im new please help!!

Santechbox

I need arduino due library for connecting multiple TCA9548A 8 channel I2C expander.  Does anyone have connected three TCA9548A in a single I2C line of Arduino due?  Please help with this.

MartinZ

#152
Mar 31, 2019, 06:10 pm Last Edit: Mar 31, 2019, 10:30 pm by MartinZ Reason: new information after done some research.
Hi ,

finally i got my "Yamaha THR10" (guitar amp, that can be configured via MIDI-SysEx) working with USBHost Library (arduino-libraries/USBHost)
in conjunction with the
" bbx10/USBH-Midi branch Due"-library

on "Arduino Due", but there were several problems to solve before:


Concerning library (arduino-libraries/USBHost):

USB-Enumeration works only, if Debug-outputs are enabled in USBHost.h

Code: [Select]

#define TRACE_USBHOST(x) x
//#define TRACE_USBHOST(x)


otherwise device is not detected.

Don't ask me why…
Is it perhaps a timing problem, that is solved when a "printf" delays process at the right time?
 (Edit: in fact there are two places in USB.cpp, where short delays are necessary to get it work.
          You can leave TRACE_USBHOST(x) x   like it was, if you add that two delays.
          Details at the end of this message!)

Has anyone had the same Problem with (native) USBHost - Library for  Due?


Issues concerning library (bbx10/USBH-Midi branch Due):

Adding an "else if" in descriptor parsing

Code: [Select]

if( buf_ptr[5] == USB_CLASS_AUDIO && buf_ptr[6] == USB_SUBCLASS_MIDISTREAMING )
{ //p[5]; bInterfaceClass = 1(Audio), p[6]; bInterfaceSubClass = 3(MIDI Streaming)
isMidiFound = true; //MIDI device found.
isMidi = true;
}
//Yamaha THR10
else if( buf_ptr[5] == USB_CLASS_VENDOR_SPECIFIC && buf_ptr[6] == USB_SUBCLASS_MIDISTREAMING ) //Yamaha THR10
{
//p[5]; bInterfaceClass = 255(VENDOR), p[6]; bInterfaceSubClass = 3(MIDI Streaming)
isMidiFound = true; //MIDI device found.
isMidi = true;
}
else
{
#ifdef DEBUG
Serial.print("No MIDI Device\n");
#endif
// buf_ptr += total_length + 1;
// bConfNum = 0;
isMidi = false;
}
break;


Solving buffer problems:

always use (uint16_t) cast instead of (uint8_t) cast for epInfo[index].maxPktSize
e.g.

Code: [Select]

// Extract Max Packet Size from device descriptor
epInfo[0].maxPktSize = (uint16_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
quick and dirty change for buffersize, that works for THR10 (just a work around, no proper solution, i guess!!!):
if( isMidi )
{
if ((epDesc->bEndpointAddress & 0x80) == 0x80)
{
// Input
index = epDataInIndex;
epInfo[index].epAddr = (epDesc->bEndpointAddress & 0x0F);
//epInfo[index].maxPktSize = (uint16_t)epDesc->wMaxPacketSize;
epInfo[index].maxPktSize = (uint16_t)2048; //necessary for YAMAHA THR10
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].epAddr, UOTGHS_HSTPIPCFG_PTYPE_BLK, UOTGHS_HSTPIPCFG_PTOKEN_IN, epInfo[index].maxPktSize, 0, UOTGHS_HSTPIPCFG_PBK_1_BANK);
}
else
{
// Output
index = epDataOutIndex;
epInfo[index].epAddr = (epDesc->bEndpointAddress & 0x0F);
//epInfo[index].maxPktSize = (uint8_t)epDesc->wMaxPacketSize;
epInfo[index].maxPktSize = (uint16_t)2048; //necessary for YAMAHA THR10
pipe = UHD_Pipe_Alloc(bAddress, epInfo[index].epAddr, UOTGHS_HSTPIPCFG_PTYPE_BLK, UOTGHS_HSTPIPCFG_PTOKEN_OUT, epInfo[index].maxPktSize, 0, UOTGHS_HSTPIPCFG_PBK_1_BANK);
}



After that modifikations, i can send System-Exlusive Messages to THR10, like
Code: [Select]

uint8_t msg1[]= {0xF0,0x43,0x7D,0x30,0x41,0x30,0x01,0x01,0xF7}; //Lamp off
uint8_t msg2[]= {0xF0,0x43,0x7D,0x30,0x41,0x30,0x01,0x00,0xF7}; //Lamp on


that switches the light of the Guitar-Amp (just a test,  more important, I can send sound-patches, that are created as a file before with the THR10-Editor on PC.)

This way I can build a foot-switch / pedal to change sound patches on the fly like
in the THR10 foot switch project of

http://www.mehlbrandt.de/thr/thr_1

But this guy did it with an ordinary Arduino Uno and anUSB-Host Shield.


With the Due I can use the native USB-Host-Port, have got more memory and speed.
I want to inject Samples to the THR10 with this footswitch as well, as it can also act as IN-/OUT Audio Interface.

EDIT:
1.) Add a delayMicroseconds(300ul); in  function  "USBHost::ctrlReq"   where the following lines occure:

Code: [Select]

if (dataptr != 0)
{
if (direction)
{
// IN transfer
TRACE_USBHOST(printf("    => ctrlData IN\r\n");)

Add here---->              delayMicroseconds(300ul);  //necessary!! 275ul does not work!!


2) Add a delayMicroseconds(120ul);  at start of  function  "USBHost::dispatchPkt"

Code: [Select]

uint32_t USBHost::dispatchPkt(uint32_t token, uint32_t hostPipeNum, uint32_t nak_limit)
{
uint32_t timeout = millis() + USB_XFER_TIMEOUT;
uint32_t nak_count = 0;
uint32_t rcode = USB_ERROR_TRANSFER_TIMEOUT;

---> add here: delayMicroseconds(120ul);  //NECESSARY!!  (100ul does not work!)

TRACE_USBHOST(printf("     => dispatchPkt token=%lu pipe=%lu nak_limit=%lu\r\n", token, hostPipeNum, nak_limit);)


Don't really know  w h y   this have to be done. But it does nor work otherwise.

 ;)

MartinZ

#153
May 10, 2019, 12:48 am Last Edit: Jun 04, 2019, 07:33 am by MartinZ Reason: Link for Library
Just published a fast ILI9225 library for Arduino Due.

https://github.com/martinzw/ILI9225_Due

It uses DMA and works much faster than the well known  TFT_22_ILI9225 library.


It is an adaption/mixture of ILI9341_Due and ILI9225_t3.

Go Up