
نوشته اصلی توسط
Ahmad110
ممنون دوست عزیز بابت راهنماییتون ولی خب سوال من در واقع اینه که چطوری باید این کد ها رو قرار بدم؟ همه رو بریزم تو فایل .cpp یا .h ؟ یا اینکه باید اونا رو ویرایش کنم؟ من دقیق نمیدونم اصلا عمل پورت کردن یعنی چی و چطوری پورت کنم؟
کد:
#define USE_TIKY_ON_DUE
...
#elif defined(__SAM3X8E__) && defined(USE_TIKY_ON_DUE) //TIKY_ON_DUE
#warning USE_TIKY_ON_DUE
#define USES_16BIT_BUS
// configure macros for the control pins
#define RD_PORT PIOD
#define RD_PIN 0 //D25 PD0
#define WR_PORT PIOA
#define WR_PIN 15 //D24 PA15
#define CD_PORT PIOA
#define CD_PIN 14 //D23 PA14
#define CS_PORT PIOB
#define CS_PIN 26 //D22 PB26
#define RESET_PORT PIOD
#define RESET_PIN 1 //D26 PD1
// configure macros for data bus
//
#define AMASK ((1<<7)|(1<<19)) //PA7, PA19
#define CMASK (0x1FF<<1) //PC1-PC9
#define DMASK ((3<<2)|(1<<6)|(3<<9)) //PD2-PD3, PD6, PD9-PD10
#define write_16(x) { PIOA->PIO_CODR = AMASK; PIOC->PIO_CODR = CMASK; PIOD->PIO_CODR = DMASK; \
PIOD->PIO_SODR = (((x)&(3<<0))<<2); \
PIOD->PIO_SODR = (((x)&(1<<2))<<4); \
PIOD->PIO_SODR = (((x)&(1<<3))<<6); \
PIOA->PIO_SODR = (((x)&(1<<4))<<3); \
PIOD->PIO_SODR = (((x)&(1<<5))<<5); \
PIOC->PIO_SODR = (((x)&(0x1FF<<6))>>5); \
PIOA->PIO_SODR = (((x)&(1<<15))<<4); \
}
#define read_16() ( 0\
|((PIOD->PIO_PDSR & (1<<2))>>2)\
|((PIOD->PIO_PDSR & (1<<3))>>2)\
|((PIOD->PIO_PDSR & (1<<6))>>4)\
|((PIOD->PIO_PDSR & (1<<9))>>6)\
|((PIOA->PIO_PDSR & (1<<7))>>3)\
|((PIOD->PIO_PDSR & (1<<10))>>5)\
|((PIOC->PIO_PDSR & (0x1FF<<1))<<5)\
|((PIOA->PIO_PDSR & (1<<19)>>4))\
)
#define read_8() (read_16() & 0xFF)
#define setWriteDir() {\
PIOA->PIO_OER = AMASK; PIOA->PIO_PER = AMASK; \
PIOC->PIO_OER = CMASK; PIOC->PIO_PER = CMASK; \
PIOD->PIO_OER = DMASK; PIOD->PIO_PER = DMASK; \
}
#define setReadDir() { \
PMC->PMC_PCER0 = (1 << ID_PIOA)|(1 << ID_PIOC)|(1 << ID_PIOD); \
PIOA->PIO_ODR = AMASK; \
PIOC->PIO_ODR = CMASK; \
PIOD->PIO_ODR = DMASK; \
}
#define write8(x) { write16(x & 0xFF); }
// ILI9486 is slower than ILI9481
#define write16(x) { write_16(x); WR_ACTIVE; WR_ACTIVE; WR_STROBE; }
#define READ_16(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
#define READ_8(dst) { READ_16(dst); dst &= 0xFF; }
// Shield Control macros.
#define PIN_LOW(port, pin) (port)->PIO_CODR = (1<<(pin))
#define PIN_HIGH(port, pin) (port)->PIO_SODR = (1<<(pin))
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))