acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

Setup29_ILI9341_STM32.h (3820B)

      1 
      2         ///////////////////////////////////////////////////
      3         //  Setup for STM32 Nucleo and ILI9341 display   //
      4         ///////////////////////////////////////////////////
      5 #define USER_SETUP_ID 29
      6 
      7 // Last update by Bodmer: 28/11/19
      8 
      9 // STM32 optimised functions are not yet compatible with STM32H743 processor.
     10 // The STM32H743 does work with the slower generic processor drivers
     11 //
     12 // REMINDER - Nucleo-F743ZI and Nucleo-F743ZI2 have different pin port allocations
     13 // and require appropriate selection in IDE. ^---- Note the extra 2 in part number!
     14 
     15 
     16 // Define STM32 to invoke STM32 optimised driver
     17 #define STM32
     18 
     19 // Define the TFT display driver
     20 #define ILI9341_DRIVER
     21 //#define ILI9481_DRIVER
     22 
     23 // MOSI and SCK do not need to be defined, connect:
     24 //  - Arduino SCK  to TFT SCK
     25 //  - Arduino MOSI to TFT SDI(may be marked SDA or MOSI)
     26 // Typical Arduino SPI port 1 pins are (SCK=D13, MISO=D12, MOSI=D11) this is port pins PA5, PA6 and PA7 on Nucleo-F767ZI
     27 //                 SPI port 2 pins are (SCK=D18, MISO=A7, MOSI=D17) this is port pins PB13, PC2 and PB15 on Nucleo-F767ZI
     28 
     29 /*
     30 #define TFT_SPI_PORT 1 // SPI 1 maximum clock rate is 55MHz
     31 #define TFT_MOSI PA7
     32 #define TFT_MISO PA6
     33 #define TFT_SCLK PA5
     34 //*/
     35 
     36 /*
     37 #define TFT_SPI_PORT 2 // SPI 2 maximum clock rate is 27MHz
     38 #define TFT_MOSI D17
     39 #define TFT_MISO A7
     40 #define TFT_SCLK D18
     41 //*/
     42 
     43 /*
     44 #define TFT_SPI_PORT 2 // SPI 2 maximum clock rate is 27MHz
     45 #define TFT_MOSI PB15
     46 #define TFT_MISO PC2
     47 #define TFT_SCLK PB13
     48 //*/
     49 
     50 /*
     51 #define TFT_SPI_PORT 2 // SPI 2 maximum clock rate is 27MHz
     52 #define TFT_MOSI PB15
     53 #define TFT_MISO PB14
     54 #define TFT_SCLK PB13
     55 //*/
     56 
     57 // Can use Ardiuno pin references, arbitrary allocation, TFT_eSPI controls chip select
     58 #define TFT_CS   D5 // Chip select control pin to TFT CS
     59 #define TFT_DC   D6 // Data Command control pin to TFT DC (may be labelled RS = Register Select)
     60 #define TFT_RST  D7 // Reset pin to TFT RST (or RESET)
     61 
     62 // Alternatively, we can use STM32 port reference names PXnn
     63 //#define TFT_CS   PE11 // Nucleo-F767ZI equivalent of D5
     64 //#define TFT_DC   PE9  // Nucleo-F767ZI equivalent of D6
     65 //#define TFT_RST  PF13 // Nucleo-F767ZI equivalent of D7
     66 
     67 //#define TFT_RST  -1   // Set TFT_RST to -1 if the display RESET is connected to processor reset
     68                         // Use an Arduino pin for initial testing as connecting to processor reset
     69                         // may not work (pulse too short at power up?)
     70 
     71 // Chip select for XPT2046 touch controller
     72 #define TOUCH_CS D4
     73 
     74 #define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
     75 #define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
     76 #define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
     77 #define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
     78 #define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
     79 #define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
     80 #define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
     81 
     82 // STM32 support for smooth fonts via program memory (FLASH) arrays
     83 #define SMOOTH_FONT
     84 
     85 
     86 // Nucleo-F767ZI has a ~216MHZ CPU clock, this is divided by 4, 8, 16 etc
     87 
     88 #define SPI_FREQUENCY  27000000   // 27MHz SPI clock
     89 //#define SPI_FREQUENCY  55000000   // 55MHz is over-clocking ILI9341 but seems to work reliably!
     90 
     91 #define SPI_READ_FREQUENCY  15000000 // Reads need a slower SPI clock, probably ends up at 13.75MHz (CPU clock/16)
     92 
     93 #define SPI_TOUCH_FREQUENCY  2500000 // Must be very slow
     94 
     95 // This has no effect, transactions for STM32 are automatically enabled
     96 #define SUPPORT_TRANSACTIONS