Skip to content

Add USB MSC + MSC/CDC Composite Class #1088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
26f5806
initial commit of new cdc_msc and updated msc
May 29, 2020
db11e1b
added endpoint configuration
May 29, 2020
1c247ed
added endpoint define changes
May 29, 2020
0b9e38e
added default msc interface
May 29, 2020
162ade3
fixed cdc handle nad renamed cdc msc flag
May 29, 2020
8d7e9d8
added usb class
May 29, 2020
4b489ef
add new include dirs
May 30, 2020
a144bca
formatting changes, improved usbd_ep_conf and now compiles in marlin
Jun 1, 2020
6717196
fixed bug in descriptor, small changes to USB class
Jun 1, 2020
6f3ebfc
fixed duplicate endpoint definition and somewhat fixed endpoint confi…
Jun 2, 2020
ccef556
fixed styling and changed dummy sd usb so it is always not ready
Jun 2, 2020
ff6cecf
fixed small type and more formatting
Jun 2, 2020
da5c702
added ifdef for USB.c
Jun 2, 2020
ffd635d
fixed bug in ST MSC SCSI library
Jun 2, 2020
7676e07
fixed formatting
Jun 2, 2020
3761125
introduced usb msc abstract class
Jun 3, 2020
6f00830
changes to formatting
Jun 3, 2020
f578d6c
more formatting changes
Jun 3, 2020
805113d
and more formatting changes
Jun 3, 2020
5df8d9c
small bugfixes
Jun 3, 2020
5b3e972
added back early usb initialisation and fixed write protection bug in…
Jun 3, 2020
77d673b
fixed hs/fs/other speed interface descriptors for cdc msc
Jun 3, 2020
3f3783e
small changes to ep conf
Jun 3, 2020
3c4d73d
fixed bug where usb device library relies on pdev->pClassData to dete…
Jun 4, 2020
f0e3993
update msc and cdc classes
Jun 4, 2020
a7fd6e2
fixed ep addresses
Jun 4, 2020
df73d28
fixed formatting
Jun 4, 2020
760d8e3
added back cdc clear buffer
Jun 4, 2020
f7dbf85
remove reference to userdata
Jun 4, 2020
6d0023f
fixed pointer error and warning
Jun 4, 2020
4d0f562
changes to cdc msc interface definitions
Jun 4, 2020
b29c3ea
remove SOF from MSC+CDC
Jun 4, 2020
2207a41
further changes during merging
Jun 4, 2020
a341011
set cdc usb handle to usb handle
Jun 4, 2020
8709e8f
refactored cdc msc descriptor and fixed for windowsn
Jun 7, 2020
def0867
fixed formatting
Jun 7, 2020
4447803
added extra board configurations
Jun 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
formatting changes, improved usbd_ep_conf and now compiles in marlin
  • Loading branch information
Rudi Horn committed Jun 4, 2020
commit a144bca45c37943600b1292cb6247f801348dabf
22 changes: 12 additions & 10 deletions cores/arduino/USB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "USBSerial.h"

#include "cdc/usbd_cdc.h"
#include "cdc_msc/usbd_cdc_msc.h"
#include "cdc/usbd_cdc_if.h"
#include "usbd_cdc.h"
#include "usbd_cdc_msc.h"
#include "usbd_msc.h"
#include "usbd_msc_storage_if.h"
#include "usbd_cdc_if.h"
#include "usbd_desc.h"
#include "USB.h"
#include "wiring.h"

USB USBDevice;

