Compatible with IDE 1.0.6 (Teensyduino 1.2) and IDE 1.6.x (Teensyduino 1.21b)
This commit is contained in:
parent
69391fe760
commit
91b48aeef3
2 changed files with 85 additions and 46 deletions
|
|
@ -631,17 +631,9 @@ void TFT_ILI9163C::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||||
#else
|
#else
|
||||||
writedata16(color);
|
writedata16(color);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFT_ILI9163C::setAddr(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1){
|
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
|
||||||
SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
|
|
||||||
_setAddrWindow(x0,y0,x1,y1);
|
|
||||||
#else
|
|
||||||
setAddrWindow(x0,y0,x1,y1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void TFT_ILI9163C::endProc(void){
|
void TFT_ILI9163C::endProc(void){
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
|
|
@ -818,7 +810,14 @@ void TFT_ILI9163C::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void TFT_ILI9163C::setAddr(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1){
|
||||||
|
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
|
SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
|
||||||
|
_setAddrWindow(x0,y0,x1,y1);
|
||||||
|
#else
|
||||||
|
setAddrWindow(x0,y0,x1,y1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void TFT_ILI9163C::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
void TFT_ILI9163C::setAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
|
||||||
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
#if defined(__MK20DX128__) || defined(__MK20DX256__)
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@
|
||||||
0.6b3: Clear Screen fix v2. Added Idle mode.
|
0.6b3: Clear Screen fix v2. Added Idle mode.
|
||||||
0.7: Init correction.Clear Screen fix v3 (last time?)
|
0.7: Init correction.Clear Screen fix v3 (last time?)
|
||||||
0.75: SPI transactions for arduino's (beta)
|
0.75: SPI transactions for arduino's (beta)
|
||||||
|
0.8: Compatiblke with IDE 1.0.6 (teensyduino 1.20) and IDE 1.6.x (teensyduino 1.21b)
|
||||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
BugList of the current version:
|
BugList of the current version:
|
||||||
|
|
||||||
|
|
@ -325,7 +326,11 @@ class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
uint32_t sr;
|
uint32_t sr;
|
||||||
uint32_t tmp __attribute__((unused));
|
uint32_t tmp __attribute__((unused));
|
||||||
do {
|
do {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
sr = KINETISK_SPI0.SR;
|
||||||
|
#else
|
||||||
sr = SPI0.SR;
|
sr = SPI0.SR;
|
||||||
|
#endif
|
||||||
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
||||||
} while ((sr & (15 << 12)) > (3 << 12));
|
} while ((sr & (15 << 12)) > (3 << 12));
|
||||||
}
|
}
|
||||||
|
|
@ -334,50 +339,85 @@ class TFT_ILI9163C : public Adafruit_GFX {
|
||||||
uint32_t sr;
|
uint32_t sr;
|
||||||
uint32_t tmp __attribute__((unused));
|
uint32_t tmp __attribute__((unused));
|
||||||
do {
|
do {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
sr = KINETISK_SPI0.SR;
|
||||||
|
#else
|
||||||
sr = SPI0.SR;
|
sr = SPI0.SR;
|
||||||
|
#endif
|
||||||
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
if (sr & 0xF0) tmp = SPI0_POPR; // drain RX FIFO
|
||||||
} while ((sr & 0xF0F0) > 0); // wait both RX & TX empty
|
} while ((sr & 0xF0F0) > 0); // wait both RX & TX empty
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitTransmitComplete(void) __attribute__((always_inline)) {
|
void waitTransmitComplete(void) __attribute__((always_inline)) {
|
||||||
uint32_t tmp __attribute__((unused));
|
uint32_t tmp __attribute__((unused));
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
while (!(KINETISK_SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
||||||
|
#else
|
||||||
while (!(SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
while (!(SPI0.SR & SPI_SR_TCF)) ; // wait until final output done
|
||||||
|
#endif
|
||||||
tmp = SPI0_POPR; // drain the final RX FIFO word
|
tmp = SPI0_POPR; // drain the final RX FIFO word
|
||||||
}
|
}
|
||||||
|
|
||||||
void writecommand_cont(uint8_t c) __attribute__((always_inline)) {
|
void writecommand_cont(uint8_t c) __attribute__((always_inline)) {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#else
|
||||||
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#endif
|
||||||
|
waitFifoNotFull();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writedata8_cont(uint8_t c) __attribute__((always_inline)) {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
||||||
|
#endif
|
||||||
|
waitFifoNotFull();
|
||||||
|
}
|
||||||
|
|
||||||
|
void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
||||||
|
#else
|
||||||
|
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
||||||
|
#endif
|
||||||
waitFifoNotFull();
|
waitFifoNotFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writecommand_last(uint8_t c) __attribute__((always_inline)) {
|
void writecommand_last(uint8_t c) __attribute__((always_inline)) {
|
||||||
waitFifoEmpty();
|
waitFifoEmpty();
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_TCF;
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#else
|
||||||
SPI0.SR = SPI_SR_TCF;
|
SPI0.SR = SPI_SR_TCF;
|
||||||
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#endif
|
||||||
waitTransmitComplete();
|
waitTransmitComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writedata8_cont(uint8_t c) __attribute__((always_inline)) {
|
|
||||||
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
|
|
||||||
waitFifoNotFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writedata8_last(uint8_t c) __attribute__((always_inline)) {
|
void writedata8_last(uint8_t c) __attribute__((always_inline)) {
|
||||||
waitFifoEmpty();
|
waitFifoEmpty();
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_TCF;
|
||||||
|
KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#else
|
||||||
SPI0.SR = SPI_SR_TCF;
|
SPI0.SR = SPI_SR_TCF;
|
||||||
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0);
|
||||||
|
#endif
|
||||||
waitTransmitComplete();
|
waitTransmitComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
|
|
||||||
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
|
|
||||||
waitFifoNotFull();
|
|
||||||
}
|
|
||||||
|
|
||||||
void writedata16_last(uint16_t d) __attribute__((always_inline)) {
|
void writedata16_last(uint16_t d) __attribute__((always_inline)) {
|
||||||
waitFifoEmpty();
|
waitFifoEmpty();
|
||||||
|
#if ARDUINO >= 160
|
||||||
|
KINETISK_SPI0.SR = SPI_SR_TCF;
|
||||||
|
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
||||||
|
#else
|
||||||
SPI0.SR = SPI_SR_TCF;
|
SPI0.SR = SPI_SR_TCF;
|
||||||
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1);
|
||||||
|
#endif
|
||||||
waitTransmitComplete();
|
waitTransmitComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue