当前位置:网站首页>移植DAC芯片MCP4725驱动到NUC980
移植DAC芯片MCP4725驱动到NUC980
2022-07-06 17:35:00 【Ti-laser】
本文介绍了移植DAC芯片MCP4725的方法。
因为官方提供的linux-4.4.x虽然有一个mcp4725.c的驱动,但该驱动适合无dts的老的应用场景,而我的系统使用了dts树所以需要更换该驱动,具体方法为:
从网站linux/mcp4725.c at master · torvalds/linux · GitHub
下载mcp4725.c,下载的该文件要做下面调整才能被正常编译使用,具体如下:
1 增加头文件:#include <linux/of_device.h>
2 找到IIO_ENUM_AVAILABLE并删除第二个参数,变成如下形式:
IIO_ENUM_AVAILABLE("powerdown_mode",
&mcp472x_powerdown_mode_enum[MCP4725]),
IIO_ENUM_AVAILABLE("powerdown_mode",
&mcp472x_powerdown_mode_enum[MCP4726]),
3 找到device_get_match_data改成of_device_get_match_data
if (dev_fwnode(&client->dev))
data->id = (uintptr_t)of_device_get_match_data(&client->dev);
else
......
4 替换include/linux/iio/dac/mcp4725.h为下面内容:
....
struct mcp4725_platform_data {
bool use_vref;
bool vref_buffered;
};
....
5 修改文件:
drivers/base/property.c +108,允许dev_fwnode 被外部调用:
struct fwnode_handle *dev_fwnode(struct device *dev)
{
return IS_ENABLED(CONFIG_OF) && dev->of_node ?
&dev->of_node->fwnode : dev->fwnode;
}
EXPORT_SYMBOL_GPL(dev_fwnode);
6 调整include/linux/property.h,对输出的函数进行声明
struct fwnode_handle *dev_fwnode(struct device *dev);
7 因为DAC芯片是挂接在I2c1总线上,需要修改文件nuc980-iot.dtsi,增加蓝色部分:
i2c1: [email protected] {
compatible = "nuvoton,nuc980-i2c1";
.........
#address-cells = <1>;
#size-cells = <0>;
compatible = "microchip,mcp4725";
reg = <0x61>;
};
编译正常后刷写到板子内部后进入/sys/devices/iio:deviceX即可看到节点信息,这里的X请根据自己的系统实际情况进行替换。

可以写入DA值然后实际用万用表进行测试验证。
echo 2000 > out_voltage0_raw
边栏推荐
- [JS] obtain the N days before and after the current time or the n months before and after the current time (hour, minute, second, year, month, day)
- docker 方法安装mysql
- 2022 Google CTF segfault Labyrinth WP
- Installation and testing of pyflink
- C language - array
- ClickHouse字段分组聚合、按照任意时间段粒度查询SQL
- paddlehub应用出现paddle包报错的问题
- In rails, when the resource creation operation fails and render: new is called, why must the URL be changed to the index URL of the resource?
- tensorflow 1.14指定gpu运行设置
- 【JVM调优实战100例】05——方法区调优实战(下)
猜你喜欢

Data type of pytorch tensor

"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!

LLDP兼容CDP功能配置

第三方跳转网站 出现 405 Method Not Allowed

ClickHouse字段分组聚合、按照任意时间段粒度查询SQL

Activereportsjs 3.1 Chinese version | | | activereportsjs 3.1 English version

Dell笔记本周期性闪屏故障

JTAG debugging experience of arm bare board debugging

Analysis of mutex principle in golang

2022 Google CTF SEGFAULT LABYRINTH wp
随机推荐
[hfctf2020]babyupload session parsing engine
[case sharing] basic function configuration of network loop detection
[Niuke] b-complete square
[牛客] B-完全平方数
The cost of returning tables in MySQL
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
There is an error in the paddehub application
ARM裸板调试之JTAG调试体验
JTAG debugging experience of arm bare board debugging
Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
golang中的WaitGroup实现原理
The difference between spin and sleep
Wood extraction in Halcon
Neon Optimization: summary of performance optimization experience
Gnet: notes on the use of a lightweight and high-performance go network framework
Data type of pytorch tensor
"Exquisite store manager" youth entrepreneurship incubation camp - the first phase of Shunde market has been successfully completed!
Receive user input, height BMI, BMI detection small business entry case
Dell筆記本周期性閃屏故障
树莓派/arm设备上安装火狐Firefox浏览器