2015-11-04 25 views
1

我想使用以太網盾的c庫,但它是爲ATMega644p編程的,但我使用ATMega2560。我遇到一些問題,找出我需要使用哪些端口。CS_DDR,CS_PORT,RESET_DDR和RESET_PORT Mega2560

庫可以在這裏看到:http://www.seanet.com/~karllunt/w5100_library.html

具體的地方我有一個問題是這個:

#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 */ 

我想從以下頁面https://github.com/Seeed-Studio/ArduinoPhone/blob/master/Libraries/TFT/TFT.h的端口,但它仍然無法正常工作。

回答

0

看來,CS是在D2引腳上,而RESET在D3引腳上。

DDRx寄存器用於設置引腳的方向(a 1表示該引腳是輸出,0表示該引腳是輸入)。

PORTx是引腳在輸出模式下應具有的值。

我認爲你可以以這種方式離開庫,並簡單地將CS引腳連接到D2(Arduino mega 2560上的數字引腳19)和RESET到D3(Arduino Mega 2560上的數字引腳18)。畢竟,arduino IDE使用avr-gcc進行編譯,所以使用avr-gcc的代碼也適用於arduino。

Here您可以找到Atmega2560的引腳映射。