Commit 493b1a7f authored by Bodmer's avatar Bodmer

Update RP2040 PIO support

Add example user setup 61
parent 553307aa
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// Board package specific differences // Board package specific differences
#ifdef ARDUINO_ARCH_MBED #ifdef ARDUINO_ARCH_MBED
// Not supported at the moment // Not supported at the moment
#error The Arduino RP2040 MBED board package is not supported. Use the community package by Earle Philhower. #error The Arduino RP2040 MBED board package is not supported when PIO is used. Use the community package by Earle Philhower.
#endif #endif
// Community RP2040 board package by Earle Philhower // Community RP2040 board package by Earle Philhower
...@@ -213,12 +213,12 @@ void pioinit(uint16_t clock_div, uint16_t fract_div) { ...@@ -213,12 +213,12 @@ void pioinit(uint16_t clock_div, uint16_t fract_div) {
// Create the pull stall bit mask // Create the pull stall bit mask
pull_stall_mask = 1u << (PIO_FDEBUG_TXSTALL_LSB + pio_sm); pull_stall_mask = 1u << (PIO_FDEBUG_TXSTALL_LSB + pio_sm);
// Create the assembler instruction for the jump to byte send routine // Create the instructions for the jumps to send routines
pio_instr_jmp8 = pio_encode_jmp(program_offset + tft_io_offset_start_8); pio_instr_jmp8 = pio_encode_jmp(program_offset + tft_io_offset_start_8);
//pio_instr_jmp32 = pio_encode_jmp(program_offset + tft_io_offset_start_32);
pio_instr_fill = pio_encode_jmp(program_offset + tft_io_offset_block_fill); pio_instr_fill = pio_encode_jmp(program_offset + tft_io_offset_block_fill);
pio_instr_addr = pio_encode_jmp(program_offset + tft_io_offset_set_addr_window); pio_instr_addr = pio_encode_jmp(program_offset + tft_io_offset_set_addr_window);
// Create the instructions to set and clear the DC signal
pio_instr_set_dc = pio_encode_set((pio_src_dest)0, 1); pio_instr_set_dc = pio_encode_set((pio_src_dest)0, 1);
pio_instr_clr_dc = pio_encode_set((pio_src_dest)0, 0); pio_instr_clr_dc = pio_encode_set((pio_src_dest)0, 0);
} }
......
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
// by waiting for the SM to be idle and setting its PC. // by waiting for the SM to be idle and setting its PC.
// The default SM routine is a 16 bit transfer // The default SM routine is a 16 bit transfer
public start_32:
// Fetch the next 32 bit value from the TX FIFO and set TFT_WR high.
pull side 1
// Output byte, TFT_WR low.
out pins, 8 side 0 [1]
// Loop until 4 bytes sent, TFT_WR high.
jmp !osre, send_xy side 1 [1]
//Jump back to 16 bit
jmp start_16
// Do a block fill of N+1 pixels. // Do a block fill of N+1 pixels.
public block_fill: public block_fill:
// Fetch colour value. // Fetch colour value.
......
...@@ -12,56 +12,51 @@ ...@@ -12,56 +12,51 @@
// tft_io // // tft_io //
// ------ // // ------ //
#define tft_io_wrap_target 13 #define tft_io_wrap_target 9
#define tft_io_wrap 31 #define tft_io_wrap 27
#define tft_io_offset_start_32 0u #define tft_io_offset_block_fill 0u
#define tft_io_offset_block_fill 4u #define tft_io_offset_start_16 9u
#define tft_io_offset_start_16 13u #define tft_io_offset_start_8 14u
#define tft_io_offset_start_8 18u #define tft_io_offset_set_addr_window 17u
#define tft_io_offset_set_addr_window 21u
static const uint16_t tft_io_program_instructions[] = { static const uint16_t tft_io_program_instructions[] = {
0x98a0, // 0: pull block side 1 0x98a0, // 0: pull block side 1
0x7108, // 1: out pins, 8 side 0 [1] 0xa027, // 1: mov x, osr
0x19fc, // 2: jmp !osre, 28 side 1 [1] 0x80a0, // 2: pull block
0x000d, // 3: jmp 13 0xa047, // 3: mov y, osr
0x98a0, // 4: pull block side 1 0xb8e1, // 4: mov osr, x side 1
0xa027, // 5: mov x, osr 0x7118, // 5: out pins, 24 side 0 [1]
0x80a0, // 6: pull block 0xb942, // 6: nop side 1 [1]
0xa047, // 7: mov y, osr 0x7108, // 7: out pins, 8 side 0 [1]
0xb8e1, // 8: mov osr, x side 1 0x1884, // 8: jmp y--, 4 side 1
0x7118, // 9: out pins, 24 side 0 [1]
0xb942, // 10: nop side 1 [1]
0x7108, // 11: out pins, 8 side 0 [1]
0x1888, // 12: jmp y--, 8 side 1
// .wrap_target // .wrap_target
0x98a0, // 13: pull block side 1 0x98a0, // 9: pull block side 1
0x7118, // 14: out pins, 24 side 0 [1] 0x7118, // 10: out pins, 24 side 0 [1]
0xb942, // 15: nop side 1 [1] 0xb942, // 11: nop side 1 [1]
0x7108, // 16: out pins, 8 side 0 [1] 0x7108, // 12: out pins, 8 side 0 [1]
0x180d, // 17: jmp 13 side 1 0x1809, // 13: jmp 9 side 1
0x98a0, // 18: pull block side 1 0x98a0, // 14: pull block side 1
0x7100, // 19: out pins, 32 side 0 [1] 0x7100, // 15: out pins, 32 side 0 [1]
0x180d, // 20: jmp 13 side 1 0x1809, // 16: jmp 9 side 1
0xf822, // 21: set x, 2 side 1 0xf822, // 17: set x, 2 side 1
0xe000, // 22: set pins, 0 0xe000, // 18: set pins, 0
0x80a0, // 23: pull block 0x80a0, // 19: pull block
0x7000, // 24: out pins, 32 side 0 0x7000, // 20: out pins, 32 side 0
0x003e, // 25: jmp !x, 30 0x003a, // 21: jmp !x, 26
0x98a0, // 26: pull block side 1 0x98a0, // 22: pull block side 1
0xe001, // 23: set pins, 1
0x7108, // 24: out pins, 8 side 0 [1]
0x19f8, // 25: jmp !osre, 24 side 1 [1]
0x1852, // 26: jmp x--, 18 side 1
0xe001, // 27: set pins, 1 0xe001, // 27: set pins, 1
0x7108, // 28: out pins, 8 side 0 [1]
0x19fc, // 29: jmp !osre, 28 side 1 [1]
0x1856, // 30: jmp x--, 22 side 1
0xe001, // 31: set pins, 1
// .wrap // .wrap
}; };
#if !PICO_NO_HARDWARE #if !PICO_NO_HARDWARE
static const struct pio_program tft_io_program = { static const struct pio_program tft_io_program = {
.instructions = tft_io_program_instructions, .instructions = tft_io_program_instructions,
.length = 32, .length = 28,
.origin = -1, .origin = -1,
}; };
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
The built-in fonts 4, 6, 7 and 8 are Run Length The built-in fonts 4, 6, 7 and 8 are Run Length
Encoded (RLE) to reduce the FLASH footprint. Encoded (RLE) to reduce the FLASH footprint.
Last review/edit by Bodmer: 21/04/21 Last review/edit by Bodmer: 05/01/22
****************************************************/ ****************************************************/
// Stop fonts etc being loaded multiple times // Stop fonts etc being loaded multiple times
#ifndef _TFT_eSPIH_ #ifndef _TFT_eSPIH_
#define _TFT_eSPIH_ #define _TFT_eSPIH_
#define TFT_ESPI_VERSION "2.4.21" #define TFT_ESPI_VERSION "2.4.22"
// Bit level feature flags // Bit level feature flags
// Bit 0 set: viewport capability // Bit 0 set: viewport capability
......
// Setup file for RP2040 and SPI ILI9341 display using PIO for the display interface
// The PIO can only be user with Earle Philhower's RP2040 board package:
// https://github.com/earlephilhower/arduino-pico
// PIO SPI allows high SPI clock rates to be used when the processor is over-clocked.
// PIO SPI is "write only" and the TFT_eSPI touch functions are not supported.
// A touch screen could be used with a third party library on different SPI pins.
// This invokes the PIO based SPI interface for the RP2040 processor.
#define RP2040_PIO_SPI
// TFT driver
#define ILI9341_DRIVER
// Pins - the PIO will control MOSI, SCLK and DC pins
// Any digital GPIO pins may be used
//#define TFT_MISO -1 // MISO is not used or supported
#define TFT_MOSI 11
#define TFT_SCLK 10
#define TFT_CS 9 // Chip select control pin
#define TFT_DC 8 // Data Command control pin
#define TFT_RST 15 // Reset pin (could connect to Arduino RESET pin)
//#define TFT_BL 13 // Optional LED back-light control pin
//#define TFT_BACKLIGHT_ON LOW // Level to turn ON back-light (HIGH or LOW)
#define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
#define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT
// #define SPI_FREQUENCY 1000000
// #define SPI_FREQUENCY 5000000
// #define SPI_FREQUENCY 10000000
// #define SPI_FREQUENCY 20000000
// #define SPI_FREQUENCY 32000000
#define SPI_FREQUENCY 62500000
{ {
"name": "TFT_eSPI", "name": "TFT_eSPI",
"version": "2.4.21", "version": "2.4.22",
"keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D", "keywords": "Arduino, tft, ePaper, display, Pico, RP2040, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9481, ILI9486, ILI9488, ST7789, RM68140, SSD1351, SSD1963, ILI9225, HX8357D",
"description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32", "description": "A TFT and ePaper SPI graphics library with optimisation for Raspberry Pi Pico, ESP8266, ESP32 and STM32",
"repository": "repository":
......
name=TFT_eSPI name=TFT_eSPI
version=2.4.21 version=2.4.22
author=Bodmer author=Bodmer
maintainer=Bodmer maintainer=Bodmer
sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, STM32, ESP8266 and ESP32 sentence=TFT graphics library for Arduino processors with performance optimisation for RP2040, 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