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
fb25c2d9
Commit
fb25c2d9
authored
Mar 22, 2014
by
Damien George
Browse files
stmhal: USB CDC and MSC device work together.
parent
b32db4e1
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
stmhal/Makefile
View file @
fb25c2d9
...
...
@@ -21,7 +21,7 @@ INC += -I$(PY_SRC)
INC
+=
-I
$(CMSIS_DIR)
/inc
INC
+=
-I
$(CMSIS_DIR)
/devinc
INC
+=
-I
$(HAL_DIR)
/inc
INC
+=
-I
$(USBDEV_DIR)
/core/inc
-I
$(USBDEV_DIR)
/class/cdc
/inc
-I
$(USBDEV_DIR)
/class/
msc/inc
INC
+=
-I
$(USBDEV_DIR)
/core/inc
-I
$(USBDEV_DIR)
/class/cdc
_
msc/inc
#INC += -I$(USBHOST_DIR)
INC
+=
-I
$(FATFS_DIR)
/src
#INC += -I$(CC3K_DIR)
...
...
@@ -56,9 +56,8 @@ SRC_C = \
stm32f4xx_it.c
\
stm32f4xx_hal_msp.c
\
usbd_conf.c
\
usbd_desc_
vcp
.c
\
usbd_desc_
cdc_msc
.c
\
usbd_cdc_interface.c
\
usbd_desc_msc.c
\
usbd_msc_storage.c
\
pendsv.c
\
systick.c
\
...
...
@@ -124,13 +123,14 @@ SRC_USBDEV = $(addprefix $(USBDEV_DIR)/,\
core/src/usbd_core.c
\
core/src/usbd_ctlreq.c
\
core/src/usbd_ioreq.c
\
class/cdc/src/usbd_cdc.c
\
class/msc/src/usbd_msc.c
\
class/msc/src/usbd_msc_bot.c
\
class/msc/src/usbd_msc_scsi.c
\
class/msc/src/usbd_msc_data.c
\
class/cdc_msc/src/usbd_cdc_msc.c
\
class/cdc_msc/src/usbd_msc_bot.c
\
class/cdc_msc/src/usbd_msc_scsi.c
\
class/cdc_msc/src/usbd_msc_data.c
\
)
# class/cdc/src/usbd_cdc.c \
class/msc/src/usbd_msc.c
\
# usbd_core.c \
usbd_ioreq.c
\
usbd_req.c
\
...
...
stmhal/main.c
View file @
fb25c2d9
...
...
@@ -336,7 +336,6 @@ soft_reset:
fno
.
lfname
=
NULL
;
fno
.
lfsize
=
0
;
#endif
led_debug
(
0
,
500
);
FRESULT
res
=
f_stat
(
"0:/boot.py"
,
&
fno
);
if
(
res
==
FR_OK
)
{
if
(
fno
.
fattrib
&
AM_DIR
)
{
...
...
stmhal/usb.c
View file @
fb25c2d9
...
...
@@ -2,9 +2,8 @@
#include
"usbd_core.h"
#include
"usbd_desc.h"
#include
"usbd_cdc.h"
#include
"usbd_cdc
_msc
.h"
#include
"usbd_cdc_interface.h"
#include
"usbd_msc.h"
#include
"usbd_msc_storage.h"
#include
"misc.h"
...
...
@@ -26,6 +25,7 @@ void pyb_usb_dev_init(usbd_device_kind_t device_kind, usbd_storage_medium_kind_t
if
(
!
dev_is_enabled
)
{
// only init USB once in the device's power-lifetime
switch
(
device_kind
)
{
#if 0
case USBD_DEVICE_CDC:
// XXX USBD_CDC_Init (called by one of these functions below) uses malloc,
// so the memory is invalid after a soft reset (which resets the GC).
...
...
@@ -48,6 +48,21 @@ void pyb_usb_dev_init(usbd_device_kind_t device_kind, usbd_storage_medium_kind_t
}
USBD_Start(&hUSBDDevice);
break;
#endif
case
USBD_DEVICE_CDC
:
case
USBD_DEVICE_MSC
:
USBD_Init
(
&
hUSBDDevice
,
&
VCP_Desc
,
0
);
USBD_RegisterClass
(
&
hUSBDDevice
,
&
USBD_CDC_MSC
);
USBD_CDC_RegisterInterface
(
&
hUSBDDevice
,
(
USBD_CDC_ItfTypeDef
*
)
&
USBD_CDC_fops
);
if
(
medium_kind
==
USBD_STORAGE_MEDIUM_FLASH
)
{
USBD_MSC_RegisterStorage
(
&
hUSBDDevice
,
(
USBD_StorageTypeDef
*
)
&
USBD_FLASH_STORAGE_fops
);
}
else
{
USBD_MSC_RegisterStorage
(
&
hUSBDDevice
,
(
USBD_StorageTypeDef
*
)
&
USBD_SDCARD_STORAGE_fops
);
}
USBD_Start
(
&
hUSBDDevice
);
break
;
case
USBD_DEVICE_HID
:
//USBD_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_PYB_HID_cb, &USR_cb);
...
...
stmhal/usbd_conf.c
View file @
fb25c2d9
...
...
@@ -342,10 +342,12 @@ USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
pdev
->
pData
=
&
hpcd
;
/*Initialize LL Driver */
HAL_PCD_Init
(
&
hpcd
);
HAL_PCD_SetRxFiFo
(
&
hpcd
,
0x80
);
HAL_PCD_SetTxFiFo
(
&
hpcd
,
0
,
0x40
);
HAL_PCD_SetTxFiFo
(
&
hpcd
,
1
,
0x80
);
HAL_PCD_SetTxFiFo
(
&
hpcd
,
0
,
0x20
);
HAL_PCD_SetTxFiFo
(
&
hpcd
,
1
,
0x40
);
HAL_PCD_SetTxFiFo
(
&
hpcd
,
2
,
0x20
);
HAL_PCD_SetTxFiFo
(
&
hpcd
,
3
,
0x40
);
#endif
...
...
stmhal/usbd_desc_cdc_msc.c
0 → 100644
View file @
fb25c2d9
/**
******************************************************************************
* @file USB_Device/CDC_Standalone/Src/usbd_desc.c
* @author MCD Application Team
* @version V1.0.1
* @date 26-February-2014
* @brief This file provides the USBD descriptors and string formating method.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include
"usbd_core.h"
#include
"usbd_desc.h"
#include
"usbd_conf.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define USBD_VID 0x0483
#define USBD_PID 0x5740
#define USBD_LANGID_STRING 0x409
#define USBD_MANUFACTURER_STRING "STMicroelectronics"
#define USBD_PRODUCT_HS_STRING "STM32 Virtual ComPort in HS Mode"
#define USBD_SERIALNUMBER_HS_STRING "00000000001A"
#define USBD_PRODUCT_FS_STRING "STM32 Virtual ComPort in FS Mode"
#define USBD_SERIALNUMBER_FS_STRING "00000000001B"
#define USBD_CONFIGURATION_HS_STRING "VCP Config"
#define USBD_INTERFACE_HS_STRING "VCP Interface"
#define USBD_CONFIGURATION_FS_STRING "VCP Config"
#define USBD_INTERFACE_FS_STRING "VCP Interface"
/* Private macro -------------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
uint8_t
*
USBD_VCP_DeviceDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
USBD_VCP_LangIDStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
USBD_VCP_ManufacturerStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
USBD_VCP_ProductStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
USBD_VCP_SerialStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
USBD_VCP_ConfigStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
uint8_t
*
USBD_VCP_InterfaceStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
);
#ifdef USB_SUPPORT_USER_STRING_DESC
uint8_t
*
USBD_VCP_USRStringDesc
(
USBD_SpeedTypeDef
speed
,
uint8_t
idx
,
uint16_t
*
length
);
#endif
/* USB_SUPPORT_USER_STRING_DESC */
/* Private variables ---------------------------------------------------------*/
USBD_DescriptorsTypeDef
VCP_Desc
=
{
USBD_VCP_DeviceDescriptor
,
USBD_VCP_LangIDStrDescriptor
,
USBD_VCP_ManufacturerStrDescriptor
,
USBD_VCP_ProductStrDescriptor
,
USBD_VCP_SerialStrDescriptor
,
USBD_VCP_ConfigStrDescriptor
,
USBD_VCP_InterfaceStrDescriptor
,
};
/* USB Standard Device Descriptor */
#if defined ( __ICCARM__ )
/*!< IAR Compiler */
#pragma data_alignment=4
#endif
__ALIGN_BEGIN
static
uint8_t
hUSBDDeviceDesc
[
USB_LEN_DEV_DESC
]
__ALIGN_END
=
{
0x12
,
/* bLength */
USB_DESC_TYPE_DEVICE
,
/* bDescriptorType */
0x00
,
/* bcdUSB */
0x02
,
0x00
,
/* bDeviceClass */
0x00
,
/* bDeviceSubClass */
0x00
,
/* bDeviceProtocol */
USB_MAX_EP0_SIZE
,
/* bMaxPacketSize */
LOBYTE
(
USBD_VID
),
/* idVendor */
HIBYTE
(
USBD_VID
),
/* idVendor */
LOBYTE
(
USBD_PID
),
/* idVendor */
HIBYTE
(
USBD_PID
),
/* idVendor */
0x00
,
/* bcdDevice rel. 2.00 */
0x02
,
USBD_IDX_MFC_STR
,
/* Index of manufacturer string */
USBD_IDX_PRODUCT_STR
,
/* Index of product string */
USBD_IDX_SERIAL_STR
,
/* Index of serial number string */
USBD_MAX_NUM_CONFIGURATION
/* bNumConfigurations */
};
/* USB_DeviceDescriptor */
/* USB Standard Device Descriptor */
#if defined ( __ICCARM__ )
/*!< IAR Compiler */
#pragma data_alignment=4
#endif
__ALIGN_BEGIN
static
uint8_t
USBD_LangIDDesc
[
USB_LEN_LANGID_STR_DESC
]
__ALIGN_END
=
{
USB_LEN_LANGID_STR_DESC
,
USB_DESC_TYPE_STRING
,
LOBYTE
(
USBD_LANGID_STRING
),
HIBYTE
(
USBD_LANGID_STRING
),
};
#if defined ( __ICCARM__ )
/*!< IAR Compiler */
#pragma data_alignment=4
#endif
__ALIGN_BEGIN
static
uint8_t
USBD_StrDesc
[
USBD_MAX_STR_DESC_SIZ
]
__ALIGN_END
;
/* Private functions ---------------------------------------------------------*/
/**
* @brief Returns the device descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_DeviceDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
*
length
=
sizeof
(
hUSBDDeviceDesc
);
return
hUSBDDeviceDesc
;
}
/**
* @brief Returns the LangID string descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_LangIDStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
*
length
=
sizeof
(
USBD_LangIDDesc
);
return
USBD_LangIDDesc
;
}
/**
* @brief Returns the product string descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_ProductStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
0
)
{
USBD_GetString
((
uint8_t
*
)
USBD_PRODUCT_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_PRODUCT_FS_STRING
,
USBD_StrDesc
,
length
);
}
return
USBD_StrDesc
;
}
/**
* @brief Returns the manufacturer string descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_ManufacturerStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
USBD_GetString
((
uint8_t
*
)
USBD_MANUFACTURER_STRING
,
USBD_StrDesc
,
length
);
return
USBD_StrDesc
;
}
/**
* @brief Returns the serial number string descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_SerialStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
USBD_SPEED_HIGH
)
{
USBD_GetString
((
uint8_t
*
)
USBD_SERIALNUMBER_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_SERIALNUMBER_FS_STRING
,
USBD_StrDesc
,
length
);
}
return
USBD_StrDesc
;
}
/**
* @brief Returns the configuration string descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_ConfigStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
USBD_SPEED_HIGH
)
{
USBD_GetString
((
uint8_t
*
)
USBD_CONFIGURATION_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_CONFIGURATION_FS_STRING
,
USBD_StrDesc
,
length
);
}
return
USBD_StrDesc
;
}
/**
* @brief Returns the interface string descriptor.
* @param speed: Current device speed
* @param length: Pointer to data length variable
* @retval Pointer to descriptor buffer
*/
uint8_t
*
USBD_VCP_InterfaceStrDescriptor
(
USBD_SpeedTypeDef
speed
,
uint16_t
*
length
)
{
if
(
speed
==
0
)
{
USBD_GetString
((
uint8_t
*
)
USBD_INTERFACE_HS_STRING
,
USBD_StrDesc
,
length
);
}
else
{
USBD_GetString
((
uint8_t
*
)
USBD_INTERFACE_FS_STRING
,
USBD_StrDesc
,
length
);
}
return
USBD_StrDesc
;
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
stmhal/usbd_msc_storage.c
View file @
fb25c2d9
...
...
@@ -27,7 +27,7 @@
******************************************************************************
*/
#include
"usbd_msc.h"
#include
"usbd_
cdc_
msc.h"
#include
"usbd_msc_storage.h"
#include
"misc.h"
...
...
stmhal/usbdev/class/cdc_msc/inc/usbd_cdc_msc.h
0 → 100644
View file @
fb25c2d9
#ifndef _USB_CDC_MSC_CORE_H_
#define _USB_CDC_MSC_CORE_H_
#include
"usbd_msc_bot.h"
#include
"usbd_msc_scsi.h"
#include
"usbd_ioreq.h"
// CDC endpoint parameters
#define CDC_DATA_FS_MAX_PACKET_SIZE 64 // Endpoint IN & OUT Packet size
#define CDC_CMD_PACKET_SIZE 8 // Control Endpoint Packet size
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
#if 0
// CDC
#define USB_CDC_MSC_CONFIG_DESC_SIZ (75)
#define NUM_INTERFACES (2)
#define USE_CDC (1)
#define USE_MSC (0)
#define CDC_IN_EP 0x81 /* EP1 for data IN */
#define CDC_OUT_EP 0x01 /* EP1 for data OUT */
#define CDC_CMD_EP 0x82 /* EP2 for CDC commands */
#define MSC_IN_EP (0x83)
#define MSC_OUT_EP (0x03)
#elif
0
// MSC
#define USB_CDC_MSC_CONFIG_DESC_SIZ (32)
#define NUM_INTERFACES (1)
#define USE_CDC (0)
#define USE_MSC (1)
#define CDC_IN_EP 0x81
/* EP1 for data IN */
#define CDC_OUT_EP 0x01
/* EP1 for data OUT */
#define CDC_CMD_EP 0x82
/* EP2 for CDC commands */
#define MSC_IFACE_NUM (0)
#define MSC_IN_EP (0x81)
#define MSC_OUT_EP (0x01)
#elif 0
// CDC + MSC
#define USB_CDC_MSC_CONFIG_DESC_SIZ (98)
#define NUM_INTERFACES (3)
#define USE_CDC (1)
#define USE_MSC (1)
#define CDC_IFACE_NUM (0)
#define CDC_IN_EP 0x81
/* EP1 for data IN */
#define CDC_OUT_EP 0x01
/* EP1 for data OUT */
#define CDC_CMD_EP 0x82
/* EP2 for CDC commands */
#define MSC_IFACE_NUM (2)
#define MSC_IN_EP (0x83)
#define MSC_OUT_EP (0x03)
#else
// MSC + CDC
#define USB_CDC_MSC_CONFIG_DESC_SIZ (98)
#define NUM_INTERFACES (3)
#define USE_CDC (1)
#define USE_MSC (1)
#define CDC_IFACE_NUM (1)
#define CDC_IN_EP 0x83
/* EP1 for data IN */
#define CDC_OUT_EP 0x03
/* EP1 for data OUT */
#define CDC_CMD_EP 0x82
/* EP2 for CDC commands */
#define MSC_IFACE_NUM (0)
#define MSC_IN_EP (0x81)
#define MSC_OUT_EP (0x01)
#endif
typedef
struct
{
uint32_t
bitrate
;
uint8_t
format
;
uint8_t
paritytype
;
uint8_t
datatype
;
}
USBD_CDC_LineCodingTypeDef
;
typedef
struct
_USBD_CDC_Itf
{
int8_t
(
*
Init
)
(
void
);
int8_t
(
*
DeInit
)
(
void
);
int8_t
(
*
Control
)
(
uint8_t
,
uint8_t
*
,
uint16_t
);
int8_t
(
*
Receive
)
(
uint8_t
*
,
uint32_t
*
);
}
USBD_CDC_ItfTypeDef
;
typedef
struct
{
uint32_t
data
[
CDC_DATA_FS_MAX_PACKET_SIZE
/
4
];
/* Force 32bits alignment */
uint8_t
CmdOpCode
;
uint8_t
CmdLength
;
uint8_t
*
RxBuffer
;
uint8_t
*
TxBuffer
;
uint32_t
RxLength
;
uint32_t
TxLength
;
__IO
uint32_t
TxState
;
__IO
uint32_t
RxState
;
}
USBD_CDC_HandleTypeDef
;
typedef
struct
_USBD_STORAGE
{
int8_t
(
*
Init
)
(
uint8_t
lun
);
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
(
*
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
);
int8_t
(
*
GetMaxLun
)(
void
);
int8_t
*
pInquiry
;
}
USBD_StorageTypeDef
;
typedef
struct
{
uint32_t
max_lun
;
uint32_t
interface
;
uint8_t
bot_state
;
uint8_t
bot_status
;
uint16_t
bot_data_length
;
uint8_t
bot_data
[
MSC_MEDIA_PACKET
];
USBD_MSC_BOT_CBWTypeDef
cbw
;
USBD_MSC_BOT_CSWTypeDef
csw
;
USBD_SCSI_SenseTypeDef
scsi_sense
[
SENSE_LIST_DEEPTH
];
uint8_t
scsi_sense_head
;
uint8_t
scsi_sense_tail
;
uint16_t
scsi_blk_size
;
uint32_t
scsi_blk_nbr
;
uint32_t
scsi_blk_addr
;
uint32_t
scsi_blk_len
;
}
USBD_MSC_BOT_HandleTypeDef
;
extern
USBD_ClassTypeDef
USBD_CDC_MSC
;
uint8_t
USBD_CDC_RegisterInterface
(
USBD_HandleTypeDef
*
pdev
,
USBD_CDC_ItfTypeDef
*
fops
);
uint8_t
USBD_CDC_SetTxBuffer
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
pbuff
,
uint16_t
length
);
uint8_t
USBD_CDC_SetRxBuffer
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
*
pbuff
);
uint8_t
USBD_CDC_ReceivePacket
(
USBD_HandleTypeDef
*
pdev
);
uint8_t
USBD_CDC_TransmitPacket
(
USBD_HandleTypeDef
*
pdev
);
uint8_t
USBD_MSC_RegisterStorage
(
USBD_HandleTypeDef
*
pdev
,
USBD_StorageTypeDef
*
fops
);
#endif // _USB_CDC_MSC_CORE_H_
stmhal/usbdev/class/cdc_msc/inc/usbd_msc_bot.h
0 → 100644
View file @
fb25c2d9
/**
******************************************************************************
* @file usbd_msc_bot.h
* @author MCD Application Team
* @version V2.0.0
* @date 18-February-2014
* @brief header for the usbd_msc_bot.c file
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#include
"usbd_core.h"
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_MSC_BOT_H
#define __USBD_MSC_BOT_H
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{
*/
/** @defgroup MSC_BOT
* @brief This file is the Header file for usbd_bot.c
* @{
*/
/** @defgroup USBD_CORE_Exported_Defines
* @{
*/
#define USBD_BOT_IDLE 0
/* Idle state */
#define USBD_BOT_DATA_OUT 1
/* Data Out state */
#define USBD_BOT_DATA_IN 2
/* Data In state */
#define USBD_BOT_LAST_DATA_IN 3
/* Last Data In Last */
#define USBD_BOT_SEND_DATA 4
/* Send Immediate data */
#define USBD_BOT_NO_DATA 5
/* No data Stage */
#define USBD_BOT_CBW_SIGNATURE 0x43425355
#define USBD_BOT_CSW_SIGNATURE 0x53425355
#define USBD_BOT_CBW_LENGTH 31
#define USBD_BOT_CSW_LENGTH 13
#define USBD_BOT_MAX_DATA 256
/* CSW Status Definitions */
#define USBD_CSW_CMD_PASSED 0x00
#define USBD_CSW_CMD_FAILED 0x01
#define USBD_CSW_PHASE_ERROR 0x02
/* BOT Status */
#define USBD_BOT_STATUS_NORMAL 0
#define USBD_BOT_STATUS_RECOVERY 1
#define USBD_BOT_STATUS_ERROR 2
#define USBD_DIR_IN 0
#define USBD_DIR_OUT 1
#define USBD_BOTH_DIR 2
/**
* @}
*/
/** @defgroup MSC_CORE_Private_TypesDefinitions
* @{
*/
typedef
struct
{
uint32_t
dSignature
;
uint32_t
dTag
;
uint32_t
dDataLength
;
uint8_t
bmFlags
;
uint8_t
bLUN
;
uint8_t
bCBLength
;
uint8_t
CB
[
16
];
uint8_t
ReservedForAlign
;
}
USBD_MSC_BOT_CBWTypeDef
;
typedef
struct
{
uint32_t
dSignature
;
uint32_t
dTag
;
uint32_t
dDataResidue
;
uint8_t
bStatus
;
uint8_t
ReservedForAlign
[
3
];
}
USBD_MSC_BOT_CSWTypeDef
;
/**
* @}
*/
/** @defgroup USBD_CORE_Exported_Types
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Exported_FunctionsPrototypes
* @{
*/
void
MSC_BOT_Init
(
USBD_HandleTypeDef
*
pdev
);
void
MSC_BOT_Reset
(
USBD_HandleTypeDef
*
pdev
);
void
MSC_BOT_DeInit
(
USBD_HandleTypeDef
*
pdev
);
void
MSC_BOT_DataIn
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
epnum
);
void
MSC_BOT_DataOut
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
epnum
);
void
MSC_BOT_SendCSW
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
CSW_Status
);
void
MSC_BOT_CplClrFeature
(
USBD_HandleTypeDef
*
pdev
,
uint8_t
epnum
);
/**
* @}
*/
#endif
/* __USBD_MSC_BOT_H */
/**