Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
d368611e
Commit
d368611e
authored
Sep 29, 2014
by
Dave Hylands
Committed by
Damien George
Oct 01, 2014
Browse files
Proposed fix for USB Mass Storage.
parent
c737086e
Changes
3
Hide whitespace changes
Inline
Side-by-side
stmhal/usbd_msc_storage.c
View file @
d368611e
...
...
@@ -41,10 +41,10 @@
// These are needed to support removal of the medium, so that the USB drive
// can be unmounted, and won't be remounted automatically.
static
uint8_t
flash_
remov
ed
=
0
;
static
uint8_t
flash_
start
ed
=
0
;
#if MICROPY_HW_HAS_SDCARD
static
uint8_t
sdcard_
remov
ed
=
0
;
static
uint8_t
sdcard_
start
ed
=
0
;
#endif
/******************************************************************************/
...
...
@@ -73,6 +73,7 @@ static const int8_t FLASH_STORAGE_Inquirydata[] = { // 36 bytes
*/
int8_t
FLASH_STORAGE_Init
(
uint8_t
lun
)
{
storage_init
();
flash_started
=
1
;
return
0
;
}
...
...
@@ -95,10 +96,10 @@ int8_t FLASH_STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *blo
* @retval Status
*/
int8_t
FLASH_STORAGE_IsReady
(
uint8_t
lun
)
{
if
(
flash_
remov
ed
)
{
return
-
1
;
if
(
flash_
start
ed
)
{
return
0
;
}
return
0
;
return
-
1
;
}
/**
...
...
@@ -111,8 +112,8 @@ int8_t FLASH_STORAGE_IsWriteProtected(uint8_t lun) {
}
// Remove the lun
int8_t
FLASH_STORAGE_StopUnit
(
uint8_t
lun
)
{
flash_
removed
=
1
;
int8_t
FLASH_STORAGE_
Start
StopUnit
(
uint8_t
lun
,
uint8_t
started
)
{
flash_
started
=
started
;
return
0
;
}
...
...
@@ -176,7 +177,7 @@ const USBD_StorageTypeDef USBD_FLASH_STORAGE_fops = {
FLASH_STORAGE_GetCapacity
,
FLASH_STORAGE_IsReady
,
FLASH_STORAGE_IsWriteProtected
,
FLASH_STORAGE_StopUnit
,
FLASH_STORAGE_
Start
StopUnit
,
FLASH_STORAGE_PreventAllowMediumRemoval
,
FLASH_STORAGE_Read
,
FLASH_STORAGE_Write
,
...
...
@@ -228,7 +229,7 @@ int8_t SDCARD_STORAGE_Init(uint8_t lun) {
if
(
!
sdcard_power_on
())
{
return
-
1
;
}
sdcard_started
=
1
;
return
0
;
}
...
...
@@ -264,33 +265,10 @@ int8_t SDCARD_STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *bl
* @retval Status
*/
int8_t
SDCARD_STORAGE_IsReady
(
uint8_t
lun
)
{
if
(
sdcard_
remov
ed
)
{
return
-
1
;
if
(
sdcard_
start
ed
)
{
return
0
;
}
/*
#ifndef USE_STM3210C_EVAL
static int8_t last_status = 0;
if(last_status < 0)
{
SD_Init();
last_status = 0;
}
if(SD_GetStatus() != 0)
{
last_status = -1;
return (-1);
}
#else
if( SD_Init() != 0)
{
return (-1);
}
#endif
*/
return
0
;
return
-
1
;
}
/**
...
...
@@ -303,8 +281,8 @@ int8_t SDCARD_STORAGE_IsWriteProtected(uint8_t lun) {
}
// Remove the lun
int8_t
SDCARD_STORAGE_StopUnit
(
uint8_t
lun
)
{
sdcard_
removed
=
1
;
int8_t
SDCARD_STORAGE_
Start
StopUnit
(
uint8_t
lun
,
uint8_t
started
)
{
sdcard_
started
=
started
;
return
0
;
}
...
...
@@ -356,7 +334,7 @@ const USBD_StorageTypeDef USBD_SDCARD_STORAGE_fops = {
SDCARD_STORAGE_GetCapacity
,
SDCARD_STORAGE_IsReady
,
SDCARD_STORAGE_IsWriteProtected
,
SDCARD_STORAGE_StopUnit
,
SDCARD_STORAGE_
Start
StopUnit
,
SDCARD_STORAGE_PreventAllowMediumRemoval
,
SDCARD_STORAGE_Read
,
SDCARD_STORAGE_Write
,
...
...
stmhal/usbdev/class/cdc_msc_hid/inc/usbd_cdc_msc_hid.h
View file @
d368611e
...
...
@@ -58,7 +58,7 @@ typedef struct _USBD_STORAGE {
int8_t
(
*
GetCapacity
)
(
uint8_t
lun
,
uint32_t
*
block_num
,
uint16_t
*
block_size
);
int8_t
(
*
IsReady
)
(
uint8_t
lun
);
int8_t
(
*
IsWriteProtected
)
(
uint8_t
lun
);
int8_t
(
*
StopUnit
)(
uint8_t
lun
);
int8_t
(
*
Start
StopUnit
)(
uint8_t
lun
,
uint8_t
started
);
int8_t
(
*
PreventAllowMediumRemoval
)(
uint8_t
lun
,
uint8_t
param0
);
int8_t
(
*
Read
)
(
uint8_t
lun
,
uint8_t
*
buf
,
uint32_t
blk_addr
,
uint16_t
blk_len
);
int8_t
(
*
Write
)(
uint8_t
lun
,
uint8_t
*
buf
,
uint32_t
blk_addr
,
uint16_t
blk_len
);
...
...
stmhal/usbdev/class/cdc_msc_hid/src/usbd_msc_scsi.c
View file @
d368611e
...
...
@@ -450,13 +450,10 @@ static int8_t SCSI_StartStopUnit(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t
hmsc
->
bot_data_length
=
0
;
// On Mac OS X, when the device is ejected a SCSI_START_STOP_UNIT command is sent.
// params[1]==0 means stop, param[1]==1 seems to be something else (happens after the
// device is plugged in and mounted for some time, probably a keep alive).
// Bit 0 of params[4] is the START bit.
// If we get a stop, we must really stop the device so that the Mac does not
// automatically remount it.
if
(
params
[
1
]
==
0
)
{
((
USBD_StorageTypeDef
*
)
pdev
->
pUserData
)
->
StopUnit
(
lun
);
}
((
USBD_StorageTypeDef
*
)
pdev
->
pUserData
)
->
StartStopUnit
(
lun
,
params
[
4
]
&
1
);
return
0
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment