Go Down

Topic: Decoupling shield libraries from the Arduino core (Read 734 times) previous topic - next topic

qwertymodo

I've been really interested in many of the LUFA hacks that have led to custom devices on the Arduino by re-flashing the Atmega16U2 on the Uno and Mega2560 boards.  I'm in the process of building a project with USB MIDI output, and it works great on the Uno and Mega2560, using LUFA-based MIDI firmware on the 16U2, but I would really like to cut out the middle-man and target my project to the Leonardo, so the entire code base is running on a single microcontroller.  The problem is, I'm using the Circuits@Home USB host shield, and their libraries are coupled to the Arduino core, whereas I would rather utilize the LUFA build system, which allows me complete control of the USB device descriptors, allowing me to create any kind of device I want (which is why LUFA has been the go-to library for those sorts of hacks).  So my question is, has anybody here had any experience decoupling shield libraries from the Arduino core?  Or maybe the answer is to go a different route, and link the two code libraries... but I have a feeling that wouldn't work, due to my requirement for being able to control the device descriptors via the LUFA build system, where I'm pretty sure the Arduino core handles that itself.  I would really like to end up with a truly plug-and-play device, acting as a pure generic USB MIDI controller.  So there is my dilemma.  On the one hand, I have the LUFA code doing what I want it to do as far as the PC interface side of things, but on the other hand, I need the USB Host Shield library in order to communicate with the external devices I'm using to actually control the MIDI device.  Any suggestions?

qwertymodo

Well, just to resolve this for anybody who might attempt this in the future, I was able to just include several of the Arduino core files in my project in order to satisfy the dependencies on them, but the one dependency I had to remove was the HardwareSerial library, because that relied on the CDC code (at least for the Atmega32U4 that I'm working with), which in turn depended on the entire USB core, which was what I was trying to get away from in the first place.  So the CLEAN solution would have been to re-implement the HardwareSerial interface (or at least the Serial_ class) using LUFA-compatible code, but 1)I didn't want a CDC interface in my device (though I suppose I could have implemented it via the UART instead of USB) and 2)I was lazy.  So I ended up just commenting out all of the Serial.println()'s in the shield library... which removed all of the serial debugging, but oh well.  Eventually, I'll probably just add a UART-based implementation of the Serial_ class and be done with it, but for now, it seems to be working...

Go Up