Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c1d61d2
shared/runtime: add buffer_slice() and use it in busio.SPI
lynt-smitka Oct 2, 2026
4719ff9
raspberrypi: move the SPI driver to peripherals/spi.c
lynt-smitka Oct 2, 2026
36f48d0
raspberrypi: async SPI reads, full-duplex transfers, stop and configure
lynt-smitka Oct 5, 2026
4775be0
Add awaitable C functions
lynt-smitka Oct 2, 2026
457f592
async_spi: SPI transfers for asyncio
lynt-smitka Oct 5, 2026
4f18be7
busio: reuse async_spi's argument tables
lynt-smitka Oct 5, 2026
8bbdf9b
zephyr-cp: async_spi
lynt-smitka Oct 3, 2026
7e32dae
async_spi: report Zephyr transfer errors, wait without background tasks
lynt-smitka Oct 8, 2026
9aaf7f5
busio: keep the SPI constructor's argument table under CIRCUITPY_BUSI…
lynt-smitka Oct 9, 2026
f2b40a4
Merge remote-tracking branch 'upstream/main' into async-spi-v3
lynt-smitka Oct 12, 2026
7fe5f7a
busio: own the SPI argument tables, async_spi uses them
lynt-smitka Oct 12, 2026
4a45d54
raspberrypi: keep CircuitPython's flag type out of peripherals/spi
lynt-smitka Oct 12, 2026
b1de0e7
async_spi: start functions return the context
lynt-smitka Oct 12, 2026
40d772f
async_spi: end() and cancel() get the object and a context
lynt-smitka Oct 14, 2026
d78eabf
busio: build busio.SPI on async_spi where a port has it
lynt-smitka Oct 14, 2026
cff9b57
busio: name the embedded async_spi object async_spi
lynt-smitka Oct 14, 2026
4546345
zephyr-cp: send write_value from a buffer also when it is 0
lynt-smitka Oct 14, 2026
6f5d10a
async_spi: close() on an awaitable that was never awaited finishes it
lynt-smitka Oct 14, 2026
5178374
zephyr-cp: register a waiting configure() under irq_lock()
lynt-smitka Oct 14, 2026
c96badb
raspberrypi: clear the DMA enable bits before an SPI abort on RP2350
lynt-smitka Oct 14, 2026
629e8a4
zephyr-cp: the async_spi test requires the ticker to run during the t…
lynt-smitka Oct 14, 2026
b3d34bd
build: one flag, CIRCUITPY_ASYNC_SPI, for a port with async SPI
lynt-smitka Oct 15, 2026
2e3aa3e
build: pick busio/SPI.c's home through the source lists
lynt-smitka Oct 15, 2026
271634b
busio: a blocking SPI call stops on Ctrl-C
lynt-smitka Oct 15, 2026
5f96f7b
raspberrypi: the SPI driver lives in common-hal/async_spi
lynt-smitka Oct 15, 2026
a892673
async_spi: configure() is a plain call
lynt-smitka Oct 15, 2026
4dba4c1
async_spi: a lock for the bus, held with `async with spi.lock:`
lynt-smitka Oct 16, 2026
8dbae29
async_spi: fix the lock docstring's literal block
lynt-smitka Oct 17, 2026
2465ad3
async_spi: configure() raises while a transfer is running
lynt-smitka Oct 19, 2026
447d787
async_spi: the lock comes from common-hal
lynt-smitka Oct 19, 2026
c679a9a
busio: use the async_spi lock
lynt-smitka Oct 19, 2026
1a8015b
busio: configure() no longer ends a pending write_start
lynt-smitka Oct 19, 2026
f9e0cf6
busio: polarity and phase come from async_spi
lynt-smitka Oct 19, 2026
cf470ae
async_spi: deinit() wakes the tasks waiting for the lock
lynt-smitka Oct 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
405 changes: 405 additions & 0 deletions ports/raspberrypi/common-hal/async_spi/SPI.c

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions ports/raspberrypi/common-hal/async_spi/SPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2026 Vladimir Smitka
//
// SPDX-License-Identifier: MIT

#pragma once

#include "py/obj.h"
#include "common-hal/microcontroller/Pin.h"
#include "supervisor/shared/async_flag.h"
#include "supervisor/shared/awaitable.h"

#include "hardware/spi.h"

typedef struct {
mp_obj_base_t base;
circuitpy_async_lock_obj_t lock;
spi_inst_t *peripheral;
const mcu_pin_obj_t *clock; // NULL once deinited
const mcu_pin_obj_t *mosi;
const mcu_pin_obj_t *miso;
uint32_t target_frequency;
int32_t real_frequency;
uint8_t polarity;
uint8_t phase;
uint8_t bits;
bool async_active; // an async DMA transfer may still be running
bool dma_kept; // dma_tx and dma_rx are ours until deinit
uint8_t dma_tx;
uint8_t dma_rx;
uint8_t one_byte; // the one-byte side of an async write (RX) or read (TX)
circuitpy_async_flag_t *async_done;
} async_spi_spi_obj_t;
7 changes: 7 additions & 0 deletions ports/raspberrypi/common-hal/async_spi/__init__.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is part of the CircuitPython project: https://circuitpython.org
//
// SPDX-FileCopyrightText: Copyright (c) 2026 Vladimir Smitka
//
// SPDX-License-Identifier: MIT

// No async_spi module functions.
325 changes: 0 additions & 325 deletions ports/raspberrypi/common-hal/busio/SPI.c

This file was deleted.

Loading
Loading