这是基于 RT-Thread 4.0.2 版本移植的 ADS1256 源码程序

注意: 自校准不太适合应用于压差较大环境,测试发现芯片会自动平衡差值无法很好的同时测试 5v和3.3v 两个电压,部分配置请查看数据手册

注意: RT-Thread 中 SPI 和 硬件中断 没法同时工作,因此采用轮询方式进行

以下是源码

//filePath: drv_ads1256.c
#include "drv_ads1256.h"
#include "drv_spi.h"/*
注意: SPI 和 中断都使用了系统锁所以不能在中断中使用 SPI (除非使用 IO 模拟 SPI 才可以)
鉴于任务需求只要采集16次之后就可以停止工作,则改为轮询方式进行注意: ADS1256 自带自动校准可能导致检测到的电压被均值,也就是高的被拉低,低的被拉高以便值接近
*//*ADS1256基本特性:1、模拟部分供电5V;2、SPI数字接口电平:3.3V3、PGA设置范围: 1、2、4、8、16、32、64、4、参考电压2.5V (推荐缺省的,外置的)5、输入电压范围:PGA = 1 时, 可输入正负5V6. 自动校准 (当设置了PGA,BUF使能、数据采样率时,会启动自校准)7. 输入的缓冲器可设置启用和关闭(一般选启用)外部晶振频率 = 7.68MHz,时钟频率 tCLK = 1/7.68M = 0.13uS输出数据周期 tDATA =  1 / 30K = 0.033mS  (按30Ksps计算)对SPI的时钟速度要求: (ads1256.pdf page 6)最快 4个tCLK = 0.52uS最慢 10个tDATA = 0.3mS (按 30Ksps 计算)SCL高电平和低电平持续时间最小 200nsRREG, WREG, RDATA 命令之后,需要延迟 4 * tCLK = 0.52uS;RDATAC, RESET, SYNC 命令之后,需要延迟 24 * tCLK = 3.12uS;实际测试,在3.3V上电后, 及时不做任何配置,ADS125的DRDY 口线即开始输出脉冲信号(2.6us高,33.4低,频率30KHz)
*//*调试记录(1) 设置寄存器时,SCK过快导致芯片不能每次都收到数据。原因: 发送的相邻的字节之间需要延迟一小段时间.(2) 连续复位CPU时,偶尔出现芯片输出采样率异常。
*/#define SPI_BUS_NAME "spi1"
#define SPI_ADS1256_DEVICE_NAME "spi10"
#define SPI_CS0             GPIO_PIN_4 //PA4 CS0
#define SPI_CS0_GPIO        GPIOA #define SPI_SYNC0         GET_PIN(A, 8) //PA8 SYNC0
#define SPI_DRDY0           GET_PIN(C, 4) //PC4 DRDY0
#define SPI_RST0            GET_PIN(C, 5)  //PC5 RST0/* 4194303 = 2.5V , 这是理论值,实际可以根据2.5V基准的实际值进行公式矫正 */
//校准方法: 数字电源 2.5V, 开启自校准, 取当前采集到 2.5V 的值
#define AD_2_5V_MASKVALUE 4194303static struct rt_spi_device *spi_dev_ads1256;
ADS1256_VAR_T g_tADS1256;/************** 声明区 declared section ************///读寄存器值
static rt_uint8_t rt_hw_ads1256_readReg(rt_uint8_t _RegID);
//写寄存器值
static void rt_hw_ads1256_setReg(rt_uint8_t _RegID, rt_uint8_t _RegValue);
//写单字节命令
static void rt_hw_ads1256_writeCmd(const rt_uint8_t _cmd);
//设置差分通道采集
static void rt_hw_ads1256_setDiffChannel(rt_uint8_t _ch);
//设置单通道采集
static void rt_hw_ads1256_setChannel(rt_uint8_t _ch);
//读取 ADC 数据
static rt_int32_t rt_hw_ads1256_readData(void);
//由外部中断调用的 ADC 采集程序
static void rt_hw_ads1256_getISRValue(void);
//读取 DRDY 引脚电平 低电平有效 1 表示转换完成 0 表示需要等待
static rt_uint8_t rt_hw_ads1256_readDRDY(void);//复位时缺省值
static const uint8_t s_tabDataRate[ADS1256_DRATE_MAX] =
{0xF0,0xE0,0xD0,0xC0,0xB0,0xA1,0x92,0x82,0x72,0x63,0x53,0x43,0x33,0x20,0x13,0x03
};/******************* 函数区 Function Section*******//* 中断回调函数 */
rt_uint8_t readStatus = 0;
void beep_on(void *args)
{readStatus = 1;
}
/*
@brief: IO 引脚初始化
*/
static void rt_hw_ads1256_gpio(void) {rt_pin_mode(SPI_SYNC0, PIN_MODE_OUTPUT);rt_pin_mode(SPI_RST0, PIN_MODE_OUTPUT);rt_pin_mode(SPI_CS0, PIN_MODE_OUTPUT);rt_pin_mode(SPI_DRDY0, PIN_MODE_INPUT);rt_pin_write(SPI_SYNC0, PIN_HIGH);rt_pin_write(SPI_RST0, PIN_HIGH);rt_pin_write(SPI_CS0, PIN_HIGH);rt_pin_attach_irq(SPI_DRDY0, PIN_IRQ_MODE_FALLING, beep_on, RT_NULL);
}/*
@brief: ADS1256 设备初始化
*/
static int rt_hw_ads1256_init(void)
{rt_err_t res;//挂载设备__HAL_RCC_GPIOA_CLK_ENABLE();res = rt_hw_spi_device_attach(SPI_BUS_NAME, SPI_ADS1256_DEVICE_NAME, SPI_CS0_GPIO, SPI_CS0); //挂载到 SPI 总线if (RT_EOK != res) {return -RT_ERROR;}//查找设备spi_dev_ads1256 = (struct rt_spi_device *)rt_device_find(SPI_ADS1256_DEVICE_NAME);//配置设备{struct rt_spi_configuration cfg;cfg.data_width = 8;cfg.mode = RT_SPI_MASTER | RT_SPI_MSB | RT_SPI_MODE_1;//RT_SPI_READYcfg.max_hz = 1920 * 1000; //1.92 Mrt_spi_configure(spi_dev_ads1256, &cfg);}//GPIO 引脚初始化rt_hw_ads1256_gpio();return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_ads1256_init);/*
@brief: 获取 DRDY 引脚状态
@return: 1 OK 完成; 0 need wait 等待
*/
static rt_uint8_t rt_hw_ads1256_readDRDY(void) {if (rt_pin_read(SPI_DRDY0) == PIN_HIGH) {return 0;} else {return 1;}
}
/*
@brief: 读一个寄存器值
@param: _RegID :寄存器 ID
@return: 寄存器值
*/
static rt_uint8_t rt_hw_ads1256_readReg(rt_uint8_t _RegID) {rt_uint8_t read = 0;rt_uint8_t sendCmd[] = {CMD_RREG | _RegID, 0x00};//发送数据后接收数据rt_spi_send_then_recv(spi_dev_ads1256, sendCmd, 2, &read, 1);return read;
}/*
@brief: 写一个寄存器值
@param: _RegID: 寄存器ID
@param: _RegValue: 设定值
*/
static void rt_hw_ads1256_setReg(rt_uint8_t _RegID, rt_uint8_t _RegValue) {rt_uint8_t sendCmd[] = {CMD_WREG | _RegID, 0x00, _RegValue};rt_spi_send(spi_dev_ads1256, sendCmd, 3);
}/*
@brief: 写一个单节命令
@param: _cmd: 命令(8bit)
*/
static void rt_hw_ads1256_writeCmd(const rt_uint8_t _cmd) {rt_spi_send(spi_dev_ads1256, &_cmd, 1);
}/*
@brief: 读取 ADC 采集数据
@return: 采集的数据 (24 bit)
*/
static rt_int32_t rt_hw_ads1256_readData(void) {rt_uint8_t cmd = CMD_RDATA;rt_uint8_t value[3] = {0};rt_uint32_t read = 0;//发送数据后接收数据rt_spi_send_then_recv(spi_dev_ads1256, &cmd, 1, value, 3);read = value[0] << 16;read += value[1] << 8;read += value[2];/* 负数进行扩展。24位有符号数扩展为32位有符号数 */if (read & 0x800000){read += 0xFF000000; //0xff 是负数的意思}return (rt_int32_t) read;
}/*
@brief: 配置 ADC 模式
@param: _gain: 增益
@param: _drate: 采样速率
@param: _ucScanMode: 模式 (0 单端扫描 8路, 1 差分扫描 4 路)
@process:1 启动输入缓存;不开启自校准功能;优先高位传输模式 MSB
*/
void rt_hw_ads1256_configADC(ADS1256_GAIN_E _gain, \ADS1256_DRATE_E _drate, \rt_uint8_t _ucScanMode) {rt_uint8_t data = 0x00;                                                      /* 状态寄存器定义Bits 7-4 ID3, ID2, ID1, ID0  Factory Programmed Identification Bits (Read Only)Bit 3 ORDER: Data Output Bit Order0 = Most Significant Bit First (default)1 = Least Significant Bit FirstInput data  is always shifted in most significant byte and bit first. Output data is always shifted out most significantbyte first. The ORDER bit only controls the bit order of the output data within the byte.Bit 2 ACAL : Auto-Calibration0 = Auto-Calibration Disabled (default)1 = Auto-Calibration EnabledWhen Auto-Calibration is enabled, self-calibration begins at the completion of the WREG command that changesthe PGA (bits 0-2 of ADCON register), DR (bits 7-0 in the DRATE register) or BUFEN (bit 1 in the STATUS register)values.Bit 1 BUFEN: Analog Input Buffer Enable0 = Buffer Disabled (default)1 = Buffer EnabledBit 0 DRDY :  Data Ready (Read Only)This bit duplicates the state of the DRDY pin.ACAL=1使能自校准功能。当 PGA,BUFEEN, DRATE改变时会启动自校准
*/
//开启自校准前提就是电压相近,不然会出自动平衡4.8v与3.3v同时测试,4.8v被稳到 3.3附近data = 0x01;rt_hw_ads1256_setReg(REG_STATUS, data);data = 0x08;  /* 高四位0表示AINP接 AIN0,  低四位8表示 AINN 固定接 AINCOM */rt_hw_ads1256_setReg(REG_MUX, data);
/*  ADCON: A/D Control Register (Address 02h)Bit 7 Reserved, always 0 (Read Only)Bits 6-5 CLK1, CLK0 : D0/CLKOUT Clock Out Rate Setting00 = Clock Out OFF01 = Clock Out Frequency = fCLKIN (default)10 = Clock Out Frequency = fCLKIN/211 = Clock Out Frequency = fCLKIN/4When not using CLKOUT, it is recommended that it be turned off. These bits can only be reset using the RESET pin.Bits 4-2 SDCS1, SCDS0: Sensor Detect Current Sources00 = Sensor Detect OFF (default)01 = Sensor Detect Current = 0.5 μ A10 = Sensor Detect Current = 2 μ A11 = Sensor Detect Current = 10μ AThe Sensor Detect Current Sources can be activated to verify  the integrity of an external sensor supplying a signal to theADS1255/6. A shorted sensor produces a very small signal while an open-circuit sensor produces a very large signal.Bits 2-0 PGA2, PGA1, PGA0: Programmable Gain Amplifier Setting000 = 1 (default)001 = 2010 = 4011 = 8100 = 16101 = 32110 = 64111 = 64
*/data = 0x00 | _gain;rt_hw_ads1256_setReg(REG_ADCON, data);/* 因为切换通道和读数据耗时 123uS, 因此扫描中断模式工作时,最大速率 = DRATE_1000SPS */data = s_tabDataRate[_drate];   /* 选择数据输出速率 */rt_hw_ads1256_setReg(REG_DRATE, data);{ //配置结构体g_tADS1256.Gain = _gain;g_tADS1256.DataRate = _drate;g_tADS1256.ScanMode = _ucScanMode;}//清空缓存区{for (char i = 0; i < 8; ++i) {g_tADS1256.AdcNow[i] = 0;}}
}/*
@brief: 获取芯片 ID
@return: 只有 ID = 0x30 才能认为硬件连接及工作正常
RT_EOK :   the result is ok;
-RT_ERROR: the result is error;
*/
rt_err_t rt_hw_ads1256_readChipID(void) {rt_uint8_t id = 0; //正常情况应该返回 0x3 代表读取成功id = rt_hw_ads1256_readReg(REG_STATUS); if (0x30 == id) {return RT_EOK;}return -RT_ERROR;
}   /*
@brief: 从缓冲区读取 ADC 采样结果
@param: _ch: 通道号(0-7)
@return: 采样结果
*/
rt_int32_t rt_hw_ads1256_getAdcVaule(rt_uint8_t _ch) {rt_int32_t iTemp = 0;if (_ch > 7) {return 0;}iTemp = g_tADS1256.AdcNow[_ch];return iTemp;
}/*
@brief: ADS1256 设置通道号 (AIN- 固定接地(ACOM))
@param: _ch: 通道号(0-7)
*/
static void rt_hw_ads1256_setChannel(rt_uint8_t _ch) {/*Bits 7-4 PSEL3, PSEL2, PSEL1, PSEL0: Positive Input Channel (AINP) Select0000 = AIN0 (default)0001 = AIN10010 = AIN2 (ADS1256 only)0011 = AIN3 (ADS1256 only)0100 = AIN4 (ADS1256 only)0101 = AIN5 (ADS1256 only)0110 = AIN6 (ADS1256 only)0111 = AIN7 (ADS1256 only)1xxx = AINCOM (when PSEL3 = 1, PSEL2, PSEL1, PSEL0 are “don’t care”)NOTE: When using an ADS1255 make sure to only select the available inputs.Bits 3-0 NSEL3, NSEL2, NSEL1, NSEL0: Negative Input Channel (AINN)Select0000 = AIN00001 = AIN1 (default)0010 = AIN2 (ADS1256 only)0011 = AIN3 (ADS1256 only)0100 = AIN4 (ADS1256 only)0101 = AIN5 (ADS1256 only)0110 = AIN6 (ADS1256 only)0111 = AIN7 (ADS1256 only)1xxx = AINCOM (when NSEL3 = 1, NSEL2, NSEL1, NSEL0 are “don’t care”)*/if (_ch > 7) {return;}/* Bit3 = 1, AINN 固定接 AINCOM */rt_hw_ads1256_setReg(REG_MUX, (_ch << 4) | (1 << 3));
}/*
@brief: 配置差分多路复用
@param: _ch: 通道号(0-3)
*/
static void rt_hw_ads1256_setDiffChannel(rt_uint8_t _ch) {/*Bits 7-4 PSEL3, PSEL2, PSEL1, PSEL0: Positive Input Channel (AINP) Select0000 = AIN0 (default)0001 = AIN10010 = AIN2 (ADS1256 only)0011 = AIN3 (ADS1256 only)0100 = AIN4 (ADS1256 only)0101 = AIN5 (ADS1256 only)0110 = AIN6 (ADS1256 only)0111 = AIN7 (ADS1256 only)1xxx = AINCOM (when PSEL3 = 1, PSEL2, PSEL1, PSEL0 are “don’t care”)NOTE: When using an ADS1255 make sure to only select the available inputs.Bits 3-0 NSEL3, NSEL2, NSEL1, NSEL0: Negative Input Channel (AINN)Select0000 = AIN00001 = AIN1 (default)0010 = AIN2 (ADS1256 only)0011 = AIN3 (ADS1256 only)0100 = AIN4 (ADS1256 only)0101 = AIN5 (ADS1256 only)0110 = AIN6 (ADS1256 only)0111 = AIN7 (ADS1256 only)1xxx = AINCOM (when NSEL3 = 1, NSEL2, NSEL1, NSEL0 are “don’t care”)*/switch (_ch) {case 0:/* 差分输入 AIN0, AIN1 */rt_hw_ads1256_setReg(REG_MUX, (0 << 4) | 1); break;case 1:/* 差分输入 AIN2, AIN3 */rt_hw_ads1256_setReg(REG_MUX, (2 << 4) | 3); break;case 2:/* 差分输入 AIN4, AIN5 */rt_hw_ads1256_setReg(REG_MUX, (4 << 4) | 5); break;case 3:/* 差分输入 AIN6, AIN7 */rt_hw_ads1256_setReg(REG_MUX, (6 << 4) | 7); break;}
}/*
@brief: 8路单端采集执行程序
*/
static void rt_hw_ads1256_single8Gather(void) {/* 读取采集结构,保存在全局变量 */rt_hw_ads1256_setChannel(g_tADS1256.Channel); /* 切换模拟通道 */rt_hw_ads1256_writeCmd(CMD_SYNC);rt_hw_ads1256_writeCmd(CMD_WAKEUP);if (g_tADS1256.Channel == 0) {/* 注意保存的是上一个通道的数据 */g_tADS1256.AdcNow[7] = rt_hw_ads1256_readData();   } else {/* 注意保存的是上一个通道的数据 */g_tADS1256.AdcNow[g_tADS1256.Channel-1] = rt_hw_ads1256_readData();    }if (++g_tADS1256.Channel >= 8) {g_tADS1256.Channel = 0;}
}/*
@brief: 4路差分采集执行程序
*/
static void rt_hw_ads1256_diff4Gather(void) {/* 读取采集结构,保存在全局变量 */rt_hw_ads1256_setDiffChannel(g_tADS1256.Channel);   /* 切换模拟通道 */rt_hw_ads1256_writeCmd(CMD_SYNC);rt_hw_ads1256_writeCmd(CMD_WAKEUP);if (g_tADS1256.Channel == 0) {/* 注意保存的是上一个通道的数据 */g_tADS1256.AdcNow[3] = rt_hw_ads1256_readData();       } else {/* 注意保存的是上一个通道的数据 */g_tADS1256.AdcNow[g_tADS1256.Channel-1] = rt_hw_ads1256_readData();    }if (++g_tADS1256.Channel >= 4) {g_tADS1256.Channel = 0;}
}/*
@brief: 由中断函数启动 AD 采集程序
*/
static void rt_hw_ads1256_getISRValue(void) {if (0 == g_tADS1256.ScanMode) {//单端 8 路采集rt_hw_ads1256_single8Gather();} else {rt_hw_ads1256_diff4Gather();}
}/*
@brief: ADC 转换
*/
void rt_hw_ads1256_transitionValue(rt_int32_t volt[], rt_int32_t adc[]) {for (rt_uint8_t i = 0; i < 8; i++){/* 从全局缓冲区读取采样结果。 采样结果是在中断服务程序中读取的。*/adc[i] = rt_hw_ads1256_getAdcVaule(i);/* 4194303 = 2.5V , 这是理论值,实际可以根据2.5V基准的实际值进行公式矫正 */volt[i] = ((rt_int64_t)adc[i] * 2500000) / AD_2_5V_MASKVALUE;  /* 计算实际电压值(近似估算的),如需准确,请进行校准 */}
}/******************测试用例***************************/
/*
@brief: 用来测试 AD1256 测试是否成功
@process: PGA增益 = 1, 数据输出速率 = 15sps, 扫描 8 路
*/
static void test_ads1256_setTest(void) {rt_uint8_t value = 0; //设置参数rt_hw_ads1256_configADC(ADS1256_GAIN_1, ADS1256_30000SPS, 0);// 单独测试rt_thread_mdelay(500); // 左值等于右值rt_kprintf( " If the left value equals the right value, \the setting is successful \n");value = rt_hw_ads1256_readReg(REG_STATUS); rt_kprintf(" read ADS1256 ID: %x == 36? \n", value);value = rt_hw_ads1256_readReg(REG_MUX); rt_kprintf(" read ADS1256 ID: %x == 8? \n", value);value = rt_hw_ads1256_readReg(REG_ADCON); rt_kprintf(" read ADS1256 ID: %x == %x? \n", value, ADS1256_GAIN_1);value = rt_hw_ads1256_readReg(REG_DRATE); rt_kprintf(" read ADS1256 ID: %x == f0? \n", value);
}
MSH_CMD_EXPORT(test_ads1256_setTest, spi ads1256 sample);/*
@brief: 获取芯片 ID
@return: 只有 ID = 0x30 才能认为硬件连接及工作正常
*/
static void test_ads1256_readChipID(void) {rt_uint8_t id = 0; //正常情况应该返回 0x3 代表读取成功id = rt_hw_ads1256_readReg(REG_STATUS); rt_kprintf(" read ADS1256 ID: %x \n", id);if (0x30 == id) {rt_kprintf(" ADS1256 device work OK! \n");} else {rt_kprintf(" ADS1256 device start fail! \n");}
}
MSH_CMD_EXPORT(test_ads1256_readChipID, spi ads1256 sample);/*
@brief: 采集 AD 值测试程序
*/
static void test_ads1256_getValue(void) {rt_int32_t adc[8];rt_int32_t volt[8];rt_int32_t iTemp;for (rt_uint8_t i = 0; i < 8; i++) {rt_pin_irq_enable(SPI_DRDY0, PIN_IRQ_ENABLE);while(!readStatus);rt_pin_irq_enable(SPI_DRDY0, PIN_IRQ_DISABLE);readStatus = 0;rt_hw_ads1256_getISRValue();}rt_hw_ads1256_transitionValue(volt, adc);for (rt_uint8_t i = 0; i < 8; i++) {iTemp = volt[i];    /* 余数,uV  */if (iTemp < 0) {iTemp--;rt_kprintf("%d=%6d,(-%d.%03d %03d V) \r\n", i, adc[i], iTemp /1000000, (iTemp%1000000)/1000, iTemp%1000);} else {rt_kprintf("%d=%6d,( %d.%03d %03d V) \r\n", i, adc[i], iTemp/1000000, (iTemp%1000000)/1000, iTemp%1000);}}
}
MSH_CMD_EXPORT(test_ads1256_getValue, spi ads1256 sample);
//filePath: drv_ads1256.h
#ifndef __DRV_ADS1256_H
#define __DRV_ADS1256_H#include "board.h"
/* 寄存器定义: Table 23. Register Map --- ADS1256数据手册第30页 */
enum
{/* 寄存器地址, 后面是复位后缺省值 */REG_STATUS = 0,  // x1HREG_MUX    = 1, // 01HREG_ADCON  = 2, // 20HREG_DRATE  = 3, // F0HREG_IO     = 4, // E0HREG_OFC0   = 5, // xxHREG_OFC1   = 6, // xxHREG_OFC2   = 7, // xxHREG_FSC0   = 8, // xxHREG_FSC1   = 9, // xxHREG_FSC2   = 10, // xxH
};/* 命令定义: TTable 24. Command Definitions --- ADS1256数据手册第34页 */
enum
{CMD_WAKEUP  = 0x00,   // Completes SYNC and Exits Standby Mode 0000  0000 (00h)CMD_RDATA   = 0x01, // Read Data 0000  0001 (01h)CMD_RDATAC  = 0x03, // Read Data Continuously 0000   0011 (03h)CMD_SDATAC  = 0x0F, // Stop Read Data Continuously 0000   1111 (0Fh)CMD_RREG    = 0x10, // Read from REG rrr 0001 rrrr (1xh)CMD_WREG    = 0x50, // Write to REG rrr 0101 rrrr (5xh)CMD_SELFCAL = 0xF0, // Offset and Gain Self-Calibration 1111    0000 (F0h)CMD_SELFOCAL= 0xF1, // Offset Self-Calibration 1111    0001 (F1h)CMD_SELFGCAL= 0xF2, // Gain Self-Calibration 1111    0010 (F2h)CMD_SYSOCAL = 0xF3, // System Offset Calibration 1111   0011 (F3h)CMD_SYSGCAL = 0xF4, // System Gain Calibration 1111    0100 (F4h)CMD_SYNC    = 0xFC, // Synchronize the A/D Conversion 1111   1100 (FCh)CMD_STANDBY = 0xFD, // Begin Standby Mode 1111   1101 (FDh)CMD_RESET   = 0xFE, // Reset to Power-Up Values 1111   1110 (FEh)
};/* 增益选项 */
typedef enum
{ADS1256_GAIN_1         = (0), /* 增益1(缺省) */ADS1256_GAIN_2           = (1), /* 增益2 */ADS1256_GAIN_4         = (2), /* 增益4 */ADS1256_GAIN_8         = (3), /* 增益8 */ADS1256_GAIN_16            = (4), /* 增益16 */ADS1256_GAIN_32           = (5), /* 增益32 */ADS1256_GAIN_64           = (6), /* 增益64 */
}ADS1256_GAIN_E;/* 采样速率选项 */
/* 数据转换率选择11110000 = 30,000SPS (default)11100000 = 15,000SPS11010000 = 7,500SPS11000000 = 3,750SPS10110000 = 2,000SPS10100001 = 1,000SPS10010010 = 500SPS10000010 = 100SPS01110010 = 60SPS01100011 = 50SPS01010011 = 30SPS01000011 = 25SPS00110011 = 15SPS00100011 = 10SPS00010011 = 5SPS00000011 = 2.5SPS
*/
typedef enum
{ADS1256_30000SPS = 0,ADS1256_15000SPS,ADS1256_7500SPS,ADS1256_3750SPS,ADS1256_2000SPS,ADS1256_1000SPS,ADS1256_500SPS,ADS1256_100SPS,ADS1256_60SPS,ADS1256_50SPS,ADS1256_30SPS,ADS1256_25SPS,ADS1256_15SPS,ADS1256_10SPS,ADS1256_5SPS,ADS1256_2d5SPS,ADS1256_DRATE_MAX
}ADS1256_DRATE_E;#define ADS1256_DRAE_COUNT = 15;typedef struct
{ADS1256_GAIN_E Gain;       /* 增益 */ADS1256_DRATE_E DataRate;   /* 数据输出速率 */int32_t AdcNow[8];      /* 8路ADC采集结果(实时)有符号数 */uint8_t Channel;           /* 当前通道 */uint8_t ScanMode;         /* 扫描模式,0表示单端8路, 1表示差分4路 */
}ADS1256_VAR_T;
//配置 ADS1256
void rt_hw_ads1256_configADC(ADS1256_GAIN_E _gain, \ADS1256_DRATE_E _drate, \rt_uint8_t _ucScanMode);#endif

20191101(33) 针对 RT-Thread 下 ADS1256 移植说明(SPI)相关推荐

  1. RT Thread Free Modbus移植问题整理

    RT Thread Free Modbus移植问题整理 问题描述: 在读写寄存器中,写数据正常,只能读1个寄存器的值,多个值会异常. 在移植过程中发现串口(或RS485)数据接收长度异常. 一.环境描 ...

  2. 正点原子STM32 H743完成RT Thread下的LAN8720 网卡驱动 LWIP跑起来

    ,目前RT官网对H743的支持力度还不理想,本想按照F407的搞定网卡的套路来搞定H743的网卡(因为phy也是LAN 8720),以为会很轻松,没想到却是一条遍布荆棘的路... 好在已经有不少大佬做 ...

  3. 正点原子delay函数移植到rt thread操作系统(HAL库)

    正点原子教程中涉及到的操作系统只涉及了UCOS的教程,其中例程的system文件夹中的delay.c函数只是适配了UCOS. 下面将delay.c函数移植到rt thread中,使用的bsp是rt t ...

  4. rt thread系统下添加wiznet软件包后,不插网线CPU利用率100%问题

    rt thread系统下添加wiznet软件包后如果不插网线的话其他任务运行很卡,使用ps命令发现优先级低的任务很多都超时了 rt thread线程错误码 添加了一个可以查看CPU利用率的软件包CPU ...

  5. rt thread studio使用QBOOT和片外flash实现OTA升级

    我们这里要使用单片机外部flash作为OTA的下载分区,外部flash硬件连接关系 PB3-->SPI3_CLK PB4-->SPI3_MISO PB5-->SPI3_MOSI PE ...

  6. Yeelink平台使用——远程控制 RT Thread + LwIP+ STM32

    1.前言     [2014年4月重写该博文]     经过若干时间的努力终于搞定了STM32+LwIP和yeelink平台的数据互通,在学习的过程中大部分时间花在以太网协议栈学习上,但是在RT Th ...

  7. RT Thread根据开发板制作BSP方法

    之前一直不懂怎么使用RT Thread的软件包,感谢网上的大神,看了你们的博客后大概了解一些,在此做下记录.用RT Thread软件包需要RT Thread的系统,但是RT Thread和RT Thr ...

  8. 基于rt thread smart构建EtherCAT主站

    我把源码开源到到了gitee,https://gitee.com/rathon/rt-thread-smart-soem 有兴趣的去可以下载下来跑一下 软件工程推荐用vscode 打开.rt thre ...

  9. xpt 2046的触摸屏 rt thread设备驱动框架

    1 基于rtt 开发触摸屏驱动 准备使用rtt 框架 , 驱动xpt 2046的触摸屏, 翻阅大量资料发现, 大部分文章强调的是时序图, 而且很多代码要么直接操作寄存器, 要么是io 口模拟, 只能用 ...

  10. java aix 移植linux,[转]程序的可移植性:window,linux,aix,solaris下程序移植体会

    程序的可移植性:window,linux,aix,solaris下程序移植体会 - [工作学习] 1.类型 我们知道,在Windows平台中,系统定义了很多诸如BOOL,CHAR,ULONG,HAND ...

最新文章

  1. String类中toCharArray()方法的用法
  2. Window 窗口层次关系
  3. 正式发布!中国首个LF Edge捐赠项目Baetyl 2.2发布
  4. Linux课程第十二天学习笔记
  5. 浏览器窗口尺寸clientHeight / scrollHeight / offsetHeight / innerHeight
  6. 力扣 - 独一无二的出现次数 python解
  7. 关于Myeclipse10的激活
  8. 运维人必知必会的Zabbix核心命令
  9. OFD文件怎么编辑修改?
  10. 外贸软件进口业务流程管理方案
  11. mysql odb驱动_ODB学习笔记之基础环境搭建
  12. git commit最佳实践:conventional commits
  13. CPP----C++练习100题
  14. mysql命令行不支持中文_解决MySQL命令行不支持中文的问题
  15. H5 p,b,i,em,u,s标签
  16. 通过SwitchyOmega插件实现Chrome的PAC模式代理网络连接
  17. 极智经验 | win10 IE浏览器无法打开网页解决方法
  18. 从零开始的计网学习——网络层(计算机网络重点!)
  19. 【漏洞复现】泛微 e-office v9.0任意文件上传漏洞(CNVD-2021-49104)
  20. 变频器仿真软件,安装包,学习变频器的好帮手

热门文章

  1. module java.base does not “opens java.lang“ to module spring.core
  2. 《结构思考力》思维导图
  3. CTRL键不能使用(非硬件问题)
  4. 成人学士学位英语单词(史上最全)
  5. 用自己的APP打开微信和支付宝付款码和扫一扫界面
  6. Python + Scrapy 小小爬虫有大大梦想
  7. 鸿蒙pc系统镜像,鸿蒙系统有pc版么_鸿蒙系统有pc版安装方法
  8. java forward怎么用_【后端开发】java中forward是什么
  9. 【学习笔记】Stern-Brocot Tree
  10. 赖美云的认证照_火箭少女最新路透照出炉:吴宣仪赖美云魅力十足,张紫宁傅菁凭颜值圈粉...