ChibiOS 21.11.4
|
USB Driver macros and structures. More...
#include "hal_usb_lld.h"
Go to the source code of this file.
Data Structures | |
struct | USBDescriptor |
Type of an USB descriptor. More... |
Macros | |
#define | USB_ENDPOINT_OUT(ep) |
#define | USB_ENDPOINT_IN(ep) |
#define | USB_RTYPE_DIR_MASK 0x80U |
#define | USB_RTYPE_DIR_HOST2DEV 0x00U |
#define | USB_RTYPE_DIR_DEV2HOST 0x80U |
#define | USB_RTYPE_TYPE_MASK 0x60U |
#define | USB_RTYPE_TYPE_STD 0x00U |
#define | USB_RTYPE_TYPE_CLASS 0x20U |
#define | USB_RTYPE_TYPE_VENDOR 0x40U |
#define | USB_RTYPE_TYPE_RESERVED 0x60U |
#define | USB_RTYPE_RECIPIENT_MASK 0x1FU |
#define | USB_RTYPE_RECIPIENT_DEVICE 0x00U |
#define | USB_RTYPE_RECIPIENT_INTERFACE 0x01U |
#define | USB_RTYPE_RECIPIENT_ENDPOINT 0x02U |
#define | USB_RTYPE_RECIPIENT_OTHER 0x03U |
#define | USB_REQ_GET_STATUS 0U |
#define | USB_REQ_CLEAR_FEATURE 1U |
#define | USB_REQ_SET_FEATURE 3U |
#define | USB_REQ_SET_ADDRESS 5U |
#define | USB_REQ_GET_DESCRIPTOR 6U |
#define | USB_REQ_SET_DESCRIPTOR 7U |
#define | USB_REQ_GET_CONFIGURATION 8U |
#define | USB_REQ_SET_CONFIGURATION 9U |
#define | USB_REQ_GET_INTERFACE 10U |
#define | USB_REQ_SET_INTERFACE 11U |
#define | USB_REQ_SYNCH_FRAME 12U |
#define | USB_DESCRIPTOR_DEVICE 1U |
#define | USB_DESCRIPTOR_CONFIGURATION 2U |
#define | USB_DESCRIPTOR_STRING 3U |
#define | USB_DESCRIPTOR_INTERFACE 4U |
#define | USB_DESCRIPTOR_ENDPOINT 5U |
#define | USB_DESCRIPTOR_DEVICE_QUALIFIER 6U |
#define | USB_DESCRIPTOR_OTHER_SPEED_CFG 7U |
#define | USB_DESCRIPTOR_INTERFACE_POWER 8U |
#define | USB_DESCRIPTOR_INTERFACE_ASSOCIATION 11U |
#define | USB_FEATURE_ENDPOINT_HALT 0U |
#define | USB_FEATURE_DEVICE_REMOTE_WAKEUP 1U |
#define | USB_FEATURE_TEST_MODE 2U |
#define | USB_EARLY_SET_ADDRESS 0 |
#define | USB_LATE_SET_ADDRESS 1 |
#define | USB_EP0_STATUS_STAGE_SW 0 |
#define | USB_EP0_STATUS_STAGE_HW 1 |
#define | USB_SET_ADDRESS_ACK_SW 0 |
#define | USB_SET_ADDRESS_ACK_HW 1 |
#define | USB_IN_STATE 0x08U |
#define | USB_OUT_STATE 0x10U |
#define | USB_USE_WAIT FALSE |
Enables synchronous APIs. | |
Helper macros for USB descriptors | |
#define | USB_DESC_INDEX(i) |
Helper macro for index values into descriptor strings. | |
#define | USB_DESC_BYTE(b) |
Helper macro for byte values into descriptor strings. | |
#define | USB_DESC_WORD(w) |
Helper macro for word values into descriptor strings. | |
#define | USB_DESC_BCD(bcd) |
Helper macro for BCD values into descriptor strings. | |
#define | USB_DESC_DEVICE_SIZE 18U |
#define | USB_DESC_DEVICE(bcdUSB, bDeviceClass, bDeviceSubClass, bDeviceProtocol, bMaxPacketSize, idVendor, idProduct, bcdDevice, iManufacturer, iProduct, iSerialNumber, bNumConfigurations) |
Device Descriptor helper macro. | |
#define | USB_DESC_CONFIGURATION_SIZE 9U |
Configuration Descriptor size. | |
#define | USB_DESC_CONFIGURATION(wTotalLength, bNumInterfaces, bConfigurationValue, iConfiguration, bmAttributes, bMaxPower) |
Configuration Descriptor helper macro. | |
#define | USB_DESC_INTERFACE_SIZE 9U |
Interface Descriptor size. | |
#define | USB_DESC_INTERFACE(bInterfaceNumber, bAlternateSetting, bNumEndpoints, bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol, iInterface) |
Interface Descriptor helper macro. | |
#define | USB_DESC_INTERFACE_ASSOCIATION_SIZE 8U |
Interface Association Descriptor size. | |
#define | USB_DESC_INTERFACE_ASSOCIATION(bFirstInterface, bInterfaceCount, bFunctionClass, bFunctionSubClass, bFunctionProcotol, iInterface) |
Interface Association Descriptor helper macro. | |
#define | USB_DESC_ENDPOINT_SIZE 7U |
Endpoint Descriptor size. | |
#define | USB_DESC_ENDPOINT(bEndpointAddress, bmAttributes, wMaxPacketSize, bInterval) |
Endpoint Descriptor helper macro. | |
Endpoint types and settings | |
#define | USB_EP_MODE_TYPE 0x0003U |
#define | USB_EP_MODE_TYPE_CTRL 0x0000U |
#define | USB_EP_MODE_TYPE_ISOC 0x0001U |
#define | USB_EP_MODE_TYPE_BULK 0x0002U |
#define | USB_EP_MODE_TYPE_INTR 0x0003U |
Macro Functions | |
#define | usbGetDriverStateI(usbp) |
Returns the driver state. | |
#define | usbConnectBus(usbp) |
Connects the USB device. | |
#define | usbDisconnectBus(usbp) |
Disconnect the USB device. | |
#define | usbGetFrameNumberX(usbp) |
Returns the current frame number. | |
#define | usbGetTransmitStatusI(usbp, ep) |
Returns the status of an IN endpoint. | |
#define | usbGetReceiveStatusI(usbp, ep) |
Returns the status of an OUT endpoint. | |
#define | usbGetReceiveTransactionSizeX(usbp, ep) |
Returns the exact size of a receive transaction. | |
#define | usbSetupTransfer(usbp, buf, n, endcb) |
Request transfer setup. | |
#define | usbReadSetup(usbp, ep, buf) |
Reads a setup packet from the dedicated packet buffer. | |
Low level driver helper macros | |
#define | _usb_isr_invoke_event_cb(usbp, evt) |
Common ISR code, usb event callback. | |
#define | _usb_isr_invoke_sof_cb(usbp) |
Common ISR code, SOF callback. | |
#define | _usb_isr_invoke_setup_cb(usbp, ep) |
Common ISR code, setup packet callback. | |
#define | _usb_isr_invoke_in_cb(usbp, ep) |
Common ISR code, IN endpoint callback. | |
#define | _usb_isr_invoke_out_cb(usbp, ep) |
Common ISR code, OUT endpoint event. |
Typedefs | |
typedef struct USBDriver | USBDriver |
Type of a structure representing an USB driver. | |
typedef uint8_t | usbep_t |
Type of an endpoint identifier. | |
typedef void(* | usbcallback_t) (USBDriver *usbp) |
Type of an USB generic notification callback. | |
typedef void(* | usbepcallback_t) (USBDriver *usbp, usbep_t ep) |
Type of an USB endpoint callback. | |
typedef void(* | usbeventcb_t) (USBDriver *usbp, usbevent_t event) |
Type of an USB event notification callback. | |
typedef bool(* | usbreqhandler_t) (USBDriver *usbp) |
Type of a requests handler callback. | |
typedef const USBDescriptor *(* | usbgetdescriptor_t) (USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t lang) |
Type of an USB descriptor-retrieving callback. |
Enumerations | |
enum | usbstate_t { USB_UNINIT = 0 , USB_STOP = 1 , USB_READY = 2 , USB_SELECTED = 3 , USB_ACTIVE = 4 , USB_SUSPENDED = 5 } |
Type of a driver state machine possible states. More... | |
enum | usbepstatus_t { EP_STATUS_DISABLED = 0 , EP_STATUS_STALLED = 1 , EP_STATUS_ACTIVE = 2 } |
Type of an endpoint status. More... | |
enum | usbep0state_t { USB_EP0_STP_WAITING = 0U , USB_EP0_IN_TX = USB_IN_STATE | 1U , USB_EP0_IN_WAITING_TX0 = USB_IN_STATE | 2U , USB_EP0_IN_SENDING_STS = USB_IN_STATE | 3U , USB_EP0_OUT_WAITING_STS = USB_OUT_STATE | 4U , USB_EP0_OUT_RX = USB_OUT_STATE | 5U , USB_EP0_ERROR = 6U } |
Type of an endpoint zero state machine states. More... | |
enum | usbevent_t { USB_EVENT_RESET = 0 , USB_EVENT_ADDRESS = 1 , USB_EVENT_CONFIGURED = 2 , USB_EVENT_UNCONFIGURED = 3 , USB_EVENT_SUSPEND = 4 , USB_EVENT_WAKEUP = 5 , USB_EVENT_STALLED = 6 } |
Type of an enumeration of the possible USB events. More... |
Functions | |
void | usbInit (void) |
USB Driver initialization. | |
void | usbObjectInit (USBDriver *usbp) |
Initializes the standard part of a USBDriver structure. | |
msg_t | usbStart (USBDriver *usbp, const USBConfig *config) |
Configures and activates the USB peripheral. | |
void | usbStop (USBDriver *usbp) |
Deactivates the USB peripheral. | |
void | usbInitEndpointI (USBDriver *usbp, usbep_t ep, const USBEndpointConfig *epcp) |
Enables an endpoint. | |
void | usbDisableEndpointsI (USBDriver *usbp) |
Disables all the active endpoints. | |
void | usbReadSetupI (USBDriver *usbp, usbep_t ep, uint8_t *buf) |
void | usbStartReceiveI (USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n) |
Starts a receive transaction on an OUT endpoint. | |
void | usbStartTransmitI (USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n) |
Starts a transmit transaction on an IN endpoint. | |
msg_t | usbReceive (USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n) |
Performs a receive transaction on an OUT endpoint. | |
msg_t | usbTransmit (USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n) |
Performs a transmit transaction on an IN endpoint. | |
bool | usbStallReceiveI (USBDriver *usbp, usbep_t ep) |
Stalls an OUT endpoint. | |
bool | usbStallTransmitI (USBDriver *usbp, usbep_t ep) |
Stalls an IN endpoint. | |
void | usbWakeupHost (USBDriver *usbp) |
Host wake-up procedure. | |
void | _usb_reset (USBDriver *usbp) |
USB reset routine. | |
void | _usb_suspend (USBDriver *usbp) |
USB suspend routine. | |
void | _usb_wakeup (USBDriver *usbp) |
USB wake-up routine. | |
void | _usb_ep0setup (USBDriver *usbp, usbep_t ep) |
Default EP0 SETUP callback. | |
void | _usb_ep0in (USBDriver *usbp, usbep_t ep) |
Default EP0 IN callback. | |
void | _usb_ep0out (USBDriver *usbp, usbep_t ep) |
Default EP0 OUT callback. |
USB Driver macros and structures.
Definition in file hal_usb.h.