I am having an issue with the SPI mode. When I first start, reading it results in a 0, but if I set any bits in the mode, it also sets bit 2, so mode1 results in mode5, mode2, 6, and so on. If I set it to 0, it returns 0.
I am also getting some inconsistent things happening. I am in 16 bit mode. When I send to the device 0x7200, the MOSI should be sending LSB first, sometimes it sends the MSB first. Today, that is what it is doing. Yesterday, it was working fine, today it is not.
And I also found that if I used the same code somewhere else, it would error and give me an invalid parameter. I found that this is because the structure is not cleared.
But now I have the send working correctly using the transfer code from the example, but it is reading random values back, even though it is being sent 0s. I can see the signals and everything is correct. In fact at the moment, the values sent back on the read (second word), is always 0, which isn’t correct, but I should always report 0, but it’s not. Here is the transfer structure:
struct spi_ioc_transfer tr[1];
memset(&tr, 0, sizeof(tr));
tr[0].tx_buf = (__u64)tx;
tr[0].rx_buf = (__u64)rx,
tr[0].len = (uint32_t)len;
tr[0].speed_hz = m_speed;
tr[0].delay_usecs = m_delay;
tr[0].bits_per_word = m_bits;
tr[0].tx_nbits = 16;
tr[0].rx_nbits = 16;
tr[0].bits_per_word = 16;
tr[0].cs_change = false;
I have checked and rechecked the connections to the board. The all seem good. Does anyone have any suggestions as to get this working. I do have a level shifter as the device is 3.3 volts and the board is 1.8v. But that part is working correctly.
Thanks,
Steve