-
Notifications
You must be signed in to change notification settings - Fork 3
Xiao esp32c3 #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Xiao esp32c3 #13
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ee65959
boards: add test support for xiao-esp32c3 board
deadprogram 2d6ea44
make: add make task for testing xiao-esp32c3
deadprogram 59a010c
docker: install esptool to flash esp32 boards
deadprogram 329deed
udev: add permissions for writing
deadprogram 1bd29e8
server: now try following symlinks for tests
deadprogram dd0efbd
docker: install esptool
deadprogram 35805ae
license: remove year
deadprogram 1026131
docs: add Seeedstudio Xiao-ESP32C3 board to TinyHCI
deadprogram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| module xiao-esp32c3 | ||
|
|
||
| go 1.22.1 | ||
|
|
||
| toolchain go1.24.2 | ||
|
|
||
| require tinygo.org/x/drivers v0.34.0 | ||
|
|
||
| require github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= | ||
| github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= | ||
| tinygo.org/x/drivers v0.34.0 h1:lw8ePJeUSn9oICKBvQXHC9TIE+J00OfXfkGTrpXM9Iw= | ||
| tinygo.org/x/drivers v0.34.0/go.mod h1:ZdErNrApSABdVXjA1RejD67R8SNRI6RKVfYgQDZtKtk= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| package main | ||
|
|
||
| // Integration tests for Xiao ESP32-C3 | ||
| // | ||
| // Wire up the pins, and run it while connected to the USB port. | ||
| // | ||
| // Digital read/write tests (GPIO): | ||
| // D0 <--> 3V3 | ||
| // D2 <--> D3 | ||
| // | ||
| // I2C tests: | ||
| // Xiao ESP32-C3 SCL (D5) <--> MPU6050 SCL | ||
| // Xiao ESP32-C3 SDA (D4) <--> MPU6050 SDA | ||
| // Xiao ESP32-C3 G <--> MPU6050 GND | ||
| // Xiao ESP32-C3 3V3 <--> MPU6050 VCC | ||
| // | ||
| // SPI tests: | ||
| // Xiao ESP32-C3 CDO - D10 <--> Xiao ESP32-C3 CDI - D9 | ||
| // | ||
| import ( | ||
| "machine" | ||
|
|
||
| "time" | ||
|
|
||
| "tinygo.org/x/drivers/mpu6050" | ||
| ) | ||
|
|
||
| var ( | ||
| // used by digital GPIO tests | ||
| readV = machine.D0 | ||
| readpin = machine.D2 | ||
| writepin = machine.D3 | ||
|
|
||
| // used by i2c tests | ||
| accel *mpu6050.Device | ||
| powerpin = machine.D3 | ||
| ) | ||
|
|
||
| func main() { | ||
| waitForStart() | ||
|
|
||
| digitalReadVoltageGPIO() | ||
| digitalWriteGPIO() | ||
| i2cConnection() | ||
| spiTxRx() | ||
|
|
||
| endTests() | ||
| } | ||
|
|
||
| // wait for keypress on serial port to start test suite. | ||
| func waitForStart() { | ||
| time.Sleep(5 * time.Second) | ||
|
|
||
| println("=== TINYGO INTEGRATION TESTS ===") | ||
| println("Press 't' key to begin running tests...") | ||
|
|
||
| for { | ||
| if machine.Serial.Buffered() > 0 { | ||
| data, _ := machine.Serial.ReadByte() | ||
|
|
||
| if data != 't' { | ||
| time.Sleep(100 * time.Millisecond) | ||
| } | ||
| return | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func endTests() { | ||
| println("\n### Tests complete.") | ||
|
|
||
| // tests done, now sleep waiting for baud reset to load new code | ||
| for { | ||
| time.Sleep(1 * time.Second) | ||
| } | ||
| } | ||
|
|
||
| // digital read of a GPIO pin physically connected to V | ||
| func digitalReadVoltageGPIO() { | ||
| printtest("digitalReadVoltage (GPIO)") | ||
|
|
||
| readV.Configure(machine.PinConfig{Mode: machine.PinInputPulldown}) | ||
| time.Sleep(100 * time.Millisecond) | ||
|
|
||
| // should be on | ||
| if readV.Get() { | ||
| printtestresult("pass") | ||
| return | ||
| } | ||
|
|
||
| printtestresult("fail") | ||
| } | ||
|
|
||
| // digital write on/off of one GPIO pin as input physically connected to a different GPIO pin as output. | ||
| func digitalWriteGPIO() { | ||
| readpin.Configure(machine.PinConfig{Mode: machine.PinInputPulldown}) | ||
| writepin.Configure(machine.PinConfig{Mode: machine.PinOutput}) | ||
| time.Sleep(100 * time.Millisecond) | ||
|
|
||
| printtest("digitalWriteOn (GPIO)") | ||
| writepin.High() | ||
| time.Sleep(100 * time.Millisecond) | ||
|
|
||
| // should be on | ||
| if readpin.Get() { | ||
| printtestresult("pass") | ||
| } else { | ||
| printtestresult("fail") | ||
| } | ||
|
|
||
| time.Sleep(100 * time.Millisecond) | ||
|
|
||
| printtest("digitalWriteOff (GPIO)") | ||
| writepin.Low() | ||
| time.Sleep(100 * time.Millisecond) | ||
|
|
||
| // should be off | ||
| if readpin.Get() { | ||
| printtestresult("fail") | ||
| return | ||
| } else { | ||
| printtestresult("pass") | ||
| } | ||
| } | ||
|
|
||
| // checks to see if an attached MPU6050 accelerometer is connected. | ||
| func i2cConnection() { | ||
| machine.I2C0.Configure(machine.I2CConfig{}) | ||
| time.Sleep(100 * time.Millisecond) | ||
|
|
||
| a := mpu6050.New(machine.I2C0) | ||
| accel = &a | ||
|
|
||
| printtest("i2cConnection (MPU6050)") | ||
|
|
||
| err := accel.Configure() | ||
| if err != nil { | ||
| printtestresult(err.Error()) | ||
| return | ||
| } | ||
| time.Sleep(400 * time.Millisecond) | ||
|
|
||
| if !accel.Connected() { | ||
| printtestresult("fail") | ||
| return | ||
| } | ||
|
|
||
| printtestresult("pass") | ||
| } | ||
|
|
||
| // checks if it is possible to send/receive by spi | ||
| func spiTxRx() { | ||
| spi0 := machine.SPI2 | ||
| spi0.Configure(machine.SPIConfig{ | ||
| SCK: machine.SPI_SCK_PIN, | ||
| SDO: machine.SPI_SDO_PIN, | ||
| SDI: machine.SPI_SDI_PIN, | ||
| Frequency: 4000000, | ||
| }) | ||
|
|
||
| from := make([]byte, 8) | ||
| for i := range from { | ||
| from[i] = byte(i) | ||
| } | ||
| to := make([]byte, len(from)) | ||
|
|
||
| printtest("spiTx") | ||
| err := spi0.Tx(from, to) | ||
| if err != nil { | ||
| printtestresult("fail") | ||
| } else { | ||
| printtestresult("pass") | ||
| } | ||
|
|
||
| printtest("spiRx") | ||
| for i := range from { | ||
| if from[i] != to[i] { | ||
| printtestresult("fail") | ||
| return | ||
| } | ||
| } | ||
| printtestresult("pass") | ||
| } | ||
|
|
||
| func printtest(testname string) { | ||
| print("- " + testname + " = ") | ||
| } | ||
|
|
||
| func printtestresult(result string) { | ||
| println("***" + result + "***") | ||
| } | ||
|
|
||
| func printfailexpected(reason string) { | ||
| println(" expected:", reason) | ||
| } | ||
|
|
||
| func printfailactual(val uint16) { | ||
| println(" actual:", val) | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.25.7 is out already 😺
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update that in another PR. Thanks @b0ch3nski !