Porting libraries: Pin/SPI assignments

Recommended Posts

This is likely a daft question, but the website seems to be broken right now so off we go to the forums.

I'm trying to port the USB Host library ( https://github.com/arduino-libraries/USBHost ). It uses the fairly typical avrpins.h, and further has a bunch of SPI glue in usbhost.h

Is there a guide somewhere on porting arduino libraries? At a high level it's looking for arduino pin names like pd5, which don't appear to have an obvious analog (that I saw anyway). The SPI code also seems to expect explicit pin assignments but the spi examples seem to derive their pinouts from a single wing constant

Specific snippits, for those uninterested in digging through github sources:

SPI setup

// ...
#elif  defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) 
typedef SPi< Pb5, Pb3, Pb4, Pb2 > spi;


#elif defined(__AVR_ATmega32U4__)
// Arduino Leonardo pin numbers

#define P0  Pd2 // D0 - PD2
#define P1  Pd3 // D1 - PD3
#define P2  Pd1 // D2 - PD1



Link to comment
Share on other sites

  • 2 weeks later...


There is no official guide to doing something like this but I can help you through the process. But there are several different ways this can be done and we will need to narrow in to a specific method before determining the correct pin numbers for what you want to do. So can you provide more information about how you want to do this? Are you using a Papilio DUO or a Papilio Pro. Do you want to use the AVR chip of the DUO or do you want to use the ZPUino soft processor?


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.