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! */
    }
}
相关推荐
en.en..3 小时前
STM32 HAL 库 | 核心知识点整理
单片机·嵌入式硬件
无敌贵点大王3 小时前
从寄存器层面重学STM32(9)——DMA理论
stm32·单片机·嵌入式硬件
希和20274 小时前
51 单片机入门笔记:江科大课程代码逐行讲解(按键控制 LED 流水灯)
笔记·单片机·mongodb
希和20274 小时前
51 单片机按键控制 LED:江科大课程代码小白笔记
笔记·单片机·嵌入式硬件
希和20274 小时前
51 单片机 LED 流水灯:从直接法到循环法(江科大课程笔记)
笔记·单片机·mongodb
Zwawa17 小时前
用两个按键做一个OLED菜单:先把选择和执行分开
c语言·单片机·嵌入式
Dev_XH19 小时前
【成品设计】基于CH32H417的CH32H417AIOT家庭微电网
单片机·嵌入式硬件·物联网·ai
心仪久了会沦陷21 小时前
C语言数据结构入门——树与二叉树详解:概念、堆实现与链式遍历
c语言·数据结构·算法
Severus_black1 天前
【C++初阶】list使用及相关实现,思路顺滑流畅!
c语言·数据结构·c++·stl·list