树莓派i2c可以接多少个设备_I2C通信,别掉坑里——clock stretching

I2C,一种非常常用的低速通信协议,由飞利浦提出,已经被广泛使用。他的实现成本非常低廉,所以深受各种芯片的欢迎。

同时,现在很多处理器,小到单片机,大到处理器,几乎都有I2C硬核。我们几乎不用关心I2C具体是什么样的,只要大致知道几种通信模式即可。

今天,我想跟大家挖掘下这个简单协议背后的一个巨大的坑,千万别把I2C想当然了,其实没那么简单!

这个坑就是——clock stretching。

首先简单介绍下这是什么。

我们都知道,I2C主设备始终控制着时钟线SCL,不论是往设备写还是从设备读。

一般情况下,如果操作对象是EEPROM或者其其他简单设备而言,无所谓。

但是,如果从设备是处理器,在接到主机命令后要去处理一些运算然后得出结果返回给主机。这个时候可能造成来不及处理。怎么办?这时,从设备会主动控制时钟线把它拉低!!!!

直到数据准备好之后再释放时钟线,把控制权交还给MASTER。这也是I2C通信系统中,从机唯一能控制总线到时候!。

关键是很多I2C主机不支持clock stretching功能,所以,无法和带有clock stretching功能的从机通信!!!!!所以,各位在选择主机器件之前,必须要注意这一点,不然整个设计方案可能报废,影响很大。

