Trying to convert a working sample for a BME280 sensor from I2C to SPI
nrfConnect 1.4 on nrf9160-DK
After looking at other SPI examples and noting the syntax I thought the .overlay should be like this
```
&spi3 {
status = "okay";
sck-pin = <10>;
mosi-pin = <11>;
miso-pin = <12>;
cs-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
bme280@76 {
compatible = "bosch,bme280";
reg = <0x76>;
spi-max-frequency = <4000000>;
label = "BME280";
};
};
&uart3 {
status = "disabled";
};
```
prj.conf is:
```
CONFIG_SENSOR=y
CONFIG_SPI=y
CONFIG_SPI_3=y
CONFIG_BME280=y
CONFIG_SPI_NRFX=y
CONFIG_MAIN_STACK_SIZE=4096
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=4
```
If I take out the cs-gpios line this compiles but understandably throws a runtime error.
```
[00:00:00.000,030] [0m<dbg> BME280.bme280_init: initializing BME280[0m
[00:00:00.000,030] [0m<dbg> BME280.bme280_spi_init: no chip select set[0m
[00:00:00.000,030] [0m<inf> spi_nrfx_spim: CS control inhibited (no GPIO device)[0m
[00:00:00.000,091] [0m<dbg> BME280.bme280_chip_init: bad chip id 0xff[0m
[00:00:00.000,091] [0m<dbg> BME280.bme280_init: BME280 failed[0m
```
But with that line in place west produces all sorts of errors:
```
nrf9160dk_nrf9160ns.dts.pre.tmp:357.32-361.5: Warning (simple_bus_reg): /soc/cryptocell-sw: missing or empty reg/ranges property
nrf9160dk_nrf9160ns.dts.pre.tmp:56.42-68.3: Warning (unique_unit_address_if_enabled): /soc/peripheral@40000000/flash-controller@39000: duplicate unit-address (also used in node /soc/peripheral@40000000/kmu@39000)
nrf9160dk_nrf9160ns.dts.pre.tmp:305.19-311.3: Warning (unique_unit_address_if_enabled): /soc/peripheral@40000000/clock@5000: duplicate unit-address (also used in node /soc/peripheral@40000000/power@5000)
-- Generated zephyr.dts: .../ncs/zephyr/samples/sensor/bme280spi/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: .../ncs/zephyr/samples/sensor/bme280spi/build/zephyr/include/generated/devicetree_unfixed.h
```
etc.etc.
Is the above .overlay correct for an SPI device?
BTW. the only other use of cs-gpios I found in this SDK was for the spi_flash_at45 sample which, for other reasons, does not seem to compile cleanly.
OK. I moved on a little after looking here https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.4.0/zephyr/guides/dts/howtos.html#set-devicetree-overlays
This shows a different way to specify the chip select. So my new .overlay compiles OK but still throws the same runtime error
```
&spi3 {
status = "okay";
sck-pin = <11>;
mosi-pin = <10>;
miso-pin = <12>;
bme280@13 {
compatible = "bosch,bme280";
reg = <13>;
spi-max-frequency = <4000000>;
label = "BME280";
};
};
&uart3 {
status = "disabled";
};
```