📄 hostif_low.c
字号:
* \param len Length of the message * \return void * \remark Uses the (GR, ID) reserved for the debug messages *//******************************************************************************/void debugSendErrorCode(uint8 error){#if (STM_HOSTIF_USE_DEBUG_AND_TRACE==1) extern uint8 cap_debug_to_hostif; extern uint8 ctr_debug_to_hostif[6]; extern uint8 player_debug_to_hostif[2]; uint8 *debug_msg, *local_ptr; uint16 i; debug_msg = (uint8 *) &(hostif_debug_string_buffer[0]); *debug_msg++ = HOSTIF_GROUP_MSG_STM_DEBUG_AND_TRACE; *debug_msg++ = 0x03; /* ErrorCode message ID */ *debug_msg++ = HOSTIF_DEBUG_PROTOCOL_VERSION; /* short error description */ *debug_msg++ = error; /* build the state parameter */ *debug_msg++ = cap_debug_to_hostif & 0xFF; local_ptr = &ctr_debug_to_hostif[0]; for (i = 0; i < 6; i++) { *debug_msg++ = *local_ptr++; } *debug_msg++ = player_debug_to_hostif[0]; // player state *debug_msg++ = player_debug_to_hostif[1]; // loader state hostifAppSendMsg(&(hostif_debug_string_buffer[0]), 3+10);#endif}/******************************************************************************//* Function: debugStartProfiling *//* *//*! \brief * \param * \return void * \remark Uses the (GR, ID) reserved for the debug messages * When the profiling timeout expires, HostIF task * prints the counts *//******************************************************************************/void debugStartProfiling(void){#if (1==DEBUG_INCLUDE_MIPS_PROFILING) OSAL_start_timeout(PROFILING_TIMER, 5 * T1s); Start_profiling();#endif}/******************************************************************************//* Function: hostif_reset *//* *//*! \brief Software reset of the HostIF task * \param void * \return void * \remark *//******************************************************************************/void hostif_reset(void){ hostif_inevent = 0; hostif_pending_scheduled_tx = hostif_current_scheduled_tx = 0; hostif_have_msgcmdeval = FALSE; i2c_soft_reset(); fifo_reset(&hostif_msg_fifo); hostif_state = HOSTIF_STATE_IDLE; }/******************************************************************************//* Function: hostif_process_hostcmd *//* *//*! \brief Processes commands received from the Host * \param void * \return void * \remark *//******************************************************************************/void hostif_process_hostcmd(void){ extern t_bool ConfigUpdated; static char cmd[DEFAULT_MAX_I2C_FRAME_SIZE]; uint16 cmd_len; if ((hostif_inevent & HOSTIF_EVT_LL_NEW_MSG) != 0) { //hostif_inevent &= ~HOSTIF_EVT_LL_NEW_MSG; reset_hostif_inevent(HOSTIF_EVT_LL_NEW_MSG); cmd_len = 0; hostifRecvBlock(&cmd[0], &cmd_len); if (cmd_len != 0) {#if HAVE_HOST_UPDATE_DEBUG /* remap some commands not available in the GUI */ if (cmd[HOSTIF_APP_GROUP_BYTE_INDEX] == HOSTIF_GROUP_CMD_MEDIA_INFO) { if ((cmd[HOSTIF_APP_GROUP_BYTE_INDEX+1] == 1) || (cmd[HOSTIF_APP_GROUP_BYTE_INDEX+1] == 2)) { cmd[HOSTIF_APP_GROUP_BYTE_INDEX] = HOSTIF_GROUP_CMD_UPDATE_FILE; } else if (cmd[HOSTIF_APP_GROUP_BYTE_INDEX+1] == 6) { cmd[HOSTIF_APP_GROUP_BYTE_INDEX] = HOSTIF_GROUP_CMD_UPDATE_FILE; cmd[HOSTIF_APP_GROUP_BYTE_INDEX+1] = 3; } } /* end of debug */#endif switch (cmd[HOSTIF_APP_GROUP_BYTE_INDEX]) { case HOSTIF_GROUP_CMD_PLAYER_INFO: hostifAppProcessPlayerInfoGroup(cmd, cmd_len); break; case HOSTIF_GROUP_CMD_PLAYER_CONF: ConfigUpdated = b_TRUE; hostifAppProcessPlayerConfigGroup(cmd, cmd_len); break; case HOSTIF_GROUP_CMD_PLAYER_FUNC: hostifAppProcessPlayerFunctionGroup(cmd, cmd_len); break; case HOSTIF_GROUP_CMD_MEDIA_INFO: hostifAppProcessMediaInfoGroup(cmd, cmd_len); break;#if 0 // will not be implemented case HOSTIF_GROUP_CMD_FILE_COMMANDS: hostifAppProcessFileCommandsGroup(cmd, cmd_len); break;#endif#if ((0 != HAVE_HOST_UPDATE) || (0 != HAVE_HOST_UPDATE_NEW) || (0!=IPOD_PASSTHROUGH)) case HOSTIF_GROUP_CMD_BINARY_TRANSFER: hostifAppProcessBinaryTransfersGroup(cmd, cmd_len); break;#endif#if (STM_HOSTIF_USE_DEBUG_AND_TRACE==1) case HOSTIF_GROUP_CMD_STM_DEBUG_AND_TRACE: debugStartProfiling(); // no cmd ID used for now break;#endif default: hostifAppSendMsgCmdEval(CMDE_ILLEGAL_COMMAND, cmd[HOSTIF_APP_GROUP_BYTE_INDEX], cmd[HOSTIF_APP_ID_BYTE_INDEX] ); break; } } }#if (1 == HAVE_TEMP_SENSOR) //for spontaneous send out the msg if ((hostif_inevent & HOSTIF_SPONTANEOUS_SEND_MSG) != 0) { //hostif_inevent &= ~HOSTIF_SPONTANEOUS_SEND_MSG; reset_hostif_inevent(HOSTIF_SPONTANEOUS_SEND_MSG); report_msg_temperature(); }#endif}/******************************************************************************//* Function: hostif_process_scheduled_tx *//* *//*! \brief Framework to process messages split across several packets * \param void * \return void * \remark *//******************************************************************************/void hostif_process_scheduled_tx(void){ extern t_binary_trasnfer_mode binary_trasfer_mode;#if (0!=IPOD_PASSTHROUGH) t_bool send = b_FALSE;#if (0 != IPOD_AP) t_usb_upstream_cmd_event player_upstream_cmd;#else /* !IPOD_AP */ t_usb_upstream_cmd_event hostif_upstream_command;#endif /* IPOD_AP */ #endif /* IPOD_PASSTHROUGH */ t_player_cmd_event player_command; if ((hostif_current_scheduled_tx == 0) && (hostif_pending_scheduled_tx != 0)) { /* This code defines the priority of scheduled messages */ if (hostif_pending_scheduled_tx & HOSTIF_SCHEDULED_ENTRY_NAME) { hostif_activate_pending_tx(HOSTIF_SCHEDULED_ENTRY_NAME); } if (hostif_pending_scheduled_tx & HOSTIF_SCHEDULED_LONG_ENTRY_NAME) { hostif_activate_pending_tx(HOSTIF_SCHEDULED_LONG_ENTRY_NAME); } else if (hostif_pending_scheduled_tx & HOSTIF_SCHEDULED_TEXT_INFO) { hostif_activate_pending_tx(HOSTIF_SCHEDULED_TEXT_INFO); } else if (hostif_pending_scheduled_tx & HOSTIF_SCHEDULED_ROM_DATA) { hostif_activate_pending_tx(HOSTIF_SCHEDULED_ROM_DATA); } else if (hostif_pending_scheduled_tx & HOSTIF_SCHEDULED_PLAYLIST_CONTENT) { hostif_activate_pending_tx(HOSTIF_SCHEDULED_PLAYLIST_CONTENT); } else if (hostif_pending_scheduled_tx & HOSTIF_SCHEDULED_UPDATE_IMAGE) { hostif_activate_pending_tx(HOSTIF_SCHEDULED_UPDATE_IMAGE); } } switch (hostif_current_scheduled_tx) { case HOSTIF_SCHEDULED_ENTRY_NAME: report_msg_entry_name(&saved_msgEntryParameters, USE_SHORT_NAME); hostif_deschedule_current(); break; case HOSTIF_SCHEDULED_LONG_ENTRY_NAME: if ((fifo_has_msg(&hostif_msg_fifo) == FALSE) && (report_msg_entry_name(&saved_msgLongEntryParameters, USE_LONG_NAME) == 0)) { hostif_deschedule_current(); } break; case HOSTIF_SCHEDULED_TEXT_INFO: if ((fifo_has_msg(&hostif_msg_fifo) == FALSE) && (report_msg_text_info() == 0)) { hostif_deschedule_current(); } break; case HOSTIF_SCHEDULED_ROM_DATA: if ((fifo_has_msg(&hostif_msg_fifo) == FALSE) && (report_msg_rom_media_content() == 0)) { hostif_deschedule_current(); } break; case HOSTIF_SCHEDULED_DIR_CONTENT: if ((fifo_has_msg(&hostif_msg_fifo) == FALSE) && (report_msg_dir_content() == 0)) { hostif_deschedule_current(); } break; case HOSTIF_SCHEDULED_PLAYLIST_CONTENT: if ((fifo_has_msg(&hostif_msg_fifo) == FALSE) && (report_msg_current_playlist_abs_content() == 0)) { hostif_deschedule_current(); } break;#if ((0 != HAVE_HOST_UPDATE) || (0 != HAVE_HOST_UPDATE_NEW) || (0!=IPOD_PASSTHROUGH)) case HOSTIF_SCHEDULED_UPDATE_IMAGE: {#if (0!=IPOD_PASSTHROUGH) if ( (saved_BinaryUpstreamParameters.data_cnt) || ((saved_BinaryUpstreamParameters.saved_data_count) && (saved_BinaryUpstreamParameters.flags & LAST_PACKET))) { if (fifo_has_msg(&hostif_msg_fifo) == FALSE) { //last data came, send anyway if (saved_BinaryUpstreamParameters.flags & LAST_PACKET) send = b_TRUE; //enough data for packet to be sent if ((saved_BinaryUpstreamParameters.data_cnt + saved_BinaryUpstreamParameters.saved_data_count) >= saved_BinaryUpstreamParameters.packet_size) send = b_TRUE; /* Update Flash is a special case, the packet should be sent */ /* only if it was requested by Host */ if ((HOST_UPDATE_MODE == binary_trasfer_mode) || (RESUME_MODE == binary_trasfer_mode)) { if (saved_BinaryUpstreamParameters.send_msg_now == b_TRUE) { saved_BinaryUpstreamParameters.send_msg_now = b_FALSE; send = b_TRUE; } else /* wait for command request */ { break; } /* since there's passed only one data packet pointing to hostifStoredData, crc can be calculated here */ if (RESUME_MODE == binary_trasfer_mode) { hostif_calculate_checksum(); } } if (send) { if (!(report_msg_binary_packet(&saved_BinaryUpstreamParameters))) { switch (binary_trasfer_mode) { /* report to different tasks according to transfer mode */ case RESUME_MODE: //inform player about transfer has been processed player_command.command = PCMD_UPDATE_NEXT_PACKET; player_command.cmd_params[0] = RESUME_INFO; player_cmd(&player_command); break; case HOST_UPDATE_MODE: //inform player about transfer has been processed player_command.command = PCMD_UPDATE_NEXT_PACKET; player_command.cmd_params[0] = HOST_UPDATE; player_cmd(&player_command); break;#if (0 != HAVE_USB)#if (0!=IPOD_PASSTHROUGH) case IPOD_MODE:#if (0 != IPOD_AP) //send status to USB through player player_upstream_cmd.DataTag = saved_BinaryUpstreamParameters.DataTag; //send back data transfer nr. player_upstream_command(&player_upstream_cmd);#else /* !IPOD_AP */ //send status to USB hostif_upstream_command.DataTag = saved_BinaryUpstreamParameters.DataTag; //send back data transfer nr. usb_upstream_command(&hostif_upstream_command);#endif /* IPOD_AP */ break;#endif /*IPOD_PASSTHROUGH*/#endif /* HAVE_USB */ } } } } //not enough data tb sent, store to tmp buffer else if ((!(saved_BinaryUpstreamParameters.flags & LAST_PACKET)) && ((saved_BinaryUpstreamParameters.data_cnt + saved_BinaryUpstreamParameters.saved_data_count) < saved_BinaryUpstreamParameters.packet_size)) { /* send = b_FALSE; */ //copy short memcpy(saved_BinaryUpstreamParameters.saved_data_buffer + saved_BinaryUpstreamParameters.saved_data_count, saved_BinaryUpstreamParameters.data_ptr, saved_BinaryUpstreamParameters.data_cnt); saved_BinaryUpstreamParameters.saved_data_count += saved_BinaryUpstreamParameters.data_cnt; saved_BinaryUpstreamParameters.data_cnt = 0; switch (binary_trasfer_mode) { /* report to different tasks according to transfer mode */ case HOST_UPDATE_MODE: case RESUME_MODE: //inform player about transfer has been processed player_command.command = PCMD_UPDATE_NEXT_PACKET; player_cmd(&player_command); break;#if (0 != HAVE_USB)#if (0!=IPOD_PASSTHROUGH) case IPOD_MODE:#if (0 != IPOD_AP) //send status to USB through player player_upstream_cmd.DataTag = saved_BinaryUpstreamParameters.DataTag; //send back data transfer nr. player_upstream_command(&player_upstream_cmd); #else /* !IPOD_AP */ //send status to USB hostif_upstream_command.DataTag = saved_BinaryUpstreamParameters.DataTag; //send back data transfer nr. usb_upstream_command(&hostif_upstream_command); #endif /* IPOD_AP */ break;#endif /*IPOD_PASSTHROUGH*/#endif /* HAVE_USB */ } } // else no processing, wait for empty hostif buffer }#endif /*IPOD_PASSTHROUGH*/ } break;#endif /* HAVE_HOST_UPDATE_NEW || IPOD_PASSTHROUGH */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -