int libDHStandard<T, B, S>::DHClear() { for(size_t x=0,x_e=rBP.size();x!=x_e;++x) { delete rBP[x]; } rBP.clear(); if(isMyObs) { if(y!=NULL) { y->clear(); delete y; y = NULL; } } if(isMyGraph) { if(phi!=NULL) { for(size_t x=0;x<phi->x->size();++x) { ClearFeature(phi->x->at(x)); } phi->x->clear(); delete phi->x; delete phi; phi = NULL; } } else { delete phi; phi = NULL; y = NULL; } return 0; }
U8 SCSICMD_23_READFORMATCAPACITY(void) { xdata U8 i; data U8 j; data U8 tc_state; code U8 READ_FORMAT_CAPACITY[31]={0x55,0x53,0x42,0x43,0x55,0xAA,0xBB,0x05,0xFC,0x00,0x00,0x00,0x80,0x00,0x0A,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; while(1) { // Prepare CBW data for(i=0;i<31;i++) { XBYTE[HOST_BUF_SA+i]=READ_FORMAT_CAPACITY[i]; } // OUT CBW tran_out(DeviceAddress, 31); Host_phy_Command_check(); delay(1000); // IN data(The data is useless) if(gb_HostConnect == 0) { return HOST_PHYCOUNECT_FAIL; } for(j=0;j<4;j++) { gb_shortpack=0; tran_in(DeviceAddress, 64, 0); tc_state = Host_phy_Command_check(); if((gb_shortpack==1)||(tc_state==HOST_STALL)) // 20080620 { break; } } if(tc_state==HOST_STALL) { gb_dtg_in=0; ClearFeature(DeviceAddress,0,EP_IN,0); tran_in(DeviceAddress, 13, 0); tc_state = Host_phy_Command_check(); if(tc_state!=0) // 20080620 { return tc_state; } delay(10000); SCSICMD_03_REQUESTSENSE(); delay(10000); } else { // 20080623 tran_in_(DeviceAddress, 13, 0); tc_state=Host_phy_Command_check(); if(tc_state==HOST_STALL) { gb_dtg_in=0; ClearFeature(DeviceAddress,0,EP_IN,0); tran_in(DeviceAddress, 13, 0); Host_phy_Command_check(); } return 0; } if(gb_Repeat==0) { return 0; } } }
U8 SCSICMD_25_READCAPACITY(void) { code U8 READ_CAPACITY[31]={0x55,0x53,0x42,0x43,0x55,0xAA,0xBB,0x05,0x08,0x00,0x00,0x00,0x80,0x00,0x0A,0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; data U8 tc_state; xdata U8 i; // Prepare CBW data for(i=0;i<31;i++) { XBYTE[HOST_BUF_SA+i]=READ_CAPACITY[i]; } // OUT CBW tran_out(DeviceAddress, 31); Host_phy_Command_check(); delay(1000); //for action mp3 player // IN data tran_in(DeviceAddress, 8 , 0); tc_state=Host_phy_Command_check(); gc_HostSectorUnit=XBYTE[HOST_BUF_SA+6]/2; if(!tc_state) { ((U8 *)(&gdw_CARD_TotalSizeMB))[0]=XBYTE[HOST_BUF_SA+0]; ((U8 *)(&gdw_CARD_TotalSizeMB))[1]=XBYTE[HOST_BUF_SA+1]; ((U8 *)(&gdw_CARD_TotalSizeMB))[2]=XBYTE[HOST_BUF_SA+2]; ((U8 *)(&gdw_CARD_TotalSizeMB))[3]=XBYTE[HOST_BUF_SA+3]; } if(tc_state==HOST_STALL) { Host_StallCmd_Timeout++; gb_dtg_in=0; ClearFeature(DeviceAddress,0,EP_IN,0); tran_in(DeviceAddress, 13, 0); tc_state = Host_phy_Command_check(); if(tc_state!=0) // 20080620 { return tc_state; } SCSICMD_03_REQUESTSENSE(); delay(10000); return HOST_STALL; } if(tc_state!=0) { gb_dtg_in=0; Syn_Reset(); ClearFeature(DeviceAddress,0,EP_IN,0); } // IN CSW delay(1000); tran_in(DeviceAddress, 13, 0); Host_phy_Command_check(); if(XBYTE[HOST_BUF_SA+12]!=0) { SCSICMD_03_REQUESTSENSE(); return 1; } else { return 0; } }
/***************************************************************************//** * @brief Processes Standard Request (Chapter 9 Command) * @return Status of request (type @ref USB_Status_TypeDef) * @note This function takes no parameters, but it uses the setup command * stored in @ref myUsbDevice.setup. ******************************************************************************/ USB_Status_TypeDef USBDCH9_SetupCmd(void) { USB_Status_TypeDef status = USB_STATUS_OK; switch (myUsbDevice.setup.bRequest) { case GET_STATUS: status = GetStatus(); break; case CLEAR_FEATURE: status = ClearFeature(); break; case SET_FEATURE: status = SetFeature(); break; case SET_ADDRESS: status = SetAddress(); break; case GET_DESCRIPTOR: status = GetDescriptor(); break; case GET_CONFIGURATION: status = GetConfiguration(); break; case SET_CONFIGURATION: status = SetConfiguration(); break; case GET_INTERFACE: status = GetInterface(); break; case SET_INTERFACE: status = SetInterface(); break; // case GET_MS_DESCRIPTOR: // status = HandleMsRequest(); // break; default: status = USB_STATUS_REQ_ERR; break; } // Reset index to 0 in case one of the above commands modified it USB_SetIndex(0); // If the command resulted in an error, send a procedural stall if (status == USB_STATUS_REQ_ERR) { SendEp0Stall(); } return status; }