Merge pull request #11136 from facchinm/avoid_derive_needed_usbdevice

USBDevice: Avoid forcing end device to be derived from USBDevice class
pull/11316/head
Martin Kojtal 2019-08-23 15:45:41 +02:00 committed by GitHub
commit 17fd7956ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 9 deletions

View File

@ -19,7 +19,7 @@
#define USBKEYBOARD_H
#include "USBHID.h"
#include "Stream.h"
#include "platform/Stream.h"
#include "PlatformMutex.h"
/* Modifiers, left keys then right keys. */

View File

@ -24,7 +24,7 @@
#include "USBMouse.h"
#include "USBKeyboard.h"
#include "Stream.h"
#include "platform/Stream.h"
#include "USBHID.h"
#include "PlatformMutex.h"

View File

@ -19,7 +19,7 @@
#define USBSERIAL_H
#include "USBCDC.h"
#include "Stream.h"
#include "platform/Stream.h"
#include "Callback.h"
/**

View File

@ -22,6 +22,7 @@
#include "USBDevice_Types.h"
#include "USBPhy.h"
#include "mbed_critical.h"
#include "Callback.h"
/**
* \defgroup drivers_USBDevice USBDevice class
@ -139,7 +140,7 @@ public:
* @param callback Method pointer to be called when a packet is transferred
* @returns true if successful, false otherwise
*/
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, ep_cb_t callback = NULL);
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, mbed::Callback<void()> callback = NULL);
/**
* Add an endpoint
@ -153,7 +154,7 @@ public:
template<typename T>
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, void (T::*callback)())
{
return endpoint_add(endpoint, max_packet, type, static_cast<ep_cb_t>(callback));
return endpoint_add(endpoint, max_packet, type, mbed::callback(this, static_cast<ep_cb_t>(callback)));
}
/**
@ -540,7 +541,7 @@ private:
void _complete_set_interface();
struct endpoint_info_t {
ep_cb_t callback;
mbed::Callback<void()> callback;
uint16_t max_packet_size;
uint16_t transfer_size;
uint8_t flags;

View File

@ -937,7 +937,7 @@ void USBDevice::out(usb_ep_t endpoint)
MBED_ASSERT(info->pending >= 1);
info->pending -= 1;
if (info->callback) {
(this->*(info->callback))();
info->callback();
}
}
@ -955,7 +955,7 @@ void USBDevice::in(usb_ep_t endpoint)
MBED_ASSERT(info->pending >= 1);
info->pending -= 1;
if (info->callback) {
(this->*(info->callback))();
info->callback();
}
}
@ -1051,7 +1051,7 @@ void USBDevice::sof_disable()
unlock();
}
bool USBDevice::endpoint_add(usb_ep_t endpoint, uint32_t max_packet_size, usb_ep_type_t type, ep_cb_t callback)
bool USBDevice::endpoint_add(usb_ep_t endpoint, uint32_t max_packet_size, usb_ep_type_t type, mbed::Callback<void()> callback)
{
lock();