22 #include "USBDevice_Types.h"    24 #include "mbed_critical.h"    60             uint8_t dataTransferDirection;
    78     USBDevice(
USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release);
   234     bool read_start(usb_ep_t endpoint, uint8_t *buffer, uint32_t size);
   256     bool write_start(usb_ep_t endpoint, uint8_t *buffer, uint32_t size);
   271     virtual const uint8_t *device_desc();
   279     virtual const uint8_t *configuration_desc(uint8_t index) = 0;
   286     virtual const uint8_t *string_langid_desc();
   293     virtual const uint8_t *string_imanufacturer_desc();
   300     virtual const uint8_t *string_iproduct_desc();
   307     virtual const uint8_t *string_iserial_desc();
   314     virtual const uint8_t *string_iconfiguration_desc();
   321     virtual const uint8_t *string_iinterface_desc();
   328     virtual uint16_t report_desc_dength()
   409     void complete_request(RequestResult result, uint8_t *data = NULL, uint32_t size = 0);
   442     virtual void callback_set_configuration(uint8_t configuration) = 0;
   462     virtual void callback_set_interface(uint16_t interface, uint8_t alternate) = 0;
   510     uint16_t product_release;
   511     uint8_t device_descriptor[18];
   515     virtual void power(
bool powered);
   516     virtual void suspend(
bool suspended);
   517     virtual void sof(
int frame_number);
   518     virtual void reset();
   519     virtual void ep0_setup();
   520     virtual void ep0_out();
   521     virtual void ep0_in();
   522     virtual void out(usb_ep_t endpoint);
   523     virtual void in(usb_ep_t endpoint);
   525     bool _request_get_descriptor();
   528     bool _request_set_address();
   529     bool _request_set_configuration();
   530     bool _request_set_feature();
   531     bool _request_clear_feature();
   532     bool _request_get_status();
   533     bool _request_setup();
   534     void _control_setup();
   535     void _control_abort();
   536     void _control_abort_start();
   537     void _control_setup_continue();
   539     bool _request_get_configuration();
   540     bool _request_get_interface();
   541     bool _request_set_interface();
   542     void _change_state(DeviceState state);
   543     void _run_later(
void (
USBDevice::*
function)());
   545     void _complete_request();
   546     void _complete_request_xfer_done();
   547     void _complete_set_configuration();
   548     void _complete_set_interface();
   550     struct endpoint_info_t {
   552         uint16_t max_packet_size;
   553         uint16_t transfer_size;
   558     struct usb_device_t {
   559         volatile DeviceState state;
   560         uint8_t configuration;
   579     struct complete_request_t {
   580         RequestResult result;
   585     union complete_args_t {
   586         complete_request_t request;
   590     struct control_transfer_t {
   598         UserCallback user_callback;
   599         complete_args_t args;
   602     endpoint_info_t _endpoint_info[32 - 2];
   607     bool _endpoint_add_remove_allowed;
   608     control_transfer_t _transfer;
   609     usb_device_t _device;
   610     uint32_t _max_packet_size_ep0;
   616     uint16_t _current_interface;
   617     uint8_t _current_alternate;
 void complete_request(RequestResult result, uint8_t *data=NULL, uint32_t size=0)
Called to complete the setup stage of a callback request. 
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, mbed::Callback< void()> callback=nullptr)
Add an endpoint. 
void sof_enable()
Enable the start of frame interrupt. 
void endpoint_remove_all()
Remove all non-zero endpoints. 
void deinit()
Power down this instance. 
void complete_request_xfer_done(bool success)
Called to complete the data stage of a callback request. 
void endpoint_stall(usb_ep_t endpoint)
Stall an endpoint. 
void disconnect()
Disconnect a device. 
void endpoint_remove(usb_ep_t endpoint)
Remove an endpoint. 
uint32_t read_finish(usb_ep_t endpoint)
Get the status of a read. 
virtual void callback_power(bool powered)
Called by USBDevice layer on power state change. 
uint8_t * find_descriptor(uint8_t descriptor_type, uint8_t index=0)
Find a descriptor type inside the configuration descriptor. 
virtual void callback_request_xfer_done(const setup_packet_t *setup, bool aborted)=0
Called by USBDevice on data stage completion. 
void connect()
Connect a device This method can also be used to resume USB operation when USB power is detected afte...
Abstract interface to physical USB hardware. 
virtual void callback_reset()
Called by USBDevice layer on bus reset. 
void endpoint_unstall(usb_ep_t endpoint)
Un-stall an endpoint. 
void complete_set_configuration(bool success)
Called to complete a set configuration command. 
virtual void callback_request(const setup_packet_t *setup)=0
Called by USBDevice on Endpoint0 request. 
virtual void callback_state_change(DeviceState new_state)=0
Called when USB changes state. 
bool read_start(usb_ep_t endpoint, uint8_t *buffer, uint32_t size)
start a read on the given endpoint 
void sof_disable()
Disable the start of frame interrupt. 
virtual void lock()
Acquire exclusive access to this instance USBDevice. 
const usb_ep_table_t * endpoint_table()
Get the endpoint table of this device. 
virtual void start_process()
Callback called to indicate the USB processing needs to be done. 
uint32_t endpoint_max_packet_size(usb_ep_t endpoint)
Get the current maximum size for this endpoint. 
virtual void unlock()
Release exclusive access to this instance USBDevice. 
void init()
Initialize this instance. 
bool write_start(usb_ep_t endpoint, uint8_t *buffer, uint32_t size)
Write a data to the given endpoint. 
virtual ~USBDevice()
Cleanup this USBDevice. 
void endpoint_abort(usb_ep_t endpoint)
Abort the current transfer on this endpoint. 
USBDevice(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
Instantiate a new USBDevice with the given parameters. 
bool configured()
Check if the device is configured. 
Callback class based on template specialization. 
void complete_set_interface(bool success)
Called to complete a set interface command. 
virtual void callback_sof(int frame_number)
Called by USBDevice layer on each new USB frame. 
Event handler for USBPhy. 
virtual void assert_locked()
Assert that the current thread of execution holds the lock. 
uint32_t write_finish(usb_ep_t endpoint)
Get the status of a write. 
bool endpoint_add(usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type, void(T::*callback)())
Add an endpoint.