ChibiOS/HAL  6.1.0
hal_usb.h File Reference

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_USE_WAIT   FALSE
 Enables synchronous APIs. More...
 
Helper macros for USB descriptors
#define USB_DESC_INDEX(i)   ((uint8_t)(i))
 Helper macro for index values into descriptor strings. More...
 
#define USB_DESC_BYTE(b)   ((uint8_t)(b))
 Helper macro for byte values into descriptor strings. More...
 
#define USB_DESC_WORD(w)
 Helper macro for word values into descriptor strings. More...
 
#define USB_DESC_BCD(bcd)
 Helper macro for BCD values into descriptor strings. More...
 
#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. More...
 
#define USB_DESC_CONFIGURATION_SIZE   9U
 Configuration Descriptor size. More...
 
#define USB_DESC_CONFIGURATION(wTotalLength, bNumInterfaces, bConfigurationValue, iConfiguration, bmAttributes, bMaxPower)
 Configuration Descriptor helper macro. More...
 
#define USB_DESC_INTERFACE_SIZE   9U
 Interface Descriptor size. More...
 
#define USB_DESC_INTERFACE(bInterfaceNumber, bAlternateSetting, bNumEndpoints, bInterfaceClass, bInterfaceSubClass, bInterfaceProtocol, iInterface)
 Interface Descriptor helper macro. More...
 
#define USB_DESC_INTERFACE_ASSOCIATION_SIZE   8U
 Interface Association Descriptor size. More...
 
#define USB_DESC_INTERFACE_ASSOCIATION(bFirstInterface, bInterfaceCount, bFunctionClass, bFunctionSubClass, bFunctionProcotol, iInterface)
 Interface Association Descriptor helper macro. More...
 
#define USB_DESC_ENDPOINT_SIZE   7U
 Endpoint Descriptor size. More...
 
#define USB_DESC_ENDPOINT(bEndpointAddress, bmAttributes, wMaxPacketSize, bInterval)
 Endpoint Descriptor helper macro. More...
 
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)   ((usbp)->state)
 Returns the driver state. More...
 
#define usbConnectBus(usbp)   usb_lld_connect_bus(usbp)
 Connects the USB device. More...
 
#define usbDisconnectBus(usbp)   usb_lld_disconnect_bus(usbp)
 Disconnect the USB device. More...
 
#define usbGetFrameNumberX(usbp)   usb_lld_get_frame_number(usbp)
 Returns the current frame number. More...
 
#define usbGetTransmitStatusI(usbp, ep)   (((usbp)->transmitting & (uint16_t)((unsigned)1U << (unsigned)(ep))) != 0U)
 Returns the status of an IN endpoint. More...
 
#define usbGetReceiveStatusI(usbp, ep)   (((usbp)->receiving & (uint16_t)((unsigned)1U << (unsigned)(ep))) != 0U)
 Returns the status of an OUT endpoint. More...
 
#define usbGetReceiveTransactionSizeX(usbp, ep)   usb_lld_get_transaction_size(usbp, ep)
 Returns the exact size of a receive transaction. More...
 
#define usbSetupTransfer(usbp, buf, n, endcb)
 Request transfer setup. More...
 
#define usbReadSetup(usbp, ep, buf)   usb_lld_read_setup(usbp, ep, buf)
 Reads a setup packet from the dedicated packet buffer. More...
 
Low level driver helper macros
#define _usb_isr_invoke_event_cb(usbp, evt)
 Common ISR code, usb event callback. More...
 
#define _usb_isr_invoke_sof_cb(usbp)
 Common ISR code, SOF callback. More...
 
#define _usb_isr_invoke_setup_cb(usbp, ep)
 Common ISR code, setup packet callback. More...
 
#define _usb_isr_invoke_in_cb(usbp, ep)
 Common ISR code, IN endpoint callback. More...
 
#define _usb_isr_invoke_out_cb(usbp, ep)
 Common ISR code, OUT endpoint event. More...
 

Typedefs

typedef struct USBDriver USBDriver
 Type of a structure representing an USB driver. More...
 
typedef uint8_t usbep_t
 Type of an endpoint identifier. More...
 
typedef void(* usbcallback_t) (USBDriver *usbp)
 Type of an USB generic notification callback. More...
 
typedef void(* usbepcallback_t) (USBDriver *usbp, usbep_t ep)
 Type of an USB endpoint callback. More...
 
typedef void(* usbeventcb_t) (USBDriver *usbp, usbevent_t event)
 Type of an USB event notification callback. More...
 
typedef bool(* usbreqhandler_t) (USBDriver *usbp)
 Type of a requests handler callback. More...
 
typedef const USBDescriptor *(* usbgetdescriptor_t) (USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t lang)
 Type of an USB descriptor-retrieving callback. More...
 

Enumerations

Functions

void usbInit (void)
 USB Driver initialization. More...
 
void usbObjectInit (USBDriver *usbp)
 Initializes the standard part of a USBDriver structure. More...
 
void usbStart (USBDriver *usbp, const USBConfig *config)
 Configures and activates the USB peripheral. More...
 
void usbStop (USBDriver *usbp)
 Deactivates the USB peripheral. More...
 
void usbInitEndpointI (USBDriver *usbp, usbep_t ep, const USBEndpointConfig *epcp)
 Enables an endpoint. More...
 
void usbDisableEndpointsI (USBDriver *usbp)
 Disables all the active endpoints. More...
 
void usbStartReceiveI (USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n)
 Starts a receive transaction on an OUT endpoint. More...
 
void usbStartTransmitI (USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n)
 Starts a transmit transaction on an IN endpoint. More...
 
msg_t usbReceive (USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n)
 Performs a receive transaction on an OUT endpoint. More...
 
msg_t usbTransmit (USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n)
 Performs a transmit transaction on an IN endpoint. More...
 
bool usbStallReceiveI (USBDriver *usbp, usbep_t ep)
 Stalls an OUT endpoint. More...
 
bool usbStallTransmitI (USBDriver *usbp, usbep_t ep)
 Stalls an IN endpoint. More...
 
void usbWakeupHost (USBDriver *usbp)
 Host wake-up procedure. More...
 
void _usb_reset (USBDriver *usbp)
 USB reset routine. More...
 
void _usb_suspend (USBDriver *usbp)
 USB suspend routine. More...
 
void _usb_wakeup (USBDriver *usbp)
 USB wake-up routine. More...
 
void _usb_ep0setup (USBDriver *usbp, usbep_t ep)
 Default EP0 SETUP callback. More...
 
void _usb_ep0in (USBDriver *usbp, usbep_t ep)
 Default EP0 IN callback. More...
 
void _usb_ep0out (USBDriver *usbp, usbep_t ep)
 Default EP0 OUT callback. More...
 

Detailed Description

USB Driver macros and structures.

Definition in file hal_usb.h.