Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of USBDevice by
Diff: USBMSD/USBMSD.cpp
- Revision:
- 14:d495202c90f4
- Parent:
- 11:eeb3cbbaa996
- Child:
- 18:78bdbce94509
--- a/USBMSD/USBMSD.cpp Tue Sep 10 15:14:55 2013 +0300 +++ b/USBMSD/USBMSD.cpp Thu Sep 12 14:45:27 2013 +0100 @@ -67,8 +67,12 @@ stage = READ_CBW; memset((void *)&cbw, 0, sizeof(CBW)); memset((void *)&csw, 0, sizeof(CSW)); + page = NULL; } +USBMSD::~USBMSD() { + disconnect(); +} // Called in ISR context to process a class specific request @@ -117,6 +121,7 @@ if (BlockCount > 0) { BlockSize = MemorySize / BlockCount; if (BlockSize != 0) { + free(page); page = (uint8_t *)malloc(BlockSize * sizeof(uint8_t)); if (page == NULL) return false; @@ -130,6 +135,12 @@ return true; } +void USBMSD::disconnect() { + //De-allocate MSD page size: + free(page); + page = NULL; + USBDevice::disconnect(); +} void USBMSD::reset() { stage = READ_CBW;