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

stm32/spi: slave mode support #623

Open
Dirbaio opened this issue Feb 13, 2022 · 2 comments · May be fixed by #2750
Open

stm32/spi: slave mode support #623

Dirbaio opened this issue Feb 13, 2022 · 2 comments · May be fixed by #2750
Labels
e-stm32 kind-feature New feature or request

Comments

@Dirbaio
Copy link
Member

Dirbaio commented Feb 13, 2022

No description provided.

@Dirbaio Dirbaio added kind-feature New feature or request e-stm32 labels Feb 13, 2022
@vldm
Copy link

vldm commented Jul 31, 2022

Hi, i want to implement this mode.
I already experimented with it, and the blocking mode working fine. (two stm32f407 discovery boards communicate correctly)
But then i tried to combine master and slave on single board to emulate Double SPI.
Using DMA, and found an issues, with first clock (that looks like pullup registor to me)
.

Oscilloscope Image of problem Master and slave send &[0b10010001]

During tranfser initialization clock rise up and slave shift its registor.

osci

The research lead me to the

unsafe {
T::REGS.cr1().modify(|w| {
w.set_spe(false);
});
- in this lines spi is disabled.

  1. Can you clarify is it important to reset spe flag during reconfiguration, i cannot find any info in my manual about this.

1.1. On my case it works without spi enabled flag changing - so this can be solution.

1.2. Other solution would be to set slave select signal only after reseting spi. But in order to make this work we need to change interface of transfer_inner to something like:

async fn transfer_inner<W: Word>(
        &mut self,
        read: *mut [W],
        write: *const [W],
        mut handle_slave_select: impl FnMut(),
    ) -> Result<(), Error> 

In embedded-has-async they propose to move this logic to level of SPI device https://docs.rs/embedded-hal-async/0.1.0-alpha.1/src/embedded_hal_async/spi.rs.html#59

  1. The second issue that blocks me from complete implementation is about sending only one byte (spi word?) trough DMA.
    For some reason, in this scenario, it tries to send same byte multiple time. If i send two bytes or more - it works fine.

@rokadvednt03
Copy link

async fn transfer_inner<W: Word>(
&mut self,
read: *mut [W],
write: *const [W],
mut handle_slave_select: impl FnMut(),
) -> Result<(), Error>

@tomcur tomcur linked a pull request Mar 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e-stm32 kind-feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants