I am trying to use a c libary for an ethernet shield, but it is programmed for the ATMega644p, but I am using the ATMega2560. I am having some problems figuring out what ports i need to use instead.
The library can be seen here: http://www.seanet.com/~karllunt/w5100_library.html
The specific place where I have problems is with this:
#define CS_DDR DDRD /* target-specific DDR for chip-select */
#define CS_PORT PORTD /* target-specific port used as chip-select */
#define CS_BIT 2 /* target-specific port line used as chip-select */
#define RESET_DDR DDRD /* target-specific DDR for reset */
#define RESET_PORT PORTD /* target-specific port used for reset */
#define RESET_BIT 3 /* target-specific port line used as reset */
I tried the ports from the following page https://github.com/Seeed-Studio/ArduinoPhone/blob/master/Libraries/TFT/TFT.h but it still doesn't work.
It seems that CS is on pin D2 and RESET is on pin D3.
DDRx register is for setting the direction of the pins (a 1 indicates that the pin is an output, a 0 that it is an input).
PORTx is the value the pin should have in output mode.
I think that you can leave the library this way and simply connect the CS pin to D2 (which is digital pin 19 on the Arduino mega 2560) and RESET to D3 (digital pin 18 on the Arduino Mega 2560). After all, the arduino IDE uses avr-gcc for compiling, so the code working with avr-gcc works with arduino too..
Here you can find the pin mapping for the Atmega2560.