Spitko

Porting libraries: Pin/SPI assignments

2 posts in this topic

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;
#endif

avrpins.h

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

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

 

 

Share this post


Link to post
Share on other sites

Hello,

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?

Thanks,
Jack.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now