I have an nRF5340 and need to use the
spi4device for an SPI bus with multiple devices on it. Each, of course, has a CS pin.
I have to use spi4 because I have uart0, uart1, i2c2, and i2c3 (and there is no "4" device for either UART or I2C). I don't necessarily care about the > 8MHz high-speed capabilities of SPI4, I just need it to act like a regular SPI device with multiple CS pins.
It's rather unclear from the documentation and other posts on this forum how to configure this properly. It appears there's a hardware CS pin (P0.11), which suggests that only a single device can be used (one hardware CS pin means 1 device)? Is it possible to disregard that hardware pin though, and instead use multiple GPIOs for CS pins, like so:
&spi4 { status = "okay"; pinctrl-0 = <&spi0_default>; pinctrl-1 = <&spi0_sleep>; pinctrl-names = "default", "sleep"; cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>, // 0 <&gpio0 30 GPIO_ACTIVE_LOW>, // 1 <&gpio0 7 GPIO_ACTIVE_LOW>, // 2 <&gpio1 0 GPIO_ACTIVE_LOW>, // 3 <&gpio0 26 GPIO_ACTIVE_LOW>, // 4 <&gpio0 27 GPIO_ACTIVE_LOW>; // 5 ... };
If I want to use SPI4 in this way (regular speed, multiple CS/devices), and that's actually possible, how would I configure the PIN_CNF[p].MCUSEL and H0H1 values that are mentioned in the "SPI4" bullet at the top of the nRF5340 pinout page? i.e. what values should they have, and as importantly, how do I set them?