diff --git a/Processors/TFT_eSPI_STM32.c b/Processors/TFT_eSPI_STM32.c index 0f804a7..dbc3ce7 100644 --- a/Processors/TFT_eSPI_STM32.c +++ b/Processors/TFT_eSPI_STM32.c @@ -128,14 +128,13 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){ ***************************************************************************************/ void TFT_eSPI::busDir(uint32_t mask, uint8_t mode) { - #ifdef STM_PORTA_DATA_BUS - if (mode == OUTPUT) GPIOA->CRL = 0x33333333; - else GPIOA->CRL = 0x88888888; + if (mode == OUTPUT) GPIOA->MODER = (GPIOA->MODER & 0xFFFF0000) | 0x00005555; + else GPIOA->MODER &= 0xFFFF0000; #elif STM_PORTB_DATA_BUS - if (mode == OUTPUT) GPIOB->CRL = 0x33333333; - else GPIOB->CRL = 0x88888888; + if (mode == OUTPUT) GPIOB->MODER = (GPIOB->MODER & 0xFFFF0000) | 0x00005555; + else GPIOB->MODER &= 0xFFFF0000; #else if (mode == OUTPUT) { @@ -184,12 +183,22 @@ uint8_t TFT_eSPI::readByte(void) uint8_t b = 0; RD_L; - +#ifdef STM_PORTA_DATA_BUS + b = GPIOA->IDR; + b = GPIOA->IDR; + b = GPIOA->IDR; + b = (GPIOA->IDR) & 0xFF; +#elif STM_PORTB_DATA_BUS + b = GPIOB->IDR; + b = GPIOB->IDR; + b = GPIOB->IDR; + b = (GPIOB->IDR) & 0xFF; +#else b = RD_TFT_D0 | RD_TFT_D0 | RD_TFT_D0 | RD_TFT_D0; //Delay for bits to settle b = RD_TFT_D0 | RD_TFT_D1 | RD_TFT_D2 | RD_TFT_D3; b |= RD_TFT_D4 | RD_TFT_D5 | RD_TFT_D6 | RD_TFT_D7; - +#endif RD_H; return b; diff --git a/Processors/TFT_eSPI_STM32.h b/Processors/TFT_eSPI_STM32.h index e77cc05..c38af18 100644 --- a/Processors/TFT_eSPI_STM32.h +++ b/Processors/TFT_eSPI_STM32.h @@ -118,23 +118,27 @@ #endif #else // Default display slow settings + #if defined (STM32F1xx) + // STM32F1xx series can run at full speed (unless overclocked) + #define WR_TWRL_0 + #define WR_TWRH_0 + #else + // Extra write pulse low time (delay for data setup) + //#define WR_TWRL_0 + //#define WR_TWRL_1 + //#define WR_TWRL_2 + #define WR_TWRL_3 + //#define WR_TWRL_4 + //#define WR_TWRL_5 - // Extra write pulse low time (delay for data setup) - //#define WR_TWRL_0 - //#define WR_TWRL_1 - //#define WR_TWRL_2 - //#define WR_TWRL_3 - //#define WR_TWRL_4 - #define WR_TWRL_5 - - // Extra write pulse high time (data hold time, delays next write cycle start) - //#define WR_TWRH_0 - //#define WR_TWRH_1 - //#define WR_TWRH_2 - //#define WR_TWRH_3 - //#define WR_TWRH_4 - #define WR_TWRH_5 - + // Extra write pulse high time (data hold time, delays next write cycle start) + //#define WR_TWRH_0 + //#define WR_TWRH_1 + //#define WR_TWRH_2 + //#define WR_TWRH_3 + //#define WR_TWRH_4 + #define WR_TWRH_5 + #endif #endif //////////////////////////////////////////////////////////////////////////////////////// @@ -184,11 +188,11 @@ #define DC_C // No macro allocated so it generates no code #define DC_D // No macro allocated so it generates no code #else - // Convert Arduino pin reference Dn or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dn or STM pin reference PXn to port and mask #define DC_PORT digitalPinToPort(TFT_DC) #define DC_PIN_MASK digitalPinToBitMask(TFT_DC) // Use bit set reset register - #define DC_C DC_PORT->BRR = DC_PIN_MASK + #define DC_C DC_PORT->BSRR = DC_PIN_MASK<<16 #define DC_D DC_PORT->BSRR = DC_PIN_MASK #endif @@ -199,11 +203,11 @@ #define CS_L // No macro allocated so it generates no code #define CS_H // No macro allocated so it generates no code #else - // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dx or STM pin reference PXn to port and mask #define CS_PORT digitalPinToPort(TFT_CS) #define CS_PIN_MASK digitalPinToBitMask(TFT_CS) // Use bit set reset register - #define CS_L CS_PORT->BRR = CS_PIN_MASK + #define CS_L CS_PORT->BSRR = CS_PIN_MASK<<16 #define CS_H CS_PORT->BSRR = CS_PIN_MASK #endif @@ -211,11 +215,11 @@ // Define the RD (TFT Read) pin drive code //////////////////////////////////////////////////////////////////////////////////////// #ifdef TFT_RD - // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dx or STM pin reference PXn to port and mask #define RD_PORT digitalPinToPort(TFT_RD) #define RD_PIN_MASK digitalPinToBitMask(TFT_RD) // Use bit set reset register - #define RD_L RD_PORT->BRR = RD_PIN_MASK + #define RD_L RD_PORT->BSRR = RD_PIN_MASK<<16 #define RD_H RD_PORT->BSRR = RD_PIN_MASK #endif @@ -223,11 +227,11 @@ // Define the WR (TFT Write) pin drive code //////////////////////////////////////////////////////////////////////////////////////// #ifdef TFT_WR - // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dx or STM pin reference PXn to port and mask #define WR_PORT digitalPinToPort(TFT_WR) #define WR_PIN_MASK digitalPinToBitMask(TFT_WR) // Use bit set reset register - #define WR_L WR_PORT->BRR = WR_PIN_MASK + #define WR_L WR_PORT->BSRR = WR_PIN_MASK<<16 #define WR_H WR_PORT->BSRR = WR_PIN_MASK #endif @@ -304,7 +308,7 @@ //////////////////////////////////////////////////////////////////////////////////////// #ifdef NUCLEO_64_TFT - // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dx or STM pin reference PXn to port and mask #define D0_PIN_NAME digitalPinToPinName(TFT_D0) #define D1_PIN_NAME digitalPinToPinName(TFT_D1) #define D2_PIN_NAME digitalPinToPinName(TFT_D2) @@ -415,7 +419,7 @@ //////////////////////////////////////////////////////////////////////////////////////// #elif defined (NUCLEO_144_TFT) - // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dx or STM pin reference PXn to port and mask // (diagnostic only - not used for Nucleo) #define D0_PIN_NAME digitalPinToPinName(TFT_D0) #define D1_PIN_NAME digitalPinToPinName(TFT_D1) @@ -630,15 +634,15 @@ #if defined (STM_PORTA_DATA_BUS) // Write 8 bits to TFT - #define tft_Write_8(C) GPIOA->BSRR = (0xFF0000 | (uint8_t)(C)); WR_L; WR_STB + #define tft_Write_8(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C)); WR_L; WR_STB // Write 16 bits to TFT - #define tft_Write_16(C) GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \ - GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB + #define tft_Write_16(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \ + GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB // 16 bit write with swapped bytes - #define tft_Write_16S(C) GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \ - GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>8)); WR_L; WR_STB + #define tft_Write_16S(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \ + GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB #define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C)) @@ -659,15 +663,15 @@ #elif defined (STM_PORTB_DATA_BUS) // Write 8 bits to TFT - #define tft_Write_8(C) GPIOB->BSRR = (0xFF0000 | (uint8_t)(C)); WR_L; WR_STB + #define tft_Write_8(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C)); WR_L; WR_STB // Write 16 bits to TFT - #define tft_Write_16(C) GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \ - GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB + #define tft_Write_16(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \ + GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB // 16 bit write with swapped bytes - #define tft_Write_16S(C) GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \ - GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>8)); WR_L; WR_STB + #define tft_Write_16S(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \ + GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB #define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C)) @@ -688,7 +692,7 @@ #else // This will work with any STM32 to parallel TFT pin mapping but will be slower - // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number + // Convert Arduino pin reference Dx or STM pin reference PXn to port and mask #define D0_PIN_NAME digitalPinToPinName(TFT_D0) #define D1_PIN_NAME digitalPinToPinName(TFT_D1) #define D2_PIN_NAME digitalPinToPinName(TFT_D2) diff --git a/TFT_eSPI.h b/TFT_eSPI.h index 7ca127f..11611fc 100644 --- a/TFT_eSPI.h +++ b/TFT_eSPI.h @@ -16,7 +16,7 @@ #ifndef _TFT_eSPIH_ #define _TFT_eSPIH_ -#define TFT_ESPI_VERSION "2.1.8" +#define TFT_ESPI_VERSION "2.1.9" /*************************************************************************************** ** Section 1: Load required header files diff --git a/Tools/library.properties b/Tools/library.properties new file mode 100644 index 0000000..2e9b70a --- /dev/null +++ b/Tools/library.properties @@ -0,0 +1,11 @@ +name=TFT_eSPI +version=2.1.9 +author=Bodmer +maintainer=Bodmer +sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32 +paragraph=Supports TFT displays using drivers (ILI9341 etc) that operate with hardware SPI or 8 bit parallel. +category=Display +url=https://github.com/Bodmer/TFT_eSPI +architectures=* +includes=TFT_eSPI.h + diff --git a/library.json b/library.json index c6ff5af..06f9677 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "TFT_eSPI", - "version": "2.1.8", + "version": "2.1.9", "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", "repository": diff --git a/library.properties b/library.properties index b326f8d..2e9b70a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TFT_eSPI -version=2.1.8 +version=2.1.9 author=Bodmer maintainer=Bodmer sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32