I have init spi4- for
spi4_default: spi4_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
<NRF_PSEL(SPIM_MISO, 1, 14)>,
<NRF_PSEL(SPIM_MOSI, 1, 13)>;
};
};
spi4_sleep: spi4_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
<NRF_PSEL(SPIM_MISO, 1, 14)>,
<NRF_PSEL(SPIM_MOSI, 1, 13)>;
low-power-enable;
};
};
&spi4 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi4_default>;
pinctrl-1 = <&spi4_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
mcp23s17: gpio_expander@0 {
compatible = "microchip,mcp23s17";
reg = <0>;
spi-max-frequency = <1000000>;
spi-hold-cs;
gpio-controller;
#gpio-cells = <2>;
ngpios = <16>;
status = "okay";
};
}
static const struct device *mcp =
DEVICE_DT_GET(DT_NODELABEL(mcp23s17));
char pinconf = 0;
void testextend()
{
int ret;
uint32_t val;
if (!device_is_ready(mcp))
{
printk("MCP not ready\n");
return;
}
if (pinconf == 0)
{
for (int i = 0; i < 16; i++)
{
ret = gpio_pin_configure(mcp, i, GPIO_OUTPUT_ACTIVE);
printk("CFG PIN %d RET=%d\n", i, ret);
}
pinconf = 1;
}
/* ACTIVE LOW LED -> 0 = ON */
ret = gpio_pin_set(mcp, 13, 0);
printk("PIN13 ON RET=%d\n", ret);
ret = gpio_pin_set(mcp, 14, 0);
printk("PIN14 ON RET=%d\n", ret);
ret = gpio_pin_set(mcp, 15, 0);
printk("PIN15 ON RET=%d\n", ret);
ret = gpio_port_get_raw(mcp, &val);
printk("LED ON RAW = 0x%04X\n", val);
k_sleep(K_SECONDS(1));
/* ACTIVE LOW LED -> 1 = OFF */
ret = gpio_pin_set(mcp, 13, 1);
printk("PIN13 OFF RET=%d\n", ret);
ret = gpio_pin_set(mcp, 14, 1);
printk("PIN14 OFF RET=%d\n", ret);
ret = gpio_pin_set(mcp, 15, 1);
printk("PIN15 OFF RET=%d\n", ret);
ret = gpio_port_get_raw(mcp, &val);
printk("LED OFF RAW = 0x%04X\n", val);
k_sleep(K_SECONDS(1));
}
Complete hardware is fine, Yet SPI communication is not happening, Am I missing something? I did nothing extra than this.