esp-idf-hal icon indicating copy to clipboard operation
esp-idf-hal copied to clipboard

Fix Half/Half3Wire read transactions bug

Open xiaguangbo opened this issue 10 months ago • 4 comments

fn spi_read_transactions inside spi_create_transaction's transaction_length changed to 0

xiaguangbo avatar Apr 09 '24 14:04 xiaguangbo

Sadly this breaks full duplex transfers. You need an if statement here.

Dominaezzz avatar Apr 21 '24 12:04 Dominaezzz

Sadly this breaks full duplex transfers. You need an if statement here.

Need to determine whether it is half duplex or full duplex? Or other apis to do full duplex?

xiaguangbo avatar Apr 22 '24 04:04 xiaguangbo

Sadly this breaks full duplex transfers. You need an if statement here.

Need to determine whether it is half duplex or full duplex? Or other apis to do full duplex?

You need a config setting for this.

ivmarkov avatar Apr 30 '24 04:04 ivmarkov

Sadly this breaks full duplex transfers. You need an if statement here.

Need to determine whether it is half duplex or full duplex? Or other apis to do full duplex?

You need a config setting for this.

I don't know what to do...

xiaguangbo avatar Apr 30 '24 04:04 xiaguangbo

@Dominaezzz @ivmarkov Can explain how to change it ? I changed it according to spi_write_transactions, they look the same.

xiaguangbo avatar Jul 12 '24 16:07 xiaguangbo

the spi_read_transcton function is used in different configurations of the drivers but itself doesn't now in witch state it is. Though simply changing to make it work for half3wire in this case breaks it for every case where it is not used that way. That's why it needed to be addressed on a case by case basis depending on what configuration the bus/device is.

Vollbrecht avatar Jul 12 '24 16:07 Vollbrecht

the spi_read_transcton function is used in different configurations of the drivers but itself doesn't now in witch state it is. Though simply changing to make it work for half3wire in this case breaks it for every case where it is not used that way. That's why it needed to be addressed on a case by case basis depending on what configuration the bus/device is.

I still won't, how do..., please you fix

fn spi_read_transactions(
    words: &mut [u8],
    chunk_size: usize,
) -> impl Iterator<Item = spi_transaction_t> + '_ {
    words.chunks_mut(chunk_size).map(|chunk| {
        spi_create_transaction(
            chunk.as_mut_ptr(),
            core::ptr::null(),
            chunk.len(),
            chunk.len(),
        )
    })
}

xiaguangbo avatar Jul 12 '24 18:07 xiaguangbo

You need to pass a boolean to spi_read_transactions to switch between the old full duplex behavior and your new half duplex behavior.

Dominaezzz avatar Jul 12 '24 19:07 Dominaezzz

You need to pass a boolean to spi_read_transactions to switch between the old full duplex behavior and your new half duplex behavior.

Dose spi_write_transactions need to be changed? it looks similar to spi_read_transactions

xiaguangbo avatar Jul 14 '24 17:07 xiaguangbo

I'm not sure, you'll have to check the esp-idf docs to verify. (I don't use std/esp-idf much these days)

Dominaezzz avatar Jul 14 '24 18:07 Dominaezzz

Is that the reason(L 804)? screenshot-2024-07-15-06-03-02

xiaguangbo avatar Jul 15 '24 06:07 xiaguangbo

out of date

xiaguangbo avatar Jul 15 '24 10:07 xiaguangbo