micropython / micropython/micropython

stm32: Implement Asynchronous SPI Slave

Open
#1,650 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement port-stm32
Dominant language
C
Stars
22.1k
Forks
9k
Avg merge
6d 4h
Merged PRs (30d)
16

Description

This issue is to implement asynchronous sending and receiving on the SPI when configured as a slave - instead of blocking and waiting for whenever a clock is provided from the master. SPI (read and write) should probably have a configurable buffer like uart rx currently does. When the master clocks, the contents of the send buffer should be clocked out and whatever the master is sending should be clocked in to the read buffer (if exists). The user should probably be able to choose between blocking and non-blocking modes as mentioned in #1533.

Related: #1642 (async uart tx)

Bug with existing implementation:
Currently when reading SPI as a slave, the function blocks until the specified number of bytes is received or the timeout occurs. If the timeout occurs an exception is raised (OS: 116) #1414 . An exception shouldn't be raised. Whatever data was read should be returned, just as the uart read currently does.

As a result of not having asynchronous read/writes and with the existing quirky behaviors, spi slave mode seems rather unusable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing STM32 SPI slave implementation and comparing its read behavior with the UART RX behavior described in the issue. Review #1533, #1642, and #1414; done should include configurable asynchronous send and receive buffers, selectable blocking or non-blocking operation, and returning partial data without raising a timeout exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.