Handling multiple slaves on single spi master channel

Hi, 

The spi_config structure zephyr provides is as below:

	struct spi_config
	{
		uint32_t frequency;
		uint16_t operation;
		uint16_t slave;

		const struct spi_cs_control *cs;
	};


Wherein cs is initialized to the chip select pin.

In my project I have a requirement to handle 2 slaves which are exactly the same.

Herein, how can I manage 2 instances of, same slaves

And do I need to get multiple device bindings for the same spi channel..?

Thanks,

Ubaid

Parents
  • Hi

    The host controller limit is set in master side, and the "slave number" will get a number between 0 and what the master side has set to the limit, so the master knows what slave device it is communicating with. You need to set the slave limit to 2 or more on the master side and configure a second SPI setup with another instance, etc. The SPIM API reference should be helpful here.

    Device binding and enabling SPI peripherals should be explained in this nRFConnect SDK tutorial and should give you an idea of how to set up peripherals on the master side.

    Best regards,

    Simon

Reply
  • Hi

    The host controller limit is set in master side, and the "slave number" will get a number between 0 and what the master side has set to the limit, so the master knows what slave device it is communicating with. You need to set the slave limit to 2 or more on the master side and configure a second SPI setup with another instance, etc. The SPIM API reference should be helpful here.

    Device binding and enabling SPI peripherals should be explained in this nRFConnect SDK tutorial and should give you an idea of how to set up peripherals on the master side.

    Best regards,

    Simon

Children
No Data
Related