summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwuyangyong <[email protected]>2009-12-31 15:40:59 +0000
committerwuyangyong <[email protected]>2009-12-31 15:40:59 +0000
commit620cde72e30050c0996bf1209e6345d5c783f28d (patch)
treeab4dbc72401ae61b04b458f8ce3ae759a6db4c76
parentaecf1601d8f380a507abf65a82772865ee29d670 (diff)
fix netradio mass_storage
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@270 bbd45198-f89e-11dd-88c7-29a3b14d5316
-rw-r--r--bsp/stm32_radio/Libraries/Mass_Storage/inc/mass_mal.h1
-rw-r--r--bsp/stm32_radio/Libraries/Mass_Storage/src/mass_mal.c8
-rw-r--r--bsp/stm32_radio/Libraries/Mass_Storage/src/scsi_data.c53
-rw-r--r--bsp/stm32_radio/Libraries/Mass_Storage/src/usb_bot.c30
-rw-r--r--bsp/stm32_radio/Libraries/Mass_Storage/src/usb_prop.c12
5 files changed, 40 insertions, 64 deletions
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 142969e6fc..0de1d63107 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 f635273347..9234a0edbe 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 2862ceac31..d5dffec6b7 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 8071f7662d..49ace5636f 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解码
- //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;
- //从Bulk_Data_Buff复制数据到CBW
+ /* 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;
- //如果数据长度不等于CBW的长度
+
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
{
- //无效的CBW
/* 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 204c0c358c..b36658b175 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