Closed jox1a closed 1 year ago
new macro works well T4 + Open smart 3.0" R61509v should work fine with other TFTs feel free to use``
//####################################### TEENSY 4.0 ############################
//#warning regular UNO shield on a Teensy 4.0
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST |
//MXRT pin |9.31|9.7|9.8|9.6|9.5|9.4|7.11|7.12| |6.31|6.30|6.13|6.12|8.18|
//4.x pins |29 |33 |5 |4 |3 |2 |9 |32 | |27 |26 |25 |24 |28 |
// configure macros for the data pins
GPIO7_DR_CLEAR = GMASK; GPIO9_DR_CLEAR = IMASK; \
GPIO7_DR_SET = (((d) & (1 << 0)) << 12) \
| (((d) & (1 << 1)) << 10); \
GPIO9_DR_SET = (((d) & (1 << 2)) << 2) \
| (((d) & (1 << 3)) << 2) \
| (((d) & (1 << 4)) << 2) \
| (((d) & (1 << 5)) << 3) \
| (((d) & (1 << 6)) << 1) \
| (((d) & (1 << 7)) << 24);\
}
| ((GPIO7_PSR & (1 << 11)) >> 10) \
| ((GPIO9_PSR & (1 << 4)) >> 2) \
| ((GPIO9_PSR & (1 << 5)) >> 2) \
| ((GPIO9_PSR & (1 << 6)) >> 2) \
| ((GPIO9_PSR & (1 << 8)) >> 3) \
| ((GPIO9_PSR & (1 << 7)) >> 1) \
| ((GPIO9_PSR & (1 << 31)) >> 24)))
for (int i = 32; i <= 33; i++) pinMode(i, OUTPUT); \
for (int i = A10; i <= A13; i++) pinMode(i, OUTPUT);\
pinMode(28, OUTPUT);pinMode(29, OUTPUT);pinMode(9, OUTPUT);\
}
Hi all I wrote a new macro for T4.0 However, it does not work, probably somewhere there is a mistake that I do not see. Maybe Someone with More Experience Can Have A Closer Look and Tell Me What Is Wrong.
//####################################### TEENSY 4.0 ############################
elif defined(IMXRT1062)
//jox1//////////////////////////////////////////////////////////////////////////// RD-WR Analog-Digital //LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST |
// T4.0 pin |32 |30 |31 |28 |29 |33 |3 |2 | |24 |25 |26 |27 |21 |
// MXRT pin |7.12 |8.23 |8.22|8.18|9.31|9.7 |9.5|9.4| |6.12|6.13|6.30|6.21|6.27|
define RD_PORT GPIO6
define RD_PIN 12
define WR_PORT GPIO6
define WR_PIN 13
define CD_PORT GPIO6
define CD_PIN 30 //rs
define CS_PORT GPIO6
define CS_PIN 21
define RESET_PORT GPIO6
define RESET_PIN 27
if 0
elif defined(IMXRT1062)
define WRITE_DELAY { WR_ACTIVE8;WR_ACTIVE8; }
define IDLE_DELAY { WR_IDLE2;WR_IDLE; }
define READ_DELAY { RD_ACTIVE16;RD_ACTIVE16; }
else
error unspecified delays
endif
define RD_PORT GPIO6
define RD_PIN 12
define WR_PORT GPIO6
define WR_PIN 13
define CD_PORT GPIO6
define CD_PIN 30 //rs
define CS_PORT GPIO6
define CS_PIN 21
define RESET_PORT GPIO6
define RESET_PIN 27
// configure macros for the data pins // D0 D1 D2 D3
define GMASK ((1<<4)|(1<<5)|(1<<7)|(1<<31)) //gipo9
// D4 D5 D6
define HMASK ((1<<18)|(1<<22)|(1<<23)) //gipo8
// D7
define IMASK ((1<<12)) //gipo7
define write_8(d) { \
define read_8() ((((GIPO9_PSR & (1 << 4)) >> 4)\
define setWriteDir() {GPIO7_GDIR |= IMASK; GPIO8_GDIR |= HMASK; GIPO9_GDIR |= GMASK }
define setReadDir() {GPIO7_GDIR &= ~IMASK; GIPO8_GDIT &= ~HMASK; GPIO9_GDIR &= ~GMASK; }
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; }
define READ_16(dst) { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }
define GPIO_INIT() {for (int i = 2; i <= 3; i++) pinMode(i, OUTPUT); \
define PASTE(x, y) x ## y
define PIN_LOW(port, pin) PASTE(port, _DR_CLEAR) = (1<<(pin))
define PIN_HIGH(port, pin) PASTE(port, _DR_SET) = (1<<(pin))
define PIN_OUTPUT(port, pin) PASTE(port, _GDIR) |= (1<<(pin))
Thanks.