What does spi_device_interface_config_t.mode mean

peterlspot
Posts: 13
Joined: Thu Mar 29, 2018 11:22 pm

What does spi_device_interface_config_t.mode mean

Postby peterlspot » Sun Jun 03, 2018 9:07 am

Hi,

I am wondering if there are any description about the .mode field in spi_device_interface_config_t structure?

Currently I can only find a simple comment line like "SPI mode (0-3) ", where can one find descriptions about the meaning for each value of "0, 1, 2, 3"?

I am wondering if the mode here means half-duplex or full-duplex, or anything else?

Below is what I can find from spi_master.c source code:

Code: Select all

            if (dev->cfg.mode==0) {
                host->hw->pin.ck_idle_edge=0;
                host->hw->user.ck_out_edge=0;
                host->hw->ctrl2.miso_delay_mode=nodelay?0:2;
            } else if (dev->cfg.mode==1) {
                host->hw->pin.ck_idle_edge=0;
                host->hw->user.ck_out_edge=1;
                host->hw->ctrl2.miso_delay_mode=nodelay?0:1;
            } else if (dev->cfg.mode==2) {
                host->hw->pin.ck_idle_edge=1;
                host->hw->user.ck_out_edge=1;
                host->hw->ctrl2.miso_delay_mode=nodelay?0:1;
            } else if (dev->cfg.mode==3) {
                host->hw->pin.ck_idle_edge=1;
                host->hw->user.ck_out_edge=0;
                host->hw->ctrl2.miso_delay_mode=nodelay?0:2;
            }

In my case, I am using 4 wire nCS, MISO, MOSI, SCLK to access a ADC module. I can read a single register byte using either mode 0 or 3.

Now I want read a batch of bytes from a starting register address, assuming their addresses are continuous. I am unsure if mode is related to this continuous read or not.

Regards,
peterlspot


peterlspot
Posts: 13
Joined: Thu Mar 29, 2018 11:22 pm

Re: What does spi_device_interface_config_t.mode mean

Postby peterlspot » Sun Jul 01, 2018 12:42 am

Thank you WiFive!

Who is online

Users browsing this forum: No registered users and 219 guests