Mbed OS Reference
Loading...
Searching...
No Matches
USBPhyHw Class Reference
Inheritance diagram for USBPhyHw:
USBPhy

Public Member Functions

virtual void init (USBPhyEvents *events)
 Initialize this USBPhy instance. More...
 
virtual void deinit ()
 Power down this USBPhy instance. More...
 
virtual bool powered ()
 Check if USB power is present. More...
 
virtual void connect ()
 Make the USB phy visible to the USB host. More...
 
virtual void disconnect ()
 Detach the USB phy. More...
 
virtual void configure ()
 Set this device to the configured state. More...
 
virtual void unconfigure ()
 Leave the configured state. More...
 
virtual void sof_enable ()
 Enable the start of frame interrupt. More...
 
virtual void sof_disable ()
 Disable the start of frame interrupt. More...
 
virtual void set_address (uint8_t address)
 Set the USBPhy's address. More...
 
virtual void remote_wakeup ()
 Wake upstream devices. More...
 
virtual const usb_ep_table_tendpoint_table ()
 Get the endpoint table. More...
 
virtual uint32_t ep0_set_max_packet (uint32_t max_packet)
 Set wMaxPacketSize of endpoint 0. More...
 
virtual void ep0_setup_read_result (uint8_t *buffer, uint32_t size)
 Read the contents of the SETUP packet. More...
 
virtual void ep0_read (uint8_t *data, uint32_t size)
 Start receiving a packet of up to wMaxPacketSize on endpoint 0. More...
 
virtual uint32_t ep0_read_result ()
 Read the contents of a received packet. More...
 
virtual void ep0_write (uint8_t *buffer, uint32_t size)
 Write a packet on endpoint 0. More...
 
virtual void ep0_stall ()
 Protocol stall on endpoint 0. More...
 
virtual bool endpoint_add (usb_ep_t endpoint, uint32_t max_packet, usb_ep_type_t type)
 Configure and enable an endpoint. More...
 
virtual void endpoint_remove (usb_ep_t endpoint)
 Disable an endpoint. More...
 
virtual void endpoint_stall (usb_ep_t endpoint)
 Perform a functional stall on the given endpoint. More...
 
virtual void endpoint_unstall (usb_ep_t endpoint)
 Un-stall the endpoint. More...
 
virtual bool endpoint_read (usb_ep_t endpoint, uint8_t *data, uint32_t size)
 Start a read on the given endpoint. More...
 
virtual uint32_t endpoint_read_result (usb_ep_t endpoint)
 Finish a read on the given endpoint. More...
 
virtual bool endpoint_write (usb_ep_t endpoint, uint8_t *data, uint32_t size)
 Start a write on the given endpoint. More...
 
virtual void endpoint_abort (usb_ep_t endpoint)
 Abort the current transfer if it has not yet been sent. More...
 
virtual void process ()
 Callback used for performing USB processing. More...
 

Detailed Description

Definition at line 25 of file USBPhyHw.h.

Member Function Documentation

◆ init()

virtual void init ( USBPhyEvents events)
virtual

Initialize this USBPhy instance.

This function must be called before calling any other functions of this class, unless specifically noted.

Parameters
eventsCallback class to handle USB events

Implements USBPhy.

◆ deinit()

virtual void deinit ( )
virtual

Power down this USBPhy instance.

Disable interrupts and stop sending events.

Implements USBPhy.

◆ powered()

virtual bool powered ( )
virtual

Check if USB power is present.

Devices which don't support checking the USB power state must always return true.

Returns
true if USB power is present, false otherwise

Implements USBPhy.

◆ connect()

virtual void connect ( )
virtual

Make the USB phy visible to the USB host.

Enable either the D+ or D- pullup so the host can detect the presence of this device.

Implements USBPhy.

◆ disconnect()

virtual void disconnect ( )
virtual

Detach the USB phy.

Disable the D+ and D- pullup and stop responding to USB traffic.

Implements USBPhy.

◆ configure()

virtual void configure ( )
virtual

Set this device to the configured state.

Enable added endpoints if they are not enabled already.

Implements USBPhy.

◆ unconfigure()

virtual void unconfigure ( )
virtual

Leave the configured state.

This is a notification to the USBPhy indicating that the device is leaving the configured state. The USBPhy can disable all endpoints other than endpoint 0.

Implements USBPhy.

◆ sof_enable()

virtual void sof_enable ( )
virtual

Enable the start of frame interrupt.

Call USBPhyEvents::sof on every frame.

Implements USBPhy.

◆ sof_disable()

virtual void sof_disable ( )
virtual

Disable the start of frame interrupt.

Stop calling USBPhyEvents::sof.

Implements USBPhy.

◆ set_address()

virtual void set_address ( uint8_t  address)
virtual

Set the USBPhy's address.

Parameters
addressThis device's USB address

Implements USBPhy.

◆ remote_wakeup()

