Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
0ea73d2d
Commit
0ea73d2d
authored
Sep 20, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stm32/usbdev: Simplify pointers to MSC state and block dev operations.
parent
f8f17f48
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
61 deletions
+47
-61
ports/stm32/usbdev/class/inc/usbd_cdc_msc_hid.h
ports/stm32/usbdev/class/inc/usbd_cdc_msc_hid.h
+6
-4
ports/stm32/usbdev/class/src/usbd_cdc_msc_hid.c
ports/stm32/usbdev/class/src/usbd_cdc_msc_hid.c
+2
-18
ports/stm32/usbdev/class/src/usbd_msc_bot.c
ports/stm32/usbdev/class/src/usbd_msc_bot.c
+11
-11
ports/stm32/usbdev/class/src/usbd_msc_scsi.c
ports/stm32/usbdev/class/src/usbd_msc_scsi.c
+28
-28
No files found.
ports/stm32/usbdev/class/inc/usbd_cdc_msc_hid.h
View file @
0ea73d2d
...
...
@@ -72,6 +72,9 @@ typedef struct {
uint32_t
scsi_blk_addr_in_blks
;
uint32_t
scsi_blk_len
;
// operations of the underlying block device
USBD_StorageTypeDef
*
bdev_ops
;
}
USBD_MSC_BOT_HandleTypeDef
;
typedef
enum
{
...
...
@@ -98,8 +101,6 @@ typedef struct _usbd_cdc_msc_hid_state_t {
uint8_t
*
hid_desc
;
const
uint8_t
*
hid_report_desc
;
USBD_StorageTypeDef
*
MSC_fops
;
USBD_CDC_HandleTypeDef
CDC_ClassData
;
USBD_MSC_BOT_HandleTypeDef
MSC_BOT_ClassData
;
USBD_HID_HandleTypeDef
HID_ClassData
;
...
...
@@ -108,7 +109,6 @@ typedef struct _usbd_cdc_msc_hid_state_t {
__ALIGN_BEGIN
uint8_t
usbd_config_desc
[
MAX_TEMPLATE_CONFIG_DESC_SIZE
]
__ALIGN_END
;
void
*
cdc
;
void
*
msc
;
void
*
hid
;
}
usbd_cdc_msc_hid_state_t
;
...
...
@@ -132,7 +132,9 @@ uint8_t USBD_GetMode(usbd_cdc_msc_hid_state_t *usbd);
uint8_t
USBD_CDC_ReceivePacket
(
usbd_cdc_msc_hid_state_t
*
usbd
,
uint8_t
*
buf
);
uint8_t
USBD_CDC_TransmitPacket
(
usbd_cdc_msc_hid_state_t
*
usbd
,
size_t
len
,
const
uint8_t
*
buf
);
uint8_t
USBD_MSC_RegisterStorage
(
usbd_cdc_msc_hid_state_t
*
usbd
,
USBD_StorageTypeDef
*
fops
);
static
inline
void
USBD_MSC_RegisterStorage
(
usbd_cdc_msc_hid_state_t
*
usbd
,
USBD_StorageTypeDef
*
fops
)
{
usbd
->
MSC_BOT_ClassData
.
bdev_ops
=
fops
;
}
uint8_t
USBD_HID_ReceivePacket
(
usbd_cdc_msc_hid_state_t
*
usbd
,
uint8_t
*
buf
);
int
USBD_HID_CanSendReport
(
usbd_cdc_msc_hid_state_t
*
usbd
);
...
...
ports/stm32/usbdev/class/src/usbd_cdc_msc_hid.c
View file @
0ea73d2d
...
...
@@ -662,9 +662,6 @@ static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) {
USBD_EP_TYPE_BULK
,
MSC_MAX_PACKET
);
// Set the MSC data for SCSI and BOT to reference it
usbd
->
msc
=
&
usbd
->
MSC_BOT_ClassData
;
// Init the BOT layer
MSC_BOT_Init
(
pdev
);
}
...
...
@@ -715,7 +712,7 @@ static uint8_t USBD_CDC_MSC_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
USBD_LL_CloseEP
(
pdev
,
CDC_CMD_EP
);
}
if
(
(
usbd
->
usbd_mode
&
USBD_MODE_MSC
)
&&
usbd
->
msc
)
{
if
(
usbd
->
usbd_mode
&
USBD_MODE_MSC
)
{
// MSC component
// close endpoints
...
...
@@ -724,9 +721,6 @@ static uint8_t USBD_CDC_MSC_HID_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
// DeInit the BOT layer
MSC_BOT_DeInit
(
pdev
);
// clear the state pointer
usbd
->
msc
=
NULL
;
}
if
(
usbd
->
usbd_mode
&
USBD_MODE_HID
)
{
...
...
@@ -788,7 +782,7 @@ static uint8_t USBD_CDC_MSC_HID_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTyp
switch
(
req
->
bRequest
)
{
case
BOT_GET_MAX_LUN
:
if
((
req
->
wValue
==
0
)
&&
(
req
->
wLength
==
1
)
&&
((
req
->
bmRequest
&
0x80
)
==
0x80
))
{
usbd
->
MSC_BOT_ClassData
.
max_lun
=
usbd
->
MSC_
f
ops
->
GetMaxLun
();
usbd
->
MSC_BOT_ClassData
.
max_lun
=
usbd
->
MSC_
BOT_ClassData
.
bdev_
ops
->
GetMaxLun
();
USBD_CtlSendData
(
pdev
,
(
uint8_t
*
)
&
usbd
->
MSC_BOT_ClassData
.
max_lun
,
1
);
}
else
{
USBD_CtlError
(
pdev
,
req
);
...
...
@@ -992,16 +986,6 @@ uint8_t USBD_CDC_ReceivePacket(usbd_cdc_msc_hid_state_t *usbd, uint8_t *buf) {
return
USBD_OK
;
}
uint8_t
USBD_MSC_RegisterStorage
(
usbd_cdc_msc_hid_state_t
*
usbd
,
USBD_StorageTypeDef
*
fops
)
{
if
(
fops
==
NULL
)
{
return
USBD_FAIL
;
}
else
{
usbd
->
MSC_fops
=
fops
;
usbd
->
pdev
->
pUserData
=
fops
;
// MSC uses pUserData because SCSI and BOT reference it
return
USBD_OK
;
}
}
// prepare OUT endpoint for reception
uint8_t
USBD_HID_ReceivePacket
(
usbd_cdc_msc_hid_state_t
*
usbd
,
uint8_t
*
buf
)
{
// Suspend or Resume USB Out process
...
...
ports/stm32/usbdev/class/src/usbd_msc_bot.c
View file @
0ea73d2d
...
...
@@ -104,7 +104,7 @@ static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev);
*/
void
MSC_BOT_Init
(
USBD_HandleTypeDef
*
pdev
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
hmsc
->
bot_state
=
USBD_BOT_IDLE
;
hmsc
->
bot_status
=
USBD_BOT_STATUS_NORMAL
;
...
...
@@ -112,7 +112,7 @@ void MSC_BOT_Init (USBD_HandleTypeDef *pdev)
hmsc
->
scsi_sense_tail
=
0
;
hmsc
->
scsi_sense_head
=
0
;
((
USBD_StorageTypeDef
*
)
pdev
->
pUserData
)
->
Init
(
0
);
hmsc
->
bdev_ops
->
Init
(
0
);
USBD_LL_FlushEP
(
pdev
,
MSC_OUT_EP
);
USBD_LL_FlushEP
(
pdev
,
MSC_IN_EP
);
...
...
@@ -132,7 +132,7 @@ void MSC_BOT_Init (USBD_HandleTypeDef *pdev)
*/
void
MSC_BOT_Reset
(
USBD_HandleTypeDef
*
pdev
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
hmsc
->
bot_state
=
USBD_BOT_IDLE
;
hmsc
->
bot_status
=
USBD_BOT_STATUS_RECOVERY
;
...
...
@@ -152,7 +152,7 @@ void MSC_BOT_Reset (USBD_HandleTypeDef *pdev)
*/
void
MSC_BOT_DeInit
(
USBD_HandleTypeDef
*
pdev
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
hmsc
->
bot_state
=
USBD_BOT_IDLE
;
}
...
...
@@ -166,7 +166,7 @@ void MSC_BOT_DeInit (USBD_HandleTypeDef *pdev)
void
MSC_BOT_DataIn
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
epnum
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
switch
(
hmsc
->
bot_state
)
{
...
...
@@ -199,7 +199,7 @@ void MSC_BOT_DataIn (USBD_HandleTypeDef *pdev,
void
MSC_BOT_DataOut
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
epnum
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
switch
(
hmsc
->
bot_state
)
{
...
...
@@ -231,7 +231,7 @@ void MSC_BOT_DataOut (USBD_HandleTypeDef *pdev,
*/
static
void
MSC_BOT_CBW_Decode
(
USBD_HandleTypeDef
*
pdev
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
hmsc
->
csw
.
dTag
=
hmsc
->
cbw
.
dTag
;
hmsc
->
csw
.
dDataResidue
=
hmsc
->
cbw
.
dDataLength
;
...
...
@@ -300,7 +300,7 @@ static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev,
uint8_t
*
buf
,
uint16_t
len
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
len
=
MIN
(
hmsc
->
cbw
.
dDataLength
,
len
);
hmsc
->
csw
.
dDataResidue
-=
len
;
...
...
@@ -320,7 +320,7 @@ static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev,
void
MSC_BOT_SendCSW
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
CSW_Status
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
hmsc
->
csw
.
dSignature
=
USBD_BOT_CSW_SIGNATURE
;
hmsc
->
csw
.
bStatus
=
CSW_Status
;
...
...
@@ -348,7 +348,7 @@ void MSC_BOT_SendCSW (USBD_HandleTypeDef *pdev,
static
void
MSC_BOT_Abort
(
USBD_HandleTypeDef
*
pdev
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
if
((
hmsc
->
cbw
.
bmFlags
==
0
)
&&
(
hmsc
->
cbw
.
dDataLength
!=
0
)
&&
...
...
@@ -377,7 +377,7 @@ static void MSC_BOT_Abort (USBD_HandleTypeDef *pdev)
void
MSC_BOT_CplClrFeature
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
epnum
)
{
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
msc
;
USBD_MSC_BOT_HandleTypeDef
*
hmsc
=
&
((
usbd_cdc_msc_hid_state_t
*
)
pdev
->
pClassData
)
->
MSC_BOT_ClassData
;
if
(
hmsc
->
bot_status
==
USBD_BOT_STATUS_ERROR
)
/* Bad CBW Signature */
{
...
...
ports/stm32/usbdev/class/src/usbd_msc_scsi.c
View file @
0ea73d2d
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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