当前位置:网站首页>【sylixos】i2c设备驱动创建和使用
【sylixos】i2c设备驱动创建和使用
2022-06-27 23:57:00 【zhaqonianzhu】
前提是需要已实现过i2c总线驱动
步骤
步骤分为几步:
- 创建设备 API_I2cAdapterCreate
- 传输消息 API_I2cDeviceTransfer
- 发送消息 API_I2cDeviceMasterSend
- 接收消息 API_I2cDeviceMasterRecv
- 删除设备 API_I2cDeviceDelete
示例
{
uint8_t data_buf[100]
LW_I2C_MESSAGE i2cWrMsg[2];
PLW_I2C_DEVICE pI2cDev;
pI2cDev = API_I2cDeviceCreate("/bus/i2c/0", "i2cdev", 0x60, 0);
API_I2cDeviceMasterSend("i2cdev", data_buf, 1);
API_I2cDeviceMasterRecv("i2cdev", data_buf, 1);
i2cWrMsg[0].I2CMSG_usAddr = 0x60;
i2cWrMsg[0].I2CMSG_usFlag = 0;
i2cWrMsg[0].I2CMSG_pucBuffer = (VOID*)&data_buf[1];
i2cWrMsg[0].I2CMSG_usLen = 1;
i2cWrMsg[1].I2CMSG_usAddr = i2cWrMsg[0].I2CMSG_usAddr;
i2cWrMsg[1].I2CMSG_usFlag = LW_I2C_M_RD;
i2cWrMsg[1].I2CMSG_pucBuffer = data_buf;
i2cWrMsg[1].I2CMSG_usLen = 1;
API_I2cDeviceTransfer("i2cdev", i2cWrMsg, 2);
}
边栏推荐
- Interface component telerik UI for WPF Getting Started Guide - how to switch custom styles using themes
- How to build an e-commerce platform at low cost
- Intensive reading of transformer thesis paragraph by paragraph
- Meituan dynamic thread pool practice idea has been open source
- 一张图弄懂 MIT,BSD,Apache几种开源协议之间的区别
- [embedded foundation] serial port communication
- [description] solution to JMeter garbled code
- Golang monkeys eat peaches and ask for the number of peaches on the first day
- 基于可学习尺寸自适应分子亚结构的药物相互作用预测
- Ten thousand words long article understanding business intelligence (BI) | recommended collection
猜你喜欢

Web3 技术初体验以及相关学习资料

Why stainless steel swivel

Qu'est - ce que la numérisation? Qu'est - ce que la transformation numérique? Pourquoi les entreprises choisissent - elles la transformation numérique?

Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)

Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released

药物发现综述-03-分子设计与优化

TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language

Overview of drug discovery-01 overview of drug discovery

Evaluation - rank sum ratio comprehensive evaluation

DeepMind | 通过去噪来进行分子性质预测的预训练
随机推荐
【说明】Jmeter乱码的解决方法
Li Kou today's question -522 Longest special sequence
Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
OS模块与OS.path 模块的学习
面试官问:能否模拟实现JS的new操作符
Modular development
lefse分析本地实现方法带全部安装文件和所有细节,保证成功。
零基础多图详解图神经网络
向excel中导入mysql中的数据表
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
Capacitor
数据人面试指南 | 准备好这几点做到有备无患!
Is it safe to open an online futures account?
MySQL十种锁,一篇文章带你全解析
[embedded foundation] serial port communication
Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
I/o limit process and CPU limit process
[Yocto RM] 2 - Yocto Project Terms
Maimai hot post: Why are big factories keen on making wheels?
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process