我的设计方案中,需要USB2I2C的芯片,我选择了FT2232和CY7C65215,

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
iPod+Authentication+Coprocessor+Spec+2.0C+R1Contents Chapter 1 Introduction 7 Overview 7 Authentication protocol 7 Terminology Used in This Document 8 General Specification Terms 9 s Related documents 9 Chapter 2 Signal Descriptions and Reference Circuit 11 CP Signals and Pinouts 11 Address selection 12 Reference circuit 12 Chapter 3 Hardware Configuration and Interface 13 System Voltage/ 13 Startup of the 12C Interface/13 Starting Up the cp by turning power on /13 Starting Up the Cp by Warm Reset 14 Communication Process15/ Low-Power Sleep Mode-16 Chapter 4 Coprocessor Registers 17 Register Addresses 17 Register Descriptions 19 Device version 19 Firmware version 19 Authentication Protocol Major and Minor Versions 20 Device iD 20 Error Code 20 Authentication Control and status 21 Signature Data Length 22 Signature Data 22 hallenge Data Length 23 Challenge data 23 Accessory Certificate Data Length 23 Accessory Certificate Data 23 Self- Test Control and status 23 System Event Counter 24 Apple Device Certificate Data Lengt 3 2011-06-22 I @2011 Apple Inc. All Rights Reserved. CONTENTS Apple device certificate data 25 Chapter 5 Authentication Data flows 27 Apple Device Authentication of Accessory 27 Accessory Authentication of the Apple Device 28 Chapter 6 12C Communication Protocol 31 Slave selection and reset 31 s Coprocessor Busy. 31 Writing to the Coprocessor 31 Reading from the Coprocessor 32 Chapter 7 CP Device Characteristics 33 Physical Configuration 33 Maximum Environmental Conditions 33 Recommended Operating Conditions 34 12C Interface Characteristics 34 DC Electrical Characteristics 34 Timing Characteristics 35 ppendix a Coprocessor 2.0B to 2.0C Migration Guide 37(Ay Only 12C Communication Protocol 37 Increased SCL Speed 37 Shorter Reset Cycle 37 Warm Reset Supported 37 Automatic Sleep State Entry and Exit 38 NACK Responses Replace Clock Stretching 38 Shorter Accessory Certificate Data 38 System Event Counter Must Be Zero Betore Power-Down 38 Document Revision History 39 2011-06-22 I @2011 Apple Inc. All Rights Reserved. igures and Tables Chapter 1 Introduction 7 Table 1 Document-specific terminology 8 Chapter 2 Signal Descriptions and Reference Circuit 11 Fi ure 2-1 CP chip pinouts, top view 11 Figure 2-2 Reference circuit for CP 12 Table 2-1 CP signals 11 Table 2-2 Address se n signals 12 Chapter 3 Hardware Configuration and Interface 13 Figure 3-1 P2C interface startup timing 1 Figure 3-2 1C interface warm reset timing 15 Fi gure 3-3 12C slave write address 15 Figure 3-4 12C slave read address 15 Chapter 4 Coprocessor Registers 17 Figure 4-1 Authentication Control and Status register, read-only bits 21 igure 4-2 Fi Authentication Control and Status register, write-only bits 21 Figure 4-3 Self-test Control and Status register, write-only bits 23 Figure 4-4 Self-test Control and Status register, read-only bits/24 Table 4-1 iPod Authentication Coprocessor 2.0C register map 17 Table 4-2 Error codes 20 Table 4-3 Authentication ERR SET values 21 Table 4-4 Authentication PROC RESULTS values 21 Table 4-5 Authentication Proc control values 22 Table 4-6 Self-test proc control values 24 Table 4-7 Self-test result bits 24 Chapter 5 Authentication Data flows 27 Table 5-1 Sequence of interactions by which an Apple device authenticates an accessory 27 Table 5-2 Sequence of interactions by which an accessory authenticates an Apple device 28 5 2011-06-22 I @2011 Apple Inc. All Rights Reserved. FIGURES AND TABLES Chapter 7 CP Device Characteristics 33 Figure 7-1 Authentication coprocessor 2. 0C package 33 Figure 7-2 Typical 1/0 port input waveform 35 Table 7 Maximum electrical and temperature ranges 34 Table 7-2 Recommended operating conditions 34 Table 7-3 I2C interface ranges 34 Table 7-4 Supply current into VcC, excluding external current 35 Table 7 Inputs 35> Table 7-6 Outputs 35 Table 7-7 Values for Figure 7-236 2011-06-22 I @2011 Apple Inc. All Rights Reserved. CHAPTER 1 Introduction N IOTICE OF PROPRIE TARY PROPERTY THE INFORMATION CONTAINED HEREIN IS THE PROPRIETARY PROPERTY OF APPLE INC. THE POSSESSOR AGREES TO THE FOLLOWING: (DTO MAINTAIN THIS DOCUMENT IN CONFIDENCE (ID NOT TO REPRODUCE OR COPY IT, (IID NOT TO REVEAL OR PUBLISH IT IN WHOLE OR IN PART, (IV) ALL RIGHTS RESERVED ACCESS TO THIS DOCUMENT AND THE INFORMATION CONTAINED THEREIN IS GOVERNED BY THE TERMS OF THE MFI LICENSE AGREEMENT AND/OR THE IPOD-IPHONE AIS EVALUATION AGREEMENT. ALL OTHER USE SHALL BE AT APPLES SOLE DISCRETION Note: This document uses the term"Apple device"to refer generically to iPods, iPhones, and iPads, all of which support the iPod Accessory Protocol (iAP) interface. Among these products, those that also run iOS (Apples mobile operating system)are referred to as"ioS devices. "Specifications in this document that are designated for ioS devices apply only to those products Specifications designated for iPods apply only to Apple devices that are not ios devices. Overview device by issuing an authentication challenge to the accessory the accessory must respond to the apol o An Apple device verifies whether a third-party accessory attached to it is authorized for use with the apple device's challenge, and it can do so only with the assistance of an iPod Authentication Coprocessor( CP) chip located in the accessory. Conversely, the accessory can use its CP chip to authenticate the iPod. Certain control and reporting functions of the apple device are made available externally only after it has authenticated an attached accessory as being authorized Earlier versions of the ipod authentication Coprocessor(1.0, 2.0A, and 2.0B)were implemented in QFN-40 QFN-20, and sop-8 packages. The current version, 2.0C, is supplied in a smaller and more efficient PG-USON-8-1 ackage. This document describes the configuration, usage, and specifications of Apple's iPod Authentication Coprocessor 2.00 Authentication Protocol The authentication protocol supported by the iPod Authentication Coprocessor 2.0C is based on standard X509 version 3 certification. Each certificate is generated and signed by a recognized certificate authority and has a unique serial number. Information about the X509 standard can be found at the letf website http://tools.ietf.org/html/3280 For information about the iAP General lingo commands required to perform authentication using the ipod Authentication Coprocessor 2.0C, see apple's MFi Accessory Firmware Specification Overview 2011-06-22 I @2011 Apple Inc. All Rights Reserved. CHAPTER 1 Introduction The iPod Authentication Coprocessor 2.0C supports iAP General lingo commands Ox14 through Ox1E providing five authentication-related services: For Apple device authentication of the accessory: Certificate delivery: To initiate authenticatication of the accessory that contains it, the Cp supplies an X 509 digital certificate for public key verification by the attached apple device Signature generation: To complete authentication of the accessory that contains it, the Cp generates valid digital signature in response to a challenge from an attached Apple device This signature authorizes the apple device to respond to messages and commands from the accessory For accessory authentication of the apple device: Apple device certificate validation: To initiate the authentication of an Apple device attached to an accessory, the CP verifies that the X509 certificate supplied by Apple device has been signed by the proper certificate authority. Challenge generation: To continue the authentication of an Apple device attached to an accessory, the accessory's CP can generate a challenge to be sent to the apple device Signature verification: To complete the authentication of an Apple device attached to the accessory the Cp can verify the signature returned by the apple device in response to the previous challenge Terminology Used in This Document Certain technical terms specific to this document are defined in table 1-1 Table 1-1 Document-specific terminology Teri Definition Accessory controller The microcontroller in an accessory responsible for implementing application-specific logic. Authenticatⅰon a device in an accessory controller that provides apple device-related digital coprocessor signature creation and verification services Challenge A random number sent via iAP from an apple device to an accessory controller, or vice versa. the device being challenged must perform a digital signature computation on the offered challenge and return the resulting digital signature to the challenging device for verification. Digital signature he result obtained by performing a digital signing process on an offered challenge IAP od Accessory Protocol. See Apple's MFi Accessory Firmware Specification 12C b A 2-wire serial bus designed by philips to allow easy communication between components that reside on the same circuit board. The l2C specification is located Ithttp://www.semiconductors.philipscom/acrobat_download/itera ture/9398/39340011pdf Terminology Used in This Document 2011-06-22 I @2011 Apple Inc. All Rights Reserved. CHAPTER 1 Introduction Ter Definition X 509 certification/ A standard defined by the International Telecommunication Union(ITU)that governs the format of certificates used for authentication and sender identity verification in public-key cryptography. X509 certificates contain the public keys used in the apple device's accessory authentication process General Specification terms Parts of this document contain specification requirements that are incorporated by reference into legal agreements between Apple Inc and its licensees. the use of the words"must, " "should " and "may"in these specifications have the following meanings Must"means that the specification is an absolute requirement Must not"means that the specification is an absolute prohibition Should"means that there may be valid reasons in particular circumstances to ignore the specification, but their full implications must be understood and carefully weighed before choosing to do so Should not"means that there may be valid reasons in particular circumstances that make the specifie action or feature acceptable but their full implications must be understood and carefully weighed before choosing to include it May"means that the indicated action or feature does not contravene this specification Related documents For further information about authenticating Apple devices and their attached accessories, see apple's MFi Accessory Firmware Specification and MFi Accessory Hardware Specification Related documents 9 2011-06-22 I @2011 Apple Inc. All Rights Reserved. CHAPTER 1 Introduction Related documents 2011-06-22 I@ 2011 Apple Inc. All Rights Reserved.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值