Hacking Basics
Pin Files
The best and most productive start at hacking (and contributing) to Weeno is within the pin mapping files. The pin_at90usb1287.c file in the cores/weeno/avr/at90 directory is a good example: Open the file for a look-see. The following shows one of the central concepts of Wiring/Arduino and also Weeno, that of mapping an integer to a memory slot or special function register. `
// This maps port letter (A-F) to the appropriate Digital Pin const uint8_t PROGMEM digital_pin_to_port_PGM[] = { /*Pin - Port/Bit (Alt Function) {Use on AT90USBKey Demo board} */ PA, /*51 ñ PA0 (AD0) */ /* Digital Pin 0*/
// This maps port letter (A-F) to the appropriate Digital Pin const uint8_t PROGMEM digital_pin_to_port_PGM[] = { /*Pin - Port/Bit (Alt Function) {Use on AT90USBKey Demo board} */ PA, /*51 ñ PA0 (AD0) */ /* Digital Pin 0*/`
PA is a macro define (constant) that itself points to a memory address. A search reveals that PA is simply #define PA 0x11 in Atmel's associated library. `
Finally, in the library file, sfrdefs.h we find the macro, #define PORTA _SFR_IO8(0x02) `
It is more transparent and thus better to use the actual 0x11 memory address rather than another soft link residing in a second, third or forth file buried in a dile deep in a nested directory hierarchy. `
The author of the file, pseudoname zaig, did a wonderful job of porting the at90usb1287 micro-controller to Wiring/Arduino format. His integer mapping is somewhat misleading: the mapping does not follow the physical package layout of the chip, but largely follows from the PORTA, PORTB memory address around the chip. Hence, a user unfamiliar with his code must dig a bit more to figure out the proper integer number to use. `
Weeno suggests adhering to the physical packaging numbering schema beginning at the index corner, (1,2,3,4,.....,62,63,64) in sequence around the entire 64-pin QFN package, as seen in the following diagram. `
The library user must simply be aware of the librarians integer to memory mapping, whatever the schema. `
/* AT90USB128 (64-lead QFN top view) 64....49 +-----------+ 1 |* |48 . | | . . | | . 16| |33 +-----------+ 17....32 * = INDEX CORNER
/* AT90USB128 (64-lead QFN top view) 64....49 +-----------+ 1 |* |48 . | | . . | | . 16| |33 +-----------+ 17....32 * = INDEX CORNER`