8000 tests: Add machine_spi_rate test. by projectgus · Pull Request #15543 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@projectgus
Copy link
Contributor
@projectgus projectgus commented Jul 25, 2024

Summary

Based on machine_i2s_rate, allows testing basic SPI functionality and timings.

Implemented for rp2, esp32 and pyboard.

  • Fix on pyboard (currently shows up to 14ms difference. Maybe need to account for quantisation error due to available SPI clock dividers.)

Implemented while testing #15523.

Testing

Tested on PyBoard V1.1, RP2 Pico, ESP32, ESP32-S3, ESP32-C3.

This work was funded through GitHub Sponsors.

@projectgus projectgus added the tests Relates to tests/ directory in source label Jul 25, 2024
@projectgus projectgus force-pushed the test/machine_spi_rate branch from dd57737 to d0d7313 Compare July 25, 2024 02:45
@codecov
Copy link
codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.43%. Comparing base (a4b3825) to head (1e98c4c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #15543   +/-   ##
=======================================
  Coverage   98.43%   98.43%           
=======================================
  Files         161      161           
  Lines       21281    21281           
=======================================
  Hits        20948    20948           
  Misses        333      333           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dpgeorge
Copy link
Member
  • Fix on pyboard (currently shows up to 14ms difference. Maybe need to account for quantisation error due to available SPI clock dividers

I suggest to print the SPI object (eg something like print(spi, file=stringio)) and from that parse the actual baudrate, then use that to compute the expected timing.

@projectgus
Copy link
Contributor Author

I suggest to print the SPI object (eg something like print(spi, file=stringio)) and from that parse the actual baudrate, then use that to compute the expected timing.

Yeah, I was hoping to avoid the complexity of this but I think it's going to be the way forward.

@projectgus projectgus force-pushed the test/machine_spi_rate branch from d0d7313 to a23b881 Compare August 6, 2024 00:41
@projectgus
Copy link
Contributor Author

Updated, re-tested on the implemented ports.

#
# Implementation is somewhat fiddly and inefficient to avoid dependency on
# 're' module,
s = str(spi)
Copy link
Contributor Author
@projectgus projectgus Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dpgeorge I went with str() here rather than the suggestion of printing to StringIO because it seems like this should work everywhere (string constructor calls through to mp_obj_print_helper().)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that's much simpler!

@projectgus projectgus marked this pull request as ready for review August 6, 2024 00:46
Based on machine_i2s_rate, allows testing basic SPI functionality and
timings.

Implemented and confirmed working for rp2, esp32, and pyboard.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Copy link
Member
@dpgeorge dpgeorge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I tested on Pico (rp2 port), an ESP32 board, PYBv1.0 and PYBD-SF6. Works well.

@dpgeorge dpgeorge force-pushed the test/machine_spi_rate branch from a23b881 to 1e98c4c Compare August 7, 2024 05:10
@dpgeorge dpgeorge merged commit 1e98c4c into micropython:master Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Relates to tests/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0