IPHONE DIY 部分资料
科学人2011/12/15极客DIY IP:北京
(转)

Used in 3rd and later generation iPods for charging, connecting to a PC via USB or Firewire, to a stereo via line-out, to a serial device (controlled via the Apple Accessory Protocol). This connector exists in most Apple iPod MP3 players (iPod 3G, 4G, 5G Video, 5.5G Video, Nano (1G, 2G, 3G, 4G), Mini, Classic, Touch, Touch 2G, and iPhone (1G, 3G and 3GS))
Pin Signal Description
1 GND Ground (-), internally connected with Pin 2 on iPod motherboard
2 GND Audio & Video ground (-), internally connected with Pin 1 on iPod motherboard
3 Right Line Out - R (+) (Audio output, right channel)
4 Left Line Out - L(+) (Audio output, left channel)
5 Right In Line In - R (+)
6 Left In
Line In - L (+)
7 ?  
8 Video Out Composite video output (only when slideshow active on iPod Photo)

or Component Video Pb

9 S-Video Chrominance output for iPod Color, Photo only

or Component Video Y

10 S-Video Luminance output for iPod Color, Photo only

or Component Video Pr

11 AUDIO_SW If connected to GND the iPhone sends audio signals through pin 3-4, otherwise it uses onboard speaker.  
12 Tx ipod sending line, Serial TxD
13 Rx ipod receiving line, Serial RxD

14 RSVD Reserved
15 GND Ground (-), internally connected with pin 16 on iPod motherboard
16 GND USB GND (-), internally connected with pin 15 on iPod motherboard
17 RSVD Reserved
18 3.3V 3.3V Power (+)
Stepped up to provide +5 VDC to USB on iPod Camera Connector. If iPod is put to sleep while Camera Connector is present, +5 VDC at this pin slowly drains back to 0 VDC.
19,20 +12V Firewire Power 12 VDC (+)
21 Accessory Indicator/Serial enable Different resistances indicate accessory type:
1kOhm - iPod docking station, beeps when connected
10kOhm - Takes some iPods into photo import mode

6.8 kΩ - Serial port mode. Pin 11-13 are TTL level. Requires MAX232 chip to convert to RS232 levels.
68kOhm - makes iPhone 3g send audio through line-out without any messages
500kOhm - related to serial communication / used to enable serial communications Used in Dension Ice Link Plus car interface
  1MOhm - Belkin auto adaptor, iPod shuts down automatically when power disconnected Connecting pin 21 to ground with a 1MOhm resistor does stop the ipod when power (i.e. Firewire-12V) is cut. Looks to be that when this pin is grounded it closes a switch so that on loss of power the Ipod shuts off. Dock has the same Resistor.

22 TPA (-) FireWire Data TPA (-)
23 5 VDC (+) USB Power 5 VDC (+)
24 TPA (+) FireWire Data TPA (+)
25 Data (-) USB Data (-)
26 TPB (-) FireWire Data TPB (-)
27 Data (+) USB Data (+)
Pins 25 and 27 may be used in different manner. To force the iPod 5G to charge in any case, when USB Power 5 VDC (pin 23) is fed, 25 must be connected to 5V through a 10kOhm resistor, and 27 must be connected to the Ground (for example: pin 1) with a 10kOhm resistor.

iPod 5G can also be forced to charge by attaching the data + and the data - pins to the 5v via a 10k Ohm resistor ( BOTH PINS) and connecting pin 16 to the 5v (ground). (Confirmed working with iPod 5G 20GB). This provides 500mA of current for charging. For quicker charing, up to 1A, see below.

To charge an iPhone, 3G, 3GS, 4 / iPod Touch, 2nd gen, 3rd, 4th or Ipod Classic (6th Gen), usb data- (25) should be at 2.8v, usb data+(27) should be at 2.0v. This can be done with a few simple resistors: 33k to +5v (23) and 22k to gnd(16) to obtain 2v and 33k to +5v and 47k to gnd to obtain 2.8v. This is a notification to the iphone that it is connected to the external charger and may drain amps from the usb.

To charge iPod Nano pins 25 and 27 should be tied together and then connected to a 10K ohm resistor, and the other side of this resistors then needs to be connected to 5v power.

It's also possible to charge the iPod's or iPhone's battery to make use the of internal +3.3v output (18) terminal to connect the USB Data + (27) thru a 47k ohms resistor and the USB Data- (25) thru a 47k resistor to the USB Power source +5v (23).  This way the USB function is still useable for normal operations and makes it easier the fit in a plug. The resistors are not to critical 2x 150k's still work.

28 TPB (+) FireWire Data TPB (+)
29,30 GND FireWire Ground (-)

Back side of dock connector;
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29Pins 1,2 connected on motherboard.
Pins 15,16 connected on motherboard.
Pins 19,20 connected on motherboard.
Pins 29,30 connected on motherboard.

If you disassemble the original apple-ipod-dock-connector-cable and look at the connector itself, on the back side, where it is soldered, you can see the number 1 and 30 (e.g. pin 1 and 30). In this description NUMBERING is INVERSED: pin 1 is pin 30 and pin 29 is pin 2, so, don't look at numbers on connector.

The remote control, iTalk and other serial devices use Apple Accessory Protocol for communication with iPOD. This protocol was introduced with the 3rd generation iPods, and is also compatible with the 4th generation iPods and mini iPods. The connections uses a standard 8N1 (one startbit 8 data bits 1 Stopbit) serial protocol, 19200 baud (higher rates up to 57600 also possible, but speed faster than 38400 may cause problems with large amounts of data), delay of 12 microseconds inserted between end of the stopbit and the beginning of the next startbit (also working without this delay).
Electrical: high +3,3V low 0V
default line state: high. Codes used for communication with peripherals are here

This device may be connected to the firewire computer port by straight cable (TPB+/-, TPA +/- should be twisted pairs in cable)

iPod Nano 4th Gen no longer will charge from 12 volts on the firewire pins. If you tie pins 25 and 27 together and then connect a 10K ohm resistor to +/- 5 volts to pins 23 and 15 (or 16) then it will charge. If you don't tie 25 and 27 together, it won't charge.

iPod Touch 3G: may also require for pins 1 and 2 (GND and audio out GND) to be connected in order to output audio (pin 11 to GND). Works with appr. 500 kOhm between pin 21 and GND.

iPod Touch 2G requires pin 11 connected to 15/16, then connect that to pin 21 with a 68kOhm resistor to use the audio line out. This is because the device needs to be told to redirect the signal to the Line Out pins rather than to the built-in speaker. This explains why certain accessories won't work with the iPod Touch 2G and maybe even the iPod Touch 3G. The Nano 5G will require the pin 11 connection but not the 68kOhm resistor for redirecting audio.

Nano 5G: connecting the 68kOhm resistor to ground will disable the audio redirection accomplished by connecting pin 11 to ground.
You may need to ensure 1 and 2 are connected to GND for proper charging to occur.  




深度解析iPhone应用数据交换原理
iPhone应用数据交换原理是本文要介绍的内容,主要是来学习iphone应用中如何来实现数据的交换。如果我们的应用程序想跟外设传输数据,先要透过 iPhone 的操作系统,也就是 iPhone OS,来看详细内容讲解。



iPhone应用数据交换原理是本文要介绍的内容,主要是来学习iphone应用中如何来实现数据的交换。如果我们的应用程序想跟外设传输数据,先要透过 iPhone 的操作系统,也就是 iPhone OS,而最开始的认证过程也是在外设和 iPhone OS 之间发生的,苹果为这个过程提供了一颗认证芯片(这颗芯片的作用是用来让 iPhone OS 识别这个外设是经过苹果公司承认的,他的通信方式是 I2C 总线, 而且每出一个产品苹果都会收几美元的认证费用)

iPhone OS 承认外设分两个步骤,识别和认证,我们先说说识别过程。

识别过程是使用纯物理连接来实现的,在这个过程中 iPhone 的 30pin 有三个引脚被用到,分别是 Accessory Identify,Accessory Detect,Accessory Power,Accessory Identify 接 549k 欧姆的电阻,告知 iPhone OS 使用串口通信,Accessory Detect 直接接地,告知 iPhone OS 有外设插入,Accessory Power 相当于 iPhone OS 的信号,待机时这个引脚没有输出,否则会有 3.3V 的电压输出。如果按照以上连接就完成了识别过程。

下面开始认证过程,认证过程也叫 IDPS 过程,这些就牵扯到苹果指定的通信协议了,苹果给自己的通信协议起了一个名字叫 Lingo,Lingo 分好多种有 音频的 Lingo还有显示遥控的 Lingo,而我们认证使用的 Lingo 叫做 General Lingo。

iPhone 的命令包,大家看到应该就明白了。开始 IDPS 过程首先要发送 StartIDPS 命令,这样,外设与 iPhone OS 之间的认证过程 就开始了。其中咱们应用中 EAAccessory 关于一些外设的属性,都是在这个过程中外设发给操作系统的,具体还是大家加入苹果的 mfi(made for ipod),拿到资料后,才能更明白。稍后我会将 iPhone 串口通信的源码发出来。先写到这儿吧,这些东西不能说的太多,希望会对大家有点帮助。

小结:深度解析iPhone应用数据交换原理的内容介绍完了,希望通过本文的学习能对你有所帮助!



iPhone/iPod Touch Serial Port Tutorial By Collin Meyer (TheRain) 12-09-2007

DISCLAIMER: Interfacing electronically to the Iphone has the potential to cause severe damage to your Iphone or cause your Iphone to become non-functional. By following this tutorial you take sole responsibility and understand the risks of what you are doing.

--------------------------------------------------------------------------------

Summary
This tutorial will explain how to use the serial RX and TX lines on the Iphone as a standard UART serial port. Software on the Iphone can access the UART using the same libraries and functions as in any UNIX software. This tutorial was created to explain how to get past this issue. This tutorial will explain some of the basic parts and code needed to use the UART.

Tools

Jailbroken Iphone with BSD Subsystem installed (Search the web for jailbreak tutorials)
Iphone development toolchain for Mac OSX, Linux, Windows (Cygwin) or other OS. I use this XXXXXXXXXXXXXXXXXXXXXX/p/winchain/ in Windows.
Sparkfun Ipod connector or breakout board see XXXXXXXXXXXXXXXXXXXXXXX/commerce/product_XXXXXXXp?products_id=633 or XXXXXXXXXXXXXXXXXXXXXXX/commerce/product_XXXXXXXp?products_id=8295
PC USB UART - optional, but used in this tutorial. You will need either a 3.3V level UART for PC (see XXXXXXXXXXXXXXXXXXXXXXX/commerce/product_XXXXXXXp?products_id=718) or you will need an old style 12V level serial cable with a level converter like this one XXXXXXXXXXXXXXXXXXXXXXX/workbench/On_top_of_the_Bench/Max233_Adapter/max233_XXXXXXXXXXml (see warning below)
A soldering iron will help you out [s:1]
Microsoft Visual Studio - optional, but used in the source code examples for the PC serial port communication.


WARNING! Do not try to use a 12V level RS232 port for this without a level converter to ~3V, it will severely damage your Iphone or render it non-functional.

--------------------------------------------------------------------------------

The Dock Port
In the Ipod/Iphone dock port, the pins we are concerned with are as follows
Pin 1
Ground

Pin 18
3.3V Power (+)

Pin 12
TX also known as Serial Transmit

Pin 13
RX also known as Serial Receive

To see a full description of all of the pins in the dock connector, see here: XXXXXXXXXXXXXXXXX/Devices/ipod_XXXXXXXXXtml

Connections: iPhone/iPod Touch RX should connect to TX of the connected device, TX to RX of the connected device, and Ground to the Ground of the connected device. If your device can be powered by a low amperage, 3.3V power source you may chose to connect PIN 18 as well and power your device directly from the iPhone/iPod Touch.

On the software end the Serial RX and TX lines of the Iphone can be accessed just like a standard serial port on any other UNIX-like system. See below for source example.

A Source Code Example
-Overview
In this example I will use a PC serial port to communicate with the Iphone. Initially, only the Iphone can talk over serial to whatever serial device it is talking to, a PC or other types of devices. Since this is the case, it makes sense for our Iphone application to send out a "handshaking" message to the connected device. Then the connected device can do the hardware trick mentioned above, and the Iphone will then allow data to be sent to it over serial. Since our Iphone software doesn't know when the receiving has been enabled, the connected device can send back a "handshaking" message to tell the Iphone program that it can send data to it. So our software flow looks something like this:





Iphone Code - On the Iphone we open the device tty.iap, this is the serial port device. The code works like standard Unix serial device access code. Here is an example of opening the tty.iap serial port, setting it as no hardware flow control, 8 bit data, 19200 baud rate, and BLOCKING I/O.
#include <stdio.h>   /* Standard input/output definitions */
#include <string.h>  /* String function definitions */
#include <unistd.h>  /* UNIX standard function definitions */
#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */

static struct termios gOriginalTTYAttrs;

static int OpenSerialPort()
{
    int        fileDescriptor = -1;
    int        handshake;
    struct termios  options;

    // Open the serial port read/write, with no controlling terminal, and don't wait for a connection.
    // The O_NONBLOCK flag also causes subsequent I/O on the device to be non-blocking.
    // See open(2) ("man 2 open") for details.

    fileDescriptor = open("/dev/tty.iap", O_RDWR | O_NOCTTY | O_NONBLOCK);
    if (fileDescriptor == -1)
    {
        printf("Error opening serial port %s - %s(%d).\n",
               "/dev/tty.iap", strerror(errno), errno);
        goto error;
    }

    // Note that open() follows POSIX semantics: multiple open() calls to the same file will succeed
    // unless the TIOCEXCL ioctl is issued. This will prevent additional opens except by root-owned
    // processes.
    // See tty(4) ("man 4 tty") and ioctl(2) ("man 2 ioctl") for details.

    if (ioctl(fileDescriptor, TIOCEXCL) == -1)
    {
        printf("Error setting TIOCEXCL on %s - %s(%d).\n",
            "/dev/tty.iap", strerror(errno), errno);
        goto error;
    }

    // Now that the device is open, clear the O_NONBLOCK flag so subsequent I/O will block.
    // See fcntl(2) ("man 2 fcntl") for details.

    if (fcntl(fileDescriptor, F_SETFL, 0) == -1)
    {
        printf("Error clearing O_NONBLOCK %s - %s(%d).\n",
            "/dev/tty.iap", strerror(errno), errno);
        goto error;
    }

    // Get the current options and save them so we can restore the default settings later.
    if (tcgetattr(fileDescriptor, &gOriginalTTYAttrs) == -1)
    {
        printf("Error getting tty attributes %s - %s(%d).\n",
            "/dev/tty.iap", strerror(errno), errno);
        goto error;
    }

    // The serial port attributes such as timeouts and baud rate are set by modifying the termios
    // structure and then calling tcsetattr() to cause the changes to take effect. Note that the
    // changes will not become effective without the tcsetattr() call.
    // See tcsetattr(4) ("man 4 tcsetattr") for details.

    options = gOriginalTTYAttrs;

    // Print the current input and output baud rates.
    // See tcsetattr(4) ("man 4 tcsetattr") for details.

    printf("Current input baud rate is %d\n", (int) cfgetispeed(&options));
    printf("Current output baud rate is %d\n", (int) cfgetospeed(&options));

    // Set raw input (non-canonical) mode, with reads blocking until either a single character
    // has been received or a one second timeout expires.
    // See tcsetattr(4) ("man 4 tcsetattr") and termios(4) ("man 4 termios") for details.

    cfmakeraw(&options);
    options.c_cc[VMIN] = 1;
    options.c_cc[VTIME] = 10;

    // The baud rate, word length, and handshake options can be set as follows:

    cfsetspeed(&options, B19200);    // Set 19200 baud
    options.c_cflag |= (CS8);  // RTS flow control of input


    printf("Input baud rate changed to %d\n", (int) cfgetispeed(&options));
    printf("Output baud rate changed to %d\n", (int) cfgetospeed(&options));

    // Cause the new options to take effect immediately.
    if (tcsetattr(fileDescriptor, TCSANOW, &options) == -1)
    {
        printf("Error setting tty attributes %s - %s(%d).\n",
            "/dev/tty.iap", strerror(errno), errno);
        goto error;
    }
    // Success
    return fileDescriptor;

    // Failure "/dev/tty.iap"
error:
    if (fileDescriptor != -1)
    {
        close(fileDescriptor);
    }

    return -1;
}In our main application, we impliment the handshaking method I described above.

