📄 iap.h
字号:
/************************************************** * * iAP.h * * CVS ID: $Id: iAP.h,v 1.9 2007/11/09 11:20:45 longauer Exp $ * Author: Leos Longauer [LL] - STM * Date: $Date: 2007/11/09 11:20:45 $ * Revision: $Revision: 1.9 $ * * Description: * * public header: iPod Accessory Protocol layer; * note - all iPod cmd structures are big endian * *************************************************** * * COPYRIGHT (C) ST Microelectronics 2007 * All Rights Reserved * *************************************************** * * STM CVS Log: * * $Log: iAP.h,v $ * Revision 1.9 2007/11/09 11:20:45 longauer * long ipod packets/telegrams transmission is supported + variables/functions movement * * Revision 1.8 2007/11/07 11:57:49 trubac * iap_is_cmd is comparing command id without lingo id * * Revision 1.7 2007/11/06 15:23:11 trubac * added ipod message handling for virtual navigation * * Revision 1.6 2007/10/18 10:47:42 longauer * handle authentication and automatically switches to the extended mode * * Revision 1.5 2007/09/20 21:35:52 longauer * virtual iPod authentication is working * * Revision 1.4 2007/09/04 16:54:27 longauer * coprocessor data processing; IAP_ProcessFsm() established; * * Revision 1.3 2007/09/03 13:25:19 longauer * Ipod Rx Archive; files affected: ACP.h, iAP.*, player.c, gendef.h * * Revision 1.2 2007/08/10 12:33:29 longauer * IPOD_AP compilation switch enables future iAP * * Revision 1.1 2007/07/09 10:45:08 longauer * first commit * * ***************************************************/#ifndef _IAP_H#define _IAP_H#if (0!=IPOD_AP)/*************************** DEFINITIONS **************************//*---------------------------------------------------------------------------*//*!\brief Compilation switches *//*---------------------------------------------------------------------------*///#define _IAP_DEBUG#define _B32_BACK_COMPATIBILITY //provisional#ifdef TRACE_DEBUG#define DBG_REPORT_ERROR(_err) printf("\t%d-%s:0x%x\r\n",__LINE__,__FUNCTION__,_err)#else#define DBG_REPORT_ERROR(_err) do{}while(0)#endif/*---------------------------------------------------------------------------*//*!\brief *//*---------------------------------------------------------------------------*///#define C_MAX_STRING_SIZE 64 /* application restrictions *///#define C_USB_IPOD_VID 0x05AC//#define C_USB_IPOD_PID_MASK 0x1200#define C_MAX_PAYLOAD_SIZE 256 /* info for iPod about max packet accessory is able to support; pp.102; R26 */#define C_IAP_SOP 0x55#define C_IAP_MAX_HEADER_LEN 7 /* maximal length of the header - |SOP|0|LenHi|LenLo|LID|CIDHi|CIDLo| */#define C_IAP_MAX_CERTIFICATE_LENGTH 500 /* pp.61,62; R26*///#define C_IAP_MAX_SMALL_PACKET_PAYLOAD 251 /* pp.63; R26 */ //TBD#define C_IAP_MAX_SMALL_PACKET_PAYLOAD 255 /* pp.63; R26 */#define C_IAP_LARGE_PACKET_SHIFT 2 /* large packet (header) is 2 bytes longer */#define C_IAP_EXT_LINGO_PACKET_SHIFT 1 /* extended comand is 1B longer */#define IAP_TIMER_DEFAULT_VAL 10000 //TBD#define C_IAP_BUFFER_SIZE 256 /* size of the Tx buffer (in bytes) *//* no iPod commands - iAP layer supervisor's commands */#define C_IAP_LINGO_NO 0xFF /* special(internal commands) set(no lingo) */#define C_IAP_CMD_REFRESH 0x00 /* refresh request identifier */#define C_IAP_CMD_PASS 0x01 /* no internal command *//*---------------------------------------------------------------------------*//*!\brief ARCHIVE *//*---------------------------------------------------------------------------*/#define C_IAP_ARCHIVE_BUFFER_SIZE 256 /* size of the archive (in bytes) */#define C_IAP_ARCHIVE_MAX_LEN 3 /* maximal number of iAPs in one report to be recognized *//***************************** MACROS ****************************//*---------------------------------------------------------------------------*//*!\brief flags handling *//*---------------------------------------------------------------------------*/#define M_SET_FLAG(flag) flag=TRUE#define M_SET_FLAGS(flag,value) flag=value#define M_CLEAR_FLAG(flag) flag=FALSE#define M_CLEAR_FLAGS(flag) flag=FALSE;#define M_IS_SET(flag) flag!=FALSE#define M_IS_SET_TO(flag,value) flag==value#define M_IS_CLEAR(flag) flag==FALSE#define M_READ_FLAGS(flag) flag;flag=FALSE#define M_IS_IAP_ERROR(flag) ((flag&E_IAP)==E_IAP)#define M_IS_IAP_FATAL(flag) ((flag&E_IAP_FATAL)==E_IAP_FATAL)#define M_IAP_SAVE_TX(_handler) \ M_SET_FLAG( ((tIap*)_handler)->InEvent.flag.TxAck )#define M_IAP_SAVE_RX(_handler, _rxStatus) \ M_SET_FLAG( ((tIap*)_handler)->InEvent.flag.Rx ); \ ((tIap*)_handler)->Rx.pData = (_rxStatus).pData; \ ((tIap*)_handler)->Rx.DataLength = (_rxStatus).DataLength; \ ((tIap*)_handler)->Rx.bEndFlag = (_rxStatus).bEndFlag#define M_IAP_SAVE_ACP(_handler, _cpStatus); \ M_SET_FLAG( ((tIap*)_handler)->InEvent.flag.RxAcp ); \ ((tIap*)_handler)->Acp.pData = (_cpStatus).pData; \ ((tIap*)_handler)->Acp.Cmd = (_cpStatus).ReplyStatusTo; \ ((tIap*)_handler)->Acp.Error = (_cpStatus).Error#define M_IAP_PREPARE_TX(_handler, _txCmd) \ (_txCmd).pData = ((tIap*)_handler)->Tx.pData; \ (_txCmd).DataLength = ((tIap*)_handler)->Tx.DataLength; \ (_txCmd).bEndFlag = ((tIap*)_handler)->Tx.bEndFlag#define M_IAP_PREPARE_CP(_handler, _cpCmd) \ (_cpCmd).Cmd = ((tIap*)_handler)->Acp.Cmd; \ (_cpCmd).pData = ((tIap*)_handler)->Acp.pData/********************* IAP STRUCTURES & TYPES ********************//* user defined type - pp.58; R26 */typedef enum{ IAP_VER_1 = 1, IAP_VER_2 = 2} teIapVersion;/*---------------------------------------------------------------------------*//*!\brief Lingo IDs *//*---------------------------------------------------------------------------*//* Table 5-1; pp.58; R26 */typedef enum{ IAP_LINGO_GENERAL = 0x00, IAP_LINGO_MICROPHONE, /* 0x01 */ IAP_LINGO_SIMPLE_REM, /* 0x02 */ IAP_LINGO_DISPLAY_REM, /* 0x03 */ IAP_LINGO_EXT_INTERF, /* 0x04 */ IAP_LINGO_RF_TRANSMIT, /* 0x05 */ IAP_LINGO_USB_HOST, /* 0x06 */ IAP_LINGO_RF_TUNER, /* 0x07 */ IAP_LINGO_ACCESSORY_EQ, /* 0x08 */ /* 0x09 is reserved */ IAP_LINGO_DIG_AUDIO = 0x0A /* 0x0B-0x1F are sererved */} teIapLingoId;/*---------------------------------------------------------------------------*//*!\brief General Lingo commands (0x00) *//*---------------------------------------------------------------------------*//* Table 5-4; pp.65; R26 */typedef enum{ IAP_GEN_REQ_IDENT = 0x00, /* <- iPod; v1.00 */ IAP_GEN_IDENT, /* -> iPod; 0x01; v1.00 */ IAP_GEN_ACK, /* <- iPod; 0x02; v1.00 */ IAP_GEN_REQ_REM_UI, /* -> iPod; 0x03; v1.00 */ IAP_GEN_RET_REM_UI, /* <- iPod; 0x04; v1.00 */ IAP_GEN_ENT_REM_UI, /* -> iPod; 0x05; v1.00 */ IAP_GEN_EXIT_REM_UI, /* -> iPod; 0x06; v1.00 */ IAP_GEN_REQ_NAME, /* -> iPod; 0x07; v1.00 */ IAP_GEN_RET_NAME, /* <- iPod; 0x08; v1.00 */ IAP_GEN_REQ_SW_VER, /* -> iPod; 0x09; v1.00 */ IAP_GEN_RET_SW_VER, /* <- iPod; 0x0A; v1.00 */ IAP_GEN_REQ_SER_NUM, /* -> iPod; 0x0B; v1.00 */ IAP_GEN_RET_SER_NUM, /* <- iPod; 0x0C; v1.00 */ IAP_GEN_REQ_MODEL, /* -> iPod; 0x0D; v1.00 */ IAP_GEN_RET_MODEL, /* <- iPod; 0x0E; v1.00 */ IAP_GEN_REQ_LINGO_VER, /* -> iPod; 0x0F; v1.00 */ IAP_GEN_RET_LINGO_VER, /* <- iPod; 0x10; v1.00 */ /* 0x11, 0x12 are reserved */ IAP_GEN_IDENT_DEV_LINGO = 0x13, /* -> iPod; v1.01 */ IAP_GEN_GET_DEV_AUTH_INFO, /* <- iPod; 0x14; v1.01 */ IAP_GEN_RET_DEV_AUTH_INFO, /* -> iPod; 0x15; v1.01 */ IAP_GEN_ACK_DEV_AUTH_INFO, /* <- iPod; 0x16; v1.01 */ IAP_GEN_GET_DEV_AUTH_SIGN, /* <- iPod; 0x17; v1.01 */ IAP_GEN_RET_DEV_AUTH_SIGN, /* -> iPod; 0x18; v1.01 */ IAP_GEN_ACK_DEV_AUTH_STAT, /* <- iPod; 0x19; v1.01 */ IAP_GEN_GET_AUTH_INFO, /* -> iPod; 0x1A; v1.01 */ IAP_GEN_RET_AUTH_INFO, /* <- iPod; 0x1B; v1.01 */ IAP_GEN_ACK_AUTH_INFO, /* -> iPod; 0x1C; v1.01 */ IAP_GEN_GET_AUTH_SIGN, /* -> iPod; 0x1D; v1.01 */ IAP_GEN_RET_AUTH_SIGN, /* <- iPod; 0x1E; v1.01 */ IAP_GEN_ACK_AUTH_STATUS, /* -> iPod; 0x1F; v1.01 */ /* 0x20 - 0x22 are reserved */ IAP_GEN_NOT_STATE_CHNG = 0x23, /* <- iPod; v1.02 */ IAP_GEN_GET_OPTIONS, /* -> iPod; 0x24; v1.05 */ IAP_GEN_RET_OPTIONS, /* <- iPod; 0x25; v1.05 */ /* 0x26 is reserved */ IAP_GEN_GET_ACC_INFO = 0x27, /* <- iPod; v1.04 */ IAP_GEN_RET_ACC_INFO, /* -> iPod; 0x28; v1.04 */ IAP_GEN_GET_PREFERENC, /* -> iPod; 0x29; v1.05 */ IAP_GEN_RET_PREFERENC, /* <- iPod; 0x2A; v1.05 */ IAP_GEN_SET_PREFERENC, /* -> iPod; 0x2B; v1.05 */ /* 0x2C - 0xFF are reserved */} teIapGenCmd;/* Table 5-10 ACK packet; pp.72; R26 */typedef enum{ IAP_ACK = 0, IAP_E_UNK_DB_CAT, IAP_E_CMD_FAILED, IAP_E_OUT_OF_RES, IAP_E_BAD_PARAM, IAP_E_UNK_ID, IAP_E_CMD_PENDING, IAP_E_NOT_AUTHENT, IAP_E_BAD_AUTH_VER, IAP_E_CERT_INVALID = 0x0A, IAP_E_CERT_PERM} teIapAck;/* Table 5-31 IdentifyDeviceLingoes packet; pp.85; R26 */#define C_IAP_13_CTRL_NO 0x0#define C_IAP_13_CTRL_DEFER 0x1#define C_IAP_13_CTRL_IMMED 0x2#define C_IAP_13_POWER_LOW 0x0#define C_IAP_13_POWER_INTERMIT 0x1/* Table 5-47 NotifyIpodStateChange packet; pp.95; R26 */typedef enum{ IAP_STATE_NO_CHNG = 0, IAP_STATE_DEEP_SLEEP, IAP_STATE_HIBERNATE, IAP_STATE_LIGHT_SLEEP, IAP_STATE_POWER_ON} teIapStateChg;/* Table 5-51 Accessory Info Types; pp.98; R26 */typedef enum{ IAP_INFOTYPE_CAPABILITIES = 0x00, IAP_INFOTYPE_NAME, /* 0x01 */ IAP_INFOTYPE_MIN_SUP_FW_VER, /* 0x02 */ IAP_INFOTYPE_MIN_SUP_LINGO_VER, /* 0x03 */ IAP_INFOTYPE_FW_VER, /* 0x04 */ IAP_INFOTYPE_HW_VER, /* 0x05 */ IAP_INFOTYPE_MANUFACTURER, /* 0x06 */ IAP_INFOTYPE_MODEL_NUM, /* 0x07 */ IAP_INFOTYPE_SERIAL_NUM, /* 0x08 */ IAP_INFOTYPE_IN_MAX_PLOAD_SIZE /* 0x09 */} teIapInfoType;/* Table 5-62 iPod preference class and setting IDs; pp.104; R26 */typedef enum /* not fully defined */{ IAP_VIDEO_OUT = 0, IAP_SCREEN_CONFIG, IAP_VIDEO_FORMAT} teIapPrefClasID;/*---------------------------------------------------------------------------*//*!\brief ExtendedInterface Lingo commands (0x04) *//*---------------------------------------------------------------------------*//* Table 6-1; pp.47; R18*/typedef enum{ /* 0x00 is reserved */ IAP_EXT_ACK = 0x01, /* <- iPod; v1.00 */ IAP_EXT_GET_CUR_PT_CHAPT_INFO, /* -> iPod; 0x02; v.106, Playback Engine */ IAP_EXT_RET_CUR_PT_CHAPT_INFO, /* <- iPod; 0x03; v.106, Playback Engine */ IAP_EXT_SET_CUR_PT_CHAPT, /* -> iPod; 0x04; v.106, Playback Engine */ IAP_EXT_GET_CUR_PT_CHAPT_PLAY_STATUS, /* -> iPod; 0x05; v.106, Playback Engine */ IAP_EXT_RET_CUR_PT_CHAPT_PLAY_STATUS, /* <- iPod; 0x06; v.106, Playback Engine */ IAP_EXT_GET_CUR_PT_CHAPT_NAME, /* -> iPod; 0x07; v.106, Playback Engine */ IAP_EXT_RET_CUR_PT_CHAPT_NAME, /* <- iPod; 0x08; v.106, Playback Engine */ IAP_EXT_GET_ABOOK_SPEED, /* -> iPod; 0x09; v.106 */ IAP_EXT_RET_ABOOK_SPEED, /* <- iPod; 0x0A; v.106 */ IAP_EXT_SET_ABOOK_SPEED, /* -> iPod; 0x0B; v.106 */ IAP_EXT_GET_INDEX_PT_INFO, /* -> iPod; 0x0C; v.108, Playback Engine */ IAP_EXT_RET_INDEX_PT_INFO, /* <- iPod; 0x0D; v.108 */ IAP_EXT_GET_ARTW_FORMATS, /* -> iPod; 0x0E; v.110, Playback Engine */ IAP_EXT_RET_ARTW_FORMATS, /* <- iPod; 0x0F; v.110, Playback Engine */ IAP_EXT_GET_T_ARTW_DATA, /* -> iPod; 0x10; v.110, Playback Engine */ IAP_EXT_RET_T_ARTW_DATA, /* <- iPod; 0x11; v.110, Playback Engine */ IAP_EXT_REQ_PROTOC_VER, /* -> iPod; 0x12; v.100 */ IAP_EXT_RET_PROTOC_VER, /* <- iPod; 0x13; v.100 */ IAP_EXT_REQ_NAME, /* -> iPod; 0x14; v.100 */ IAP_EXT_RET_NAME, /* <- iPod; 0x15; v.100 */ IAP_EXT_RST_DB_SELECTION, /* -> iPod; 0x16; v.100, Database Engine */ IAP_EXT_SEL_DB_REC, /* -> iPod; 0x17; v.100, Database Engine(x) */ IAP_EXT_GET_NUM_CATEG_DB_REC, /* -> iPod; 0x18; v.100, Database Engine */ IAP_EXT_RET_NUM_CATEG_DB_REC, /* <- iPod; 0x19; v.100 */ IAP_EXT_RER_CATEG_DB_REC, /* -> iPod; 0x1A; v.100, Database Engine */ IAP_EXT_CATEG_DB_REC, /* <- iPod; 0x1B; v.100 */ IAP_EXT_GET_PLAY_STATE, /* -> iPod; 0x1C; v.100, Playback Engine */ IAP_EXT_RET_PLAY_STATE, /* <- iPod; 0x1D; v.100 */ IAP_EXT_GET_CUR_PT_INDEX, /* -> iPod; 0x1E; v.100, Playback Engine */ IAP_EXT_RET_CUR_PT_INDEX, /* <- iPod; 0x1F; v.100 */ IAP_EXT_GET_INDEX_PT_TITLE, /* -> iPod; 0x20; v.100, Playback Engine */ IAP_EXT_RET_INDEX_PT_TITLE, /* <- iPod; 0x21; v.100 */ IAP_EXT_GET_INDEX_PT_ART_NAME, /* -> iPod; 0x22; v.100, Playback Engine */ IAP_EXT_RET_INDEX_PT_ART_NAME, /* <- iPod; 0x23; v.100 */ IAP_EXT_GET_INDEX_PT_ALB_NAME, /* -> iPod; 0x24; v.100, Playback Engine */ IAP_EXT_RET_INDEX_PT_ALB_NAME, /* <- iPod; 0x25; v.100 */ IAP_EXT_SET_P_STATE_CHNG_NOTIF, /* -> iPod; 0x26; v.100, Playback Engine */ IAP_EXT_PLAY_STATE_CHNG_NOTIF, /* <- iPod; 0x27; v.100 */ IAP_EXT_PLAY_CUR_SELECTION, /* -> iPod; 0x28; v.100, Database&Playback Engine */ IAP_EXT_PLAY_CONTROL, /* -> iPod; 0x29; v.100, Playback Engine */ IAP_EXT_GET_T_ARTW_TIMES, /* -> iPod; 0x2A; v.110, Playback Engine */ IAP_EXT_RET_T_ARTW_TIMES, /* <- iPod; 0x2B; v.110, Playback Engine */ IAP_EXT_GET_SHUFFLE, /* -> iPod; 0x2C; v.100 */ IAP_EXT_RET_SHUFFLE, /* <- iPod; 0x2D; v.100 */ IAP_EXT_SET_SHUFFLE, /* -> iPod; 0x2E; v.100 */ IAP_EXT_GET_REPEAT, /* -> iPod; 0x2F; v.100 */ IAP_EXT_RET_REPEAT, /* <- iPod; 0x30; v.100 */ IAP_EXT_SET_REPEAT, /* -> iPod; 0x31; v.100 */ IAP_EXT_SET_DISP_IMG, /* -> iPod; 0x32; v.101 */ IAP_EXT_GET_MONO_DISP_IMG_LIM, /* -> iPod; 0x33; v.101 */ IAP_EXT_RET_MONO_DISP_IMG_LIM, /* <- iPod; 0x34; v.101 */ IAP_EXT_GET_NUM_P_TRACKS, /* -> iPod; 0x35; v.101, Playback Engine */ IAP_EXT_RET_NUM_P_TRACKS, /* <- iPod; 0x36; v.101 */ IAP_EXT_SET_CUR_P_TRACK, /* -> iPod; 0x37; v.101, Playback Engine */ IAP_EXT_SEL_SORT_DB_REC, /* -> iPod; 0x38; v.101, Playback Engine */ IAP_EXT_GET_COLORDISP_IMG_LIM, /* -> iPod; 0x39; v.109 */ IAP_EXT_RET_COLORDISP_IMG_LIM, /* <- iPod; 0x3A; v.109 */ IAP_EXT_RST_DB_SEL_HIERARCHY, /* -> iPod; 0x3B; v.111, Playback Engine */ /* 0x002C - 0xFFFF are reserved */} teIapExtCmd;/*---------------------------------------------------------------------------*//*!\brief Digital Audio Lingo commands (0x0A); protocol version: 1.00 *//*---------------------------------------------------------------------------*//* Table 6-163; pp.211; R26 */typedef enum{ IAP_DIG_ACC_ACK = 0x00, IAP_DIG_IPOD_ACK, /* 0x01 */ IAP_DIG_GET_ACC_SAMPLRATE_CAP, /* 0x02 */ IAP_DIG_RET_ACC_SAMPLRATE_CAP, /* 0x03 */ IAP_DIG_NEW_TRACK_INFO, /* 0x04 */ /* 0x05 - 0xFF are reserved */} teIapDigCmd;/* Table 5-24; pp.79; R26 */typedef enum{ IAP_MODEL_3G = 0x0003, IAP_MODEL_MINI, /* 0x0004 */ IAP_MODEL_4G, /* 0x0005 */ IAP_MODEL_PHOTO, /* 0x0006 */ IAP_MODEL_2GMINI, /* 0x0007 */ IAP_MODEL_5G = 0x000B, IAP_MODEL_NANO, /* 0x000C */ IAP_MODEL_2GNANO = 0x0010} teIapModelId;/* Table 5-35; pp.87; R26 */typedef enum{ IAP_AUTH_PASSED = 0x00, IAP_AUTH_SUPPORTED = 0x00, IAP_AUTH_UNSUPPORTED = 0x08, IAP_AUTH_CERT_INVALID = 0x0A, IAP_AUTH_CERT_NOTPERMIT} teIapAuthStatus;typedef uint16 tIapCmdId;typedef union{ teIapGenCmd Gen :16; teIapExtCmd Ext :16; teIapDigCmd Dig :16;} tuIapCmd;typedef struct{ tIapCmdId CmdId :16; teIapLingoId LingoId :8; uint8 reserved;} tIapCmdCode;/*---------------------------------------------------------------------------*//*!\brief General Lingo command payloads (0x0A); *//*---------------------------------------------------------------------------*/typedef struct{ union { struct { teIapAck result :8; uint8 CmdAck; } Done; struct { teIapAck result :8; uint8 CmdAck; uint32 MaxPendWait; } Pending; } Ack;} tIapGenCmd0x02iData;#define SWAP32_FROM(_paddress) \ ( (* (uint8*)(_paddress) << 24) + \ (*((uint8*)(_paddress)+1) << 16) + \ (*((uint8*)(_paddress)+2) << 8 ) + \ (*((uint8*)(_paddress)+3) ) )#define SWAP16_FROM(_paddress) \ ( (* (uint8*)(_paddress) << 8) + \ (*((uint8*)(_paddress)+1) ) )//TBD - to optimize#define SWAP32(_value) \ ( (uint8)((_value) >> 24) + \ ((uint8)((_value) >> 16) <<8) + \ ((uint8)((_value) >> 8) <<16) + \ ((uint8)(_value) <<24) )typedef struct{ uint16 StringLen; uint8 String[C_IAP_MAX_SMALL_PACKET_PAYLOAD];} tIapGenCmdStringi;typedef struct{ uint8 MajorVerNum; uint8 MinorVerNum; uint8 RevVerNum;} tIapGenCmd0x0AiData;typedef struct{ uint32 ModelId33 :8; uint32 ModelId23 :8; uint32 ModelId13 :8; uint32 ModelId03 :8; tIapGenCmdStringi ModelNumber;} tIapGenCmd0x0EiData;typedef struct{ teIapLingoId LingoId; uint8 Major; uint8 Minor;} tIapGenProtocolVersion;typedef tIapGenProtocolVersion tIapGenCmd0x10iData;typedef struct{ /* 4th byte */ uint32 res4 : 8; /* 3rd byte */ uint32 res3 : 8; /* 2nd byte*/ uint32 AEQ : 1; uint32 res21: 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -