Edit online

GPAI Demo

4 Dec 2024
Read time: 1 minute(s)

此 Demo 是 gpai 命令的部分代码(详见 drv_gpai.c),可以作为 GPAI 设备的使用参考:
u32 ch = 0;
struct rt_adc_device *dev = NULL;

dev = (struct rt_adc_device *)rt_device_find("gpai");
if (!dev) {
    LOG_E("Failed to open %s device\n", "gpai");
    return;
}
ret = rt_adc_enable(dev, ch);
if (!ret) {
    val = rt_adc_read(dev, ch);
    printf("GPAI ch%d: %d\n", ch, val);
}

rt_adc_disable(dev, ch);