開發板:omapl138
ad模組:ad7606
1 交叉編譯libiio
關於libiio的交叉編譯,見《linux中交叉編譯libiio》。
2 簡單例項
#include #include #include #include #include /*
* 功 能: 通道屬性檢索
* 參 數: chn —— ad 通道
* attr —— 需要檢索的屬性
* 返 回: true —— ad通道存在屬性attr
* false —— ad通道不存在屬性attr
*/static bool channel_has_attr(struct iio_channel *chn, const char *attr)
/* * 功 能: 獲取通道chan的取樣值
* 參 數: chn —— ad 通道
* 返 回: chn 通道的取樣值
*/static double get_channel_value(struct iio_channel *chn)
else
if (channel_has_attr(chn, "scale"))
} val = val * 5 / 32768.0;
return val;
}int main(void)
// get device count
nb_devices = iio_context_get_devices_count(ctx);
// get device name
dev = iio_context_get_device(ctx, 0);
nb_channels = iio_device_get_channels_count(dev);
chn = iio_device_get_channel(dev, 0);
printf("channel_value:\n");
for (i = 0; i < 100000; i++)
iio_context_destroy(ctx);
return 0;
}
參考資料
[1]what is libiio?
[2]libiio_main page
[3]about libiio
[4]iio-trig-sysfs driver
[5]iio command server
[6][rfc] libiio
[7]libiio buffering
[8]how to get analog input on the beaglebone black
[9]how to use the linux industrial io (iio) inte***ce
[10]am335x adc driver's guide
[11]ad7606: data capture by setting sampling frequency & buffer mode
[12]iio, a new kernel subsystem
[13]why this program can't receive the right data?
[14]linux-3.2.20/drivers/staging/iio/industrialio-buffer.c
[15]linux core adc user's guide
[16]am335x adc除錯
Linux中交叉編譯libiio
1 toolchainfile.cmake 交叉編譯libiio,需要使用到cmake。而根據參考資料 1 中有關交叉編譯的說明,cmake此時需要乙個toolchainfile.cmake檔案 改為其它名字也行 根據參考資料 2 的說明,編輯toolchainfile.cmake的內容如下 thi...
Linux中的curses程式設計
記得在選修作業系統課程的時候,有一次不小心翻到教材後面,看到裡面介紹了乙個編寫動畫遊戲的函式庫,叫做curses。感覺很好玩,就跟著上面學了一段時間,還編寫了乙個小遊戲。curses是乙個函式庫,包含許多庫函式,專門用來進行unix終端環境下的螢幕介面處理及i o處理。但是在一般linux環境中不能...
linux程式設計中的時間
在linux中的時間有 time t和struct tm time t的定義為type long time t time t描述的時間是從1970年1月1日0時0分0秒到獲取時間的那一秒的秒數。函式time null 可以獲取當前的時間並以time t的型別返回。time t 獲取到的時間不夠直觀,...