📄 hostif_low.h
字号:
/************************************************** * * hostif_low.h * * CVS ID: $Id: hostif_low.h,v 1.32 2007/11/15 13:21:29 belardi Exp $ * Author: Raffaele Belardi [RB] - STM * Date: $Date: 2007/11/15 13:21:29 $ * Revision: $Revision: 1.32 $ * * Description: * * Host communication protocol, low level (transport and link layer) * *************************************************** * * COPYRIGHT (C) ST Microelectronics 2005 * All Rights Reserved * *************************************************** * * STM CVS Log: * * $Log: hostif_low.h,v $ * Revision 1.32 2007/11/15 13:21:29 belardi * New request/message ReqCurrentPlaylistAbsContent * * Revision 1.31 2007/10/12 13:15:51 marcucci * Add protection against interrupt modification of hostif_inevent variable. * This variable should be always modified in a Task by means of the set_hostif_inevent() * and the reset_hostif_inevent() procedures * * Revision 1.30 2007/10/02 09:02:28 belardi * Commented out unused function * * Revision 1.29 2007/08/21 09:42:24 belardi * Fixed wrond max lenght definition for MsgTextInfo * * Revision 1.28 2007/08/02 13:36:37 sedmik * added define HOSTIF_SCHEDULED_DIR_CONTENT * * Revision 1.27 2007/03/05 15:11:52 belardi * Addition to CIS: * - new parameter in MsgPlayerMode indicating current source * - new values for PAR11 of MsgTimeInfo to indicate the type of file (CDDA, MP3, WMA, AAC) * - new command/message ReqLongEntryName to transmit the filename in multi-packet format * * Revision 1.26 2007/02/15 16:09:03 sedmik * fix in hostifStoredDataType * * Revision 1.25 2007/02/15 13:11:55 marcucci * Bootloader Optimization * * Revision 1.24 2007/02/13 11:04:21 sedmik * func hostifAppProcessUpdateFileGroup renamed to hostifAppProcessBinaryTransfersGroup * * Revision 1.23 2006/12/12 10:55:20 sedmik * structure used for storing to NVRAM changed * * Revision 1.22 2006/11/30 11:03:10 belardi * Removed unused CIS_0_05 definitions * * Revision 1.21 2006/11/27 19:50:30 belardi * Host Update protocol addition * - new functions * * Revision 1.20 2006/11/25 08:57:22 belardi * Coditional compilatio for HAVE_TEMP_SENSOR * * Revision 1.19 2006/11/24 11:35:59 zhong * Karbin for Temperature sensor detect * * Revision 1.18 2006/11/17 16:38:57 dellorto * added PVD address in read TOC message * added auto text messages * added configurable text item length * * Revision 1.17 2006/10/31 08:50:33 belardi * Removed unused timer * * Revision 1.16 2006/10/20 15:41:10 belardi * Support for long multi-packet transmission (or scheduled tx) * * Revision 1.15 2006/09/18 09:55:23 belardi * Corrected CVS keyword usage * * Revision 1.14 2006/09/18 09:24:13 belardi * Added Log CVS keyword into file header * * ***************************************************/#ifndef _HOSTIF_LOW_H_#define _HOSTIF_LOW_H_#include "i2c.h"typedef enum { HOSTIF_STATE_IDLE, HOSTIF_STATE_TX_INPROGRESS, HOSTIF_STATE_TX_WAITACK} t_hostif_state;/* parameter for hostifSendBlock */typedef enum { HOSTIF_NO_TX, HOSTIF_TX_MSGCMDEVAL, HOSTIF_TX_BLOCK_NORMAL, HOSTIF_TX_BLOCK_RESEND, HOSTIF_TX_BLOCK_ABORT} hostif_block_tx_mode;typedef enum { TL_ready, TL_inprogress,} TLStatusType;typedef enum { LL_ok, LL_checksumError, /* The checksum doesn't match the data content */ LL_badSize /* The received packet length does not agree with the physical packet length */} LLStatusType;#define HOSTIF_MSG_FIFO_LEN 256typedef struct{ char circular_buffer[HOSTIF_MSG_FIFO_LEN]; char *writep, *readp, *top;} t_hostif_msg_fifo;#define HOSTIF_SCHEDULED_ENTRY_NAME 0x0001#define HOSTIF_SCHEDULED_TEXT_INFO 0x0002#define HOSTIF_SCHEDULED_ROM_DATA 0x0004#define HOSTIF_SCHEDULED_UPDATE_IMAGE 0x0008#define HOSTIF_SCHEDULED_LONG_ENTRY_NAME 0x0010#define HOSTIF_SCHEDULED_DIR_CONTENT 0x0020#define HOSTIF_SCHEDULED_PLAYLIST_CONTENT 0x0040/************************************************** * * Data storage * * *************************************************//* Communication protocol parameters */typedef struct hostifCommProtocolParam_tag {// uint8 I2CSlaveAddress; uint16 maxI2CFrameSize;} hostifCommProtocolParamType;extern hostifCommProtocolParamType hostifCommProtocolParam;#if (0 != HAVE_POSITION)/* Data object to be stored */typedef struct _hostifStoredValueType{ t_player_resume_info resume_info[DEV_SLOTS]; //JS commented due to new implementation#if 0 uint16 player_resume_song_index_relative; t_player_song_time player_song_resume_time; t_duid player_resume_device; uint32 player_resume_device_identifier; // STTODO MISSING CD or USD id (to verify media change)#endif } hostifStoredValueType;typedef struct _hostifStoredDataType{ union { hostifStoredValueType v; uint8 all[ DEV_SLOTS * sizeof (t_player_resume_info)]; } f; uint32 Checksum;} hostifStoredDataType;extern hostifStoredDataType hostifStoredData;extern uint32 hostifLoadData;#endif /* HAVE_POSITION *//******************************//* Host interface events *//******************************/typedef uint32 t_hostif_inevent;extern t_hostif_inevent hostif_inevent;#define HOSTIF_LL_CRQ_TIMER_DURATION T200ms#define HOSTIF_LL_STOP_TIMER_DURATION T10000ms#define HOSTIF_TL_TX_ACK_TIMER_DURATION T500ms#define HOSTIF_CMD_SEND_HOST_MSG 0x0001#define HOSTIF_EVT_LL_AF_ERR 0x0002#define HOSTIF_EVT_LL_NEW_MSG 0x0004#define HOSTIF_EVT_LL_TX_COMPLETE 0x0008#define HOSTIF_EVT_LL_STOP_TIMEOUT 0x0010#define HOSTIF_EVT_LL_CRQ_TIMEOUT 0x0020#if (1 == HAVE_TEMP_SENSOR)#define HOSTIF_SPONTANEOUS_SEND_MSG 0x0040 // define for spontaneous send out the message#endif#define HOSTIF_SEND_MSGCMDEVAL 0x0080#if (0 != HAVE_POSITION)#define HOSTIF_STORE_DATA 0x0100#define HOSTIF_STORE_DATA_ERASE 0x0000#define HOSTIF_STORE_DATA_WRITE 0x0200#define HOSTIF_STORE_DATA_WAIT 0x0400#define HOSTIF_STORE_DATA_DONE 0x0800#define HOSTIF_STORE_DATA_MASK 0x0E00#define HOSTIF_STORE_DATA_CLEAR 0x0F00#define HOSTIF_LOAD_DATA 0x1000#define HOSTIF_LOAD_DATA_READ 0x0000#define HOSTIF_LOAD_DATA_CHECK 0x2000#define HOSTIF_LOAD_DATA_DONE 0x4000#define HOSTIF_LOAD_DATA_MASK 0x6000#define HOSTIF_LOAD_DATA_CLEAR 0x7000#endif /* HAVE_POSITION */#if (1 == HAVE_HOST_UPDATE) || (1 == HAVE_HOST_UPDATE_NEW)#define HOSTIF_EVT_UPDATE_BLOCK_RDY 0x40000#define HOSTIF_EVT_UPDATE_LAST_BLOCK_RDY 0x20000#define HOSTIF_SEND_UPDATE_PACKET 0x10000#endif/******************************//* Data storage *//******************************/ /* Maximum size of Application Layer message when not using the TL */ /* The LL adds one byte for the 'length' and one for the 'checksum' */ #define HOSTIF_MAX_BLOCK_SIZE (DEFAULT_MAX_I2C_FRAME_SIZE - 2)/* Max string len for debug and trace over I2C *//* Max Size for printable string is I2C frame len minus: *//* GR, ID, protocol vesion, LL checksum, LL len */#define HOSTIF_MAX_DEBUG_STRING_SIZE (DEFAULT_MAX_I2C_FRAME_SIZE - 5)/* Max size for memory dump is equal to string size less the 4-byte address */#define HOSTIF_MAX_DEBUG_DUMP_SIZE (HOSTIF_MAX_DEBUG_STRING_SIZE - 4)/* Lenght of the ErrorCode parameter, in bytes. */#define HOSTIF_MAX_DEBUG_ERRORCODE_SIZE 10/* definitions for update_flash() message */#define UPDATE_FLAG_LAST_OF_BLOCK 0x01#define UPDATE_FLAG_LAST_OF_FILE 0x02#define HOSTIF_UPDATE_HEADER_DIM 9#define HOSTIF_UPDATE_DATA_DIM (HOSTIF_MAX_BLOCK_SIZE - HOSTIF_UPDATE_HEADER_DIM)#define HOSTIF_TEXT_HEADER_SIZE 10 // GR, ID, PAR1-PAR8#define HOSTIF_MAX_TEXT_PACKET_LENGTH (HOSTIF_MAX_BLOCK_SIZE - HOSTIF_TEXT_HEADER_SIZE)#define HOSTIF_MIN_TEXT_PACKET_LENGTH 16#define HOSTIF_DEBUG_PROTOCOL_VERSION 0x01#define I2C_CRQ_OR_MASK 0x0002 // use to set the CRQ high (inactive)#define I2C_CRQ_AND_MASK 0xFFFD // use to set the CRQ low (active)#define HOSTIF_LL_MAX_RETRY_COUNT 3#if (0 != HAVE_POSITION)#define HOSTIF_STORE_ADDRESS_4M 0x00070000#define HOSTIF_STORE_ADDRESS_1M 0x18000#endif /* HAVE_POSITION */extern uint32 hostif_ll_retry_count;extern char i2c_irq_rx_buffer[];extern uint16 i2c_irq_rx_buffer_idx;extern char i2c_irq_tx_buffer[];extern uint32 hostif_current_scheduled_tx;/************************************************** * * Function definitions and return types * * *************************************************//* Parameter for hostifHasParameter *//* Do not change the values, code assumes these! */typedef enum { PAR1 = 0, PAR2 = 1, PAR3 = 2, PAR4 = 3, PAR5 = 4, PAR6 = 5} hostifParameterIdType;void hostif_reset(void);void hostif_process_hostcmd(void);void hostif_process_scheduled_tx(void);void hostif_activate_pending_tx(uint32 which_tx);void hostif_schedule_tx(uint32 which_tx);void hostif_deschedule_tx(uint32 which_tx);void hostif_deschedule_current(void);void hostif_transition_handler(void);/* Application Layer */void hostifAppProcessPlayerInfoGroup(char *, uint16);void hostifAppProcessPlayerConfigGroup(char *, uint16);void hostifAppProcessPlayerFunctionGroup(char *, uint16);void hostifAppProcessMediaInfoGroup(char *, uint16);void hostifAppProcessBinaryTransfersGroup(char *, uint16);t_bool hostifAppHasParameter(uint16, hostifParameterIdType);uint8 hostifAppGetParameter(char *, hostifParameterIdType);void createMsgCmdEval(char *, uint8, uint8, uint8);void hostifAppSendMsgCmdEval(uint8, uint8, uint8);void hostifAppSendMsg(char *, uint16);void hostifAppSendMsgOneParameter(char *, char, char, char);void hostifAppSendMsgTwoParameter(char *, char, char, char, char);void send_hostif_inevent(uint32);void reset_hostif_inevent(uint32);//#if (1 == HAVE_HOST_UPDATE)void set_hostif_inevent(uint32);//#endifvoid debugSendPrintableString(char *, uint16);void debugSendMemoryDump(void *, char *, uint16);void debugSendErrorCode(uint8);#if (0 != HAVE_POSITION)extern uint32 hostif_calculate_checksum(void);extern uint8 hostif_verify_checksum(void);extern void hostif_update_checksum(void);#endif /* HAVE_POSITION */#endif //_HOSTIF_LOW_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -