Skip to content

Esp32s3 implement spi#5169

Merged
deadprogram merged 7 commits intotinygo-org:devfrom
dimajolkin:esp32s3-spi
Feb 15, 2026
Merged

Esp32s3 implement spi#5169
deadprogram merged 7 commits intotinygo-org:devfrom
dimajolkin:esp32s3-spi

Conversation

@dimajolkin
Copy link

@dimajolkin dimajolkin commented Jan 10, 2026

Hi! I tried to create a SPI, and it seems to have worked. I tested it on esp32s3-wroom1
I ran LILYGO T-Deck Plus.

image

It also changed to a gradual frequency increase. My esp32s3-wroom1 would freeze if I set it to 240 immediately.

@dgryski
Copy link
Member

dgryski commented Jan 11, 2026

/cc @ysoldak

@ysoldak
Copy link
Contributor

ysoldak commented Jan 13, 2026

Sorry, I have esp32c3 only, not "s", otherwise would help testing, of course.

@deadprogram
Copy link
Member

I have a esp32-s3 to test with, and will take a look.

@deadprogram
Copy link
Member

So far I have not been able to get SPI working on my Xiao ESP32s3 with this PR.

Any thoughts on this @dimajolkin ?

@dimajolkin
Copy link
Author

dimajolkin commented Jan 14, 2026

I will check docs for this MC) And order this for test

@deadprogram I made a quick fix to the frequency calculation. Can you check it?

@dimajolkin
Copy link
Author

dimajolkin commented Jan 14, 2026

I've placed an order for this MK. When it arrives, I'll debug it for him too, if the fix doesn't work.

Additions:

const (
	TFT_SCLK machine.Pin = 7 // SCK - Serial Clock (GPIO7)
	TFT_MOSI machine.Pin = 8 // MOSI / SDO (GPIO8)
)

func main() {
	spi := machine.SPI1
	spi.Configure(machine.SPIConfig{
		SCK:       TFT_SCLK,
		SDO:       TFT_MOSI,
	})

7, 8 - pins tested too

@deadprogram
Copy link
Member

@dimajolkin looks like you need to run the linter:

Unformatted:
  src/machine/machine_esp32s3_spi.go
make: *** [GNUmakefile:207: fmt-check] Error 1

@dm-vev
Copy link

dm-vev commented Jan 20, 2026

Hi, thanks for the SPI work and the T-Deck test.

Could you please share the test code you used to drive the display on the T-Deck (the one shown in the screenshot)?
I’d like to use the same code for testing.

@dimajolkin
Copy link
Author

Hi, thanks for the SPI work and the T-Deck test.

Could you please share the test code you used to drive the display on the T-Deck (the one shown in the screenshot)?

I’d like to use the same code for testing.

Hi, for tdeck need specific driver, you can find here:
https://github.com/dimajolkin/tinygo-lilygo-drivers

@dimajolkin
Copy link
Author

dimajolkin commented Feb 13, 2026

image

@dimajolkin
Copy link
Author

package main

import (
	"image/color"
	"machine"
	"time"

	"tinygo.org/x/drivers/st7789"
)

var (
	RED     = color.RGBA{255, 0, 0, 255}
	GREEN   = color.RGBA{0, 255, 0, 255}
	BLUE    = color.RGBA{0, 0, 255, 255}
	WHITE   = color.RGBA{255, 255, 255, 255}
	BLACK   = color.RGBA{0, 0, 0, 255}
	YELLOW  = color.RGBA{255, 255, 0, 255}
	CYAN    = color.RGBA{0, 255, 255, 255}
	MAGENTA = color.RGBA{255, 0, 255, 255}
)

const (
	TFT_CS  machine.Pin = machine.D1 // Chip Select
	TFT_DC  machine.Pin = machine.D2 // Data/Command
	TFT_RST machine.Pin = machine.D3 // Reset
	TFT_BLK machine.Pin = machine.D4 // Reset
)

func main() {
	led := machine.D6
	led.Configure(machine.PinConfig{Mode: machine.PinOutput})

	spi := machine.SPI0
	spi.Configure(machine.SPIConfig{})

	display := st7789.New(spi, TFT_RST, TFT_DC, TFT_CS, TFT_BLK)
	display.Configure(st7789.Config{
		Width:  240,
		Height: 320,
	})

	for {
		led.Low()
		time.Sleep(time.Millisecond * 100)
		testBasicColors(display)
		led.High()
		time.Sleep(time.Millisecond * 100)
	}
}

// Test basic color fills
func testBasicColors(display st7789.Device) {
	colors := []color.RGBA{RED, GREEN, BLUE, WHITE, BLACK, YELLOW, CYAN, MAGENTA}
	for _, col := range colors {
		display.FillScreen(col)
		time.Sleep(500 * time.Millisecond)
	}
}

@dimajolkin
Copy link
Author

@deadprogram
Hi! I got the esp32s3 and it worked. There was a problem with the default pins. Now it works on both devices.
I separated esp32s3-wroom1, but now it behaves like an esp32s3.

@deadprogram
Copy link
Member

Thanks for all your work on this PR. Last thing would be to add this to the smoke tests here: https://github.com/tinygo-org/tinygo/blob/dev/GNUmakefile#L907-L926

Probably building the examples/mcp3008 would be the best one.

@dimajolkin
Copy link
Author

@deadprogram Look, the tests are passing, but there are some random failures..

@deadprogram
Copy link
Member

Thank you very much for all your work on this @dimajolkin now squash/merging.

@deadprogram deadprogram merged commit 4b0e858 into tinygo-org:dev Feb 15, 2026
22 of 23 checks passed
@dimajolkin
Copy link
Author

Thank you, I appreciate it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants