- Notifications
You must be signed in to change notification settings - Fork1k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
rudihorn wants to merge37 commits intostm32duino:mainChoose a base branch fromrudihorn:usb_msc_cdc
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
37 commits Select commitHold shift + click to select a range
26f5806
initial commit of new cdc_msc and updated msc
db11e1b
added endpoint configuration
1c247ed
added endpoint define changes
0b9e38e
added default msc interface
162ade3
fixed cdc handle nad renamed cdc msc flag
8d7e9d8
added usb class
4b489ef
add new include dirs
a144bca
formatting changes, improved usbd_ep_conf and now compiles in marlin
6717196
fixed bug in descriptor, small changes to USB class
6f3ebfc
fixed duplicate endpoint definition and somewhat fixed endpoint confi…
ccef556
fixed styling and changed dummy sd usb so it is always not ready
ff6cecf
fixed small type and more formatting
da5c702
added ifdef for USB.c
ffd635d
fixed bug in ST MSC SCSI library
7676e07
fixed formatting
3761125
introduced usb msc abstract class
6f00830
changes to formatting
f578d6c
more formatting changes
805113d
and more formatting changes
5df8d9c
small bugfixes
5b3e972
added back early usb initialisation and fixed write protection bug in…
77d673b
fixed hs/fs/other speed interface descriptors for cdc msc
3f3783e
small changes to ep conf
3c4d73d
fixed bug where usb device library relies on pdev->pClassData to dete…
f0e3993
update msc and cdc classes
a7fd6e2
fixed ep addresses
df73d28
fixed formatting
760d8e3
added back cdc clear buffer
f7dbf85
remove reference to userdata
6d0023f
fixed pointer error and warning
4d0f562
changes to cdc msc interface definitions
b29c3ea
remove SOF from MSC+CDC
2207a41
further changes during merging
a341011
set cdc usb handle to usb handle
8709e8f
refactored cdc msc descriptor and fixed for windowsn
def0867
fixed formatting
4447803
added extra board configurations
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletionsboards.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletionscores/arduino/USB.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
Copyright (c) 2015 Arduino LLC. All right reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
#ifdef USBCON | ||
#include "usbd_desc.h" | ||
#include "USB.h" | ||
#include "wiring.h" | ||
#ifdef USBD_USE_CDC_CLASS | ||
#include "usbd_cdc.h" | ||
#include "usbd_cdc_msc.h" | ||
#include "usbd_cdc_if.h" | ||
#endif | ||
#ifdef USBD_USE_MSC_CLASS | ||
#include "usbd_msc.h" | ||
#include "usbd_msc_storage_if.h" | ||
#endif | ||
USB USBDevice; | ||
void USB::begin() | ||
{ | ||
if (!initialized) { | ||
initialize(); | ||
} | ||
} | ||
#ifdef USBD_USE_MSC_CLASS | ||
DummyUSBMscHandler dummyHandler; | ||
void USB::registerMscHandler(USBMscHandler &handler) | ||
{ | ||
pSingleMscHandler = &handler; | ||
registerMscHandlers(1, &pSingleMscHandler, USBD_MSC_fops.pInquiry); | ||
} | ||
void USB::registerMscHandlers(uint8_t count, USBMscHandler **ppHandlers, uint8_t *pInquiryData) | ||
{ | ||
if (count == 0) { | ||
registerMscHandler(dummyHandler); | ||
} else { | ||
ppUsbMscHandlers = ppHandlers; | ||
usbMscMaxLun = count - 1; | ||
USBD_MSC_fops.pInquiry = pInquiryData; | ||
} | ||
} | ||
#endif | ||
void USB::initialize() | ||
{ | ||
hUSBD_Device_CDC = &hUSBD_Device; | ||
/* Init Device Library */ | ||
if (USBD_Init(&hUSBD_Device, &USBD_Desc, 0) != USBD_OK) { | ||
return; | ||
} | ||
/* Add Supported Class and register interface */ | ||
#ifdef USBD_USE_CDC | ||
if (USBD_RegisterClass(&hUSBD_Device, &USBD_CDC) != USBD_OK) { | ||
return; | ||
} | ||
#elif USBD_USE_CDC_MSC | ||
if (USBD_RegisterClass(&hUSBD_Device, &USBD_CDC_MSC) != USBD_OK) { | ||
return; | ||
} | ||
#elif USBD_USE_MSC | ||
if (USBD_RegisterClass(&hUSBD_Device, &USBD_CDC_MSC) != USBD_OK) { | ||
return; | ||
} | ||
#endif | ||
#ifdef USBD_USE_CDC_CLASS | ||
hUSBD_Device_CDC = &hUSBD_Device; | ||
if (USBD_CDC_RegisterInterface(&hUSBD_Device, &USBD_CDC_fops) != USBD_OK) { | ||
return; | ||
} | ||
#endif | ||
#ifdef USBD_USE_MSC_CLASS | ||
if (ppUsbMscHandlers == nullptr) { | ||
registerMscHandler(dummyHandler); | ||
} | ||
if (USBD_MSC_RegisterStorage(&hUSBD_Device, &USBD_MSC_fops) != USBD_OK) { | ||
return; | ||
} | ||
#endif | ||
/* Start Device Process */ | ||
USBD_Start(&hUSBD_Device); | ||
initialized = true; | ||
} | ||
void USB::end() | ||
{ | ||
if (initialized) { | ||
deinitialize(); | ||
} | ||
} | ||
void USB::deinitialize() | ||
{ | ||
USBD_Stop(&hUSBD_Device); | ||
USBD_DeInit(&hUSBD_Device); | ||
initialized = false; | ||
} | ||
#endif // USBCON |
58 changes: 58 additions & 0 deletionscores/arduino/USB.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
Copyright (c) 2015 Arduino LLC. All right reserved. | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
#ifndef _USB_H_ | ||
#define _USB_H_ | ||
#ifdef USBCON | ||
#include "usbd_core.h" | ||
#include "usbd_ep_conf.h" | ||
#ifdef USBD_USE_MSC_CLASS | ||
#include "USBMscHandler.h" | ||
#endif | ||
class USB { | ||
public: | ||
#ifdef USBD_USE_MSC_CLASS | ||
void registerMscHandler(USBMscHandler &pHandler); | ||
void registerMscHandlers(uint8_t count, USBMscHandler **pHandlers, uint8_t *pInquiryData); | ||
#endif | ||
void begin(void); | ||
void end(void); | ||
protected: | ||
void initialize(); | ||
void deinitialize(); | ||
bool initialized; | ||
USBD_HandleTypeDef hUSBD_Device; | ||
#ifdef USBD_USE_MSC_CLASS | ||
USBMscHandler *pSingleMscHandler; | ||
#endif | ||
}; | ||
extern USB USBDevice; | ||
#endif // USBCON | ||
#endif // _USB_H_ |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.