Add SPI loopback test app - #585
Conversation
ppannuto
left a comment
There was a problem hiding this comment.
Meta: This should move to examples/tests/spi_loopback/
00e5f1d to
857f46d
Compare
|
Moved to |
857f46d to
676c40e
Compare
|
Fixed: |
There is no example that exercises the current libtock/peripherals/ spi_controller.h API end-to-end -- the existing wip/spi/* examples predate it and don't build against it. Add a small standalone loopback test: write a known pattern, read it back over the same transfer, and print SPI PASS/FAIL depending on whether they match. Only meaningful on a board with SPI in hardware loopback (e.g. Tock's QEMU qemu_arm_mps2_an385/an386 boards); on a board with a real, non-looped-back peripheral, a mismatch is expected. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
676c40e to
d0d2234
Compare
|
Addressed the third review round: |
Summary
Adds
examples/tests/spi_loopback, a small standalone app that exercises thecurrent
libtock/peripherals/spi_controller.hAPI end-to-end: writes a knownpattern and reads it back in the same transfer, then checks the two match,
printing
SPI PASSorSPI FAIL: <reason>.This fills a gap found while adding SPI support to a new board in
tock/tock#5115: there was no
example that builds against the current
libtock_spi_controller_*API — theexisting
wip/spi/*examples predate it (different function names, noreturncode_t) and don't compile against it without a rewrite.The test is only meaningful on a board where SPI is configured in hardware
loopback mode (read data is expected to equal write data), such as the new
QEMU
qemu_arm_mps2_an385/qemu_arm_mps2_an386boards. On a board wired toa real, non-looped-back peripheral, a mismatch is expected and not a bug —
noted in the app's README.
Testing
Built for both
cortex-m3andcortex-m4(TOCK_TARGETS=cortex-m3 make/TOCK_TARGETS=cortex-m4 make), and run under QEMU against the boards intock/tock#5115 (
qemu_arm_mps2_an385/an386) alongsidec_helloandblink, confirmingSPI PASS. Re-verifiedSPI PASSagain from thecurrent
examples/tests/spi_loopbackpath after the review round below.make format(uncrustify) passes clean with no changes.AI disclosure
Written by Claude (Claude Code), as part of the same session that produced
tock/tock#5115, in response to:
The second prompt was in response to Pat's own review (as
ppannuto,requesting changes): moved the app to
examples/tests/spi_loopback,renamed
wbuf/rbuftowrite_buf/read_buf, dated theset_chip_selectcomment, lifted the SPI rate to a namedSPI_RATE_HZconst with a comment on its provenance, printed both buffers on mismatch,
and dropped a redundant README note — see inline replies on the review for
detail on each.
Review status: reviewed once by Pat Pannuto (changes requested); the above
addresses that round. Not yet re-reviewed/approved.