Commit f71df4ff authored by Bodmer's avatar Bodmer

#581 fallout update

parent d1b0bab9
...@@ -132,24 +132,24 @@ void TFT_eSPI::busDir(uint32_t mask, uint8_t mode) ...@@ -132,24 +132,24 @@ void TFT_eSPI::busDir(uint32_t mask, uint8_t mode)
// Now we can use a minimal set of register changes // Now we can use a minimal set of register changes
if (mode == OUTPUT) { if (mode == OUTPUT) {
LL_GPIO_SetPinMode(D0_PIN_PORT, D0_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D0_PIN_PORT, D0_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D1_PIN_PORT, D1_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D1_PIN_PORT, D1_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D2_PIN_PORT, D2_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D2_PIN_PORT, D2_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D3_PIN_PORT, D3_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D3_PIN_PORT, D3_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D4_PIN_PORT, D4_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D4_PIN_PORT, D4_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D5_PIN_PORT, D5_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D5_PIN_PORT, D5_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D6_PIN_PORT, D6_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D6_PIN_PORT, D6_PIN_MASK, LL_GPIO_MODE_OUTPUT);
LL_GPIO_SetPinMode(D7_PIN_PORT, D7_PIN_BIT, LL_GPIO_MODE_OUTPUT); LL_GPIO_SetPinMode(D7_PIN_PORT, D7_PIN_MASK, LL_GPIO_MODE_OUTPUT);
} }
else { else {
LL_GPIO_SetPinMode(D0_PIN_PORT, D0_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D0_PIN_PORT, D0_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D1_PIN_PORT, D1_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D1_PIN_PORT, D1_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D2_PIN_PORT, D2_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D2_PIN_PORT, D2_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D3_PIN_PORT, D3_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D3_PIN_PORT, D3_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D4_PIN_PORT, D4_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D4_PIN_PORT, D4_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D5_PIN_PORT, D5_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D5_PIN_PORT, D5_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D6_PIN_PORT, D6_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D6_PIN_PORT, D6_PIN_MASK, LL_GPIO_MODE_INPUT);
LL_GPIO_SetPinMode(D7_PIN_PORT, D7_PIN_BIT, LL_GPIO_MODE_INPUT); LL_GPIO_SetPinMode(D7_PIN_PORT, D7_PIN_MASK, LL_GPIO_MODE_INPUT);
} }
} }
......
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
#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 hardware port and mask // Convert Arduino pin reference Dn or STM pin reference PXn to pin lookup reference number
#define DC_PIN_NAME digitalPinToPinName(TFT_DC) #define DC_PIN_NAME digitalPinToPinName(TFT_DC)
#define DC_PORT get_GPIO_Port(STM_PORT(DC_PIN_NAME)) #define DC_PORT get_GPIO_Port(STM_PORT(DC_PIN_NAME))
#define DC_PIN_MASK STM_LL_GPIO_PIN(DC_PIN_NAME) #define DC_PIN_MASK STM_LL_GPIO_PIN(DC_PIN_NAME)
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
#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 hardware port and mask // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number
#define CS_PIN_NAME digitalPinToPinName(TFT_CS) #define CS_PIN_NAME digitalPinToPinName(TFT_CS)
#define CS_PORT get_GPIO_Port(STM_PORT(CS_PIN_NAME)) #define CS_PORT get_GPIO_Port(STM_PORT(CS_PIN_NAME))
#define CS_PIN_MASK STM_LL_GPIO_PIN(CS_PIN_NAME) #define CS_PIN_MASK STM_LL_GPIO_PIN(CS_PIN_NAME)
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
// 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 hardware port and mask // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number
#define RD_PIN_NAME digitalPinToPinName(TFT_RD) #define RD_PIN_NAME digitalPinToPinName(TFT_RD)
#define RD_PORT get_GPIO_Port(STM_PORT(RD_PIN_NAME)) #define RD_PORT get_GPIO_Port(STM_PORT(RD_PIN_NAME))
#define RD_PIN_MASK STM_LL_GPIO_PIN(RD_PIN_NAME) #define RD_PIN_MASK STM_LL_GPIO_PIN(RD_PIN_NAME)
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
// 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 hardware port and mask // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number
#define WR_PIN_NAME digitalPinToPinName(TFT_WR) #define WR_PIN_NAME digitalPinToPinName(TFT_WR)
#define WR_PORT get_GPIO_Port(STM_PORT(WR_PIN_NAME)) #define WR_PORT get_GPIO_Port(STM_PORT(WR_PIN_NAME))
#define WR_PIN_MASK STM_LL_GPIO_PIN(WR_PIN_NAME) #define WR_PIN_MASK STM_LL_GPIO_PIN(WR_PIN_NAME)
...@@ -304,17 +304,27 @@ ...@@ -304,17 +304,27 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#ifdef NUCLEO_64_TFT #ifdef NUCLEO_64_TFT
// Nucleo 64 boards use the same ports/pins // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number
#define D0_PIN_BIT LL_GPIO_PIN_9 #define D0_PIN_NAME digitalPinToPinName(TFT_D0)
#define D1_PIN_BIT LL_GPIO_PIN_7 #define D1_PIN_NAME digitalPinToPinName(TFT_D1)
#define D2_PIN_BIT LL_GPIO_PIN_10 #define D2_PIN_NAME digitalPinToPinName(TFT_D2)
#define D3_PIN_BIT LL_GPIO_PIN_3 #define D3_PIN_NAME digitalPinToPinName(TFT_D3)
#define D4_PIN_BIT LL_GPIO_PIN_5 #define D4_PIN_NAME digitalPinToPinName(TFT_D4)
#define D5_PIN_BIT LL_GPIO_PIN_4 #define D5_PIN_NAME digitalPinToPinName(TFT_D5)
#define D6_PIN_BIT LL_GPIO_PIN_10 #define D6_PIN_NAME digitalPinToPinName(TFT_D6)
#define D7_PIN_BIT LL_GPIO_PIN_8 #define D7_PIN_NAME digitalPinToPinName(TFT_D7)
// Ports associated with pins - better than get_GPIO_Port() which seems to be slow... // Pin port bit number 0-15 (not used for Nucleo)
#define D0_PIN_BIT (D0_PIN_NAME & 0xF)
#define D1_PIN_BIT (D1_PIN_NAME & 0xF)
#define D2_PIN_BIT (D2_PIN_NAME & 0xF)
#define D3_PIN_BIT (D3_PIN_NAME & 0xF)
#define D4_PIN_BIT (D4_PIN_NAME & 0xF)
#define D5_PIN_BIT (D5_PIN_NAME & 0xF)
#define D6_PIN_BIT (D6_PIN_NAME & 0xF)
#define D7_PIN_BIT (D7_PIN_NAME & 0xF)
// Pin port - better than get_GPIO_Port() which seems to be slow...
#define D0_PIN_PORT GPIOA #define D0_PIN_PORT GPIOA
#define D1_PIN_PORT GPIOC #define D1_PIN_PORT GPIOC
#define D2_PIN_PORT GPIOA #define D2_PIN_PORT GPIOA
...@@ -405,16 +415,29 @@ ...@@ -405,16 +415,29 @@
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
#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
// (diagnostic only - not used for Nucleo)
#define D0_PIN_NAME digitalPinToPinName(TFT_D0)
#define D1_PIN_NAME digitalPinToPinName(TFT_D1)
#define D2_PIN_NAME digitalPinToPinName(TFT_D2)
#define D3_PIN_NAME digitalPinToPinName(TFT_D3)
#define D4_PIN_NAME digitalPinToPinName(TFT_D4)
#define D5_PIN_NAME digitalPinToPinName(TFT_D5)
#define D6_PIN_NAME digitalPinToPinName(TFT_D6)
#define D7_PIN_NAME digitalPinToPinName(TFT_D7)
// Pin port bit number 0-15 (diagnostic only - not used for Nucleo)
#define D0_PIN_BIT (D0_PIN_NAME & 0xF)
#define D1_PIN_BIT (D1_PIN_NAME & 0xF)
#define D2_PIN_BIT (D2_PIN_NAME & 0xF)
#define D3_PIN_BIT (D3_PIN_NAME & 0xF)
#define D4_PIN_BIT (D4_PIN_NAME & 0xF)
#define D5_PIN_BIT (D5_PIN_NAME & 0xF)
#define D6_PIN_BIT (D6_PIN_NAME & 0xF)
#define D7_PIN_BIT (D7_PIN_NAME & 0xF)
#if !defined (STM32H7xx) #if !defined (STM32H7xx)
// Nucleo 144 boards use the same ports/pins
#define D0_PIN_BIT LL_GPIO_PIN_12
#define D1_PIN_BIT LL_GPIO_PIN_15
#define D2_PIN_BIT LL_GPIO_PIN_15
#define D3_PIN_BIT LL_GPIO_PIN_13
#define D4_PIN_BIT LL_GPIO_PIN_14
#define D5_PIN_BIT LL_GPIO_PIN_11
#define D6_PIN_BIT LL_GPIO_PIN_9
#define D7_PIN_BIT LL_GPIO_PIN_13
// Ports associated with pins - get_GPIO_Port() seems to be slow... // Ports associated with pins - get_GPIO_Port() seems to be slow...
#define D0_PIN_PORT GPIOF #define D0_PIN_PORT GPIOF
...@@ -507,16 +530,6 @@ ...@@ -507,16 +530,6 @@
// Test setup for STM32H743 - starts to run, slow and then crashes! Board support bug? // Test setup for STM32H743 - starts to run, slow and then crashes! Board support bug?
// Nucleo 144 boards use the same ports/pins
#define D0_PIN_BIT LL_GPIO_PIN_3
#define D1_PIN_BIT LL_GPIO_PIN_15
#define D2_PIN_BIT LL_GPIO_PIN_14
#define D3_PIN_BIT LL_GPIO_PIN_13
#define D4_PIN_BIT LL_GPIO_PIN_14
#define D5_PIN_BIT LL_GPIO_PIN_11
#define D6_PIN_BIT LL_GPIO_PIN_9
#define D7_PIN_BIT LL_GPIO_PIN_12
// Ports associated with pins - get_GPIO_Port() seems to be slow... // Ports associated with pins - get_GPIO_Port() seems to be slow...
#define D0_PIN_PORT GPIOF #define D0_PIN_PORT GPIOF
#define D1_PIN_PORT GPIOD #define D1_PIN_PORT GPIOD
...@@ -617,7 +630,7 @@ ...@@ -617,7 +630,7 @@
// 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 hardware port and mask // Convert Arduino pin reference Dx or STM pin reference PXn to pin lookup reference number
#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)
...@@ -627,6 +640,7 @@ ...@@ -627,6 +640,7 @@
#define D6_PIN_NAME digitalPinToPinName(TFT_D6) #define D6_PIN_NAME digitalPinToPinName(TFT_D6)
#define D7_PIN_NAME digitalPinToPinName(TFT_D7) #define D7_PIN_NAME digitalPinToPinName(TFT_D7)
// Pin port bit number 0-15
#define D0_PIN_BIT (D0_PIN_NAME & 0xF) #define D0_PIN_BIT (D0_PIN_NAME & 0xF)
#define D1_PIN_BIT (D1_PIN_NAME & 0xF) #define D1_PIN_BIT (D1_PIN_NAME & 0xF)
#define D2_PIN_BIT (D2_PIN_NAME & 0xF) #define D2_PIN_BIT (D2_PIN_NAME & 0xF)
...@@ -636,6 +650,7 @@ ...@@ -636,6 +650,7 @@
#define D6_PIN_BIT (D6_PIN_NAME & 0xF) #define D6_PIN_BIT (D6_PIN_NAME & 0xF)
#define D7_PIN_BIT (D7_PIN_NAME & 0xF) #define D7_PIN_BIT (D7_PIN_NAME & 0xF)
// Pin port
#define D0_PIN_PORT get_GPIO_Port(STM_PORT(D0_PIN_NAME)) #define D0_PIN_PORT get_GPIO_Port(STM_PORT(D0_PIN_NAME))
#define D1_PIN_PORT get_GPIO_Port(STM_PORT(D1_PIN_NAME)) #define D1_PIN_PORT get_GPIO_Port(STM_PORT(D1_PIN_NAME))
#define D2_PIN_PORT get_GPIO_Port(STM_PORT(D2_PIN_NAME)) #define D2_PIN_PORT get_GPIO_Port(STM_PORT(D2_PIN_NAME))
...@@ -645,6 +660,7 @@ ...@@ -645,6 +660,7 @@
#define D6_PIN_PORT get_GPIO_Port(STM_PORT(D6_PIN_NAME)) #define D6_PIN_PORT get_GPIO_Port(STM_PORT(D6_PIN_NAME))
#define D7_PIN_PORT get_GPIO_Port(STM_PORT(D7_PIN_NAME)) #define D7_PIN_PORT get_GPIO_Port(STM_PORT(D7_PIN_NAME))
// Pin masks for set/clear
#define D0_PIN_MASK STM_LL_GPIO_PIN(D0_PIN_NAME) #define D0_PIN_MASK STM_LL_GPIO_PIN(D0_PIN_NAME)
#define D1_PIN_MASK STM_LL_GPIO_PIN(D1_PIN_NAME) #define D1_PIN_MASK STM_LL_GPIO_PIN(D1_PIN_NAME)
#define D2_PIN_MASK STM_LL_GPIO_PIN(D2_PIN_NAME) #define D2_PIN_MASK STM_LL_GPIO_PIN(D2_PIN_NAME)
......
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