Commit 732bdd32 authored by Bodmer's avatar Bodmer

Port A+B and BRR update

PortA and Port B direction control now works on all STM processors.
Correct BRR to BSRR to support all STM processors.
parent fa2727b5
...@@ -128,14 +128,13 @@ void TFT_eSPI::pushPixels(const void* data_in, uint32_t len){ ...@@ -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) void TFT_eSPI::busDir(uint32_t mask, uint8_t mode)
{ {
#ifdef STM_PORTA_DATA_BUS #ifdef STM_PORTA_DATA_BUS
if (mode == OUTPUT) GPIOA->CRL = 0x33333333; if (mode == OUTPUT) GPIOA->MODER = (GPIOA->MODER & 0xFFFF0000) | 0x00005555;
else GPIOA->CRL = 0x88888888; else GPIOA->MODER &= 0xFFFF0000;
#elif STM_PORTB_DATA_BUS #elif STM_PORTB_DATA_BUS
if (mode == OUTPUT) GPIOB->CRL = 0x33333333; if (mode == OUTPUT) GPIOB->MODER = (GPIOB->MODER & 0xFFFF0000) | 0x00005555;
else GPIOB->CRL = 0x88888888; else GPIOB->MODER &= 0xFFFF0000;
#else #else
if (mode == OUTPUT) { if (mode == OUTPUT) {
...@@ -184,12 +183,22 @@ uint8_t TFT_eSPI::readByte(void) ...@@ -184,12 +183,22 @@ uint8_t TFT_eSPI::readByte(void)
uint8_t b = 0; uint8_t b = 0;
RD_L; 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_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_D0 | RD_TFT_D1 | RD_TFT_D2 | RD_TFT_D3;
b |= RD_TFT_D4 | RD_TFT_D5 | RD_TFT_D6 | RD_TFT_D7; b |= RD_TFT_D4 | RD_TFT_D5 | RD_TFT_D6 | RD_TFT_D7;
#endif
RD_H; RD_H;
return b; return b;
......
...@@ -118,23 +118,27 @@ ...@@ -118,23 +118,27 @@
#endif #endif
#else // Default display slow settings #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) // Extra write pulse high time (data hold time, delays next write cycle start)
//#define WR_TWRL_0 //#define WR_TWRH_0
//#define WR_TWRL_1 //#define WR_TWRH_1
//#define WR_TWRL_2 //#define WR_TWRH_2
//#define WR_TWRL_3 //#define WR_TWRH_3
//#define WR_TWRL_4 //#define WR_TWRH_4
#define WR_TWRL_5 #define WR_TWRH_5
#endif
// 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 @@ ...@@ -184,11 +188,11 @@
#define DC_C // No macro allocated so it generates no code #define DC_C // No macro allocated so it generates no code
#define DC_D // No macro allocated so it generates no code #define DC_D // No macro allocated so it generates no code
#else #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_PORT digitalPinToPort(TFT_DC)
#define DC_PIN_MASK digitalPinToBitMask(TFT_DC) #define DC_PIN_MASK digitalPinToBitMask(TFT_DC)
// Use bit set reset register // 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 #define DC_D DC_PORT->BSRR = DC_PIN_MASK
#endif #endif
...@@ -199,11 +203,11 @@ ...@@ -199,11 +203,11 @@
#define CS_L // No macro allocated so it generates no code #define CS_L // No macro allocated so it generates no code
#define CS_H // No macro allocated so it generates no code #define CS_H // No macro allocated so it generates no code
#else #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_PORT digitalPinToPort(TFT_CS)
#define CS_PIN_MASK digitalPinToBitMask(TFT_CS) #define CS_PIN_MASK digitalPinToBitMask(TFT_CS)
// Use bit set reset register // 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 #define CS_H CS_PORT->BSRR = CS_PIN_MASK
#endif #endif
...@@ -211,11 +215,11 @@ ...@@ -211,11 +215,11 @@
// Define the RD (TFT Read) pin drive code // Define the RD (TFT Read) pin drive code
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#ifdef TFT_RD #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_PORT digitalPinToPort(TFT_RD)
#define RD_PIN_MASK digitalPinToBitMask(TFT_RD) #define RD_PIN_MASK digitalPinToBitMask(TFT_RD)
// Use bit set reset register // 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 #define RD_H RD_PORT->BSRR = RD_PIN_MASK
#endif #endif
...@@ -223,11 +227,11 @@ ...@@ -223,11 +227,11 @@
// Define the WR (TFT Write) pin drive code // Define the WR (TFT Write) pin drive code
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#ifdef TFT_WR #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_PORT digitalPinToPort(TFT_WR)
#define WR_PIN_MASK digitalPinToBitMask(TFT_WR) #define WR_PIN_MASK digitalPinToBitMask(TFT_WR)
// Use bit set reset register // 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 #define WR_H WR_PORT->BSRR = WR_PIN_MASK
#endif #endif
...@@ -304,7 +308,7 @@ ...@@ -304,7 +308,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#ifdef NUCLEO_64_TFT #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 D0_PIN_NAME digitalPinToPinName(TFT_D0)
#define D1_PIN_NAME digitalPinToPinName(TFT_D1) #define D1_PIN_NAME digitalPinToPinName(TFT_D1)
#define D2_PIN_NAME digitalPinToPinName(TFT_D2) #define D2_PIN_NAME digitalPinToPinName(TFT_D2)
...@@ -415,7 +419,7 @@ ...@@ -415,7 +419,7 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#elif defined (NUCLEO_144_TFT) #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) // (diagnostic only - not used for Nucleo)
#define D0_PIN_NAME digitalPinToPinName(TFT_D0) #define D0_PIN_NAME digitalPinToPinName(TFT_D0)
#define D1_PIN_NAME digitalPinToPinName(TFT_D1) #define D1_PIN_NAME digitalPinToPinName(TFT_D1)
...@@ -630,15 +634,15 @@ ...@@ -630,15 +634,15 @@
#if defined (STM_PORTA_DATA_BUS) #if defined (STM_PORTA_DATA_BUS)
// Write 8 bits to TFT // 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 // Write 16 bits to TFT
#define tft_Write_16(C) GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \ #define tft_Write_16(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \
GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB
// 16 bit write with swapped bytes // 16 bit write with swapped bytes
#define tft_Write_16S(C) GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \ #define tft_Write_16S(C) GPIOA->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \
GPIOA->BSRR = (0xFF0000 | (uint8_t)(C>>8)); 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)) #define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))
...@@ -659,15 +663,15 @@ ...@@ -659,15 +663,15 @@
#elif defined (STM_PORTB_DATA_BUS) #elif defined (STM_PORTB_DATA_BUS)
// Write 8 bits to TFT // 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 // Write 16 bits to TFT
#define tft_Write_16(C) GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \ #define tft_Write_16(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>8)); WR_L; WR_STB; \
GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB
// 16 bit write with swapped bytes // 16 bit write with swapped bytes
#define tft_Write_16S(C) GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \ #define tft_Write_16S(C) GPIOB->BSRR = (0x00FF0000 | (uint8_t)(C>>0)); WR_L; WR_STB; \
GPIOB->BSRR = (0xFF0000 | (uint8_t)(C>>8)); 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)) #define tft_Write_32(C) tft_Write_16((uint16_t)((C)>>16)); tft_Write_16((uint16_t)(C))
...@@ -688,7 +692,7 @@ ...@@ -688,7 +692,7 @@
#else #else
// This will work with any STM32 to parallel TFT pin mapping but will be slower // 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 D0_PIN_NAME digitalPinToPinName(TFT_D0)
#define D1_PIN_NAME digitalPinToPinName(TFT_D1) #define D1_PIN_NAME digitalPinToPinName(TFT_D1)
#define D2_PIN_NAME digitalPinToPinName(TFT_D2) #define D2_PIN_NAME digitalPinToPinName(TFT_D2)
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _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 ** Section 1: Load required header files
......
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
{ {
"name": "TFT_eSPI", "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", "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", "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=2.1.8 version=2.1.9
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment