Post Go back to editing

Using AD7949 with pyadi-iio

Category: Software
Product Number: AD7949

Hello,
I am trying to access an AD7949 via I2C (Raspberry PI) with pyadi-iio. In Github this is listed as supported hardware. However, I can't find any reference to it in the documentation. Did I miss something?

I use libiio 0.25, pyadi-iio 0.0.17.

Thanks a lot

Thread Notes

Parents
  • AD7949 is supported by the AD7689 class pyadi-iio/adi/ad7689.py at 24b753e22e5e3c440a8dc06941ed884db3e9fe8e · analogdevicesinc/pyadi-iio (github.com)

    pyadi-iio assumes you are using the IIO driver for the device. Is this the case?

    -Travis

  • Thank you, Travis.
    I got libiio and pylibiio installed.

    If try to run the example code of the AD7689 I get:
    "ERROR: Unable to create Avahi DNS-SD browser: Invalid host name"

    Is there anything i am doing wrong? This is my first time, I am a rookie and so I will make nearly every rookie mistake.
    Sorry for this in advance.

    iio_info shows only the devices of the raspberry (cpu thermal and rpi volt) if this is of any importance.

    Thank you
    -Max

  • "ERROR: Unable to create Avahi DNS-SD browser: Invalid host name"

    This likely means avahi (autodiscovery) is not correctly setup on your system. Make sure the service is running if you need that feature. Otherwise, just directly provide the constructor the URI.

    iio_info shows only the devices of the raspberry (cpu thermal and rpi volt) if this is of any importance.

    You likely don't have the driver setup. Are you using the ADI kernel (it comes with Kuiper Linux) and have you enabled the correct devicetree through the config.txt file?

    -Travis

  • Thank you. Since the AD7689 is not listed in the project files, it is not possible for me to access the AD7949, I guess?
    https://wiki.analog.com/resources/tools-software/linux-software/kuiper-linux/project-list.

    The AD7949 is on a self designed RPi-Shield and is connected to the SPI-Pins.

    -Max

  • I have installed kuiper linux. Since there is no driver for the 7949, I have added the driver.
    Could you please check if this process correct?

    git clone https://github.com/analogdevicesinc/linux
    cd linux
    git checkout rpi-5.10.y


    -I have download driver ad7949.c (https://github.com/torvalds/linux/blob/master/drivers/iio/adc/ad7949.c) and put the file inside this directory.:`/linux-adi/drivers/ad7949/ad7949.c`
        
    -I created the Makefile inside the ad7949 directory and edited it. This will appear like `/linux-adi/drivers/ad7949/Makefile`
       `obj-$(CONFIG_ad7949) += ad7949.o`

       
    -I created `Kconfig` file inside the ad7949 directory, this will appeare`/linux-adi/drivers/ad7949/Kconfig`
        
        config ad7949
        tristate "ad7949" //gives your driver description like vendor name etc.
        depends on ARM
        default y if ARM
        help
          my driver module.

    -Edit `Makefile` and `Kconfig` file  at `/linux-adi/drivers/Makefile` and `/linux-adi/drivers/Kconfig`
    Makefile:
         obj-$(CONFIG_AD7949)   += ad7040/
        
    Kconfig:   
        source "drivers/my_drvr/Kconfig"
        
    -Edited `Kconfig` file into `kernel_source/arch/arm/configs/adi_bcm2711_defconfig` since i am using RPi 4
               CONFIG_AD7949=y


    -Edit build_rpi_kernel_image.sh
                 DEFCONFIG=${DEFCONFIG:-adi_bcm2711_defconfig}

    -run  ./build_rpi_kernel_image.sh

    -Copy kernel7 to RPi /boot/

    If i run lsmod it does not show up but i don't get an error message when i run modprobe ad7949.

    Could you confirme this? As next step i will try to setup a device tree overlay.

    Thank you!

  • After setting up the device tree the ad7949 gets recognized in the iio_info

    analog@analog:~ $ sudo iio_info
    [sudo] password for analog:
    Library version: 0.24 (git tag: accb7b5)
    Compiled with backends: local xml ip usb serial
    IIO context created with local backend.
    Backend version: 0.24 (git tag: accb7b5)
    Backend description string: Linux analog 5.10.63-v7l+ #1 SMP Fri Mar 10 16:35:58 UTC 2023 armv7l
    IIO context has 4 attributes:
            hw_carrier: Raspberry Pi 4 Model B Rev 1.4
            dtoverlay: vc4-kms-v3d,ad7479
            local,kernel: 5.10.63-v7l+
            uri: local:
    IIO context has 4 devices:
            hwmon0: cpu_thermal
                    1 channels found:
                            temp1:  (input)
                            1 channel-specific attributes found:
                                    attr  0: input value: 49660
                    No trigger on this device
            hwmon1: rpi_volt
                    1 channels found:
                            in0:  (input)
                            1 channel-specific attributes found:
                                    attr  0: lcrit_alarm value: 0
                    No trigger on this device
            iio:device0: ad7949
                    8 channels found:
                            voltage6:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 16383
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage3:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 0
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage7:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 16383
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage0:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 0
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage4:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 0
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage1:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 250
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage5:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 16383
                                    attr  1: scale ERROR: Invalid argument (22)
                            voltage2:  (input)
                            2 channel-specific attributes found:
                                    attr  0: raw value: 0
                                    attr  1: scale ERROR: Invalid argument (22)
                    1 debug attributes found:
                                    debug attr  0: direct_reg_access value: 0x3D79
                    No trigger on this device
            iio_sysfs_trigger:
                    0 channels found:
                    2 device-specific attributes found:
                                    attr  0: add_trigger ERROR: Permission denied (13)
                                    attr  1: remove_trigger ERROR: Permission denied (13)
                    No trigger on this device

    I can access the ad7949 via python but cannot ad7949.rx().

    Is there anything I have forgotten in my dts-file or what you cause this issue. Thank you a lot.

    /dts-v1/;
    /plugin/;
    
    / {
            compatible = "brcm,bcm2708", "brcm,bcm2709";
    
    
            fragment@0 {
                    target = <&spi0>;
                    __overlay__ {
                            #address-cells = <1>;
                            #size-cells = <0>;
                            status = "okay";
    
                            ad7949@0{
                                    #clock-cells = <0>;
                                    compatible = "ad7949";
                                    reg = <0>;
                                    spi-max-frequency = <1000000>;
                                    spi-cpol;
                                    vref-supply = <4096000>;
                            };
                    };
            };
    };
    
    

Reply Children
No Data