int main(int args, char *argv[])
{
    int fd;
    char somechar[8];
    fd=OpenSerialPort(); // Open tty.iap with no hardware control, 8 bit, BLOCKING and at 19200 baud
    if(fd>-1)
    {
        write(fd,"*",1); // Write handshaking message over serial
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        // After this, our device or our PC program should be strobing serial ground to gain access to the
Iphone Serial Line
        //////////////////////////////////////////////////////////////////////////////////////////////////
        read(fd,&somechar[0],1); // Read 1 byte  over serial.  This will block (wait) untill the byte has been
received
        if(somechar[0]=='*') // Check if this byte is a "handshaking" message
        {
            printf("Serial connection established!\n"); // If it is, we have established a connection to the
device and can freely read/write over serial!
            while(1) // Do this forever or untill someone presses CTRL+C
            {
                read(fd,&somechar[0],1);  // Read a character over serial!
                putchar(somechar[0]); // Write the character to the Terminal!!
            }
        }
    }
    return 0;
}
The Connected Device in this case is simulated by a Windows program written in C#. The C# program receives the Handshaking message from the Iphone. It then sends the '*' handshaking message back to the Iphone to let it know that it can safely send data back and forth now. After this, you can click the "Hello Iphone!" button in the Windows program to send a string to the Iphone. The Iphone will output this string to the terminal.
+50  科创币    天易    2011/12/15 鼓励为大家提供资料——尽管俺看不懂英文。
来自:综合交流区 / 极客DIY
6
已屏蔽 原因:{{ notice.reason }}已屏蔽
{{notice.noticeContent}}
~~空空如也
科学人 作者
13年1个月前 IP:未同步
344775
回 2楼(婺源寻芳) 的帖子
其实IPHONE也不用开盖子的,接口统一比较方便。
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

所属专业
上级专业
同级专业
科学人
学者 笔友
文章
178
回复
1739
学术分
1
2011/07/24注册,6年11个月前活动
暂无简介
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:未同步
文件下载
加载中...
{{errorInfo}}
{{downloadWarning}}
你在 {{downloadTime}} 下载过当前文件。
文件名称:{{resource.defaultFile.name}}
下载次数:{{resource.hits}}
上传用户:{{uploader.username}}
所需积分:{{costScores}},{{holdScores}}下载当前附件免费{{description}}
积分不足,去充值
文件已丢失

当前账号的附件下载数量限制如下:
时段 个数
{{f.startingTime}}点 - {{f.endTime}}点 {{f.fileCount}}
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
支持的图片格式:jpg, jpeg, png
插入公式
评论控制
加载中...
文号:{{pid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
详情
详情
推送到专栏从专栏移除
设为匿名取消匿名
查看作者
回复
只看作者
加入收藏取消收藏
收藏
取消收藏
折叠回复
置顶取消置顶
评学术分
鼓励
设为精选取消精选
管理提醒
编辑
通过审核
评论控制
退修或删除
历史版本
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}