OK335xD开发板AD开发测试程序
这是开发板提供的AD模块测试程序,有人知道为什么在读AD值的时候buf定义为char??还有就是读取的值在buf中是什么样的存储形式呢?真正的AD转换结果的数字量(0~4095)应该怎么换算?
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
int pd;
char buf;
memset(buf,0,sizeof(buf));
pd = ::open("/proc/boardname", O_RDONLY);
if (::read(pd, buf, 32) < 0){
QMessageBox::about(this,"error","open boardname failure");
exit(1);
}
if (strncmp(buf,"OK335xD",7) == 0) {
QMessageBox::about(this,"error","this board doesn't have AD");
exit(1);
}
::close(pd);
boardname = buf;
timer.start(500,this);
}
void MainWindow::timerEvent(QTimerEvent *)
{
char buf;
int fd;
memset(buf,0,sizeof(buf));
if(boardname == QString("OK335xS"))
fd = ::open("/sys/bus/iio/devices/iio:device0/in_voltage4_raw",O_RDONLY);
else if(boardname == QString("OK335xS2"))
fd = ::open("/sys/bus/iio/devices/iio:device0/in_voltage6_raw",O_RDONLY);
if(fd < 0)
{
QMessageBox::about(this,"error","open devices failure");
exit(-1);
}
::read(fd,buf,sizeof(buf));
ui->value->setText(QString(buf));
::close(fd);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::moveEvent(QMoveEvent *)
{
this->move(QPoint(0,0));
}
void MainWindow::resizeEvent(QResizeEvent *)
{
this->showMaximized();
}
void MainWindow::closeEvent(QCloseEvent *)
{
exit(0);
}
http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver's_Guide?keyMatch=adc&tisearch=Search-EN
您好,ti官网上有关于adc换算以及驱动测试的说明,您可以参考一下 飞凌-unix 发表于 2016-9-7 08:46
http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver's_Guide?keyMatch=adc&tisearch=Search-EN
...
点击链接后显示没有文本
飞凌-unix 发表于 2016-9-7 08:46
http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver's_Guide?keyMatch=adc&tisearch=Search-EN
...
为啥提供的gui测试程序中可以用read来读取buf,,,,,,读出的buf里面存放的是什么数据格式???而generic-buffer.c在编译的时候报错:找不到iio_utils.h文件,这个文件不在include目录下面,应该怎么办??????求教
页:
[1]