Merge remote-tracking branch 'refs/remotes/origin/test_7793'

This commit is contained in:
prenticedavid
2022-01-26 17:50:56 +00:00

View File

@@ -47,11 +47,13 @@ ST7796S tWC = 66ns tWRH = 15ns tRCFM = 450ns tRC = 160ns
#elif defined(USE_MY_PICO) && defined(ARDUINO_ARCH_RP2040) //regular UNO shield on PICO
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST | |
//RP2040 pin|GP13|GP12|GP11|GP10|GP9 |GP8|GP19|GP18| |GP14|GP26|GP27|GP28|GP16|GP17|
//BODMER pin|GP13|GP12|GP11|GP10|GP9 |GP8|GP7 |GP6 | |GP14|GP22|GP27|GP28|GP16|GP17|
//UNO pins |7 |6 |5 |4 |3 |2 |9 |8 | |A0 |A1 |A2 |A3 |A4 |A5 |
//LCD pins |CS |MOSI|MISO|SCK | |SDA|SCL|
//RP2040 pin|GP21|GP3 |GP4 |GP2 | |GP6|GP7|
//UNO pins |10 |11 |12 |13 | |18 |19 |
//#define USE_BODMER
#define WRITE_DELAY { WR_ACTIVE4; }
#define IDLE_DELAY { WR_IDLE; }
@@ -70,14 +72,19 @@ ST7796S tWC = 66ns tWRH = 15ns tRCFM = 450ns tRC = 160ns
#define LMASK (0x03 << 18)
#define HMASK (0xFC << 6)
#if defined(USE_BODMER)
//#define WR_PIN 22
#define LMASK (0x00 << 18)
#define HMASK (0xFF << 6)
#endif
#define GPMASK (LMASK | HMASK) //more intuitive style for mixed Ports
#define write_8(x) { sio_hw->gpio_clr = GPMASK; \
sio_hw->gpio_set = ((((x) & 0x03) << 18)) | ((((x) & 0xFC) << 6)); \
sio_hw->gpio_set = (((x) << 18) & LMASK) | (((x) << 6) & HMASK); \
}
#define read_8() ( ((sio_hw->gpio_in & HMASK) >> 6) | ((sio_hw->gpio_in & LMASK) >> 18) )
#define setWriteDir() { sio_hw->gpio_oe_set = GPMASK; }
#define setReadDir() { sio_hw->gpio_oe_clr = GPMASK; }
#define GPIO_INIT() {for (int i = 8; i <= 14; i++) pinMode(i, OUTPUT); for (int i = 16; i <= 28; i++) pinMode(i, OUTPUT);}
#define GPIO_INIT() {for (int i = 6; i <= 14; i++) pinMode(i, OUTPUT); for (int i = 16; i <= 28; i++) pinMode(i, OUTPUT);}
#define write8(x) { write_8(x); WRITE_DELAY; WR_STROBE; IDLE_DELAY; }
#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_IDLE2; RD_IDLE; }
@@ -87,102 +94,87 @@ ST7796S tWC = 66ns tWRH = 15ns tRCFM = 450ns tRC = 160ns
#define PIN_HIGH(port, pin) (port)->gpio_set = (1<<(pin))
#define PIN_OUTPUT(port, pin) (port)->gpio_oe_set = (1<<(pin))
#elif defined(__AVR_ATxmega128A1__) // Xplained or MIKROE
#if defined(USE_MIKROELEKTRONIKA) // HX8347-D 16.2ns@62MHz 20.9ns@48MHz
//################################### XMEGA BOARDS ##############################
#elif defined(__AVR_ATxmega128A1__)||defined(__AVR_ATxmega128A4U__)||defined(__AVR_ATxmega32A4U__)||defined(__AVR_ATxmega32E5__)
#if defined(__AVR_ATxmega128A1__) && defined(USE_CVSTK600)
#warning Home made shield with Xplained A1: CTL=J3 (PD), DATA=J2 (PA)
#define VPMAP10 0x10 // VPORT0=A, 1=B, 2=C, 3=D
#define VPMAP32 0x32 // VPORT0=A, 1=B, 2=C, 3=D
#define DATPORT VPORT0 //PORTA
#define CTLPORT VPORT3 //PORTD
#define RD_PORT CTLPORT //PD2. use individual jumper cables
#define RD_PIN 2
#define WR_PORT CTLPORT
#define WR_PIN 3
#define CD_PORT CTLPORT
#define CD_PIN 1
#define CS_PORT CTLPORT
#define CS_PIN 0
#define RESET_PORT CTLPORT
#define RESET_PIN 4
#elif defined(__AVR_ATxmega128A1__) && defined(USE_MIKROELEKTRONIKA) // HX8347-D 16.2ns@62MHz 20.9ns@48MHz
#if F_CPU > 46000000
#error MIKROELEKTRONIKA must be less than 48MHz
#else
#warning MIKROELEKTRONIKA DEV BOARD (48MHz max)
#endif
#define WRITE_DELAY { }
#define READ_DELAY { RD_ACTIVE4; }
#define VPMAP10 0x58 // VPORT0=J, 1=F, 2=K, 3=D
#define VPMAP32 0x39 // VPORT0=J, 1=F, 2=K, 3=D
#define RD_PORT VPORT0 //PJ2.
#define DATPORT VPORT2 //PORTK
#define CTLPORT VPORT0 //PORTJ
#define RD_PORT CTLPORT //PJ2.
#define RD_PIN 2
#define WR_PORT VPORT0
#define WR_PORT CTLPORT
#define WR_PIN 3
#define CD_PORT VPORT0
#define CD_PORT CTLPORT
#define CD_PIN 4
#define CS_PORT VPORT0
#define CS_PORT CTLPORT
#define CS_PIN 5
#define RESET_PORT VPORT0 //PJ1
#define RESET_PORT CTLPORT //PJ1
#define RESET_PIN 1
#else
#warning Home made shield with Xplained CTL=J1 (PC), DATA=J4 (PF)
#define WRITE_DELAY { }
#define READ_DELAY { RD_ACTIVE4; }
#define VPMAP10 0x15 // VPORT0=F, 1=B, 2=C, 3=D
#define VPMAP32 0x32 // VPORT0=F, 1=B, 2=C, 3=D
#define RD_PORT VPORT0 //PF0.
#elif defined(__AVR_ATxmega128A1__)
#warning Home made shield with Xplained A1 CTL=J4 (PC), DATA=J2 (PA)
#define VPMAP10 0x50 // VPORT0=A, 1=F, 2=C, 3=D
#define VPMAP32 0x32 // VPORT0=A, 1=F, 2=C, 3=D
#define DATPORT VPORT0 //PORTA
#define CTLPORT VPORT2 //PORTC
#define RD_PORT CTLPORT //PC0.
#define RD_PIN 0
#define WR_PORT VPORT0
#define WR_PORT CTLPORT
#define WR_PIN 1
#define CD_PORT VPORT0
#define CD_PORT CTLPORT
#define CD_PIN 2
#define CS_PORT VPORT0
#define CS_PORT CTLPORT
#define CS_PIN 3
#define RESET_PORT VPORT0 //PK4
#define RESET_PORT CTLPORT //PC4
#define RESET_PIN 4
#endif
// VPORTs are very fast. CBI, SBI are only one cycle. Hence all those RD_ACTIVEs
// ILI9320 data sheet says tDDR=100ns. We need 218ns to read REGs correctly.
#define write_8(x) { VPORT2.OUT = x; }
#define read_8() ( VPORT2.IN )
#define setWriteDir() { PORTCFG.VPCTRLA=VPMAP10; PORTCFG.VPCTRLB=VPMAP32; VPORT2.DIR = 0xFF; }
#define setReadDir() { VPORT2.DIR = 0x00; }
#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; RD_ACTIVE2; RD_ACTIVE; dst = read_8(); RD_IDLE; }
#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_ATxmega32A4U__) || defined(__AVR_ATxmega128A4U__) // Home made shield with Batsocks module
#warning Home made shield with Batsocks module
#define RD_PORT VPORT1 //PB0. VPORT0=A, 1=B, 2=C, 3=D
#define VPMAP10 0x10 // VPORT0=A, 1=B, 2=C, 3=D
#define VPMAP32 0x32 // VPORT0=A, 1=B, 2=C, 3=D
#define DATPORT VPORT2 //PORTC
#define CTLPORT VPORT1 //PORTB
#define RD_PORT CTLPORT //PB0.
#define RD_PIN 0
#define WR_PORT VPORT1
#define WR_PORT CTLPORT
#define WR_PIN 1
#define CD_PORT VPORT1
#define CD_PORT CTLPORT
#define CD_PIN 2
#define CS_PORT VPORT1
#define CS_PORT CTLPORT
#define CS_PIN 3
#define RESET_PORT PORTE
#define RESET_PIN 0
// VPORTs are very fast. CBI, SBI are only one cycle. Hence all those RD_ACTIVEs
// ILI9320 data sheet says tDDR=100ns. We need 218ns to read REGs correctly.
// S6D0154 data sheet says tDDR=250ns. We need ~500ns to read REGs correctly.
// ST7789 data sheet says tRC=450ns. We need ~167ns to read REGs correctly. (10 cycles @ 60MHz )
// 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_ACTIVE4; }
#define write_8(x) { VPORT2.OUT = x; }
#define read_8() ( VPORT2.IN )
#define setWriteDir() { PORTCFG.VPCTRLA=0x10; PORTCFG.VPCTRLB=0x32; VPORT2.DIR = 0xFF; }
#define setReadDir() { VPORT2.DIR = 0x00; }
#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_ATxmega32E5__) // Xplained E5 F_CPU <= 46MHz
#warning Home made shield with Xplained E5: CTL=J2 (PD), DATA=J0 (PA)
#define CTLPORT VPORT2 //PORTD on J2
#define DATPORT VPORT0 //PORTA on J3, SW103=hdr
#define WRITE_DELAY { }
#define READ_DELAY { RD_ACTIVE4; }
#define RD_PORT CTLPORT
#warning Home made shield with Xplained E5: CTL=J4 (PD), DATA=J2 (PA)
//no VPMAPxx on 32E5. Fixed VPORT0=A, 1=C, 2=D, 3=R
#define CTLPORT VPORT2 //PORTD on J4
#define DATPORT VPORT0 //PORTA on J2, SW103=hdr
#define RD_PORT CTLPORT //PD0.
#define RD_PIN 0
#define WR_PORT CTLPORT
#define WR_PIN 1
@@ -193,11 +185,25 @@ ST7796S tWC = 66ns tWRH = 15ns tRCFM = 450ns tRC = 160ns
#define RESET_PORT CTLPORT //10k p.u. to 3V3
#define RESET_PIN 4
#endif //VPORT and pin mapping
#if defined(VPMAP10)
#define MAP_VPORTS() { PORTCFG.VPCTRLA=VPMAP10; PORTCFG.VPCTRLB=VPMAP32; }
#else
#define MAP_VPORTS()
#endif
// VPORTs are very fast. CBI, SBI are only one cycle. Hence all those RD_ACTIVEs
// ILI9320 data sheet says tDDR=100ns. We need 218ns to read REGs correctly.
// S6D0154 data sheet says tDDR=250ns. We need ~500ns to read REGs correctly.
// ST7789 data sheet says tRC=450ns. We need ~167ns to read REGs correctly. (10 cycles @ 60MHz )
// 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_ACTIVE4; }
#define write_8(x) { DATPORT.OUT = x; }
#define read_8() ( DATPORT.IN )
#define setWriteDir() { DATPORT.DIR = 0xFF; }
#define setWriteDir() { MAP_VPORTS(); DATPORT.DIR = 0xFF; }
#define setReadDir() { DATPORT.DIR = 0x00; }
#define write8(x) { write_8(x); WRITE_DELAY; WR_STROBE; }
#define write16(x) { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
@@ -517,6 +523,12 @@ static __attribute((always_inline)) void write_8(uint8_t val)
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
#elif defined(__AVR_ATmega2560__) && defined(USE_MEGA_16BIT_SHIELD)
//LCD pins |D15 |D14 |D13 |D12 |D11 |D10 |D9 |D8 |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
//ATmega2560 |PA7 |PA6 |PA5 |PA4 |PA3 |PA2 |PA1 |PA0 |PC7 |PC6 |PC5 |PC4 |PC3 |PC2 |PC1 |PC0 |
//MEGA2560pin|29 |28 |27 |26 |25 |24 |23 |22 |30 |31 |32 |33 |34 |35 |36 |37 |
//LCD pins |RD |WR |RS |CS |RST |
//ATmega2560 |PL6 |PG2 |PD7 |PG1 |PG0 |
//MEGA2560pin|43 |39 |38 |40 |41 |
#warning USE_MEGA_16BIT_SHIELD
#define USES_16BIT_BUS
#define RD_PORT PORTL
@@ -547,6 +559,9 @@ static __attribute((always_inline)) void write_8(uint8_t val)
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
#elif defined(__AVR_ATmega2560__) && defined(USE_MEGA_8BIT_SHIELD)
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST |
//ATmega2560 |PA7 |PA6 |PA5 |PA4 |PA3 |PA2 |PA1 |PA0 | |PL6 |PG2 |PD7 |PG1 |PG0 |
//MEGA2560pin|29 |28 |27 |26 |25 |24 |23 |22 | |43 |39 |38 |40 |41 |
#warning USE_MEGA_8BIT_SHIELD for vagos21
#define RD_PORT PORTL
#define RD_PIN 6 //PL6 (D43). Graham has PA15 (D24) on Due Shield
@@ -574,6 +589,9 @@ static __attribute((always_inline)) void write_8(uint8_t val)
#define PIN_OUTPUT(p, b) *(&p-1) |= (1<<(b))
#elif defined(__AVR_ATmega2560__) && defined(USE_MEGA_8BIT_PORTC_SHIELD)
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST |
//ATmega2560 |PC7 |PC6 |PC5 |PC4 |PC3 |PC2 |PC1 |PC0 | |PL6 |PG2 |PD7 |PG1 |PG0 |
//MEGA2560pin|30 |31 |32 |33 |34 |35 |36 |37 | |43 |39 |38 |40 |41 |
#warning USE_MEGA_8BIT_PORTC_SHIELD for Mihael54
#define RD_PORT PORTL
#define RD_PIN 6 //PL6 (D43). Graham has PA15 (D24) on Due Shield
@@ -801,6 +819,12 @@ static __attribute((always_inline)) void write_8(uint8_t val)
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))
#elif defined(__SAM3X8E__) && defined(USE_MEGA_16BIT_SHIELD) //regular MEGA shield on DUE
//LCD pins |D15 |D14 |D13 |D12 |D11 |D10 |D9 |D8 |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
//SAM3XE pin |PD6 |PD3 |PD2 |PD1 |PD0 |PA15|PA14|PB26|PD9 |PA7 |PD10|PC1 |PC2 |PC3 |PC4 |PC5 |
//Due pins |29 |28 |27 |26 |25 |24 |23 |22 |30 |31 |32 |33 |34 |35 |36 |37 |
//LCD pins |RD |WR |RS |CS |RST |
//SAM3XE pin |PA20|PC7 |PC6 |PC8 |PC9 |
//Due pins |43 |39 |38 |40 |41 |
#warning USE_MEGA_16BIT_SHIELD
#define USES_16BIT_BUS
// configure macros for the control pins
@@ -880,6 +904,9 @@ static __attribute((always_inline)) void write_8(uint8_t val)
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))
#elif defined(__SAM3X8E__) && defined(USE_MEGA_8BIT_SHIELD) //regular CTE shield on DUE
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST |
//SAM3XE pin |PD6 |PD3 |PD2 |PD1 |PD0 |PA15|PA14|PB26| |PA20|PC7 |PC6 |PC8 |PC9 |
//Due pins |29 |28 |27 |26 |25 |24 |23 |22 | |43 |39 |38 |40 |41 |
#warning USE_MEGA_8BIT_SHIELD for peloxp
// configure macros for the control pins
#define RD_PORT PIOA
@@ -936,6 +963,9 @@ static __attribute((always_inline)) void write_8(uint8_t val)
#define PIN_OUTPUT(port, pin) (port)->PIO_OER = (1<<(pin))
#elif defined(__SAM3X8E__) && defined(USE_MEGA_8BIT_PORTC_SHIELD) //Surenoo 8/16bit shield on DUE
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST |
//SAM3XE pin |PD9 |PA7 |PD10|PC1 |PC2 |PC3 |PC4 |PC5 | |PA20|PC7 |PC6 |PC8 |PC9 |
//Due pins |30 |31 |32 |33 |34 |35 |36 |37 | |43 |39 |38 |40 |41 |
#warning USE_MEGA_8BIT_PORTC_SHIELD on DUE
// configure macros for the control pins
#define RD_PORT PIOA