hostif_high.c

来自「本程序为ST公司开发的源代码」· C语言 代码 · 共 2,071 行 · 第 1/5 页

C
2,071
字号
    else    {      uint16 i;            response_msg[0] = HOSTIF_GROUP_MSG_PLAYER_INFO;      response_msg[1] = MSG_MECH_PARAMETER;      for (i = 1; i <= MAX_SERVO_PARAMETER; i++)      {        response_msg[i + 1] = hostif_servo_parameters_vector[i];      }      response_msg[MAX_SERVO_PARAMETER + 2] = hostif_servo_parameters_vector[STARTUP_STATUS_BYTE];      hostifAppSendMsg(&response_msg[0], MAX_SERVO_PARAMETER + 3);    }    break;      case REQ_USB_HIGH_Z:         player_command.command = PCMD_USB_HIGH_Z;      player_command.cmd_params[0] = hostifAppGetParameter(cmd, PAR1);      player_command.flash_operation = FLASH_DATA_NO_OPERATION;      player_cmd(&player_command);              break;    case REQ_MECH_MEASUREMENTS:                if(ACQ_STATUS.field.unlocked)      {       hf_level = 0x00;      }      else      {       if(PWM_POWER_ON != power_mode)       {        hf_level = 0;       }       else       {        hf_level = dsp_read_ymem(HFLDEC_ADD);       }       }                                         hf_level >>= 4;                  response_msg[0] = HOSTIF_GROUP_MSG_PLAYER_INFO;      response_msg[1] = MSG_MECH_MEASUREMENTS;          response_msg[2] = jitter_percentage_val;      response_msg[3] = (hf_level & 0xFF00) >> 8;      response_msg[4] = (hf_level & 0xFF);            hostifAppSendMsg(&response_msg[0], 5);       break;    case REQ_MISSING_ITEMS:   response_msg[0] = HOSTIF_GROUP_MSG_PLAYER_INFO;   response_msg[1] = MSG_MISSING_ITEMS;          response_msg[2] = (ItemsThrown & 0xFF00) >> 8;   response_msg[3] = (ItemsThrown & 0xFF);   hostifAppSendMsg(&response_msg[0], 4);  break;    default:    hostifAppSendMsgCmdEval(CMDE_ILLEGAL_COMMAND, HOSTIF_GROUP_CMD_PLAYER_INFO, cmd_id);    break;  }}/************************************************** * * hostifAppProcessPlayerConfigGroup() *  * Parameters: *  TBD, *  * Description: * Application Layer Command Processing function. * Processes commands of the group 0x02 (Player Configuration) *  * *************************************************/void hostifAppProcessPlayerConfigGroup(char *cmd, uint16 cmd_len){  t_player_cmd_event * pout_event;  t_player_cmd_event player_cmd_event;  uint8 cmd_id = *(cmd + 1);  char response_msg[HOSTIF_MAX_BLOCK_SIZE];  uint8 addr;  uint8 length;  uint8 mask_0;  uint8 mask_1;  uint8 index;  switch (cmd_id)  {  case CMD_WRITE_CFG_TABLE:    addr = hostifAppGetParameter(cmd, PAR1);    length = hostifAppGetParameter(cmd, PAR2);    if ((addr > MODULE_CONFIG_SIZE - 1) || (length == 0))    {    	hostifAppSendMsgCmdEval(CMDE_ILLEGAL_PARAMETER, HOSTIF_GROUP_CMD_PLAYER_CONF, CMD_WRITE_CFG_TABLE);    	return; /* avoid sending update event to Player */    }        if (addr + length - 1 > MODULE_CONFIG_SIZE - 1)    {    	length = MODULE_CONFIG_SIZE - addr;    }        index = 0;    while (index < length)    {      mconfig_write_byte(addr + index, hostifAppGetParameter(cmd, (hostifParameterIdType)(PAR3 + index)));      index++;    }    mconfig_update_params(addr, length);    if (length > HOSTIF_MAX_BLOCK_SIZE - 4)    {    	length = HOSTIF_MAX_BLOCK_SIZE - 4;    }    response_msg[0] = HOSTIF_GROUP_MSG_PLAYER_INFO;    response_msg[1] = MSG_CONFIG_VALUE;    response_msg[2] = addr;    response_msg[3] = length;    index = 0;    while (index < length)    {      response_msg[index + 4] = mconfig_read_byte(addr + index);      index++;    }    hostifAppSendMsg(&response_msg[0], length + 4);    break;  case CMD_READ_CFG_TABLE:    addr = hostifAppGetParameter(cmd, PAR1);    length = hostifAppGetParameter(cmd, PAR2);    if (length > HOSTIF_MAX_BLOCK_SIZE - 4)    {    	length = HOSTIF_MAX_BLOCK_SIZE - 4;    }    response_msg[0] = HOSTIF_GROUP_MSG_PLAYER_INFO;    response_msg[1] = MSG_CONFIG_VALUE;    response_msg[2] = addr;    response_msg[3] = length;    index = 0;    while (index < length)    {      response_msg[index + 4] = mconfig_read_byte(addr + index);      index++;    }    hostifAppSendMsg(&response_msg[0], length + 4);    break;  case CMD_WRITE_CFG_BITS: // [FD] not a CIS command, internal only for debug    addr = hostifAppGetParameter(cmd, PAR1);    mask_0 = hostifAppGetParameter(cmd, PAR2);    mask_1 = hostifAppGetParameter(cmd, PAR3);    mconfig_write_bits(addr, mask_0, mask_1);    mconfig_update_params(addr, 1);    response_msg[0] = HOSTIF_GROUP_MSG_PLAYER_INFO;    response_msg[1] = MSG_CONFIG_VALUE;    response_msg[2] = addr;    response_msg[3] = 0x01;    response_msg[4] = mconfig_read_byte(addr);    hostifAppSendMsg(&response_msg[0], 5);    break;  }  //singnal config to player immediatelly    player_cmd_event.command = PCMD_CONFIG_UPDATED;  pout_event = (t_player_cmd_event *)pevent_get_out(PLAYER_CMD_EVENT);  *pout_event = player_cmd_event;  event_set_out(PLAYER_CMD_EVENT);     //priority dependent (semaphore signal immediatelly)  event_out_shedule(PLAYER_CMD_EVENT);  }/************************************************** * * check_preconditions() *  * Parameters: void *   * returns : b_TRUE if preconditions are ok *           b_FALSE preconditions not met *            * Description: Common preconditions testing *  **************************************************/t_bool check_preconditions (void){	if (power_mode != PWM_POWER_ON)	{		report_msg_error_mode(ERM_NA_STATE_ERROR);		report_msg_power_mode(power_mode);		return b_FALSE;	}	if (player_mode == PLM_STARTUP)	{		report_msg_error_mode(ERM_NA_STATE_ERROR);		report_msg_player_mode(PLM_STARTUP, player_transition_state, player_current_resume_info_available,0);		return b_FALSE;		}	else if ((player_params.device == DEV_CD_ID) && (loader_mode != LDM_STOP))	{    		report_msg_error_mode(ERM_NA_STATE_ERROR);        report_msg_loader_mode(loader_mode, LDMA_NONE);        return b_FALSE;  }  else if (0 == (player_params.device & player_params.DevicesReady))    //device not yet prepared!  {      	  	switch (player_params.device)  	{  	        case DEV_CD_ID:    		report_msg_error_mode(ERM_NA_STATE_ERROR);    		          report_msg_loader_mode(loader_mode, LDMA_NONE);        break;#if (0 != HAVE_USB)      case DEV_USB_ID:      	report_msg_error_mode(ERM_NA_STATE_ERROR);        if (player_mount_params.DevicesWaitingForMount & DEV_USB_ID)          report_msg_insert_mode(USB_MOUNT, player_mount_params.VID, player_mount_params.PID);        else          report_msg_insert_mode(USB_DISCONNECT, DUMMY_VALUE, DUMMY_VALUE);#endif /* HAVE_USB */        break;      case DEV_SDC_ID:      	report_msg_error_mode(ERM_NA_STATE_ERROR);        if (player_mount_params.DevicesWaitingForMount & DEV_SDC_ID)          report_msg_insert_mode(SDC_MOUNT, DUMMY_VALUE, DUMMY_VALUE);        else          report_msg_insert_mode(SDC_DISCONNECT, DUMMY_VALUE, DUMMY_VALUE);        break;  	}    return b_FALSE;             }  return b_TRUE; // all conditions are correct, continue }#if ((0 != HAVE_HOST_UPDATE) || (0 != HAVE_HOST_UPDATE_NEW))/************************************************** * * hostifAppProcessBinaryTransfersGroup() *  * Parameters: *  TBD, *  * Description: * Application Layer Command Processing function. * Processes commands of the group 0x06 (Flash update) *  * *************************************************/void hostifAppProcessBinaryTransfersGroup(char *cmd, uint16 cmd_len){  uint8 cmd_id = *(cmd + 1);  uint8 par1 = *(cmd + 2);  char      response_msg[3];  #if (0!=IPOD_PASSTHROUGH)  t_usb_downstream_cmd_event downstream_cmd_struct;#endif /*IPOD_PASSTHROUGH*/#if (0 != HAVE_HOST_UPDATE_NEW)  	  t_player_cmd_event player_command;    player_command.command = PCMD_NONE;  	  #endif /* HAVE_HOST_UPDATE_NEW */	      switch (cmd_id)   {    /* initialise transfers */  	case CMD_BIN_TRANSFER_START:      	  /* check preconditions */  	  if (((player_mode == PLM_STOP) && (player_transition_state == PLTS_IDLE))  	      || (player_mode == PLM_UPDATE))//  	   && (binary_trasfer_mode == NO_TRANSFER)  	  {#if (0!=IPOD_PASSTHROUGH)        /* data path from accordo to host, init vars */        saved_BinaryUpstreamParameters.packet_size = PACKET_LENGTH;         saved_BinaryUpstreamParameters.block_index = 0;        saved_BinaryUpstreamParameters.packet_index = 0;        saved_BinaryUpstreamParameters.offset = 0;        saved_BinaryUpstreamParameters.flags = 0;        saved_BinaryUpstreamParameters.data_cnt = 0;        saved_BinaryUpstreamParameters.saved_data_count = 0;        saved_BinaryUpstreamParameters.send_msg_now = b_FALSE;                /* init vars used for downstream transfers */        saved_BinaryDownstreamParameters.data_pending = b_FALSE;        saved_BinaryDownstreamParameters.last_block_nr = 0;        saved_BinaryDownstreamParameters.last_flag = LAST_PACKET_OF_FILE;        saved_BinaryDownstreamParameters.last_packet_nr = -1;        saved_BinaryDownstreamParameters.read_slot = 0;        saved_BinaryDownstreamParameters.slots_full = 0;        saved_BinaryDownstreamParameters.usb_packet_nr = 0;        saved_BinaryDownstreamParameters.write_slot = 0;#endif /*IPOD_PASSTHROUGH*/  	  }  	  else  	  {  	        	    report_msg_error_mode(ERM_NA_STATE_ERROR);  	    return;  	  }  	        switch (par1)      {        case HOST_UPDATE:#if (0 != HAVE_HOST_UPDATE_NEW)          /* mode dependent conditions */           if (  (host_update_file_index == 0)      //index containing xid of update file              || (b_FALSE == check_preconditions())             || (!(player_params.device & player_params.DevicesReady)))          {             report_msg_error_mode(ERM_NA_STATE_ERROR);             return;          }                    else           {                                binary_trasfer_mode = HOST_UPDATE_MODE;            hostif_schedule_tx(HOSTIF_SCHEDULED_UPDATE_IMAGE);            player_command.command = PCMD_UPDATE_START;              player_command.cmd_params[0] = HOST_UPDATE;            player_cmd(&player_command);      	  }#else          report_msg_error_mode(ERM_NA_STATE_ERROR);      	  #endif /* HAVE_HOST_UPDATE_NEW */	        	  break;        case IPOD:#if (0 != IPOD_PASSTHROUGH)#if (0 != HAVE_USB)          if (player_params.DevicesReady & DEV_IPOD_ID)          {                        binary_trasfer_mode = IPOD_MODE;            hostif_schedule_tx(HOSTIF_SCHEDULED_UPDATE_IMAGE);            report_msg_insert_mode(USB_READY_IPOD, player_mount_params.VID, player_mount_params.PID); // [RB] signal to Radio          }          else          {                        report_msg_error_mode(ERM_NA_STATE_ERROR);                              }#endif /* HAVE_USB */#else          report_msg_error_mode(ERM_NA_STATE_ERROR);          #endif /* IPOD_PASSTHROUGH */                    break;        case RESUME_INFO:          //tbd add preconditions          {                                binary_trasfer_mode = RESUME_MODE;            hostif_schedule_tx(HOSTIF_SCHEDULED_UPDATE_IMAGE);            player_command.command = PCMD_UPDATE_START;              player_command.cmd_params[0] = RESUME_INFO;            player_cmd(&player_command);      	  }          break;        default:            hostifAppSendMsgCmdEval(CMDE_ILLEGAL_COMMAND, HOSTIF_GROUP_CMD_BINARY_TRANSFER, cmd_id);    	    break;      }  	  break;  	    	/* Abort transfers */    	case CMD_BIN_TRANSFER_ABORT:  	  /* data path from accordo to host, init vars */  	  binary_trasfer_mode = NO_TRANSFER;#if (0!=IPOD_PASSTHROUGH)  	  saved_BinaryUpstreamParameters.packet_size = PACKET_LENGTH;       saved_BinaryUpstreamParameters.block_index = 0;      saved_BinaryUpstreamParameters.packet_index = 0;      saved_BinaryUpstreamParameters.offset = 0;      saved_BinaryUpstreamParameters.flags = 0;      saved_BinaryUpstreamParameters.data_cnt = 0;      saved_BinaryUpstreamParameters.saved_data_count = 0;      saved_BinaryUpstreamParameters.send_msg_now = b_FALSE;#endif /*IPOD_PASSTHROUGH)*/      hostif_deschedule_tx(HOSTIF_SCHEDULED_UPDATE_IMAGE);      //hostif_inevent &= ~(HOSTIF_EVT_UPDATE_BLOCK_RDY | HOSTIF_EVT_UPDATE_LAST_BLOCK_RDY | HOSTIF_SEND_UPDATE_PACKET);      reset_hostif_inevent(HOSTIF_EVT_UPDATE_BLOCK_RDY | HOSTIF_EVT_UPDATE_LAST_BLOCK_RDY | HOSTIF_SEND_UPDATE_PACKET);#if (0 != HAVE_HOST_UPDATE_NEW)  	   	  player_command.command = PCMD_UPDATE_ABORT;   	  player_cmd(&player_command);  #endif  	  break;  	    	/* Host reads data packet */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?