Hello @jaredwolff
I am currently using nRF52840 DK. On that board I2S peripheral is not available by default in device tree, but Zephyr has provided drivers for I2S. So i added I2S peripheral in dtsi and dts file. Also configured CONFIG_I2S=y in project configuration file. And after building the object i can see it’s giving a status Okay in Zephy.dts file.
Here is the snippet of the zephyr.dts
i2s: i2s@40025000 {
#address-cells = < 0x1 >;
#size-cells = < 0x0 >;
compatible = "nordic,nrf-i2s";
reg = < 0x40025000 0x1000 >;
interrupts = < 0x25 0x1 >;
status = "okay";
label = "I2S";
sck-pin = < 0x11 >;
lrck-pin = < 0x12 >;
sdin-pin = < 0x13 >;
my_i2s_device: mp34dt05@0 {
compatible = "st,mpxxdtyy";
reg = < 0x0 >;
label = "MP34DT05";
};
};
Now after getting the device label, when i call device get binding function on it, result is a NULL pointer. Most probably the DEVICE_DEFINE() is not getting executed for I2S peripheral otherwise it would have found the I2S peripheral config pointers from ROM.
Below is my code for reference :
#include <zephyr.h>
#include <sys/printk.h>
#include <sys/util.h>
#include <string.h>
#include <usb/usb_device.h>
#include <drivers/uart.h>
#include <stdio.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
#include <drivers/i2s.h>
//Device structures
const struct device *usb_dev;
const struct device *i2s_dev;
/ * The devicetree node identifier for the I2S */
#define MY_I2S DT_NODELABEL(i2s)
void main(void)
{
uint32_t dtr = 0;
//get usb device
usb_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME);
if (usb_enable(NULL)) {
return;
}
while (!dtr) {
uart_line_ctrl_get(usb_dev, UART_LINE_CTRL_DTR, &dtr);
}
if (strlen(CONFIG_UART_CONSOLE_ON_DEV_NAME) !=
strlen("CDC_ACM_0") ||
strncmp(CONFIG_UART_CONSOLE_ON_DEV_NAME, "CDC_ACM_0",
strlen(CONFIG_UART_CONSOLE_ON_DEV_NAME))) {
printk("Error: Console device name is not USB ACM\n");
return;
}
k_msleep(100);
//Checking status of I2S in device tree
#if DT_NODE_HAS_STATUS(MY_I2S, okay)
printk("I2S enabled in Zephyr DeviceTree \r\n");
#else
printk("I2S is disabled in DeviceTree\r\n");
#endif
//Get I2S device
i2s_dev = device_get_binding(DT_LABEL(MY_I2S));
if(i2s_dev == NULL){
printk("I2S not found\r\n");
}else{
printk("I2S found\r\n");
}
while (1)
{
}
}
Do you have any idea how to solve this issue ?