void USB::begin() {
if (!initialized) initialize();
}
Expand All @@ -35,7 +38,7 @@ void USB::initialize() {
if (USBD_Init(&hUSBD_Device, &USBD_Desc, 0) == USBD_OK) {
#ifdef USBD_USE_CDC
/* Add Supported Class */
if (USBD_RegisterClass(&hUSBD_Device_CDC, USBD_CDC_CLASS) == USBD_OK) {
if (USBD_RegisterClass(&hUSBD_Device_CDC, &USBD_CDC) == USBD_OK) {
/* Add CDC Interface Class */
if (USBD_CDC_RegisterInterface(&hUSBD_Device_CDC, &USBD_CDC_fops) == USBD_OK) {
/* Start Device Process */
Expand All @@ -45,7 +48,7 @@ void USB::initialize() {
}
#elif USBD_USE_CDC_MSC
/* Add Supported Class */
if (USBD_RegisterClass(&hUSBD_Device, USBD_CDC_MSC_CLASS) == USBD_OK) {
if (USBD_RegisterClass(&hUSBD_Device, &USBD_CDC_MSC) == USBD_OK) {
/* Add CDC Interface Class */
if (USBD_CDC_RegisterInterface(&hUSBD_Device, &USBD_CDC_fops) == USBD_OK) {
/* Add MSC Interface Class */
Expand All @@ -65,8 +68,7 @@ void USB::end() {
}

void USB::deinitialize() {
USBD_Stop(&hUSBD_Device_CDC);
USBD_CDC_DeInit();
USBD_DeInit(&hUSBD_Device_CDC);
USBD_Stop(&hUSBD_Device);
USBD_DeInit(&hUSBD_Device);
initialized = false;
}
9 changes: 6 additions & 3 deletions cores/arduino/USB.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ class USB {
void initialize();
void deinitialize();

bool initialized();
bool initialized;

USBD_HandleTypeDef hUSBD_Device;
}
};

#endif
extern USB USBDevice;

#endif // USBCON
#endif // _USB_H_
7 changes: 5 additions & 2 deletions cores/arduino/USBSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "usbd_ep_conf.h"

#if defined (USBCON) && defined(USBD_USE_CDC_CLASS)

#include "USB.h"
#include "USBSerial.h"
#include "usbd_cdc.h"
#include "usbd_cdc_if.h"
Expand All @@ -31,7 +34,7 @@ void serialEventUSB() __attribute__((weak));

void USBSerial::begin(void)
{
USB::begin();
USBDevice.begin();
}

void USBSerial::begin(uint32_t /* baud_count */)
Expand All @@ -48,7 +51,7 @@ void USBSerial::begin(uint32_t /* baud_count */, uint8_t /* config */)

void USBSerial::end()
{
USB::end();
USBDevice.end();
}

int USBSerial::availableForWrite()
Expand Down
3 changes: 2 additions & 1 deletion cores/arduino/USBSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
#ifndef _USBSERIAL_H_
#define _USBSERIAL_H_

#include "usbd_core.h"
#include "usbd_ep_conf.h"

#if defined (USBCON) && defined(USBD_USE_CDC_CLASS)
#include "usbd_core.h"
#include "Stream.h"

//================================================================================
Expand Down
4 changes: 3 additions & 1 deletion cores/arduino/stm32/usb/cdc/cdc_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
******************************************************************************
*/

#include "usbd_ep_conf.h"

#ifdef USBCON
#ifdef USBD_USE_CDC
#ifdef USBD_USE_CDC_CLASS

#include "cdc_queue.h"

Expand Down
4 changes: 3 additions & 1 deletion cores/arduino/stm32/usb/cdc/usbd_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@
******************************************************************************
*/

#include "usbd_ep_conf.h"

#ifdef USBCON
#ifdef USBD_USE_CDC_CLASS

/* Includes ------------------------------------------------------------------*/
#include "usbd_cdc.h"
#include "usbd_ctlreq.h"

#ifdef USBD_USE_CDC_CLASS

/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
Expand Down
1 change: 0 additions & 1 deletion cores/arduino/stm32/usb/cdc/usbd_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ typedef struct {


extern USBD_ClassTypeDef USBD_CDC;
#define USBD_CDC_CLASS &USBD_CDC

extern USBD_CDC_HandleTypeDef *cdc_handle;

Expand Down
3 changes: 1 addition & 2 deletions cores/arduino/stm32/usb/cdc/usbd_cdc_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
******************************************************************************
*/

#ifdef USBCON

#include "usbd_ep_conf.h"

#ifdef USBCON
#ifdef USBD_USE_CDC_CLASS

/* Includes ------------------------------------------------------------------*/
Expand Down
84 changes: 7 additions & 77 deletions cores/arduino/stm32/usb/cdc_msc/usbd_cdc_msc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,55 +35,14 @@
******************************************************************************
*/

/* Includes ------------------------------------------------------------------*/
#include "usbd_ep_conf.h"

#ifdef USBCON
#ifdef USBD_USE_CDC_MSC

#include "usbd_cdc_msc.h"
#include "usbd_ctlreq.h"


/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/


/** @defgroup USBD_COMPOSITE
* @brief usbd core module
* @{
*/

/** @defgroup USBD_COMPOSITE_Private_TypesDefinitions
* @{
*/
/**
* @}
*/


/** @defgroup USBD_COMPOSITE_Private_Defines
* @{
*/

/**
* @}
*/


/** @defgroup USBD_COMPOSITE_Private_Macros
* @{
*/

/**
* @}
*/




/** @defgroup USBD_COMPOSITE_Private_FunctionPrototypes
* @{
*/


static uint8_t USBD_COMPOSITE_Init(USBD_HandleTypeDef *pdev,
uint8_t cfgidx);

Expand All @@ -103,19 +62,9 @@ static uint8_t USBD_COMPOSITE_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);

static uint8_t USBD_COMPOSITE_EP0_RxReady(USBD_HandleTypeDef *pdev);

static uint8_t USBD_COMPOSITE_EP0_TxReady(USBD_HandleTypeDef *pdev);

static uint8_t USBD_COMPOSITE_SOF(USBD_HandleTypeDef *pdev);

/**
* @}
*/

/** @defgroup USBD_COMPOSITE_Private_Variables
* @{
*/

USBD_ClassTypeDef USBD_CDC_MSC_CLASS =
USBD_ClassTypeDef USBD_CDC_MSC =
{
USBD_COMPOSITE_Init,
USBD_COMPOSITE_DeInit,
Expand Down Expand Up @@ -280,14 +229,6 @@ static uint8_t USBD_COMPOSITE_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] =
0x00,
};

/**
* @}
*/

/** @defgroup USBD_COMPOSITE_Private_Functions
* @{
*/

/**
* @brief USBD_COMPOSITE_Init
* Initialize the COMPOSITE interface
Expand Down Expand Up @@ -491,18 +432,7 @@ uint8_t *USBD_COMPOSITE_GetDeviceQualifierDesc(uint16_t *length)
return USBD_COMPOSITE_DeviceQualifierDesc;
}

/**
* @}
*/


/**
* @}
*/


/**
* @}
*/
#endif /* USBD_USE_MSC_CLASS */
#endif /* USBCON */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
4 changes: 2 additions & 2 deletions cores/arduino/stm32/usb/cdc_msc/usbd_cdc_msc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#ifndef __USB_CDC_MSC_CORE_H_
#define __USB_CDC_MSC_CORE_H_

#include "../cdc/usbd_cdc.h"
#include "usbd_cdc.h"
#include "usbd_msc.h"
#include "usbd_ioreq.h"

Expand All @@ -34,7 +34,7 @@

#define USB_CDC_MSC_CONFIG_DESC_SIZ (USB_CDC_CONFIG_DESC_SIZ - 9 + USB_MSC_CONFIG_DESC_SIZ)

extern USBD_ClassTypeDef USBD_CDC_MSC_CLASS;
extern USBD_ClassTypeDef USBD_CDC_MSC;

#endif /* __USB_CDC_MSC_CORE_H_ */

Expand Down
Loading