ad7124

https://ez.analog.com/cn/data-converters/f/forum/94403/adc-ad7124-8/108165#108165

ad7124 采样

复制代码
#include "AD7124.h"      /* AD7124 definitions */
#include "AD7124_regs.h" /* We want to use the ad7124_regs array defined in ad7124_regs.h/.c */
 
void main(void)
{
    struct ad7124_device my_ad7124;                    /* A new driver instance */
    struct ad7124_device *ad7124_handler = &my_ad7124; /* A driver handle to pass around */
    enum ad7124_registers regNr;                       /* Variable to iterate through registers */
    long timeout = 1000;                               /* Number of tries before a function times out */
    long ret = 0;                                      /* Return value */
    long sample;                                       /* Stores raw value read from the ADC */
 
 
    /* Initialize AD7124 device. */
    ret = AD7124_Setup(ad7124_handler, AD7124_SLAVE_ID, (ad7124_st_reg *)&ad7124_regs);
    if (ret < 0)
    {
        /* AD7124 initialization failed, check the value of ret! */
    }
    else
    {
        /* AD7124 initialization OK */
    } 
 
    /* Read all registers */
    for (regNr = AD7124_Status; (regNr < AD7124_REG_NO) && !(ret < 0); regNr++)
    {
        ret = AD7124_ReadRegister(ad7124_handler, &ad7124_regs[regNr]);
    }
 
    /* Read data from the ADC */
    ret = AD7124_WaitForConvReady(ad7124_handler, timeout);
    if (ret < 0)
    {
	/* Something went wrong, check the value of ret! */
    }
 
    ret = AD7124_ReadData(ad7124_handler, &sample);
    if (ret < 0)
    {
        /* Something went wrong, check the value of ret! */
    }
}
相关推荐
创界工坊工作室2 小时前
133-基于Arduino六足爬虫机器人设计
stm32·单片机·嵌入式硬件·机器人·51单片机·proteus
LabVIEW开发3 小时前
SIM928 电压源 + LabVIEW 低温偏置怎么加?
单片机·嵌入式硬件·labview
瑶池酒剑仙4 小时前
C++重构与代码质量完全指南:从设计模式、SOLID原则到代码审查与静态分析的工程实践(所赖君子见机)
c语言·开发语言·c++·设计模式·重构·哈希算法·visual studio
Go-higher9 小时前
C语言--数据结构-栈、队列、堆
c语言·数据结构
小李不想当小白9 小时前
HAL库之定时器输出比较(STM32 HAL库学习笔记)
笔记·stm32·单片机·嵌入式硬件·学习·嵌入式
LabVIEW开发10 小时前
PAV 电源 + LabVIEW:电压拉偏怎么做?
单片机·嵌入式硬件·labview
2601_966492311 天前
C语言变量揭秘
c语言·变量·编译器·线程安全·内存布局
郝学胜-神的一滴1 天前
Effective STL 条款 14:用扩容函数避免重新分配
linux·开发语言·网络·数据结构·c++·单片机
AndreaYYmm1 天前
SIGUSR2 触发热重载:一个正在抓包的进程如何原子地换掉规则集
c语言·网络协议
2601_966494721 天前
C语言是什么
c语言·rust·linux内核·内存管理·系统编程