This commit is contained in:
hathach 2018-07-04 14:40:30 +07:00
parent ab9a0aa9bf
commit f8a593bb1b
3 changed files with 12 additions and 49 deletions

@ -1 +1 @@
Subproject commit ec3227b2202b007da1b76c20394b6f4d774f68b6 Subproject commit 3eb410cf8521755874fb9900a7f711bcafdc81d5

View File

@ -40,15 +40,6 @@
#include "pstorage.h" #include "pstorage.h"
// for formatting fatfs when Softdevice is not enabled
#include "nrf_nvmc.h"
#define SECTORS_PER_FAT 7
#define ROOT_DIR_SECTOR 8
#define SECTOR_DATA (1+SECTORS_PER_FAT+ROOT_DIR_SECTOR)
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* MACRO TYPEDEF CONSTANT ENUM /* MACRO TYPEDEF CONSTANT ENUM
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
@ -72,12 +63,6 @@ static scsi_inquiry_data_t const mscd_inquiry_data =
.product_revision = "1.0" .product_revision = "1.0"
}; };
static scsi_read_capacity10_data_t const mscd_read_capacity10_data =
{
.last_lba = ENDIAN_BE(MSC_UF2_BLOCK_NUM-1), // read capacity
.block_size = ENDIAN_BE(MSC_UF2_BLOCK_SIZE)
};
static scsi_sense_fixed_data_t mscd_sense_data = static scsi_sense_fixed_data_t mscd_sense_data =
{ {
.response_code = 0x70, .response_code = 0x70,
@ -85,14 +70,6 @@ static scsi_sense_fixed_data_t mscd_sense_data =
.additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8 .additional_sense_len = sizeof(scsi_sense_fixed_data_t) - 8
}; };
static scsi_read_format_capacity_data_t const mscd_format_capacity_data =
{
.list_length = 8,
.block_num = ENDIAN_BE(MSC_UF2_BLOCK_NUM), // write capacity
.descriptor_type = 2, // TODO formatted media, refractor to const
.block_size_u16 = ENDIAN_BE16(MSC_UF2_BLOCK_SIZE)
};
static scsi_mode_parameters_t const msc_dev_mode_para = static scsi_mode_parameters_t const msc_dev_mode_para =
{ {
.mode_data_length = 3, .mode_data_length = 3,
@ -101,19 +78,6 @@ static scsi_mode_parameters_t const msc_dev_mode_para =
.block_descriptor_length = 0 .block_descriptor_length = 0
}; };
/*------------------------------------------------------------------*/
/*
*------------------------------------------------------------------*/
static inline uint32_t lba2addr(uint32_t lba)
{
return MSC_UF2_FLASH_ADDR_START + lba*MSC_UF2_BLOCK_SIZE;
}
/*------------------------------------------------------------------*/
/*
*------------------------------------------------------------------*/
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/
/* API /* API
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
@ -152,21 +116,11 @@ int32_t tud_msc_scsi_cb (uint8_t rhport, uint8_t lun, uint8_t const scsi_cmd[16]
len = sizeof(scsi_inquiry_data_t); len = sizeof(scsi_inquiry_data_t);
break; break;
case SCSI_CMD_READ_CAPACITY_10:
ptr = &mscd_read_capacity10_data;
len = sizeof(scsi_read_capacity10_data_t);
break;
case SCSI_CMD_REQUEST_SENSE: case SCSI_CMD_REQUEST_SENSE:
ptr = &mscd_sense_data; ptr = &mscd_sense_data;
len = sizeof(scsi_sense_fixed_data_t); len = sizeof(scsi_sense_fixed_data_t);
break; break;
case SCSI_CMD_READ_FORMAT_CAPACITY:
ptr = &mscd_format_capacity_data;
len = sizeof(scsi_read_format_capacity_data_t);
break;
case SCSI_CMD_MODE_SENSE_6: case SCSI_CMD_MODE_SENSE_6:
ptr = &msc_dev_mode_para; ptr = &msc_dev_mode_para;
len = sizeof(msc_dev_mode_para); len = sizeof(msc_dev_mode_para);

View File

@ -43,6 +43,8 @@
extern "C" { extern "C" {
#endif #endif
#include "uf2/uf2cfg.h" // for block num
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// COMMON CONFIGURATION // COMMON CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -92,12 +94,19 @@
*/ */
#define CFG_TUD_CDC_FLUSH_ON_SOF 0 #define CFG_TUD_CDC_FLUSH_ON_SOF 0
// Number of supported Logical Unit Number (At least 1) // Number of supported Logical Unit Number
#define CFG_TUD_MSC_MAXLUN 1 #define CFG_TUD_MSC_MAXLUN 1
// Buffer size of Device Mass storage // Number of Blocks
#define CFG_TUD_MSC_BLOCK_NUM UF2_NUM_BLOCKS
// Block size
#define CFG_TUD_MSC_BLOCK_SZ 512
// Buffer size for each read/write transfer, the more the better
#define CFG_TUD_MSC_BUFSIZE (4*1024) #define CFG_TUD_MSC_BUFSIZE (4*1024)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// USB RAM PLACEMENT // USB RAM PLACEMENT
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+