Updated USBHost for library changes

Updated USBHost classes to use Callback<void()> and new Thread API to
fix compiler warnings.
pull/2634/head
neilt6 2016-09-06 11:31:20 -06:00
parent 9111aa4c2d
commit ae0137681a
6 changed files with 11 additions and 12 deletions

View File

@ -21,6 +21,7 @@
#include "USBEndpoint.h" #include "USBEndpoint.h"
#include "USBHostConf.h" #include "USBHostConf.h"
#include "rtos.h" #include "rtos.h"
#include "Callback.h"
class USBHostHub; class USBHostHub;
@ -31,7 +32,7 @@ typedef struct {
uint8_t intf_subclass; uint8_t intf_subclass;
uint8_t intf_protocol; uint8_t intf_protocol;
USBEndpoint * ep[MAX_ENDPOINT_PER_INTERFACE]; USBEndpoint * ep[MAX_ENDPOINT_PER_INTERFACE];
FunctionPointer detach; Callback<void()> detach;
char name[10]; char name[10];
} INTERFACE; } INTERFACE;

View File

@ -17,7 +17,7 @@
#ifndef USBENDPOINT_H #ifndef USBENDPOINT_H
#define USBENDPOINT_H #define USBENDPOINT_H
#include "FunctionPointer.h" #include "Callback.h"
#include "USBHostTypes.h" #include "USBHostTypes.h"
#include "rtos.h" #include "rtos.h"
@ -153,7 +153,7 @@ private:
int transferred; int transferred;
uint8_t * buf_start; uint8_t * buf_start;
FunctionPointer rx; Callback<void()> rx;
USBEndpoint* nextEp; USBEndpoint* nextEp;

View File

@ -247,11 +247,7 @@ void USBHost::usb_process() {
} }
} }
/* static */void USBHost::usb_process_static(void const * arg) { USBHost::USBHost() : usbThread(osPriorityNormal, USB_THREAD_STACK)
((USBHost *)arg)->usb_process();
}
USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPriorityNormal, USB_THREAD_STACK)
{ {
headControlEndpoint = NULL; headControlEndpoint = NULL;
headBulkEndpoint = NULL; headBulkEndpoint = NULL;
@ -279,6 +275,8 @@ USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPrio
hub_in_use[i] = false; hub_in_use[i] = false;
} }
#endif #endif
usbThread.start(this, &USBHost::usb_process);
} }
USBHost::Lock::Lock(USBHost* pHost) : m_pHost(pHost) USBHost::Lock::Lock(USBHost* pHost) : m_pHost(pHost)

View File

@ -278,7 +278,6 @@ private:
Thread usbThread; Thread usbThread;
void usb_process(); void usb_process();
static void usb_process_static(void const * arg);
Mail<message_t, 10> mail_usb_event; Mail<message_t, 10> mail_usb_event;
Mutex usb_mutex; Mutex usb_mutex;
Mutex td_mutex; Mutex td_mutex;

View File

@ -136,7 +136,7 @@ int USBHostMSD::readCapacity() {
if (status == 0) { if (status == 0) {
blockCount = (result[0] << 24) | (result[1] << 16) | (result[2] << 8) | result[3]; blockCount = (result[0] << 24) | (result[1] << 16) | (result[2] << 8) | result[3];
blockSize = (result[4] << 24) | (result[5] << 16) | (result[6] << 8) | result[7]; blockSize = (result[4] << 24) | (result[5] << 16) | (result[6] << 8) | result[7];
USB_INFO("MSD [dev: %p] - blockCount: %lld, blockSize: %d, Capacity: %lld\r\n", dev, blockCount, blockSize, blockCount*blockSize); USB_INFO("MSD [dev: %p] - blockCount: %u, blockSize: %d, Capacity: %d\r\n", dev, blockCount, blockSize, blockCount*blockSize);
} }
return status; return status;
} }

View File

@ -24,6 +24,7 @@
#include "USBHost.h" #include "USBHost.h"
#include "Stream.h" #include "Stream.h"
#include "MtxCircBuffer.h" #include "MtxCircBuffer.h"
#include "Callback.h"
/** /**
* A class to communicate a USB virtual serial port * A class to communicate a USB virtual serial port
@ -137,8 +138,8 @@ private:
void rxHandler(); void rxHandler();
void txHandler(); void txHandler();
FunctionPointer rx; Callback<void()> rx;
FunctionPointer tx; Callback<void()> tx;
uint8_t serial_intf; uint8_t serial_intf;
}; };