How to keep MOSI line high at idle?

gerard-hm
Posts: 3
Joined: Sun Aug 01, 2021 12:34 am

How to keep MOSI line high at idle?

Postby gerard-hm » Sun Aug 01, 2021 1:00 am

My SPI setup:

Code: Select all

SPI_DEVICE_NO_DUMMY
SPI_DEVICE_3WIRE
SPI_DEVICE_HALFDUPLEX
no DMA
no interrupts (I use polling instead)
no address, no command phases, just data phase for a custom protocol
I'm currently using multiple DATA phases one after another with all 1s to simulate idle logic high, but there is still a small gap between the 64 bytes worth of DATA phases.

Is there a better, another way to keep MOSI line high at idle?

Some other hardware architectures apparently seem to hold the idle MOSI line at whatever level the last bit was sent, is there a way to have that behavior for ESP32?

thanks

gerard-hm
Posts: 3
Joined: Sun Aug 01, 2021 12:34 am

Re: How to keep MOSI line high at idle?

Postby gerard-hm » Sat Aug 14, 2021 12:46 am

To answer my own question - the way to do it is to invert signal using:

Code: Select all

        esp_rom_gpio_connect_out_signal(mosi, spi_periph_signal[host_device].spid_out, invert, false);
        esp_rom_gpio_connect_in_signal(mosi, spi_periph_signal[host_device].spid_in, invert);
and then invert again all the data bytes:

Code: Select all

        buffer[i]  = ~data_byte; // invert

Who is online

Users browsing this forum: No registered users and 25 guests