当前位置:网站首页>移植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
边栏推荐
猜你喜欢

Provincial and urban level three coordinate boundary data CSV to JSON

2022 Google CTF SEGFAULT LABYRINTH wp

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

力扣1037. 有效的回旋镖

Send template message via wechat official account

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

云呐|工单管理软件,工单管理软件APP

Transformation transformation operator

Building a dream in the digital era, the Xi'an station of the city chain science and Technology Strategy Summit ended smoothly

Do you understand this patch of the interface control devaxpress WinForms skin editor?
随机推荐
负载均衡性能参数如何测评?
Building a dream in the digital era, the Xi'an station of the city chain science and Technology Strategy Summit ended smoothly
Mongodb client operation (mongorepository)
[Niuke] [noip2015] jumping stone
THREE.AxesHelper is not a constructor
[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
Dell筆記本周期性閃屏故障
JTAG debugging experience of arm bare board debugging
paddlehub应用出现paddle包报错的问题
[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)
线段树(SegmentTree)
UI control telerik UI for WinForms new theme - vs2022 heuristic theme
【JVM调优实战100例】05——方法区调优实战(下)
接收用户输入,身高BMI体重指数检测小业务入门案例
tensorflow 1.14指定gpu运行设置
Spark TPCDS Data Gen
ARM裸板调试之JTAG原理
Spark TPCDS Data Gen
Let's see through the network i/o model from beginning to end
免费白嫖的图床对比