mirror of
https://github.com/YuzuZensai/MCUFRIEND_kbv.git
synced 2026-01-31 14:57:48 +00:00
@@ -577,9 +577,11 @@ void MCUFRIEND_kbv::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_
|
||||
while (h-- > 0) {
|
||||
end = w;
|
||||
#if USING_16BIT_BUS
|
||||
#if defined(__SAM3X8E__)
|
||||
#if defined(__MK66FX1M0__) //180MHz M4
|
||||
#define STROBE_16BIT {WR_ACTIVE;WR_ACTIVE;WR_ACTIVE;WR_ACTIVE;WR_ACTIVE;WR_IDLE;WR_IDLE;WR_IDLE;WR_IDLE;WR_IDLE;}
|
||||
#elif defined(__SAM3X8E__) //84MHz M3
|
||||
#define STROBE_16BIT {WR_ACTIVE;WR_ACTIVE;WR_ACTIVE;WR_IDLE;WR_IDLE;}
|
||||
#else
|
||||
#else //16MHz AVR
|
||||
#define STROBE_16BIT {WR_ACTIVE; WR_IDLE;}
|
||||
#endif
|
||||
write_16(color); //we could just do the strobe
|
||||
|
||||
362
extras/unused/mcufriend_special_3.h
Normal file
362
extras/unused/mcufriend_special_3.h
Normal file
@@ -0,0 +1,362 @@
|
||||
//################################# SSD1289 SHIELD #######################
|
||||
#define SSD1289_JUMPERS 2 //Uno Shield with VERY different pin-out to Mcufriend
|
||||
//#define USE_SSD1289_SHIELD_UNO
|
||||
//#define USE_SSD1289_SHIELD_MEGA
|
||||
//#define USE_SSD1289_SHIELD_DUE
|
||||
|
||||
#elif defined(__AVR_ATmega328P__) && defined(USE_SSD1289_SHIELD_UNO) //on UNO
|
||||
#warning using SSD1289 Shield for mega328
|
||||
#define RD_PORT PORTC
|
||||
#define RD_PIN 3
|
||||
#define WR_PORT PORTC
|
||||
#define WR_PIN 2
|
||||
#define CD_PORT PORTC
|
||||
#define CD_PIN 1
|
||||
#define CS_PORT PORTC
|
||||
#define CS_PIN 0
|
||||
#define RESET_PORT PORTB
|
||||
#define RESET_PIN 1 //actually SD_CS
|
||||
|
||||
// SSD1289 shield has LCD_D0 on RXD0. Fine for write-only
|
||||
// For any Read operations, put jumper from D0 to D8, Switch #2 to OFF.
|
||||
// If using Serial, jumper D1 to A5, Switch #1 to OFF
|
||||
#if SSD1289_JUMPERS == 0
|
||||
#warning no jumpers. Switch #1=ON, #2=ON
|
||||
#define BMASK 0x00 //0x00 for output, 0x01 for Read + Serial
|
||||
#define CMASK 0x00 //0x20 for Read + Serial
|
||||
#define DMASK (~BMASK)
|
||||
#define write8(x) { PORTD = x; WR_STROBE; }
|
||||
#define read_8() ( PIND )
|
||||
#elif SSD1289_JUMPERS == 1
|
||||
#warning jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#define BMASK 0x01 //0x00 for output, 0x01 for Read + Serial
|
||||
#define CMASK 0x00 //0x20 for Read + Serial
|
||||
#define DMASK (~BMASK)
|
||||
#define write8(x) { PORTD = (PORTD & ~DMASK) | (x & DMASK); PORTB = (PORTB & ~BMASK) | (x & BMASK); WR_STROBE; }
|
||||
#define read_8() ( (PIND & DMASK)|(PINB & BMASK) )
|
||||
#elif SSD1289_JUMPERS == 2
|
||||
#warning jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#define BMASK (1<<0) //0x00 for output, 0x01 for Read + Serial
|
||||
#define CMASK (1<<5) //0x20 for Read + Serial
|
||||
#define DMASK (0xFC)
|
||||
#define write8(x) { PORTC = (PORTC & ~CMASK) | ((x<<4) & CMASK);\
|
||||
PORTD = (PORTD & ~DMASK) | (x & DMASK);\
|
||||
PORTB = (PORTB & ~BMASK) | (x & BMASK); WR_STROBE; }
|
||||
#define read_8() ( ((PINC & CMASK)>>4)|(PIND & DMASK)|(PINB & BMASK) )
|
||||
#endif
|
||||
#define setWriteDir() { DDRC |= CMASK; DDRD |= DMASK; DDRB |= BMASK; }
|
||||
#define setReadDir() { DDRC &= ~CMASK; DDRD &= ~DMASK; DDRB &= ~BMASK; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; 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) &= ~(1<<(b))
|
||||
#define PIN_HIGH(p, b) (p) |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
|
||||
|
||||
#elif defined(__AVR_ATmega2560__) && defined(USE_SSD1289_SHIELD_MEGA) //on MEGA2560
|
||||
#warning using SSD1289 Shield for mega2560
|
||||
#define RD_PORT PORTF
|
||||
#define RD_PIN 3 //A3
|
||||
#define WR_PORT PORTF
|
||||
#define WR_PIN 2 //A2
|
||||
#define CD_PORT PORTF
|
||||
#define CD_PIN 1 //A1
|
||||
#define CS_PORT PORTF
|
||||
#define CS_PIN 0 //A0
|
||||
#define RESET_PORT PORTH
|
||||
#define RESET_PIN 6 //D9 DS_CS, D10=T_CS, D9=SD_CS, D8=n.c.
|
||||
|
||||
// only for SSD1289 data bus on D2..D9 UNTESTED
|
||||
#if (SSD1289_JUMPERS == 0) //Switch #1=ON, #2=ON
|
||||
#warning no jumpers Switch #1=ON, #2=ON
|
||||
#define EMASK 0x3B
|
||||
#define FMASK 0x00
|
||||
#define HMASK 0x18
|
||||
#define GMASK 0x20
|
||||
#define write_8(x) { PORTH &= ~HMASK; PORTG &= ~GMASK; PORTE &= ~EMASK; \
|
||||
PORTE |= (((x) & (1<<0)) << 0); \
|
||||
PORTE |= (((x) & (1<<1)) << 0); \
|
||||
PORTE |= (((x) & (3<<2)) << 2); \
|
||||
PORTG |= (((x) & (1<<4)) << 1); \
|
||||
PORTE |= (((x) & (1<<5)) >> 2); \
|
||||
PORTH |= (((x) & (3<<6)) >> 3); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PINE & (1<<0)) >> 0)\
|
||||
| ((PINE & (1<<1)) >> 0)\
|
||||
| ((PINE & (3<<4)) >> 2)\
|
||||
| ((PING & (1<<5)) >> 1)\
|
||||
| ((PINE & (1<<3)) << 2)\
|
||||
| ((PINH & (3<<3)) << 3)\
|
||||
)
|
||||
#elif (SSD1289_JUMPERS == 1) //jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#warning jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#define EMASK 0x3A
|
||||
#define FMASK 0x00
|
||||
#define HMASK 0x38
|
||||
#define GMASK 0x20
|
||||
#define write_8(x) { PORTH &= ~HMASK; PORTG &= ~GMASK; PORTE &= ~EMASK; \
|
||||
PORTH |= (((x) & (1<<0)) << 5); \
|
||||
PORTE |= (((x) & (1<<1)) << 0); \
|
||||
PORTE |= (((x) & (3<<2)) << 2); \
|
||||
PORTG |= (((x) & (1<<4)) << 1); \
|
||||
PORTE |= (((x) & (1<<5)) >> 2); \
|
||||
PORTH |= (((x) & (3<<6)) >> 3); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PINH & (1<<5)) >> 5)\
|
||||
| ((PINE & (1<<1)) >> 0)\
|
||||
| ((PINE & (3<<4)) >> 2)\
|
||||
| ((PING & (1<<5)) >> 1)\
|
||||
| ((PINE & (1<<3)) << 2)\
|
||||
| ((PINH & (3<<3)) << 3)\
|
||||
)
|
||||
#elif (SSD1289_JUMPERS == 2) //jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#warning jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#define FMASK 0x20
|
||||
#define EMASK 0x38
|
||||
#define HMASK 0x38
|
||||
#define GMASK 0x20
|
||||
#define write_8(x) { PORTH &= ~HMASK; PORTG &= ~GMASK; PORTF &= ~FMASK; PORTE &= ~EMASK; \
|
||||
PORTH |= (((x) & (1<<0)) << 5); \
|
||||
PORTF |= (((x) & (1<<1)) << 4); \
|
||||
PORTE |= (((x) & (3<<2)) << 2); \
|
||||
PORTG |= (((x) & (1<<4)) << 1); \
|
||||
PORTE |= (((x) & (1<<5)) >> 2); \
|
||||
PORTH |= (((x) & (3<<6)) >> 3); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PINH & (1<<5)) >> 5)\
|
||||
| ((PINF & (1<<5)) >> 4)\
|
||||
| ((PINE & (3<<4)) >> 2)\
|
||||
| ((PING & (1<<5)) >> 1)\
|
||||
| ((PINE & (1<<3)) << 2)\
|
||||
| ((PINH & (3<<3)) << 3)\
|
||||
)
|
||||
#endif
|
||||
#define setWriteDir() { DDRH |= HMASK; DDRG |= GMASK; DDRF |= FMASK; DDRE |= EMASK; }
|
||||
#define setReadDir() { DDRH &= ~HMASK; DDRG &= ~GMASK; DDRF &= ~FMASK; DDRE &= ~EMASK; }
|
||||
#define write8(x) { write_8(x); WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { RD_STROBE; dst = read_8(); RD_IDLE; RD_STROBE; dst = (dst<<8) | read_8(); RD_IDLE; }
|
||||
|
||||
#define PIN_LOW(p, b) (p) &= ~(1<<(b))
|
||||
#define PIN_HIGH(p, b) (p) |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
|
||||
|
||||
#elif defined(__SAM3X8E__) && defined(USE_SSD1289_SHIELD_DUE) // on DUE
|
||||
#warning USE_SSD1289_SHIELD_DUE
|
||||
// configure macros for the control pins
|
||||
#define RD_PORT PIOA
|
||||
#define RD_PIN 22 //A3
|
||||
#define WR_PORT PIOA
|
||||
#define WR_PIN 23 //A2
|
||||
#define CD_PORT PIOA
|
||||
#define CD_PIN 24 //A1
|
||||
#define CS_PORT PIOA
|
||||
#define CS_PIN 16 //A0
|
||||
#define RESET_PORT PIOC
|
||||
#define RESET_PIN 21 //D9 Touch CS
|
||||
// configure macros for data bus
|
||||
// only for SSD1289 data bus on D2..D9 UNTESTED
|
||||
#if SSD1289_JUMPERS == 0
|
||||
#warning no jumpers Switch #1=ON, #2=ON
|
||||
#define AMASK (3<<8)
|
||||
#define BMASK (1<<25)
|
||||
#define CMASK (0xBC << 21)
|
||||
#define write_8(x) { PIOA->PIO_CODR = AMASK; PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
|
||||
PIOA->PIO_SODR = (((x) & (1<<0)) << 8); \
|
||||
PIOA->PIO_SODR = (((x) & (1<<1)) << 8); \
|
||||
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PIOA->PIO_PDSR & (1<<8)) >> 8)\
|
||||
| ((PIOA->PIO_PDSR & (1<<9)) >> 8)\
|
||||
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
|
||||
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
|
||||
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
|
||||
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
|
||||
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
|
||||
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
|
||||
)
|
||||
#elif SSD1289_JUMPERS == 1
|
||||
#warning jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#define AMASK (1<<9)
|
||||
#define BMASK (1<<25)
|
||||
#define CMASK (0xBE << 21)
|
||||
#define write_8(x) { PIOA->PIO_CODR = AMASK; PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
|
||||
PIOC->PIO_SODR = (((x) & (1<<0)) << 22); \
|
||||
PIOA->PIO_SODR = (((x) & (1<<1)) << 8); \
|
||||
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PIOC->PIO_PDSR & (1<<22)) >> 22)\
|
||||
| ((PIOA->PIO_PDSR & (1<<9)) >> 8)\
|
||||
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
|
||||
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
|
||||
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
|
||||
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
|
||||
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
|
||||
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
|
||||
)
|
||||
#elif SSD1289_JUMPERS == 2
|
||||
#warning jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#define AMASK (1<<4)
|
||||
#define BMASK (1<<25)
|
||||
#define CMASK (0xBE << 21)
|
||||
#define write_8(x) { PIOA->PIO_CODR = AMASK; PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
|
||||
PIOC->PIO_SODR = (((x) & (1<<0)) << 22); \
|
||||
PIOA->PIO_SODR = (((x) & (1<<1)) << 3); \
|
||||
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PIOC->PIO_PDSR & (1<<22)) >> 22)\
|
||||
| ((PIOA->PIO_PDSR & (1<<4)) >> 3)\
|
||||
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
|
||||
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
|
||||
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
|
||||
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
|
||||
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
|
||||
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
|
||||
)
|
||||
#endif
|
||||
#define setWriteDir() { PIOA->PIO_OER = AMASK; PIOB->PIO_OER = BMASK; PIOC->PIO_OER = CMASK; }
|
||||
#define setReadDir() { \
|
||||
PMC->PMC_PCER0 = (1 << ID_PIOA)|(1 << ID_PIOB)|(1 << ID_PIOC);\
|
||||
PIOA->PIO_ODR = AMASK; PIOB->PIO_ODR = BMASK; PIOC->PIO_ODR = CMASK;\
|
||||
}
|
||||
#define write8(x) { write_8(x); WR_ACTIVE; WR_STROBE; WR_IDLE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE4; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
// 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))
|
||||
|
||||
//##################################### USE_FRDM_K20 ###################################################
|
||||
//#define USE_FRDM_K20
|
||||
#elif defined(__MK20DX128__) && defined(USE_FRDM_K20) // Uno Shield on FRDM-K20
|
||||
#warning Uno Shield on FRDM-K20
|
||||
#define RD_PORT GPIOC
|
||||
#define RD_PIN 0
|
||||
#define WR_PORT GPIOC
|
||||
#define WR_PIN 1
|
||||
#define CD_PORT GPIOD
|
||||
#define CD_PIN 6
|
||||
#define CS_PORT GPIOD
|
||||
#define CS_PIN 5
|
||||
#define RESET_PORT GPIOB
|
||||
#define RESET_PIN 1
|
||||
|
||||
// configure macros for the data pins
|
||||
#define AMASK ((1<<12)|(1<<5)|(1<<2)|(1<<1))
|
||||
#define CMASK ((1<<8)|(1<<4)|(1<<3))
|
||||
#define DMASK ((1<<4))
|
||||
#define write_8(d) { \
|
||||
GPIOA_PCOR = AMASK; GPIOC_PCOR = CMASK; GPIOD_PCOR = DMASK; \
|
||||
GPIOA_PSOR = (((d) & (1<<0)) << 12) \
|
||||
| (((d) & (1<<1)) << 1) \
|
||||
| (((d) & (1<<2)) << 3) \
|
||||
| (((d) & (1<<5)) >> 4); \
|
||||
GPIOC_PSOR = (((d) & (1<<4)) << 4) \
|
||||
| (((d) & (3<<6)) >> 3); \
|
||||
GPIOD_PSOR = (((d) & (1<<3)) << 1); \
|
||||
}
|
||||
#define read_8() ( (((GPIOA_PDIR & (1<<5)) >> 3) \
|
||||
| ((GPIOA_PDIR & (1<<1)) << 4) \
|
||||
| ((GPIOA_PDIR & (1<<12)) >> 12) \
|
||||
| ((GPIOA_PDIR & (1<<2)) >> 1) \
|
||||
| ((GPIOC_PDIR & (1<<8)) >> 4) \
|
||||
| ((GPIOC_PDIR & (3<<3)) << 3) \
|
||||
| ((GPIOD_PDIR & (1<<4)) >> 1)))
|
||||
#define setWriteDir() {GPIOA_PDDR |= AMASK;GPIOC_PDDR |= CMASK;GPIOD_PDDR |= DMASK; }
|
||||
#define setReadDir() {GPIOA_PDDR &= ~AMASK;GPIOC_PDDR &= ~CMASK;GPIOD_PDDR &= ~DMASK; }
|
||||
|
||||
#define write8(x) { write_8(x); WR_ACTIVE2; WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE4; RD_ACTIVE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
|
||||
#define PASTE(x, y) x ## y
|
||||
|
||||
#define PIN_LOW(port, pin) PASTE(port, _PCOR) = (1<<(pin))
|
||||
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
|
||||
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
|
||||
|
||||
//####################################### D21_XPRO ###########################################################
|
||||
#elif defined(__SAMD21J18A__) //regular UNO shield on D21_XPRO
|
||||
#warning regular UNO shield on D21_XPRO
|
||||
#include "samd21.h"
|
||||
// configure macros for the control pins
|
||||
#define RD_PORT PORT->Group[1]
|
||||
#define RD_PIN 0
|
||||
#define WR_PORT PORT->Group[1]
|
||||
#define WR_PIN 1
|
||||
#define CD_PORT PORT->Group[0]
|
||||
#define CD_PIN 10
|
||||
#define CS_PORT PORT->Group[0]
|
||||
#define CS_PIN 11
|
||||
#define RESET_PORT PORT->Group[0]
|
||||
#define RESET_PIN 8
|
||||
// configure macros for data bus
|
||||
#define AMASK 0x00220000
|
||||
#define BMASK 0x0000C0E4
|
||||
#define write_8(d) { \
|
||||
PORT->Group[0].OUT.reg = (PORT->Group[0].OUT.reg & ~AMASK) \
|
||||
| (((d) & (1<<5)) << 16) \
|
||||
| (((d) & (1<<7)) << 10); \
|
||||
PORT->Group[1].OUT.reg = (PORT->Group[1].OUT.reg & ~BMASK) \
|
||||
| (((d) & (3<<0)) << 6) \
|
||||
| (((d) & (1<<2)) << 12) \
|
||||
| (((d) & (1<<3)) >> 1) \
|
||||
| (((d) & (1<<4)) << 1) \
|
||||
| (((d) & (1<<6)) << 9); \
|
||||
}
|
||||
#define read_8() ( (((PORT->Group[0].IN.reg & (1<<21)) >> 16) \
|
||||
| ((PORT->Group[0].IN.reg & (1<<17)) >> 10) \
|
||||
| ((PORT->Group[1].IN.reg & (3<<6)) >> 6) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<14)) >> 12) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<2)) << 1) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<5)) >> 1) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<15)) >> 9)))
|
||||
#define setWriteDir() { \
|
||||
PORT->Group[0].DIRSET.reg = AMASK; \
|
||||
PORT->Group[1].DIRSET.reg = BMASK; \
|
||||
PORT->Group[0].WRCONFIG.reg = (AMASK>>16) | (0<<22) | (0<<28) | (1<<30) | (1<<31); \
|
||||
PORT->Group[1].WRCONFIG.reg = (BMASK & 0xFFFF) | (0<<22) | (0<<28) | (1<<30); \
|
||||
}
|
||||
#define setReadDir() { \
|
||||
PORT->Group[0].DIRCLR.reg = AMASK; \
|
||||
PORT->Group[1].DIRCLR.reg = BMASK; \
|
||||
PORT->Group[0].WRCONFIG.reg = (AMASK>>16) | (1<<17) | (0<<28) | (1<<30) | (1<<31); \
|
||||
PORT->Group[1].WRCONFIG.reg = (BMASK & 0xFFFF) | (1<<17) | (0<<28) | (1<<30); \
|
||||
}
|
||||
|
||||
#define write8(x) { write_8(x); WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { RD_STROBE; dst = read_8(); RD_IDLE; RD_STROBE; dst = (dst<<8) | read_8(); RD_IDLE; }
|
||||
// Shield Control macros.
|
||||
#define PIN_LOW(port, pin) (port).OUTCLR.reg = (1<<(pin))
|
||||
#define PIN_HIGH(port, pin) (port).OUTSET.reg = (1<<(pin))
|
||||
#define PIN_OUTPUT(port, pin) (port).DIR.reg |= (1<<(pin))
|
||||
|
||||
//###################################################################################
|
||||
@@ -67,8 +67,8 @@ BusOut analog(A0, A1, A2, A3, A4, A5, NC, NC);
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
|
||||
#define CTL_INIT() { RD_OUTPUT; WR_OUTPUT; CD_OUTPUT; CS_OUTPUT; RESET_OUTPUT; }
|
||||
#define WriteCmd(x) { CD_COMMAND; write16(x); }
|
||||
#define WriteData(x) { CD_DATA; write16(x); }
|
||||
#define WriteCmd(x) { CD_COMMAND; write16(x); CD_DATA; }
|
||||
#define WriteData(x) { write16(x); }
|
||||
|
||||
#endif //!USE_SERIAL
|
||||
#endif //MCUFRIEND_KEIL_H_
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
//#define USE_SPECIAL //check for custom drivers
|
||||
#if defined(USE_SPECIAL)
|
||||
#include "mcufriend_special.h"
|
||||
#if !defined(USE_SPECIAL_FAIL)
|
||||
#warning WE ARE USING A SPECIAL CUSTOM DRIVER
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(USE_SPECIAL) || defined (USE_SPECIAL_FAIL)
|
||||
|
||||
#define WR_ACTIVE2 {WR_ACTIVE; WR_ACTIVE;}
|
||||
#define WR_ACTIVE4 {WR_ACTIVE2; WR_ACTIVE2;}
|
||||
@@ -15,6 +8,14 @@
|
||||
#define RD_ACTIVE8 {RD_ACTIVE4; RD_ACTIVE4;}
|
||||
#define RD_ACTIVE16 {RD_ACTIVE8; RD_ACTIVE8;}
|
||||
|
||||
#if defined(USE_SPECIAL)
|
||||
#include "mcufriend_special.h"
|
||||
#if !defined(USE_SPECIAL_FAIL)
|
||||
#warning WE ARE USING A SPECIAL CUSTOM DRIVER
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(USE_SPECIAL) || defined (USE_SPECIAL_FAIL)
|
||||
|
||||
#if 0
|
||||
//################################### UNO ##############################
|
||||
#elif defined(__AVR_ATmega328P__) //regular UNO shield on UNO
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
#define SSD1289_JUMPERS 2 //Uno Shield with VERY different pin-out to Mcufriend
|
||||
// only define one "USE_XXX" macro at any time
|
||||
//#define USE_SSD1289_SHIELD_UNO
|
||||
//#define USE_SSD1289_SHIELD_MEGA
|
||||
//#define USE_SSD1289_SHIELD_DUE
|
||||
|
||||
//#define USE_MEGA_8BIT_PROTOSHIELD
|
||||
//#define USE_MEGA_8BIT_SHIELD // 4.7sec Mega2560 Shield
|
||||
//#define USE_MEGA_16BIT_SHIELD // 2.14sec Mega2560 Shield
|
||||
@@ -11,63 +8,14 @@
|
||||
//#define USE_DUE_8BIT_PROTOSHIELD
|
||||
//#define USE_DUE_16BIT_SHIELD //RD on PA15 (D24)
|
||||
//#define USE_BOBCACHELOT_TEENSY
|
||||
//#define USE_FRDM_K20
|
||||
//#define USE_OPENSMART_SHIELD_PINOUT_UNO
|
||||
//#define USE_OPENSMART_SHIELD_PINOUT_MEGA
|
||||
//#define USE_OPENSMART_SHIELD_PINOUT_DUE //thanks Michel53
|
||||
//#define USE_ELECHOUSE_DUE_16BIT_SHIELD //Untested yet
|
||||
//#define USE_MY_BLUEPILL
|
||||
//#define USE_ADIGITALEU_TEENSY
|
||||
|
||||
#if 0
|
||||
#elif defined(__AVR_ATmega328P__) && defined(USE_SSD1289_SHIELD_UNO) //on UNO
|
||||
#warning using SSD1289 Shield for mega328
|
||||
#define RD_PORT PORTC
|
||||
#define RD_PIN 3
|
||||
#define WR_PORT PORTC
|
||||
#define WR_PIN 2
|
||||
#define CD_PORT PORTC
|
||||
#define CD_PIN 1
|
||||
#define CS_PORT PORTC
|
||||
#define CS_PIN 0
|
||||
#define RESET_PORT PORTB
|
||||
#define RESET_PIN 1 //actually SD_CS
|
||||
|
||||
// SSD1289 shield has LCD_D0 on RXD0. Fine for write-only
|
||||
// For any Read operations, put jumper from D0 to D8, Switch #2 to OFF.
|
||||
// If using Serial, jumper D1 to A5, Switch #1 to OFF
|
||||
#if SSD1289_JUMPERS == 0
|
||||
#warning no jumpers. Switch #1=ON, #2=ON
|
||||
#define BMASK 0x00 //0x00 for output, 0x01 for Read + Serial
|
||||
#define CMASK 0x00 //0x20 for Read + Serial
|
||||
#define DMASK (~BMASK)
|
||||
#define write8(x) { PORTD = x; WR_STROBE; }
|
||||
#define read_8() ( PIND )
|
||||
#elif SSD1289_JUMPERS == 1
|
||||
#warning jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#define BMASK 0x01 //0x00 for output, 0x01 for Read + Serial
|
||||
#define CMASK 0x00 //0x20 for Read + Serial
|
||||
#define DMASK (~BMASK)
|
||||
#define write8(x) { PORTD = (PORTD & ~DMASK) | (x & DMASK); PORTB = (PORTB & ~BMASK) | (x & BMASK); WR_STROBE; }
|
||||
#define read_8() ( (PIND & DMASK)|(PINB & BMASK) )
|
||||
#elif SSD1289_JUMPERS == 2
|
||||
#warning jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#define BMASK (1<<0) //0x00 for output, 0x01 for Read + Serial
|
||||
#define CMASK (1<<5) //0x20 for Read + Serial
|
||||
#define DMASK (0xFC)
|
||||
#define write8(x) { PORTC = (PORTC & ~CMASK) | ((x<<4) & CMASK);\
|
||||
PORTD = (PORTD & ~DMASK) | (x & DMASK);\
|
||||
PORTB = (PORTB & ~BMASK) | (x & BMASK); WR_STROBE; }
|
||||
#define read_8() ( ((PINC & CMASK)>>4)|(PIND & DMASK)|(PINB & BMASK) )
|
||||
#endif
|
||||
#define setWriteDir() { DDRC |= CMASK; DDRD |= DMASK; DDRB |= BMASK; }
|
||||
#define setReadDir() { DDRC &= ~CMASK; DDRD &= ~DMASK; DDRB &= ~BMASK; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; 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) &= ~(1<<(b))
|
||||
#define PIN_HIGH(p, b) (p) |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
|
||||
|
||||
#elif defined(__AVR_ATxmega128A1__) // Home made shield with Xplained
|
||||
#warning Home made shield with Xplained
|
||||
@@ -90,7 +38,7 @@
|
||||
#define setReadDir() { VPORT2.DIR = 0x00; }
|
||||
#define write8(x) { write_8(x); WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE2; RD_ACTIVE; 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))
|
||||
@@ -116,7 +64,7 @@
|
||||
// ST7789 says tRC=160ns for ID and tRC=450ns for Frame Memory
|
||||
// ILI9341 says tRC=160ns for ID and tRC=450ns for Frame Memory. They are FASTER
|
||||
#define WRITE_DELAY { }
|
||||
#define READ_DELAY { RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; }
|
||||
#define READ_DELAY { RD_ACTIVE4; }
|
||||
#define write_8(x) { VPORT2.OUT = x; }
|
||||
#define read_8() ( VPORT2.IN )
|
||||
#define setWriteDir() { PORTCFG.VPCTRLA=0x10; PORTCFG.VPCTRLB=0x32; VPORT2.DIR = 0xFF; }
|
||||
@@ -181,98 +129,6 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#define PIN_HIGH(p, b) (p) |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
|
||||
|
||||
#elif defined(__AVR_ATmega2560__) && defined(USE_SSD1289_SHIELD_MEGA) //on MEGA2560
|
||||
#warning using SSD1289 Shield for mega2560
|
||||
#define RD_PORT PORTF
|
||||
#define RD_PIN 3 //A3
|
||||
#define WR_PORT PORTF
|
||||
#define WR_PIN 2 //A2
|
||||
#define CD_PORT PORTF
|
||||
#define CD_PIN 1 //A1
|
||||
#define CS_PORT PORTF
|
||||
#define CS_PIN 0 //A0
|
||||
#define RESET_PORT PORTH
|
||||
#define RESET_PIN 6 //D9 DS_CS, D10=T_CS, D9=SD_CS, D8=n.c.
|
||||
|
||||
// only for SSD1289 data bus on D2..D9 UNTESTED
|
||||
#if (SSD1289_JUMPERS == 0) //Switch #1=ON, #2=ON
|
||||
#warning no jumpers Switch #1=ON, #2=ON
|
||||
#define EMASK 0x3B
|
||||
#define FMASK 0x00
|
||||
#define HMASK 0x18
|
||||
#define GMASK 0x20
|
||||
#define write_8(x) { PORTH &= ~HMASK; PORTG &= ~GMASK; PORTE &= ~EMASK; \
|
||||
PORTE |= (((x) & (1<<0)) << 0); \
|
||||
PORTE |= (((x) & (1<<1)) << 0); \
|
||||
PORTE |= (((x) & (3<<2)) << 2); \
|
||||
PORTG |= (((x) & (1<<4)) << 1); \
|
||||
PORTE |= (((x) & (1<<5)) >> 2); \
|
||||
PORTH |= (((x) & (3<<6)) >> 3); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PINE & (1<<0)) >> 0)\
|
||||
| ((PINE & (1<<1)) >> 0)\
|
||||
| ((PINE & (3<<4)) >> 2)\
|
||||
| ((PING & (1<<5)) >> 1)\
|
||||
| ((PINE & (1<<3)) << 2)\
|
||||
| ((PINH & (3<<3)) << 3)\
|
||||
)
|
||||
#elif (SSD1289_JUMPERS == 1) //jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#warning jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#define EMASK 0x3A
|
||||
#define FMASK 0x00
|
||||
#define HMASK 0x38
|
||||
#define GMASK 0x20
|
||||
#define write_8(x) { PORTH &= ~HMASK; PORTG &= ~GMASK; PORTE &= ~EMASK; \
|
||||
PORTH |= (((x) & (1<<0)) << 5); \
|
||||
PORTE |= (((x) & (1<<1)) << 0); \
|
||||
PORTE |= (((x) & (3<<2)) << 2); \
|
||||
PORTG |= (((x) & (1<<4)) << 1); \
|
||||
PORTE |= (((x) & (1<<5)) >> 2); \
|
||||
PORTH |= (((x) & (3<<6)) >> 3); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PINH & (1<<5)) >> 5)\
|
||||
| ((PINE & (1<<1)) >> 0)\
|
||||
| ((PINE & (3<<4)) >> 2)\
|
||||
| ((PING & (1<<5)) >> 1)\
|
||||
| ((PINE & (1<<3)) << 2)\
|
||||
| ((PINH & (3<<3)) << 3)\
|
||||
)
|
||||
#elif (SSD1289_JUMPERS == 2) //jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#warning jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#define FMASK 0x20
|
||||
#define EMASK 0x38
|
||||
#define HMASK 0x38
|
||||
#define GMASK 0x20
|
||||
#define write_8(x) { PORTH &= ~HMASK; PORTG &= ~GMASK; PORTF &= ~FMASK; PORTE &= ~EMASK; \
|
||||
PORTH |= (((x) & (1<<0)) << 5); \
|
||||
PORTF |= (((x) & (1<<1)) << 4); \
|
||||
PORTE |= (((x) & (3<<2)) << 2); \
|
||||
PORTG |= (((x) & (1<<4)) << 1); \
|
||||
PORTE |= (((x) & (1<<5)) >> 2); \
|
||||
PORTH |= (((x) & (3<<6)) >> 3); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PINH & (1<<5)) >> 5)\
|
||||
| ((PINF & (1<<5)) >> 4)\
|
||||
| ((PINE & (3<<4)) >> 2)\
|
||||
| ((PING & (1<<5)) >> 1)\
|
||||
| ((PINE & (1<<3)) << 2)\
|
||||
| ((PINH & (3<<3)) << 3)\
|
||||
)
|
||||
#endif
|
||||
#define setWriteDir() { DDRH |= HMASK; DDRG |= GMASK; DDRF |= FMASK; DDRE |= EMASK; }
|
||||
#define setReadDir() { DDRH &= ~HMASK; DDRG &= ~GMASK; DDRF &= ~FMASK; DDRE &= ~EMASK; }
|
||||
#define write8(x) { write_8(x); WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { RD_STROBE; dst = read_8(); RD_IDLE; RD_STROBE; dst = (dst<<8) | read_8(); RD_IDLE; }
|
||||
|
||||
#define PIN_LOW(p, b) (p) &= ~(1<<(b))
|
||||
#define PIN_HIGH(p, b) (p) |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
|
||||
|
||||
#elif defined(__AVR_ATmega2560__) && defined(USE_MEGA_16BIT_SHIELD)
|
||||
#warning USE_MEGA_16BIT_SHIELD
|
||||
#define USES_16BIT_BUS
|
||||
@@ -411,168 +267,6 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#define PIN_HIGH(p, b) (p) |= (1<<(b))
|
||||
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
|
||||
|
||||
#elif defined(__SAMD21J18A__) //regular UNO shield on D21_XPRO
|
||||
#warning regular UNO shield on D21_XPRO
|
||||
#include "samd21.h"
|
||||
// configure macros for the control pins
|
||||
#define RD_PORT PORT->Group[1]
|
||||
#define RD_PIN 0
|
||||
#define WR_PORT PORT->Group[1]
|
||||
#define WR_PIN 1
|
||||
#define CD_PORT PORT->Group[0]
|
||||
#define CD_PIN 10
|
||||
#define CS_PORT PORT->Group[0]
|
||||
#define CS_PIN 11
|
||||
#define RESET_PORT PORT->Group[0]
|
||||
#define RESET_PIN 8
|
||||
// configure macros for data bus
|
||||
#define AMASK 0x00220000
|
||||
#define BMASK 0x0000C0E4
|
||||
#define write_8(d) { \
|
||||
PORT->Group[0].OUT.reg = (PORT->Group[0].OUT.reg & ~AMASK) \
|
||||
| (((d) & (1<<5)) << 16) \
|
||||
| (((d) & (1<<7)) << 10); \
|
||||
PORT->Group[1].OUT.reg = (PORT->Group[1].OUT.reg & ~BMASK) \
|
||||
| (((d) & (3<<0)) << 6) \
|
||||
| (((d) & (1<<2)) << 12) \
|
||||
| (((d) & (1<<3)) >> 1) \
|
||||
| (((d) & (1<<4)) << 1) \
|
||||
| (((d) & (1<<6)) << 9); \
|
||||
}
|
||||
#define read_8() ( (((PORT->Group[0].IN.reg & (1<<21)) >> 16) \
|
||||
| ((PORT->Group[0].IN.reg & (1<<17)) >> 10) \
|
||||
| ((PORT->Group[1].IN.reg & (3<<6)) >> 6) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<14)) >> 12) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<2)) << 1) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<5)) >> 1) \
|
||||
| ((PORT->Group[1].IN.reg & (1<<15)) >> 9)))
|
||||
#define setWriteDir() { \
|
||||
PORT->Group[0].DIRSET.reg = AMASK; \
|
||||
PORT->Group[1].DIRSET.reg = BMASK; \
|
||||
PORT->Group[0].WRCONFIG.reg = (AMASK>>16) | (0<<22) | (0<<28) | (1<<30) | (1<<31); \
|
||||
PORT->Group[1].WRCONFIG.reg = (BMASK & 0xFFFF) | (0<<22) | (0<<28) | (1<<30); \
|
||||
}
|
||||
#define setReadDir() { \
|
||||
PORT->Group[0].DIRCLR.reg = AMASK; \
|
||||
PORT->Group[1].DIRCLR.reg = BMASK; \
|
||||
PORT->Group[0].WRCONFIG.reg = (AMASK>>16) | (1<<17) | (0<<28) | (1<<30) | (1<<31); \
|
||||
PORT->Group[1].WRCONFIG.reg = (BMASK & 0xFFFF) | (1<<17) | (0<<28) | (1<<30); \
|
||||
}
|
||||
|
||||
#define write8(x) { write_8(x); WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { RD_STROBE; dst = read_8(); RD_IDLE; RD_STROBE; dst = (dst<<8) | read_8(); RD_IDLE; }
|
||||
// Shield Control macros.
|
||||
#define PIN_LOW(port, pin) (port).OUTCLR.reg = (1<<(pin))
|
||||
#define PIN_HIGH(port, pin) (port).OUTSET.reg = (1<<(pin))
|
||||
#define PIN_OUTPUT(port, pin) (port).DIR.reg |= (1<<(pin))
|
||||
|
||||
#elif defined(__SAM3X8E__) && defined(USE_SSD1289_SHIELD_DUE) // on DUE
|
||||
#warning USE_SSD1289_SHIELD_DUE
|
||||
// configure macros for the control pins
|
||||
#define RD_PORT PIOA
|
||||
#define RD_PIN 22 //A3
|
||||
#define WR_PORT PIOA
|
||||
#define WR_PIN 23 //A2
|
||||
#define CD_PORT PIOA
|
||||
#define CD_PIN 24 //A1
|
||||
#define CS_PORT PIOA
|
||||
#define CS_PIN 16 //A0
|
||||
#define RESET_PORT PIOC
|
||||
#define RESET_PIN 21 //D9 Touch CS
|
||||
// configure macros for data bus
|
||||
// only for SSD1289 data bus on D2..D9 UNTESTED
|
||||
#if SSD1289_JUMPERS == 0
|
||||
#warning no jumpers Switch #1=ON, #2=ON
|
||||
#define AMASK (3<<8)
|
||||
#define BMASK (1<<25)
|
||||
#define CMASK (0xBC << 21)
|
||||
#define write_8(x) { PIOA->PIO_CODR = AMASK; PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
|
||||
PIOA->PIO_SODR = (((x) & (1<<0)) << 8); \
|
||||
PIOA->PIO_SODR = (((x) & (1<<1)) << 8); \
|
||||
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PIOA->PIO_PDSR & (1<<8)) >> 8)\
|
||||
| ((PIOA->PIO_PDSR & (1<<9)) >> 8)\
|
||||
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
|
||||
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
|
||||
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
|
||||
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
|
||||
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
|
||||
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
|
||||
)
|
||||
#elif SSD1289_JUMPERS == 1
|
||||
#warning jumper D0 to D8. Switch #1=ON, #2=OFF
|
||||
#define AMASK (1<<9)
|
||||
#define BMASK (1<<25)
|
||||
#define CMASK (0xBE << 21)
|
||||
#define write_8(x) { PIOA->PIO_CODR = AMASK; PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
|
||||
PIOC->PIO_SODR = (((x) & (1<<0)) << 22); \
|
||||
PIOA->PIO_SODR = (((x) & (1<<1)) << 8); \
|
||||
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PIOC->PIO_PDSR & (1<<22)) >> 22)\
|
||||
| ((PIOA->PIO_PDSR & (1<<9)) >> 8)\
|
||||
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
|
||||
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
|
||||
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
|
||||
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
|
||||
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
|
||||
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
|
||||
)
|
||||
#elif SSD1289_JUMPERS == 2
|
||||
#warning jumper D0 to D8, D1 to A5. Switch #1=OFF, #2=OFF
|
||||
#define AMASK (1<<4)
|
||||
#define BMASK (1<<25)
|
||||
#define CMASK (0xBE << 21)
|
||||
#define write_8(x) { PIOA->PIO_CODR = AMASK; PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
|
||||
PIOC->PIO_SODR = (((x) & (1<<0)) << 22); \
|
||||
PIOA->PIO_SODR = (((x) & (1<<1)) << 3); \
|
||||
PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
|
||||
PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
|
||||
}
|
||||
|
||||
#define read_8() ( ((PIOC->PIO_PDSR & (1<<22)) >> 22)\
|
||||
| ((PIOA->PIO_PDSR & (1<<4)) >> 3)\
|
||||
| ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
|
||||
| ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
|
||||
| ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
|
||||
| ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
|
||||
| ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
|
||||
| ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
|
||||
)
|
||||
#endif
|
||||
#define setWriteDir() { PIOA->PIO_OER = AMASK; PIOB->PIO_OER = BMASK; PIOC->PIO_OER = CMASK; }
|
||||
#define setReadDir() { \
|
||||
PMC->PMC_PCER0 = (1 << ID_PIOA)|(1 << ID_PIOB)|(1 << ID_PIOC);\
|
||||
PIOA->PIO_ODR = AMASK; PIOB->PIO_ODR = BMASK; PIOC->PIO_ODR = CMASK;\
|
||||
}
|
||||
#define write8(x) { write_8(x); WR_ACTIVE; WR_STROBE; WR_IDLE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
// 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))
|
||||
|
||||
#elif defined(__SAM3X8E__) && defined(USE_DUE_8BIT_PROTOSHIELD) //regular UNO shield on DUE
|
||||
#warning USE_DUE_8BIT_PROTOSHIELD
|
||||
// configure macros for the control pins
|
||||
@@ -595,7 +289,7 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#define setReadDir() { PMC->PMC_PCER0 = (1 << ID_PIOD); PIOD->PIO_ODR = DMASK;}
|
||||
#define write8(x) { write_8(x); WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE4; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
// Shield Control macros.
|
||||
#define PIN_LOW(port, pin) (port)->PIO_CODR = (1<<(pin))
|
||||
@@ -631,7 +325,7 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#define setReadDir() { PMC->PMC_PCER0 = (1 << ID_PIOC); PIOC->PIO_ODR = CMASK; }
|
||||
#define write8(x) { write16(x & 0xFF); }
|
||||
#define write16(x) { write_16(x); WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
|
||||
#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_16(dst) { RD_STROBE; RD_ACTIVE4; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_8(dst) { READ_16(dst); dst &= 0xFF; }
|
||||
|
||||
// Shield Control macros.
|
||||
@@ -668,7 +362,7 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#define setReadDir() { PMC->PMC_PCER0 = (1 << ID_PIOC); PIOC->PIO_ODR = CMASK; }
|
||||
#define write8(x) { write16(x & 0xFF); }
|
||||
#define write16(x) { write_16(x); WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
|
||||
#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_16(dst) { RD_STROBE; RD_ACTIVE4; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_8(dst) { READ_16(dst); dst &= 0xFF; }
|
||||
|
||||
// Shield Control macros.
|
||||
@@ -746,8 +440,8 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
}
|
||||
#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 write16(x) { write_16(x); WR_ACTIVE2; WR_STROBE; }
|
||||
#define READ_16(dst) { RD_STROBE; RD_ACTIVE4; dst = read_16(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_8(dst) { READ_16(dst); dst &= 0xFF; }
|
||||
|
||||
// Shield Control macros.
|
||||
@@ -801,9 +495,9 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
}
|
||||
|
||||
// ILI9486 is slower than ILI9481. HX8357-D is slower
|
||||
#define write8(x) { write_8(x); WR_ACTIVE; WR_ACTIVE; WR_ACTIVE; WR_ACTIVE; WR_STROBE; WR_IDLE; WR_IDLE; }
|
||||
#define write8(x) { write_8(x); WR_ACTIVE4; WR_STROBE; WR_IDLE; WR_IDLE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE4; dst = read_8(); RD_IDLE; RD_IDLE; RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
|
||||
// Shield Control macros.
|
||||
@@ -900,54 +594,6 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
|
||||
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
|
||||
|
||||
#elif defined(__MK20DX128__) && defined(USE_FRDM_K20) // Uno Shield on FRDM-K20
|
||||
#warning Uno Shield on FRDM-K20
|
||||
#define RD_PORT GPIOC
|
||||
#define RD_PIN 0
|
||||
#define WR_PORT GPIOC
|
||||
#define WR_PIN 1
|
||||
#define CD_PORT GPIOD
|
||||
#define CD_PIN 6
|
||||
#define CS_PORT GPIOD
|
||||
#define CS_PIN 5
|
||||
#define RESET_PORT GPIOB
|
||||
#define RESET_PIN 1
|
||||
|
||||
// configure macros for the data pins
|
||||
#define AMASK ((1<<12)|(1<<5)|(1<<2)|(1<<1))
|
||||
#define CMASK ((1<<8)|(1<<4)|(1<<3))
|
||||
#define DMASK ((1<<4))
|
||||
#define write_8(d) { \
|
||||
GPIOA_PCOR = AMASK; GPIOC_PCOR = CMASK; GPIOD_PCOR = DMASK; \
|
||||
GPIOA_PSOR = (((d) & (1<<0)) << 12) \
|
||||
| (((d) & (1<<1)) << 1) \
|
||||
| (((d) & (1<<2)) << 3) \
|
||||
| (((d) & (1<<5)) >> 4); \
|
||||
GPIOC_PSOR = (((d) & (1<<4)) << 4) \
|
||||
| (((d) & (3<<6)) >> 3); \
|
||||
GPIOD_PSOR = (((d) & (1<<3)) << 1); \
|
||||
}
|
||||
#define read_8() ( (((GPIOA_PDIR & (1<<5)) >> 3) \
|
||||
| ((GPIOA_PDIR & (1<<1)) << 4) \
|
||||
| ((GPIOA_PDIR & (1<<12)) >> 12) \
|
||||
| ((GPIOA_PDIR & (1<<2)) >> 1) \
|
||||
| ((GPIOC_PDIR & (1<<8)) >> 4) \
|
||||
| ((GPIOC_PDIR & (3<<3)) << 3) \
|
||||
| ((GPIOD_PDIR & (1<<4)) >> 1)))
|
||||
#define setWriteDir() {GPIOA_PDDR |= AMASK;GPIOC_PDDR |= CMASK;GPIOD_PDDR |= DMASK; }
|
||||
#define setReadDir() {GPIOA_PDDR &= ~AMASK;GPIOC_PDDR &= ~CMASK;GPIOD_PDDR &= ~DMASK; }
|
||||
|
||||
#define write8(x) { write_8(x); WR_ACTIVE; WR_ACTIVE; WR_STROBE; }
|
||||
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
|
||||
#define READ_8(dst) { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
|
||||
|
||||
#define PASTE(x, y) x ## y
|
||||
|
||||
#define PIN_LOW(port, pin) PASTE(port, _PCOR) = (1<<(pin))
|
||||
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
|
||||
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
|
||||
|
||||
#elif defined(__AVR_ATmega328P__) && defined(USE_OPENSMART_SHIELD_PINOUT_UNO)
|
||||
#define RD_PORT PORTC
|
||||
#define RD_PIN 0
|
||||
@@ -1073,6 +719,54 @@ static __attribute((always_inline)) void write_8(uint8_t val)
|
||||
#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); }
|
||||
|
||||
//####################################### ADIGITALEU_TEENSY ############################
|
||||
//UNTESTED
|
||||
#elif defined(__MK66FX1M0__) && defined(USE_ADIGITALEU_TEENSY) // 16bit on a Teensy 3.6
|
||||
#warning "Teensy 3.6 16bit port C & D only (for now)"
|
||||
// Note: Port usage explained in UTFT Teensy edition ...\libraries\UTFT\hardware\arm\HW_Teensy3.h"
|
||||
|
||||
#define USES_16BIT_BUS
|
||||
|
||||
#define WRITE_DELAY { WR_ACTIVE8; }
|
||||
#define READ_DELAY { RD_ACTIVE16; }
|
||||
|
||||
#define RD_PORT GPIOA
|
||||
#define RD_PIN 16 //28 RD
|
||||
#define WR_PORT GPIOA
|
||||
#define WR_PIN 5 //25 WR
|
||||
#define CD_PORT GPIOE
|
||||
#define CD_PIN 26 //24 RS
|
||||
#define CS_PORT GPIOA
|
||||
#define CS_PIN 14 //26 CS
|
||||
#define RESET_PORT GPIOA
|
||||
#define RESET_PIN 15 //27 Reset
|
||||
|
||||
#define write_8(d) { GPIOC_PDOR = d; }
|
||||
#define write_16(d) { GPIOC_PDOR = d; GPIOD_PDOR = (d >> 8);}
|
||||
|
||||
#define read_8() (GPIOC_PDIR)
|
||||
#define read_16() (GPIOC_PDIR | GPIOD_PDIR << 8)
|
||||
|
||||
#define setWriteDir() {GPIOC_PDDR |= 0xFF; GPIOD_PDDR |= 0xFF; }
|
||||
#define setReadDir() {GPIOC_PDDR &= ~0xFF; GPIOD_PDDR &= ~0xFF; }
|
||||
|
||||
#define write8(x) {write_8(x); WRITE_DELAY; WR_STROBE }
|
||||
#define write16(x) {write_16(x); WRITE_DELAY; WR_STROBE }
|
||||
|
||||
#define READ_8(dst) { RD_STROBE; READ_DELAY; dst = read_8(); RD_IDLE; }
|
||||
#define READ_16(dst) { RD_STROBE; READ_DELAY; dst = read_16(); RD_IDLE;}
|
||||
|
||||
//Data: Teensy pins -> D0-D15 :
|
||||
// Teensy probably initialises some pins for Analog, Timer, Alternate, ...
|
||||
// so it is probably wise to use pinMode(n, OUTPUT) for all the control and data lines
|
||||
#define GPIO_INIT() {pinMode(2, OUTPUT); for (int i = 5; i <= 15; i++) pinMode(i, OUTPUT); for (int i = 20; i <= 28; i++) pinMode(i, OUTPUT);}
|
||||
|
||||
#define PASTE(x, y) x ## y
|
||||
|
||||
#define PIN_LOW(port, pin) PASTE(port, _PCOR) = (1<<(pin))
|
||||
#define PIN_HIGH(port, pin) PASTE(port, _PSOR) = (1<<(pin))
|
||||
#define PIN_OUTPUT(port, pin) PASTE(port, _PDDR) |= (1<<(pin))
|
||||
|
||||
#else
|
||||
#define USE_SPECIAL_FAIL
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user