-
Hello, I am working with a Sparkfun RED-V board and I am unable to get the I2C device struct. I need it to be able to utilize a series of peripherals connected through the Qwiic port. According to the official Sparkfun website the Qwicc libraries are not available on Zephyr yet but as far as I understand I should still be able to access the sensors through I2C. I am working in VSCode with platformIO. Here's a snippet of the device tree:
Every GPIO pin can implement up to 2 HW-Driven functions (IOF) and from the FE310 manual looks like GPIO_12 can be configured with I2C0_SDA and as far as my understanding goes (I'm new to the embedded world) getting the i2c0 device should take care of configuring the GPIO pin as well, but please let me know if I'm wrong. I tried const struct device *i2c_dev = device_get_binding("I2C_0");
if (!i2c_dev) {
printk("Failed to get I2C device\n");
} but the pointer is always null. I tried with the Tested with macros as well: #define MY_DEVICE DT_PATH(soc, i2c_10016000)
void main(void)
{
const struct device *const dev = DEVICE_DT_GET(MY_DEVICE);
if (!device_is_ready(dev)) {
printk("Failed to get I2C device\n");
return;
}
} but I get the following error when building: /home/pc/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld.bfd: .pio/build/sparkfun_redboard_v/src/main.o: in function `.L0 ':
/home/pc/.platformio/packages/framework-zephyr/include/device.h:573: undefined reference to `__device_dts_ord_19'
/home/pc/.platformio/packages/toolchain-riscv/bin/../lib/gcc/riscv64-unknown-elf/8.3.0/../../../../riscv64-unknown-elf/bin/ld.bfd: /home/pc/.platformio/packages/framework-zephyr/include/device.h:573: undefined reference to `__device_dts_ord_19'
collect2: error: ld returned 1 exit status
*** [.pio/build/sparkfun_redboard_v/zephyr/firmware-pre.elf] Error 1 For instance, I have no issues with getting the gpio device and configure them: #include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#define PIN 5
void main(void) {
const struct device *gpio_dev = device_get_binding("gpio_0");
if (!gpio_dev) {
printk("Cannot find GPIO device!\n");
return;
}
// Configure GPIO pin 5 as an output
int ret = gpio_pin_configure(gpio_dev, PIN, GPIO_OUTPUT);
if (ret) {
printk("Error configuring GPIO pin!\n");
return;
}
while (1) {
// Set the state of the GPIO pin to high (ON)
ret = gpio_pin_set(gpio_dev, PIN, 1);
if (ret) {
printk("Error setting GPIO pin!\n");
return;
}
k_sleep(K_MSEC(500));
// Set the state of the GPIO pin to low (OFF)
ret = gpio_pin_set(gpio_dev, PIN, 0);
if (ret) {
printk("Error setting GPIO pin!\n");
return;
}
k_sleep(K_MSEC(500));
}
} I just seem to not be able to get the I2C device (and UART). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
platformio is not supported, you should use native zephyr |
Beta Was this translation helpful? Give feedback.
platformio is not supported, you should use native zephyr