Skip to content
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

SAMD51 SPI Secondary Mode #9385

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

Randall-Scharpf
Copy link

Addresses #2131. Tested on a pair of custom breakout boards which were derived from the Metro M4 Express.

Randall-Scharpf and others added 26 commits November 7, 2023 13:35
…o adafruit-9.0.x

Rebasing onto 9.0.3 (plus 4 commits) from 9.0.0-alpha, to get updates that fix asyncio library
…erted Metro M4 Express board configurations to original
…ld scripts to build firmware for rapid0 boards, updated peripherals submodule
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! A couple organization suggestions that will slim down this PR.

.gitmodules Outdated Show resolved Hide resolved
shared-bindings/busio/SPI.c Outdated Show resolved Hide resolved
shared-bindings/busio/SPI.c Outdated Show resolved Hide resolved
@dhalbert
Copy link
Collaborator

dhalbert commented Jul 1, 2024

Adafruit has been using "main" and "secondary" for the "M" and "S" names. I have also seen "sub" or "subnode". There was a proposal for "peripheral" and "controller", with "PICO" and "CIPO" pin names, but that has not been widely adopted. We aren't planning to rename "MOSI" and "MISO", so "main" and "secondary" are probably fine.

@dhalbert dhalbert changed the title SAMD51 SPI Slave Mode SAMD51 SPI Secondary Mode Nov 14, 2024
@Randall-Scharpf
Copy link
Author

Hi, just wanted to follow up to see if there's changes to be requested on this feature. I added some commits a few months back to address the concerns you've expressed so far. I know you guys are busy, let me know how I can help or if there's something I missed!

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thanks for the ping! Sorry for not getting back to you. I was on leave last fall (and will be later this year again.)

Please ensure the CI tests are passing too. That way we can merge if it is ready.

//| """Queue data for the next SPI transfer from the main device.
//| If a packet has already been queued for this SPI bus but has not yet been transferred, an error will be raised.
//|
//| :param bytearray miso_packet: Packet data to be sent from secondary to main on next request."""
Copy link
Member

Choose a reason for hiding this comment

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

Please document mosi_packet too. Is the expectation that this memory isn't mutated after the function call?

}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(spitarget_spi_target_load_packet_obj, 1, spitarget_spi_target_load_packet);

//| def try_transfer(self, *, timeout: float = -1) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//| def try_transfer(self, *, timeout: float = -1) -> bool:
//| def wait_transfer(self, *, timeout: float = -1) -> bool:

I think I'd call this wait since it doesn't initiate the transfer.

#include "py/runtime.h"

//| class SPITarget:
//| """Serial Peripheral Interface protocol target"""
Copy link
Member

Choose a reason for hiding this comment

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

Please include a basic example here so that we can see what the API use looks like.

uint8_t MISO_pin;
uint8_t SS_pin;

dma_descr_t running_dma;
Copy link
Member

Choose a reason for hiding this comment

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

I think you'll want to store the buffer objects here while a transfer is in progress. If you don't the garbage collector may clean them up while a transfer is in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants