1 /* 2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef R_USB_API_H 8 #define R_USB_API_H 9 10 /*********************************************************************************************************************** 11 * Includes 12 **********************************************************************************************************************/ 13 14 /* Includes board and MCU related header files. */ 15 #include "bsp_api.h" 16 17 /* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ 18 FSP_HEADER 19 20 /********************************************************************************************************************** 21 * Macro definitions 22 **********************************************************************************************************************/ 23 24 /* Descriptor type Define */ 25 #define USB_DT_DEVICE (0x01U) /* Device Descriptor */ 26 #define USB_DT_CONFIGURATION (0x02U) /* Configuration Descriptor */ 27 #define USB_DT_STRING (0x03U) /* String Descriptor */ 28 #define USB_DT_INTERFACE (0x04U) /* Interface Descriptor */ 29 #define USB_DT_ENDPOINT (0x05U) /* Endpoint Descriptor */ 30 #define USB_DT_DEVICE_QUALIFIER (0x06U) /* Device Qualifier Descriptor */ 31 #define USB_DT_OTHER_SPEED_CONF (0x07U) /* Other Speed Configuration Descriptor */ 32 #define USB_DT_INTERFACE_POWER (0x08U) /* Interface Power Descriptor */ 33 #define USB_DT_OTGDESCRIPTOR (0x09U) /* OTG Descriptor */ 34 #define USB_DT_HUBDESCRIPTOR (0x29U) /* HUB descriptor */ 35 36 /********************************************************************************************************************** 37 * Typedef definitions 38 **********************************************************************************************************************/ 39 40 /** USB request type */ 41 typedef enum e_usb_request_type 42 { 43 USB_REQ_TYPE_STANDARD = 0, 44 USB_REQ_TYPE_CLASS, 45 USB_REQ_TYPE_VENDOR, 46 USB_REQ_TYPE_INVALID 47 } usb_request_type_t; 48 49 /** USB request recipient */ 50 typedef enum e_usb_request_recipient 51 { 52 USB_REQ_RCPT_DEVICE = 0, 53 USB_REQ_RCPT_INTERFACE, 54 USB_REQ_RCPT_ENDPOINT, 55 USB_REQ_RCPT_OTHER 56 } usb_request_recipient_t; 57 58 /** USB Endpoint Descriptor */ 59 typedef __PACKED_STRUCT st_usb_desc_endpoint 60 { 61 uint8_t bLength; /* Size of this descriptor in bytes */ 62 uint8_t bDescriptorType; /* ENDPOINT Descriptor Type */ 63 uint8_t bEndpointAddress; /* The address of the endpoint */ 64 65 __PACKED_STRUCT 66 { 67 uint8_t xfer : 2; /* Control, ISO, Bulk, Interrupt */ 68 uint8_t sync : 2; /* None, Asynchronous, Adaptive, Synchronous */ 69 uint8_t usage : 2; /* Data, Feedback, Implicit feedback */ 70 uint8_t : 2; 71 } bmAttributes; 72 73 uint16_t wMaxPacketSize; /* Bit 10..0 : max packet size, bit 12..11 additional transaction per highspeed micro-frame */ 74 uint8_t bInterval; /* Polling interval, in frames or microframes depending on the operating speed */ 75 } usb_desc_endpoint_t; 76 77 /** USB xfer type */ 78 typedef enum e_usb_xfer_type 79 { 80 USB_XFER_CONTROL = 0, 81 USB_XFER_ISOCHRONOUS, 82 USB_XFER_BULK, 83 USB_XFER_INTERRUPT 84 } usb_xfer_type_t; 85 86 /** USB endpoint direction */ 87 typedef enum e_usb_dir 88 { 89 USB_DIR_OUT = 0, 90 USB_DIR_IN = 1, 91 USB_DIR_IN_MASK = 0x80 92 } usb_dir_t; 93 94 /** USB speed */ 95 typedef enum e_usb_speed 96 { 97 USB_SPEED_LS = 0, /* Low speed operation */ 98 USB_SPEED_FS, /* Full speed operation */ 99 USB_SPEED_HS, /* Hi speed operation */ 100 USB_SPEED_INVALID, 101 } usb_speed_t; 102 103 /** USB xfer result */ 104 typedef enum e_usb_xfer_result 105 { 106 USB_XFER_RESULT_SUCCESS = 0, 107 USB_XFER_RESULT_FAILED, 108 USB_XFER_RESULT_STALLED, 109 USB_XFER_RESULT_TIMEOUT, 110 USB_XFER_RESULT_INVALID 111 } usb_xfer_result_t; 112 113 #endif /* R_USB_API_H */ 114