This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI three lines mode

I want to use the SPI in master mode, but the slave just have three lines,the miso and the mosi is the same line,but I don't know how to config the pins? Do the nRF52832 supports this mode? if YES,could you tell me how to use it or some examples to reference ?

Parents
  • Sorry for digging up an old question, but I just had to make a sensor with only "3-wire SPI" work with nRF52. Didn't see a similar answer (sorry if I missed it) and this seemed as good as any to blurt out my own solution.

    devzone.nordicsemi.com/.../ is a hardware solution that should work as RK mentioned, but I had to preferably solve it in software.

    A software solution that worked for me (reading a register) using the vanilla nrf_drv_spi:

    1. (SPI is uninitialised when not in use)
    2. Initialise SPI with MOSI as [SDIO_PIN] and MISO & CS as NRF_DRV_SPI_PIN_NOT_USED
    3. Assert CS
    4. Make a pure tx transfer (instance, tx_buf, tx_len, NULL, 0)
    5. Uninitialise SPI
    6. Initialise SPI with MISO as [SDIO_PIN] and MOSI & CS as NRF_DRV_SPI_PIN_NOT_USED
    7. Make a pure rx transfer (instance, NULL, 0, rx_buf, rx_len)
    8. Deassert CS
    9. (Uninitialise SPI)

    I guess some sensors might throw a hissy fit in between the transfers if there's too much delay, but at least I got it working with my own setup.

    Anyhoo hope this helps someone in the same situation in the future.

Reply
  • Sorry for digging up an old question, but I just had to make a sensor with only "3-wire SPI" work with nRF52. Didn't see a similar answer (sorry if I missed it) and this seemed as good as any to blurt out my own solution.

    devzone.nordicsemi.com/.../ is a hardware solution that should work as RK mentioned, but I had to preferably solve it in software.

    A software solution that worked for me (reading a register) using the vanilla nrf_drv_spi:

    1. (SPI is uninitialised when not in use)
    2. Initialise SPI with MOSI as [SDIO_PIN] and MISO & CS as NRF_DRV_SPI_PIN_NOT_USED
    3. Assert CS
    4. Make a pure tx transfer (instance, tx_buf, tx_len, NULL, 0)
    5. Uninitialise SPI
    6. Initialise SPI with MISO as [SDIO_PIN] and MOSI & CS as NRF_DRV_SPI_PIN_NOT_USED
    7. Make a pure rx transfer (instance, NULL, 0, rx_buf, rx_len)
    8. Deassert CS
    9. (Uninitialise SPI)

    I guess some sensors might throw a hissy fit in between the transfers if there's too much delay, but at least I got it working with my own setup.

    Anyhoo hope this helps someone in the same situation in the future.

Children
Related