当前位置:网站首页>移植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
边栏推荐
- golang中的WaitGroup实现原理
- Dell笔记本周期性闪屏故障
- Let's talk about 15 data source websites I often use
- Atomic in golang and CAS operations
- [100 cases of JVM tuning practice] 04 - Method area tuning practice (Part 1)
- Dell Notebook Periodic Flash Screen Fault
- [HFCTF2020]BabyUpload session解析引擎
- 界面控件DevExpress WinForms皮肤编辑器的这个补丁,你了解了吗?
- pytorch之数据类型tensor
- tensorflow 1.14指定gpu运行设置
猜你喜欢
【案例分享】网络环路检测基本功能配置
ESP Arduino (IV) PWM waveform control output
2022 Google CTF SEGFAULT LABYRINTH wp
How to manage distributed teams?
windows安装mysql8(5分钟)
线段树(SegmentTree)
Boot - Prometheus push gateway use
boot - prometheus-push gateway 使用
Transformation transformation operator
MySQL script batch queries all tables containing specified field types in the database
随机推荐
golang中的atomic,以及CAS操作
go-zero微服务实战系列(九、极致优化秒杀性能)
Taro 小程序开启wxml代码压缩
Oracle:CDB限制PDB资源实战
云呐|工单管理软件,工单管理软件APP
自旋与sleep的区别
Chenglian premium products has completed the first step to enter the international capital market by taking shares in halber international
安全保护能力是什么意思?等保不同级别保护能力分别是怎样?
Dell笔记本周期性闪屏故障
免费白嫖的图床对比
Meet in the middle
docker 方法安装mysql
ARM裸板调试之JTAG调试体验
2022 Google CTF SEGFAULT LABYRINTH wp
table表格设置圆角
[batch dos-cmd command - summary and summary] - string search, search, and filter commands (find, findstr), and the difference and discrimination between find and findstr
Neon Optimization: About Cross access and reverse cross access
Force buckle 1037 Effective boomerang
[hfctf2020]babyupload session parsing engine
Body mass index program, entry to write dead applet project