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.
Dependents: STM32F103C8T6_WebUSBDFU STM32F103C8T6_USBDFU STM32F103C8T6_USBDFU dfu_usb_stm32f103
Fork of USBDevice_STM32F103 by
Revision 51:deafa44182d9, committed 2015-04-23
- Comitter:
- mbed_official
- Date:
- Thu Apr 23 08:45:28 2015 +0100
- Parent:
- 50:a3c50882f2c5
- Child:
- 52:fb344268a308
- Commit message:
- Synchronized with git revision 7c4831f300daf357b21e4301785771d48f00e3a6
Full URL: https://github.com/mbedmicro/mbed/commit/7c4831f300daf357b21e4301785771d48f00e3a6/
Changed CircBuffer to take its size as a template parameters for efficientcy.
Changed in this revision
--- a/USBMSD/USBMSD.cpp Mon Apr 20 10:45:54 2015 +0100
+++ b/USBMSD/USBMSD.cpp Thu Apr 23 08:45:28 2015 +0100
@@ -135,10 +135,10 @@
}
void USBMSD::disconnect() {
+ USBDevice::disconnect();
//De-allocate MSD page size:
free(page);
page = NULL;
- USBDevice::disconnect();
}
void USBMSD::reset() {
--- a/USBSerial/CircBuffer.h Mon Apr 20 10:45:54 2015 +0100
+++ b/USBSerial/CircBuffer.h Thu Apr 23 08:45:28 2015 +0100
@@ -19,20 +19,10 @@
#ifndef CIRCBUFFER_H
#define CIRCBUFFER_H
-template <class T>
+template <class T, int Size>
class CircBuffer {
public:
- CircBuffer(int length) {
- write = 0;
- read = 0;
- size = length + 1;
- buf = (T *)malloc(size * sizeof(T));
- };
-
- ~CircBuffer() {
- free(buf);
- }
-
+ CircBuffer():write(0), read(0){}
bool isFull() {
return ((write + 1) % size == read);
};
@@ -66,8 +56,8 @@
private:
volatile uint16_t write;
volatile uint16_t read;
- uint16_t size;
- T * buf;
+ static const int size = Size+1; //a modern optimizer should be able to remove this so it uses no ram.
+ T buf[Size];
};
#endif
--- a/USBSerial/USBSerial.h Mon Apr 20 10:45:54 2015 +0100
+++ b/USBSerial/USBSerial.h Thu Apr 23 08:45:28 2015 +0100
@@ -56,7 +56,7 @@
* @param connect_blocking define if the connection must be blocked if USB not plugged in
*
*/
- USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001, bool connect_blocking = true): USBCDC(vendor_id, product_id, product_release, connect_blocking), buf(128){
+ USBSerial(uint16_t vendor_id = 0x1f00, uint16_t product_id = 0x2012, uint16_t product_release = 0x0001, bool connect_blocking = true): USBCDC(vendor_id, product_id, product_release, connect_blocking){
settingsChangedCallback = 0;
};
@@ -154,7 +154,7 @@
private:
FunctionPointer rx;
- CircBuffer<uint8_t> buf;
+ CircBuffer<uint8_t,128> buf;
void (*settingsChangedCallback)(int baud, int bits, int parity, int stop);
};
