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 USBHost by
Revision 13:b58a2204422f, committed 2013-09-16
- Comitter:
- mbed_official
- Date:
- Mon Sep 16 15:36:24 2013 +0100
- Parent:
- 12:4d2f8064b747
- Child:
- 14:80c2d927b9b5
- Commit message:
- Synchronized with git revision 061259c07c5cd9172d2dbfabf1f0edc51604f316
Changed in this revision
--- a/USBHost/USBEndpoint.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHost/USBEndpoint.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -27,8 +27,8 @@
//TDs have been allocated by the host
memcpy((HCTD**)td_list, td_list_, sizeof(HCTD*)*2); //TODO: Maybe should add a param for td_list size... at least a define
- memcpy(td_list_[0], 0, sizeof(HCTD));
- memcpy(td_list_[1], 0, sizeof(HCTD));
+ memset(td_list_[0], 0, sizeof(HCTD));
+ memset(td_list_[1], 0, sizeof(HCTD));
td_list[0]->ep = this;
td_list[1]->ep = this;
--- a/USBHost/USBHALHost.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHost/USBHALHost.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -39,7 +39,7 @@
#define TOTAL_SIZE (HCCA_SIZE + (MAX_ENDPOINT*ED_SIZE) + (MAX_TD*TD_SIZE))
-static volatile __align(256) uint8_t usb_buf[TOTAL_SIZE] __attribute((section("AHBSRAM1"),aligned)); //256 bytes aligned!
+static volatile uint8_t usb_buf[TOTAL_SIZE] __attribute((section("AHBSRAM1"),aligned(256))); //256 bytes aligned!
USBHALHost * USBHALHost::instHost;
--- a/USBHost/USBHost.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHost/USBHost.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -96,7 +96,6 @@
if (i == MAX_DEVICE_CONNECTED) {
USB_ERR("Too many device connected!!\r\n");
- deviceInited[i] = false;
usb_mutex.unlock();
continue;
}
@@ -287,7 +286,7 @@
{
uint8_t state;
- if(addr == NULL)
+ if(addr == 0)
return;
volatile HCTD* tdList = NULL;
@@ -482,6 +481,8 @@
case INTERRUPT_ENDPOINT:
tailInterruptEndpoint = prec;
break;
+ default:
+ break;
}
}
current->setState(USB_TYPE_FREE);
@@ -1152,13 +1153,12 @@
void USBHost::fillControlBuf(uint8_t requestType, uint8_t request, uint16_t value, uint16_t index, int len)
{
-#ifdef __BIG_ENDIAN
-#error "Must implement BE to LE conv here"
-#endif
setupPacket[0] = requestType;
setupPacket[1] = request;
- //We are in LE so it's fine
- *((uint16_t*)&setupPacket[2]) = value;
- *((uint16_t*)&setupPacket[4]) = index;
- *((uint16_t*)&setupPacket[6]) = (uint32_t) len;
+ setupPacket[2] = (uint8_t) value;
+ setupPacket[3] = (uint8_t) (value >> 8);
+ setupPacket[4] = (uint8_t) index;
+ setupPacket[5] = (uint8_t) (index >> 8);
+ setupPacket[6] = (uint8_t) len;
+ setupPacket[7] = (uint8_t) (len >> 8);
}
--- a/USBHost/USBHostTypes.h Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHost/USBHostTypes.h Mon Sep 16 15:36:24 2013 +0100
@@ -18,6 +18,7 @@
#define USB_INC_H
#include "mbed.h"
+#include "toolchain.h"
enum USB_TYPE {
USB_TYPE_OK = 0,
@@ -135,34 +136,34 @@
#define CONFIGURATION_DESCRIPTOR_LENGTH 0x09
// ------------ HostController Transfer Descriptor ------------
-typedef __packed struct HCTD {
+typedef struct HCTD {
__IO uint32_t control; // Transfer descriptor control
__IO uint8_t * currBufPtr; // Physical address of current buffer pointer
__IO HCTD * nextTD; // Physical pointer to next Transfer Descriptor
__IO uint8_t * bufEnd; // Physical address of end of buffer
void * ep; // ep address where a td is linked in
uint32_t dummy[3]; // padding
-} HCTD;
+} PACKED HCTD;
// ----------- HostController EndPoint Descriptor -------------
-typedef __packed struct hcEd {
+typedef struct hcEd {
__IO uint32_t control; // Endpoint descriptor control
__IO HCTD * tailTD; // Physical address of tail in Transfer descriptor list
__IO HCTD * headTD; // Physcial address of head in Transfer descriptor list
__IO hcEd * nextED; // Physical address of next Endpoint descriptor
-} HCED;
+} PACKED HCED;
// ----------- Host Controller Communication Area ------------
-typedef __packed struct hcca {
+typedef struct hcca {
__IO uint32_t IntTable[32]; // Interrupt Table
__IO uint32_t FrameNumber; // Frame Number
__IO uint32_t DoneHead; // Done Head
volatile uint8_t Reserved[116]; // Reserved for future use
volatile uint8_t Unknown[4]; // Unused
-} HCCA;
+} PACKED HCCA;
-typedef __packed struct {
+typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdUSB;
@@ -177,9 +178,9 @@
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
-} DeviceDescriptor;
+} PACKED DeviceDescriptor;
-typedef __packed struct {
+typedef struct {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t wTotalLength;
@@ -188,7 +189,7 @@
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t bMaxPower;
-} ConfigurationDescriptor;
+} PACKED ConfigurationDescriptor;
typedef struct {
uint8_t bLength;
--- a/USBHost/dbg.h Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHost/dbg.h Mon Sep 16 15:36:24 2013 +0100
@@ -24,26 +24,26 @@
#define DEBUG_EVENT 0
#if (DEBUG)
-#define USB_DBG(x, ...) std::printf("[USB_DBG: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define USB_DBG(x, ...) std::printf("[USB_DBG: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
#else
#define USB_DBG(x, ...)
#endif
#if (DEBUG_TRANSFER)
-#define USB_DBG_TRANSFER(x, ...) std::printf("[USB_TRANSFER: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define USB_DBG_TRANSFER(x, ...) std::printf("[USB_TRANSFER: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
#else
#define USB_DBG_TRANSFER(x, ...)
#endif
#if (DEBUG_EVENT)
-#define USB_DBG_EVENT(x, ...) std::printf("[USB_EVENT: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define USB_DBG_EVENT(x, ...) std::printf("[USB_EVENT: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
#else
#define USB_DBG_EVENT(x, ...)
#endif
-#define USB_INFO(x, ...) std::printf("[USB_INFO: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
-#define USB_WARN(x, ...) std::printf("[USB_WARNING: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
-#define USB_ERR(x, ...) std::printf("[USB_ERR: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define USB_INFO(x, ...) std::printf("[USB_INFO: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define USB_WARN(x, ...) std::printf("[USB_WARNING: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
+#define USB_ERR(x, ...) std::printf("[USB_ERR: %s:%d]" x "\r\n", __FILE__, __LINE__, ##__VA_ARGS__);
#endif
--- a/USBHostHID/USBHostMouse.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHostHID/USBHostMouse.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -82,7 +82,6 @@
void USBHostMouse::rxHandler() {
int len_listen = int_in->getSize();
- int len = int_in->getLengthTransferred();
if (onUpdate) {
(*onUpdate)(report[0] & 0x07, report[1], report[2], report[3]);
--- a/USBHostHub/USBHostHub.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHostHub/USBHostHub.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -192,7 +192,7 @@
host->deviceConnected(dev->getHub() + 1, port, status & PORT_LOW_SPEED, this);
} else {
USB_DBG("[hub handler hub: %d - port: %d] device disconnected", dev->getHub(), port);
- host->deviceDisconnected(dev->getHub() + 1, port, this, NULL);
+ host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
}
clearPortFeature(C_PORT_CONNECTION_FEATURE, port);
@@ -209,7 +209,7 @@
if ((status & PORT_OVER_CURRENT)) {
USB_ERR("OVER CURRENT DETECTED\r\n");
clearPortFeature(PORT_OVER_CURRENT, port);
- host->deviceDisconnected(dev->getHub() + 1, port, this, NULL);
+ host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
}
}
}
@@ -229,7 +229,7 @@
if (status & PORT_OVER_CURRENT) {
USB_ERR("OVER CURRENT DETECTED\r\n");
clearPortFeature(PORT_OVER_CURRENT, port);
- host->deviceDisconnected(dev->getHub() + 1, port, this, NULL);
+ host->deviceDisconnected(dev->getHub() + 1, port, this, 0);
break;
}
Thread::wait(10);
--- a/USBHostMSD/USBHostMSD.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHostMSD/USBHostMSD.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -154,7 +154,7 @@
int USBHostMSD::inquiry(uint8_t lun, uint8_t page_code) {
USB_DBG("Inquiry");
uint8_t evpd = (page_code == 0) ? 0 : 1;
- uint8_t cmd[6] = {0x12, (lun << 5) | evpd, page_code, 0, 36, 0};
+ uint8_t cmd[6] = {0x12, uint8_t((lun << 5) | evpd), page_code, 0, 36, 0};
uint8_t result[36];
int status = SCSITransfer(cmd, 6, DEVICE_TO_HOST, result, 36);
if (status == 0) {
--- a/USBHostMSD/USBHostMSD.h Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHostMSD/USBHostMSD.h Mon Sep 16 15:36:24 2013 +0100
@@ -73,7 +73,7 @@
uint8_t nb_ep;
// Bulk-only CBW
- typedef __packed struct {
+ typedef struct {
uint32_t Signature;
uint32_t Tag;
uint32_t DataLength;
@@ -81,15 +81,15 @@
uint8_t LUN;
uint8_t CBLength;
uint8_t CB[16];
- } CBW;
+ } PACKED CBW;
// Bulk-only CSW
- typedef __packed struct {
+ typedef struct {
uint32_t Signature;
uint32_t Tag;
uint32_t DataResidue;
uint8_t Status;
- } CSW;
+ } PACKED CSW;
CBW cbw;
CSW csw;
--- a/USBHostSerial/USBHostSerial.cpp Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHostSerial/USBHostSerial.cpp Mon Sep 16 15:36:24 2013 +0100
@@ -131,10 +131,10 @@
line_coding.stop_bits = (stop_bits == 1) ? 0 : 2;
// set line coding
- int res = host->controlWrite( dev,
- USB_RECIPIENT_INTERFACE | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS,
- SET_LINE_CODING,
- 0, serial_intf, (uint8_t *)&line_coding, 7);
+ host->controlWrite( dev,
+ USB_RECIPIENT_INTERFACE | USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS,
+ SET_LINE_CODING,
+ 0, serial_intf, (uint8_t *)&line_coding, 7);
}
int USBHostSerial::_getc() {
--- a/USBHostSerial/USBHostSerial.h Tue Aug 13 09:42:31 2013 +0000
+++ b/USBHostSerial/USBHostSerial.h Mon Sep 16 15:36:24 2013 +0100
@@ -142,12 +142,12 @@
uint8_t buf[64];
- typedef __packed struct {
+ typedef struct {
uint32_t baudrate;
uint8_t stop_bits;
uint8_t parity;
uint8_t data_bits;
- } LINE_CODING;
+ } PACKED LINE_CODING;
LINE_CODING line_coding;
