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

How use multiple peripherals with one SPI port ?

Hello,

I have two differents sensors on one SPI port and I don't really know how to be able to use both. Of course all are connected in the same MISO/MOSI/SCK but there, is only one SS for it like in the example below:

void spi0_accel_init(void)
{
    xfer_spi0_desc.p_tx_buffer = (uint8_t const *) m_tx0_buf;
    xfer_spi0_desc.tx_length = sizeof(m_tx0_buf);
    xfer_spi0_desc.p_rx_buffer = m_rx0_buf;
    xfer_spi0_desc.rx_length = sizeof(m_rx0_buf);

    nrfx_spim_config_t spi0_config = NRFX_SPIM_DEFAULT_CONFIG;
    spi0_config.ss_pin   = SPIM0_SS_PIN;   //SER_APP_SPIM0_SS_PIN;//SPI_SS_PIN;
    spi0_config.miso_pin = SPIM0_MISO_PIN; //SER_APP_SPIM0_MISO_PIN;//SPI_MISO_PIN;
    spi0_config.mosi_pin = SPIM0_MOSI_PIN; //SER_APP_SPIM0_MOSI_PIN;//SPI_MOSI_PIN;
    spi0_config.sck_pin  = SPIM0_SCK_PIN;  //SER_APP_SPIM0_SCK_PIN;//SPI_SCK_PIN;

    APP_ERROR_CHECK(nrfx_spim_init(&spi0, &spi0_config, spi0_accel_event_handler, NULL));
}

Do you have an idea or should I modify the pin state manually of both SS of my sensors ?

Thank you !

Parents Reply Children
Related