virtual void remote_wakeup ( )
virtual

Wake upstream devices.

Implements USBPhy.

◆ endpoint_table()

virtual const usb_ep_table_t * endpoint_table ( )
virtual

Get the endpoint table.

This function returns a table which describes the endpoints can be used, the functionality of those endpoints and the resource cost.

Implements USBPhy.

◆ ep0_set_max_packet()

virtual uint32_t ep0_set_max_packet ( uint32_t  max_packet)
virtual

Set wMaxPacketSize of endpoint 0.

Parameters
max_packetThe wMaxPacketSize value for endpoint 0
Returns
The actual size of endpoint 0

Implements USBPhy.

◆ ep0_setup_read_result()

virtual void ep0_setup_read_result ( uint8_t *  buffer,
uint32_t  size 
)
virtual

Read the contents of the SETUP packet.

Parameters
bufferBuffer to fill with data
sizeSize of buffer passed in

Implements USBPhy.

◆ ep0_read()

virtual void ep0_read ( uint8_t *  data,
uint32_t  size 
)
virtual

Start receiving a packet of up to wMaxPacketSize on endpoint 0.

Parameters
dataBuffer to fill with the data read
sizeSize of buffer

Implements USBPhy.

◆ ep0_read_result()

virtual uint32_t ep0_read_result ( )
virtual

Read the contents of a received packet.

Returns
Size of data read

Implements USBPhy.

◆ ep0_write()

virtual void ep0_write ( uint8_t *  buffer,
uint32_t  size 
)
virtual

Write a packet on endpoint 0.

Parameters
bufferBuffer fill with data to send
sizeSize of data to send

Implements USBPhy.

◆ ep0_stall()

virtual void ep0_stall ( )
virtual

Protocol stall on endpoint 0.

Stall all IN and OUT packets on endpoint 0 until a setup packet is received.

Note
The stall is cleared automatically when a setup packet is received

Implements USBPhy.

◆ endpoint_add()

virtual bool endpoint_add ( usb_ep_t  endpoint,
uint32_t  max_packet,
usb_ep_type_t  type 
)
virtual

Configure and enable an endpoint.

Parameters
endpointEndpoint to configure and enable
max_packetThe maximum packet size that can be sent or received
typeThe type of endpoint this should be configured as - USB_EP_TYPE_BULK, USB_EP_TYPE_INT or USB_EP_TYPE_ISO
Note
This function cannot be used to configure endpoint 0. That must be done with ep0_set_max_packet

Implements USBPhy.

◆ endpoint_remove()

virtual void endpoint_remove ( usb_ep_t  endpoint)
virtual

Disable an endpoint.

Parameters
endpointEndpoint to disable

Implements USBPhy.

◆ endpoint_stall()

virtual void endpoint_stall ( usb_ep_t  endpoint)
virtual

Perform a functional stall on the given endpoint.

Set the HALT feature for this endpoint so that all further communication is aborted.

Parameters
endpointEndpoint to stall

Implements USBPhy.

◆ endpoint_unstall()

virtual void endpoint_unstall ( usb_ep_t  endpoint)
virtual

Un-stall the endpoint.

Clear the HALT feature on this endpoint so communication can resume.

Parameters
endpointEndpoint to stall

Implements USBPhy.

◆ endpoint_read()

virtual bool endpoint_read ( usb_ep_t  endpoint,
uint8_t *  data,
uint32_t  size 
)
virtual

Start a read on the given endpoint.

Parameters
endpointEndpoint to start the read on
dataBuffer to fill with data
sizeSize of the read buffer. This must be at least the max packet size for this endpoint.
Returns
true if the read was successfully started, false otherwise

Implements USBPhy.

◆ endpoint_read_result()

virtual uint32_t endpoint_read_result ( usb_ep_t  endpoint)
virtual

Finish a read on the given endpoint.

Parameters
endpointEndpoint to check
Returns
The number of bytes received

Implements USBPhy.

◆ endpoint_write()

virtual bool endpoint_write ( usb_ep_t  endpoint,
uint8_t *  data,
uint32_t  size 
)
virtual

Start a write on the given endpoint.

Parameters
endpointEndpoint to write to
dataBuffer to write
sizeSize of data to write
Returns
true if the data was prepared for transmit, false otherwise

Implements USBPhy.

◆ endpoint_abort()

virtual void endpoint_abort ( usb_ep_t  endpoint)
virtual

Abort the current transfer if it has not yet been sent.

Parameters
endpointEndpoint to abort the transfer on. It is implementation defined if this function has an effect on receive endpoints.

Implements USBPhy.

◆ process()

virtual void process ( )
virtual

Callback used for performing USB processing.

USBPhy processing should be triggered by calling USBPhyEvents::start_process and done inside process. All USBPhyEvents callbacks aside from USBPhyEvents::start_process must be called in the context of process

Implements USBPhy.