Skip to content

Commit ec37b59

Browse files
neilt6adbridge
authored andcommitted
Updated USBHost for library changes
Updated USBHost classes to use Callback<void()> and new Thread API to fix compiler warnings.
1 parent 3022bff commit ec37b59

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

libraries/USBHost/USBHost/USBDeviceConnected.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "USBEndpoint.h"
2222
#include "USBHostConf.h"
2323
#include "rtos.h"
24+
#include "Callback.h"
2425

2526
class USBHostHub;
2627

@@ -31,7 +32,7 @@ typedef struct {
3132
uint8_t intf_subclass;
3233
uint8_t intf_protocol;
3334
USBEndpoint * ep[MAX_ENDPOINT_PER_INTERFACE];
34-
FunctionPointer detach;
35+
Callback<void()> detach;
3536
char name[10];
3637
} INTERFACE;
3738

libraries/USBHost/USBHost/USBEndpoint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef USBENDPOINT_H
1818
#define USBENDPOINT_H
1919

20-
#include "FunctionPointer.h"
20+
#include "Callback.h"
2121
#include "USBHostTypes.h"
2222
#include "rtos.h"
2323

@@ -153,7 +153,7 @@ class USBEndpoint
153153
int transferred;
154154
uint8_t * buf_start;
155155

156-
FunctionPointer rx;
156+
Callback<void()> rx;
157157

158158
USBEndpoint* nextEp;
159159

libraries/USBHost/USBHost/USBHost.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,7 @@ void USBHost::usb_process() {
247247
}
248248
}
249249

250-
/* static */void USBHost::usb_process_static(void const * arg) {
251-
((USBHost *)arg)->usb_process();
252-
}
253-
254-
USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPriorityNormal, USB_THREAD_STACK)
250+
USBHost::USBHost() : usbThread(osPriorityNormal, USB_THREAD_STACK)
255251
{
256252
headControlEndpoint = NULL;
257253
headBulkEndpoint = NULL;
@@ -279,6 +275,8 @@ USBHost::USBHost() : usbThread(USBHost::usb_process_static, (void *)this, osPrio
279275
hub_in_use[i] = false;
280276
}
281277
#endif
278+
279+
usbThread.start(this, &USBHost::usb_process);
282280
}
283281

284282
USBHost::Lock::Lock(USBHost* pHost) : m_pHost(pHost)

libraries/USBHost/USBHost/USBHost.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ class USBHost : public USBHALHost {
278278

279279
Thread usbThread;
280280
void usb_process();
281-
static void usb_process_static(void const * arg);
282281
Mail<message_t, 10> mail_usb_event;
283282
Mutex usb_mutex;
284283
Mutex td_mutex;

libraries/USBHost/USBHostMSD/USBHostMSD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int USBHostMSD::readCapacity() {
136136
if (status == 0) {
137137
blockCount = (result[0] << 24) | (result[1] << 16) | (result[2] << 8) | result[3];
138138
blockSize = (result[4] << 24) | (result[5] << 16) | (result[6] << 8) | result[7];
139-
USB_INFO("MSD [dev: %p] - blockCount: %lld, blockSize: %d, Capacity: %lld\r\n", dev, blockCount, blockSize, blockCount*blockSize);
139+
USB_INFO("MSD [dev: %p] - blockCount: %u, blockSize: %d, Capacity: %d\r\n", dev, blockCount, blockSize, blockCount*blockSize);
140140
}
141141
return status;
142142
}

libraries/USBHost/USBHostSerial/USBHostSerial.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "USBHost.h"
2525
#include "Stream.h"
2626
#include "MtxCircBuffer.h"
27+
#include "Callback.h"
2728

2829
/**
2930
* A class to communicate a USB virtual serial port
@@ -137,8 +138,8 @@ class USBHostSerialPort : public Stream {
137138

138139
void rxHandler();
139140
void txHandler();
140-
FunctionPointer rx;
141-
FunctionPointer tx;
141+
Callback<void()> rx;
142+
Callback<void()> tx;
142143

143144
uint8_t serial_intf;
144145
};

0 commit comments

Comments
 (0)