mirror of
https://github.com/YuzuZensai/MCUFRIEND_kbv.git
synced 2026-01-31 14:57:48 +00:00
SPECIAL for XPRO-4809 with XPRO_Shield Adapter
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
//#define USE_MEGA_16BIT_SHIELD // 2.14sec Mega2560 Shield
|
||||
//#define USE_BLD_BST_MEGA32U4
|
||||
//#define USE_BLD_BST_MEGA2560 // 12.23sec Uno Shield (17.38s C)
|
||||
//#define USE_BLD_BST_MEGA4809 // 5.43sec XPRO-Adapter (7.09s C)
|
||||
//#define USE_DUE_8BIT_PROTOSHIELD
|
||||
//#define USE_DUE_16BIT_SHIELD //RD on PA15 (D24)
|
||||
//#define USE_BOBCACHELOT_TEENSY
|
||||
@@ -93,6 +94,117 @@ ST7789V tWC = 66ns tWRH = 15ns tRCFM = 450ns tRC = 160ns
|
||||
#define PIN_HIGH(p, b) (p).OUT |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) (p).DIR |= (1<<(b))
|
||||
|
||||
//################################# XPRO-4809 with XPRO-Shield_Adapter ############################
|
||||
#elif defined(__AVR_ATmega4809__) && !defined(USE_BLD_BST_MEGA4809) // XPRO-4809 with XPRO-Shield_Adapter
|
||||
#warning XPRO-4809 with XPRO-Shield_Adapter using PORT.OUTSET
|
||||
#define RD_PORT PORTD //
|
||||
#define RD_PIN 2
|
||||
#define WR_PORT PORTD
|
||||
#define WR_PIN 3
|
||||
#define CD_PORT PORTD
|
||||
#define CD_PIN 4
|
||||
#define CS_PORT PORTD
|
||||
#define CS_PIN 5
|
||||
#define RESET_PORT PORTC
|
||||
#define RESET_PIN 2
|
||||
|
||||
// PORT.OUTSET is fast but still 2 cycles. Hence all those RD_ACTIVEs
|
||||
#define AMASK (3<<2)
|
||||
#define BMASK (3<<2)
|
||||
#define CMASK (3<<6)
|
||||
#define EMASK (1<<1)
|
||||
#define FMASK (1<<6)
|
||||
#define write_8(x) { \
|
||||
PORTA.OUTCLR = AMASK; PORTA.OUTSET = (((x) & (3<<0)) << 2); \
|
||||
PORTB.OUTCLR = BMASK; PORTB.OUTSET = (((x) & (1<<2))) | (((x) & (1<<6)) >> 3); \
|
||||
PORTC.OUTCLR = CMASK; PORTC.OUTSET = (((x) & (3<<3)) << 3); \
|
||||
PORTE.OUTCLR = EMASK; PORTE.OUTSET = (((x) & (1<<7)) >> 6); \
|
||||
PORTF.OUTCLR = FMASK; PORTF.OUTSET = (((x) & (1<<5)) << 1); \
|
||||
}
|
||||
#define read_8() ( ((PORTA.IN & AMASK) >> 2)\
|
||||
| ((PORTB.IN & (1<<2)) >> 0)\
|
||||
| ((PORTB.IN & (1<<3)) << 3)\
|
||||
| ((PORTC.IN & CMASK) >> 3)\
|
||||
| ((PORTE.IN & EMASK) << 6)\
|
||||
| ((PORTF.IN & FMASK) >> 1)\
|
||||
)
|
||||
#define setWriteDir() { PORTA.DIRSET = AMASK; PORTB.DIRSET = BMASK; PORTC.DIRSET = CMASK; PORTE.DIRSET = EMASK; PORTF.DIRSET = FMASK; }
|
||||
#define setReadDir() { PORTA.DIRCLR = AMASK; PORTB.DIRCLR = BMASK; PORTC.DIRCLR = CMASK; PORTE.DIRCLR = EMASK; PORTF.DIRCLR = FMASK; }
|
||||
|
||||
#define WRITE_DELAY { WR_ACTIVE2; WR_ACTIVE; } //-Os=7.09s @20MHz (-O1=8.13s, -O3=6.03s)
|
||||
#define READ_DELAY { RD_ACTIVE2; } //ID=0x7789
|
||||
#define write8(x) { write_8(x); WRITE_DELAY; WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; READ_DELAY; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
|
||||
#define PIN_LOW(p, b) (p).OUTCLR = (1<<(b))
|
||||
#define PIN_HIGH(p, b) (p).OUTSET = (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) (p).DIRSET = (1<<(b))
|
||||
|
||||
#elif defined(__AVR_ATmega4809__) && defined(USE_BLD_BST_MEGA4809) // XPRO-4809 with XPRO-Shield_Adapter
|
||||
#warning XPRO-4809 with XPRO-Shield_Adapter using VPORT.OUT and BLD/BST
|
||||
#define RD_PORT VPORTD //
|
||||
#define RD_PIN 2
|
||||
#define WR_PORT VPORTD
|
||||
#define WR_PIN 3
|
||||
#define CD_PORT VPORTD
|
||||
#define CD_PIN 4
|
||||
#define CS_PORT VPORTD
|
||||
#define CS_PIN 5
|
||||
#define RESET_PORT VPORTC
|
||||
#define RESET_PIN 2
|
||||
|
||||
#define AMASK (3<<2)
|
||||
#define BMASK (3<<2)
|
||||
#define CMASK (3<<6)
|
||||
#define EMASK (1<<1)
|
||||
#define FMASK (1<<6)
|
||||
static __attribute((always_inline))
|
||||
void write_8(uint8_t val)
|
||||
{
|
||||
asm volatile("in __tmp_reg__,0x01" "\n\t" //VPORTA.OUT
|
||||
"BST %0,0" "\n\t" "BLD __tmp_reg__,2" "\n\t"
|
||||
"BST %0,1" "\n\t" "BLD __tmp_reg__,3" "\n\t"
|
||||
"out 0x01,__tmp_reg__" : : "a" (val));
|
||||
asm volatile("in __tmp_reg__,0x05" "\n\t" //VPORTB.OUT
|
||||
"BST %0,2" "\n\t" "BLD __tmp_reg__,2" "\n\t"
|
||||
"BST %0,6" "\n\t" "BLD __tmp_reg__,3" "\n\t"
|
||||
"out 0x05,__tmp_reg__" : : "a" (val));
|
||||
asm volatile("in __tmp_reg__,0x09" "\n\t" //VPORTC.OUT
|
||||
"BST %0,3" "\n\t" "BLD __tmp_reg__,6" "\n\t"
|
||||
"BST %0,4" "\n\t" "BLD __tmp_reg__,7" "\n\t"
|
||||
"out 0x09,__tmp_reg__" : : "a" (val));
|
||||
asm volatile("in __tmp_reg__,0x11" "\n\t" //VPORTE.OUT
|
||||
"BST %0,7" "\n\t" "BLD __tmp_reg__,1" "\n\t"
|
||||
"out 0x11,__tmp_reg__" : : "a" (val));
|
||||
asm volatile("in __tmp_reg__,0x15" "\n\t" //VPORTF.OUT
|
||||
"BST %0,5" "\n\t" "BLD __tmp_reg__,6" "\n\t"
|
||||
"out 0x15,__tmp_reg__" : : "a" (val));
|
||||
}
|
||||
|
||||
#define read_8() ( ((VPORTA_IN & AMASK) >> 2)\
|
||||
| ((VPORTB_IN & (1<<2)) >> 0)\
|
||||
| ((VPORTB_IN & (1<<3)) << 3)\
|
||||
| ((VPORTC_IN & CMASK) >> 3)\
|
||||
| ((VPORTE_IN & EMASK) << 6)\
|
||||
| ((VPORTF_IN & FMASK) >> 1)\
|
||||
)
|
||||
#define setWriteDir() { VPORTA_DIR |= AMASK; VPORTB_DIR |= BMASK; VPORTC_DIR |= CMASK; VPORTE_DIR |= EMASK; VPORTF_DIR |= FMASK; }
|
||||
#define setReadDir() { VPORTA_DIR &= ~AMASK; VPORTB_DIR &= ~BMASK; VPORTC_DIR &= ~CMASK; VPORTE_DIR &= ~EMASK; VPORTF_DIR &= ~FMASK; }
|
||||
|
||||
//#define WRITE_DELAY { WR_ACTIVE; WR_ACTIVE; } //6.47s no_inline
|
||||
#define WRITE_DELAY { WR_ACTIVE2; WR_ACTIVE; } //-Os=5.43s @20MHz always_inline. (-O1=5.41s, -O3=5.25s)
|
||||
#define READ_DELAY { RD_ACTIVE4; } //ID=0x7789
|
||||
#define write8(x) { write_8(x); WRITE_DELAY; WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; READ_DELAY; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
|
||||
#define PIN_LOW(p, b) (p).OUT &= ~(1<<(b))
|
||||
#define PIN_HIGH(p, b) (p).OUT |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) (p).DIR |= (1<<(b))
|
||||
|
||||
#elif defined(__AVR_ATmega328P__) && defined(USE_OPENSMART_SHIELD_PINOUT_UNO)
|
||||
#define RD_PORT PORTC
|
||||
#define RD_PIN 0
|
||||
|
||||
Reference in New Issue
Block a user