当前位置:网站首页>移植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
边栏推荐
- go-zero微服务实战系列(九、极致优化秒杀性能)
- Pytorch中torch和torchvision的安装
- Chenglian premium products has completed the first step to enter the international capital market by taking shares in halber international
- Docker method to install MySQL
- Telerik UI 2022 R2 SP1 Retail-Not Crack
- Byte P7 professional level explanation: common tools and test methods for interface testing, Freeman
- Segmenttree
- 【案例分享】网络环路检测基本功能配置
- C# 计算农历日期方法 2022
- pytorch之数据类型tensor
猜你喜欢
随机推荐
How to manage distributed teams?
[batch dos-cmd command - summary and summary] - view or modify file attributes (attrib), view and modify file association types (Assoc, ftype)
从零开始匹配vim(0)——vimscript 简介
UI控件Telerik UI for WinForms新主题——VS2022启发式主题
NEON优化:关于交叉存取与反向交叉存取
ARM裸板调试之JTAG原理
Let's see through the network i/o model from beginning to end
云呐|工单管理软件,工单管理软件APP
Dell笔记本周期性闪屏故障
Boot - Prometheus push gateway use
The difference between spin and sleep
Docker method to install MySQL
Taro2.* 小程序配置分享微信朋友圈
Data type of pytorch tensor
ESP Arduino (IV) PWM waveform control output
HMM 笔记
Pytorch中torch和torchvision的安装
Make a simple graphical interface with Tkinter
Tensorflow GPU installation
[hfctf2020]babyupload session parsing engine






![[Niuke] b-complete square](/img/bd/0812b4fb1c4f6217ad5a0f3f3b8d5e.png)

![[Niuke] [noip2015] jumping stone](/img/9f/b48f3c504e511e79935a481b15045e.png)
