diff --git a/bsp/stm32_radio/Libraries/Mass_Storage/inc/mass_mal.h b/bsp/stm32_radio/Libraries/Mass_Storage/inc/mass_mal.h index 142969e6f..0de1d6310 100644 --- a/bsp/stm32_radio/Libraries/Mass_Storage/inc/mass_mal.h +++ b/bsp/stm32_radio/Libraries/Mass_Storage/inc/mass_mal.h @@ -22,7 +22,6 @@ /* Exported constants --------------------------------------------------------*/ #define MAL_OK 0 #define MAL_FAIL 1 -#define MAX_LUN 1 /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ diff --git a/bsp/stm32_radio/Libraries/Mass_Storage/src/mass_mal.c b/bsp/stm32_radio/Libraries/Mass_Storage/src/mass_mal.c index f63527334..9234a0edb 100644 --- a/bsp/stm32_radio/Libraries/Mass_Storage/src/mass_mal.c +++ b/bsp/stm32_radio/Libraries/Mass_Storage/src/mass_mal.c @@ -15,13 +15,13 @@ /* Includes ------------------------------------------------------------------*/ #include "platform_config.h" -#include "sdcard.h" #include "mass_mal.h" #include "rtthread.h" -uint32_t Mass_Memory_Size[2]; -uint32_t Mass_Block_Size[2]; -uint32_t Mass_Block_Count[2]; +uint32_t Mass_Memory_Size[3]; +uint32_t Mass_Block_Size[3]; +uint32_t Mass_Block_Count[3]; +uint32_t Max_Lun = 0; rt_device_t dev_sdio = RT_NULL; diff --git a/bsp/stm32_radio/Libraries/Mass_Storage/src/scsi_data.c b/bsp/stm32_radio/Libraries/Mass_Storage/src/scsi_data.c index 2862ceac3..d5dffec6b 100644 --- a/bsp/stm32_radio/Libraries/Mass_Storage/src/scsi_data.c +++ b/bsp/stm32_radio/Libraries/Mass_Storage/src/scsi_data.c @@ -17,66 +17,65 @@ #include "usb_scsi.h" #include "memory.h" uint8_t Page00_Inquiry_Data[] = - { +{ 0x00, /* PERIPHERAL QUALIFIER & PERIPHERAL DEVICE TYPE*/ 0x00, 0x00, 0x00, 0x00 /* Supported Pages 00*/ - }; +}; uint8_t Standard_Inquiry_Data[] = - { +{ 0x00, /* Direct Access Device */ 0x80, /* RMB = 1: Removable Medium */ 0x02, /* Version: No conformance claim to standard */ 0x02, - 36 - 4, /* Additional Length */ + 36 - 4, /* Additional Length */ 0x00, /* SCCS = 1: Storage Controller Component */ 0x00, 0x00, /* Vendor Identification */ - 'S', 'T', 'M', ' ', 'C', 'M', '-', '3', + 'S', 'T', 'M', '3', '2', ' ', ' ', ' ', /* Product Identification */ - 'S', 'D', ' ', 'F', 'l', 'a', 's', 'h', ' ', - 'D', 'i', 's', 'k', ' ', ' ', ' ', + 'n', 'e', 't', 'r', 'a', 'd', 'i', 'o', ' ', + 'D', 'I', 'S', 'K', '1', ' ', ' ', /* Product Revision Level */ '1', '.', '0', ' ' - }; +}; uint8_t Standard_Inquiry_Data2[] = - { - 0x00, /* Direct Access Device *///磁盘设备 - //其中最高位D7为RMB。RMB=0,表示不可移除设备。如果RMB=1,则为可移除设备。 +{ + 0x00, /* Direct Access Device */ 0x80, /* RMB = 1: Removable Medium */ 0x02, /* Version: No conformance claim to standard */ - 0x02, //数据响应格式 + 0x02, /* 数据响应格式 */ - 36 - 4, //附加数据长度,为31字节 + 36 - 4, /* 附加数据长度,为31字节 */ 0x00, /* SCCS = 1: Storage Controller Component */ 0x00, 0x00, /* Vendor Identification */ - 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', + 'S', 'T', 'M', '3', '2', ' ', ' ', ' ', /* Product Identification */ - 'N', 'A', 'N', 'D', ' ', 'F', 'l', 'a', 's', 'h', ' ', - 'D', 'i', 's', 'k', ' ', + 'n', 'e', 't', 'r', 'a', 'd', 'i', 'o', ' ', + 'D', 'I', 'S', 'K', '2', ' ', ' ', /* Product Revision Level */ '1', '.', '0', ' ' - }; +}; /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ uint8_t Mode_Sense6_data[] = - { +{ 0x03, 0x00, 0x00, 0x00, - }; +}; /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ uint8_t Mode_Sense10_data[] = - { +{ 0x00, 0x06, 0x00, @@ -85,9 +84,9 @@ uint8_t Mode_Sense10_data[] = 0x00, 0x00, 0x00 - }; +}; uint8_t Scsi_Sense_Data[] = - { +{ 0x70, /*RespCode*/ 0x00, /*SegmentNumber*/ NO_SENSE, /* Sens_Key*/ @@ -106,9 +105,9 @@ uint8_t Scsi_Sense_Data[] = 0x00, /*TBD*/ 0x00, 0x00 /*SenseKeySpecific*/ - }; +}; uint8_t ReadCapacity10_Data[] = - { +{ /* Last Logical Block */ 0, 0, @@ -120,10 +119,10 @@ uint8_t ReadCapacity10_Data[] = 0, 0, 0 - }; +}; uint8_t ReadFormatCapacity_Data [] = - { +{ 0x00, 0x00, 0x00, @@ -140,6 +139,6 @@ uint8_t ReadFormatCapacity_Data [] = 0, 0, 0 - }; +}; /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_bot.c b/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_bot.c index 8071f7662..49ace5636 100644 --- a/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_bot.c +++ b/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_bot.c @@ -21,6 +21,7 @@ #include "usb_conf.h" #include "usb_bot.h" #include "memory.h" + /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ @@ -81,26 +82,21 @@ void Mass_Storage_In (void) void Mass_Storage_Out (void) { uint8_t CMD; - CMD = CBW.CB[0];//寰楀埌涓婁竴娆$殑? - //寰楀埌绔偣2鎺ユ敹鍒扮殑鏁版嵁闀垮害 + CMD = CBW.CB[0]; Data_Len = GetEPRxCount(ENDP2); - //print(" MS_Out:");//print_dec(Data_Len); - //璇诲嚭鏁版嵁鍒 Bulk_Data_Buff + /* read data to Bulk_Data_Buff */ PMAToUserBufferCopy(Bulk_Data_Buff, ENDP2_RXADDR, Data_Len); switch (Bot_State) { - case BOT_IDLE://绌洪棽鐘舵 杩涘叆CBW瑙g爜 - //print("BOT_IDLE"); + case BOT_IDLE: CBW_Decode(); break; - case BOT_DATA_OUT://鏁版嵁杈撳嚭鐘舵 - //print("BOT_DATA_OUT"); + case BOT_DATA_OUT: if (CMD == SCSI_WRITE10) { - //print(" CMD == SCSI_WRITE10"); SCSI_Write10_Cmd(CBW.bLUN , SCSI_LBA , SCSI_BlkLen); break; } @@ -128,18 +124,17 @@ void CBW_Decode(void) { uint32_t Counter; - //浠嶣ulk_Data_Buff澶嶅埗鏁版嵁鍒癈BW + /* read data from Bulk_Data_Buff to CBW */ for (Counter = 0; Counter < Data_Len; Counter++) { *((uint8_t *)&CBW + Counter) = Bulk_Data_Buff[Counter]; } - //澶嶅埗TAG鐢ㄤ簬杩斿洖 + /* copy return TAG */ CSW.dTag = CBW.dTag; CSW.dDataResidue = CBW.dDataLength; - //濡傛灉鏁版嵁闀垮害涓嶇瓑浜嶤BW鐨勯暱搴 + if (Data_Len != BOT_CBW_PACKET_LENGTH) { - //print(" Data_Len != BOT_CBW_PACKET_LENGTH"); Bot_Abort(BOTH_DIR); /* reset the CBW.dSignature to desible the clear feature until receiving a Mass storage reset*/ CBW.dSignature = 0; @@ -148,22 +143,18 @@ void CBW_Decode(void) return; } - //璇诲啓鏁版嵁 if ((CBW.CB[0] == SCSI_READ10 ) || (CBW.CB[0] == SCSI_WRITE10 )) { /* Calculate Logical Block Address */ - //璁$畻閫昏緫鍧楀湴鍧 姣忎釜鎵囧尯512瀛楄妭 SCSI_LBA = (CBW.CB[2] << 24) | (CBW.CB[3] << 16) | (CBW.CB[4] << 8) | CBW.CB[5]; /* Calculate the Number of Blocks to transfer */ - //璁$畻浼犻佺殑鍧楀ぇ灏 浠ユ墖鍖轰负鍗曚綅? SCSI_BlkLen = (CBW.CB[7] << 8) | CBW.CB[8]; } - //USBC + /* USBC */ if (CBW.dSignature == BOT_CBW_SIGNATURE) { /* Valid CBW */ - //鏈夋晥浣嗗弬鏁伴敊璇 if ((CBW.bLUN > Max_Lun) || (CBW.bCBLength < 1) || (CBW.bCBLength > 16)) { Bot_Abort(BOTH_DIR); @@ -202,11 +193,9 @@ void CBW_Decode(void) SCSI_TestUnitReady_Cmd(CBW.bLUN); break; case SCSI_READ10: - //璇绘暟鎹 SCSI_Read10_Cmd(CBW.bLUN, SCSI_LBA , SCSI_BlkLen); break; case SCSI_WRITE10: - //鍐欐暟鎹 SCSI_Write10_Cmd(CBW.bLUN, SCSI_LBA , SCSI_BlkLen); break; case SCSI_VERIFY10: @@ -266,7 +255,6 @@ void CBW_Decode(void) } else { - //鏃犳晥鐨凜BW /* Invalid CBW */ Bot_Abort(BOTH_DIR); Set_Scsi_Sense_Data(CBW.bLUN, ILLEGAL_REQUEST, INVALID_COMMAND); diff --git a/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_prop.c b/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_prop.c index 204c0c358..b36658b17 100644 --- a/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_prop.c +++ b/bsp/stm32_radio/Libraries/Mass_Storage/src/usb_prop.c @@ -23,15 +23,7 @@ #include "mass_mal.h" #include "usb_prop.h" -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -#ifdef USE_STM3210B_EVAL -uint32_t Max_Lun = 0; -#else //USE_STM3210E_EVAL -uint32_t Max_Lun = 1; -#endif +extern uint32_t Max_Lun; DEVICE Device_Table = { @@ -258,13 +250,11 @@ RESULT MASS_Data_Setup(uint8_t RequestNo) { uint8_t *(*CopyRoutine)(uint16_t); - //print("MASS_Data_Setup"); CopyRoutine = NULL; if ((Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT)) && (RequestNo == GET_MAX_LUN) && (pInformation->USBwValue == 0) && (pInformation->USBwIndex == 0) && (pInformation->USBwLength == 0x01)) { - //print(" Get_Max_Lun\r\n"); CopyRoutine = Get_Max_Lun; } else