Linux Kernel 设备驱动之I2C之client之发送消息格式
2017-03-09 14:49
302 查看
前面host两种传输方式对应了两种消息格式:i2c_msg和i2c_smbus_data
/** *structi2c_msg-anI2CtransactionsegmentbeginningwithSTART *@addr:Slaveaddress,eithersevenortenbits.Whenthisisaten *bitaddress,I2C_M_TENmustbesetin@flagsandtheadapter *mustsupportI2C_FUNC_10BIT_ADDR. *@flags:I2C_M_RDishandledbyalladapters.Nootherflagsmaybe *providedunlesstheadapterexportedtherelevantI2C_FUNC_* *flagsthroughi2c_check_functionality(). *@len:Numberofdatabytesin@bufbeingreadfromorwrittentothe *I2Cslaveaddress.ForreadtransactionswhereI2C_M_RECV_LEN *isset,thecallerguaranteesthatthisbuffercanholdupto *32bytesinadditiontotheinitiallengthbytesentbythe *slave(plus,ifused,theSMBusPEC);andthisvaluewillbe *incrementedbythenumberofblockdatabytesreceived. *@buf:Thebufferintowhichdataisread,orfromwhichit'swritten. * *Ani2c_msgisthelowlevelrepresentationofonesegmentofanI2C *transaction.Itisvisibletodriversinthe@i2c_transfer()procedure, *touserspacefromi2c-dev,andtoI2Cadapterdriversthroughthe *@i2c_adapter.@master_xfer()method. * *ExceptwhenI2C"protocolmangling"isused,allI2Cadaptersimplement *thestandardrulesforI2Ctransactions.Eachtransactionbeginswitha *START.Thatisfollowedbytheslaveaddress,andabitencodingread *versuswrite.Thenfollowallthedatabytes,possiblyincludingabyte *withSMBusPEC.ThetransferterminateswithaNAK,orwhenallthose *byteshavebeentransferredandACKed.Ifthisisthelastmessageina *group,itisfollowedbyaSTOP.Otherwiseitisfollowedbythenext *@i2c_msgtransactionsegment,beginningwitha(repeated)START. * *Alternatively,whentheadaptersupportsI2C_FUNC_PROTOCOL_MANGLINGthen *passingcertain@flagsmayhavechangedthosestandardprotocolbehaviors. *Thoseflagsareonlyforusewithbroken/nonconformingslaves,andwith *adapterswhichareknowntosupportthespecificmanglingoptionsthey *need(oneormoreofIGNORE_NAK,NO_RD_ACK,NOSTART,andREV_DIR_ADDR). */ structi2c_msg{ __u16addr;/*slaveaddress*/ __u16flags; #defineI2C_M_RD0x0001/*readdata,fromslavetomaster*/ /*I2C_M_RDisguaranteedtobe0x0001!*/ #defineI2C_M_TEN0x0010/*thisisatenbitchipaddress*/ #defineI2C_M_RECV_LEN0x0400/*lengthwillbefirstreceivedbyte*/ #defineI2C_M_NO_RD_ACK0x0800/*ifI2C_FUNC_PROTOCOL_MANGLING*/ #defineI2C_M_IGNORE_NAK0x1000/*ifI2C_FUNC_PROTOCOL_MANGLING*/ #defineI2C_M_REV_DIR_ADDR0x2000/*ifI2C_FUNC_PROTOCOL_MANGLING*/ #defineI2C_M_NOSTART0x4000/*ifI2C_FUNC_NOSTART*/ #defineI2C_M_STOP0x8000/*ifI2C_FUNC_PROTOCOL_MANGLING*/ __u16len;/*msglength*/ __u8*buf;/*pointertomsgdata*/ };
/*
*DataforSMBusMessages
*/
#defineI2C_SMBUS_BLOCK_MAX32/*AsspecifiedinSMBusstandard*/
unioni2c_smbus_data{
__u8byte;
__u16word;
__u8block[I2C_SMBUS_BLOCK_MAX+2];/*block[0]isusedforlength*/
/*andonemoreforuser-spacecompatibility*/
};
相关文章推荐
- Linux Kernel 设备驱动之I2C之client描述
- Linux Kernel 设备驱动之I2C之client读写数据API
- Linux下面写i2c设备的驱动-如何枚举产生i2c_client
- Linux下面写i2c设备的驱动-如何枚举产生i2c_client
- Linux Kernel 设备驱动之I2C之host描述
- Linux Kernel 设备驱动之I2C之host之数据传输
- Linux Kernel 设备驱动之I2C之i2c设备文件
- 设备驱动基本格式介绍
- Linux I2C核心、总线与设备驱动
- 转:Linux I2C核心、总线与设备驱动
- Linux I2C核心、总线与设备驱动
- Linux I2C Input设备驱动代码的几点理解
- Linux I2C核心、总线与设备驱动
- WinAPI: waveOutMessage - 向波形输出设备发送一条消息
- I2C设备驱动流程
- Linux下I2C设备驱动开发和实现(转)
- Linux下I2C设备驱动开发和实现
- I2C设备与驱动的关联
- Linux下I2C设备驱动开发和实现
- Linux下I2C设备驱动开发和实现