当前位置:网站首页>移植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
边栏推荐
- pyflink的安装和测试
- Docker method to install MySQL
- [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)
- LLDP兼容CDP功能配置
- Informatics Orsay Ibn YBT 1172: find the factorial of n within 10000 | 1.6 14: find the factorial of n within 10000
- 实现mysql与ES的增量数据同步
- docker 方法安装mysql
- table表格设置圆角
- golang中的WaitGroup实现原理
- Come on, don't spread it out. Fashion cloud secretly takes you to collect "cloud" wool, and then secretly builds a personal website to be the king of scrolls, hehe
猜你喜欢

Periodic flash screen failure of Dell notebook

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

Come on, don't spread it out. Fashion cloud secretly takes you to collect "cloud" wool, and then secretly builds a personal website to be the king of scrolls, hehe

【JVM调优实战100例】04——方法区调优实战(上)

Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang
![[hfctf2020]babyupload session parsing engine](/img/db/6003129bc16f943ad9868561a2d5dc.png)
[hfctf2020]babyupload session parsing engine

Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which

Maidong Internet won the bid of Beijing life insurance to boost customers' brand value

Js逆向——捅了【马蜂窝】的ob混淆与加速乐

golang中的Mutex原理解析
随机推荐
Openjudge noi 1.7 10: simple password
pyflink的安装和测试
分享一个通用的so动态库的编译方法
Segmenttree
[Niuke] b-complete square
Atomic in golang and CAS operations
from . cv2 import * ImportError: libGL. so. 1: cannot open shared object file: No such file or direc
Anfulai embedded weekly report no. 272: 2022.06.27--2022.07.03
Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
C# 计算农历日期方法 2022
Supersocket 1.6 creates a simple socket server with message length in the header
The difference between spin and sleep
2022 Google CTF SEGFAULT LABYRINTH wp
[batch dos-cmd command - summary and summary] - view or modify file attributes (attrib), view and modify file association types (Assoc, ftype)
Fastdfs data migration operation record
Installation of torch and torch vision in pytorch
Come on, don't spread it out. Fashion cloud secretly takes you to collect "cloud" wool, and then secretly builds a personal website to be the king of scrolls, hehe
[batch dos-cmd command - summary and summary] - jump, cycle, condition commands (goto, errorlevel, if, for [read, segment, extract string]), CMD command error summary, CMD error
ARM裸板调试之JTAG原理
力扣1037. 有效的回旋镖