projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
USB: coding style fixes (structure naming)
[bertos.git]
/
bertos
/
drv
/
usb.h
diff --git
a/bertos/drv/usb.h
b/bertos/drv/usb.h
index d686c63ecca186266f3ad164abbf173294beb1b9..58e5c3178a608db773bf2e9eb0d8304b5c896aac 100644
(file)
--- a/
bertos/drv/usb.h
+++ b/
bertos/drv/usb.h
@@
-152,24
+152,24
@@
enum usb_device_state {
*
* It matches the different fields of the USB 2.0 spec. section 9.3, table 9-2.
*/
*
* It matches the different fields of the USB 2.0 spec. section 9.3, table 9-2.
*/
-typedef struct
usb_ctrlr
equest
+typedef struct
UsbCtrlR
equest
{
uint8_t mRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
{
uint8_t mRequestType;
uint8_t bRequest;
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
-} PACKED
usb_ctrlrequest_
t;
+} PACKED
UsbCtrlReques
t;
/* All standard descriptors have these 2 fields at the beginning */
/* All standard descriptors have these 2 fields at the beginning */
-typedef struct
usb_descriptor_h
eader
+typedef struct
UsbDescH
eader
{
uint8_t bLength;
uint8_t bDescriptorType;
{
uint8_t bLength;
uint8_t bDescriptorType;
-} PACKED
usb_descriptor_header_t
;
+} PACKED
UsbDescHeader
;
/* Device descriptor */
/* Device descriptor */
-typedef struct
usb_device_descriptor
+typedef struct
UsbDeviceDesc
{
uint8_t bLength;
uint8_t bDescriptorType;
{
uint8_t bLength;
uint8_t bDescriptorType;
@@
-185,15
+185,15
@@
typedef struct usb_device_descriptor
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
uint8_t iProduct;
uint8_t iSerialNumber;
uint8_t bNumConfigurations;
-} PACKED
usb_device_descriptor_t
;
+} PACKED
UsbDeviceDesc
;
/* USB string descriptor */
/* USB string descriptor */
-typedef struct
usb_string_descriptor
+typedef struct
UsbStringDesc
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t data[0];
{
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t data[0];
-} PACKED
usb_string_descriptor_t
;
+} PACKED
UsbStringDesc
;
/*
* Macros to define USB strings
/*
* Macros to define USB strings
@@
-221,7
+221,7
@@
typedef struct usb_string_descriptor
#define DEFINE_USB_STRING(__name, __text) \
struct { \
#define DEFINE_USB_STRING(__name, __text) \
struct { \
-
usb_descriptor_header_t __header;
\
+
UsbDescHeader __header;
\
uint8_t __body[sizeof(__text)]; \
} PACKED __name = { \
.__header = { \
uint8_t __body[sizeof(__text)]; \
} PACKED __name = { \
.__header = { \
@@
-264,7
+264,7
@@
typedef struct usb_string_descriptor
#define USB_CDC_SUBCLASS_NCM 0x0d
/* Device configuration descriptor */
#define USB_CDC_SUBCLASS_NCM 0x0d
/* Device configuration descriptor */
-typedef struct
usb_config_descriptor
+typedef struct
UsbConfigDesc
{
uint8_t bLength;
uint8_t bDescriptorType;
{
uint8_t bLength;
uint8_t bDescriptorType;
@@
-274,7
+274,7
@@
typedef struct usb_config_descriptor
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t bMaxPower;
uint8_t iConfiguration;
uint8_t bmAttributes;
uint8_t bMaxPower;
-} PACKED
usb_config_descriptor_t
;
+} PACKED
UsbConfigDesc
;
/* from config descriptor bmAttributes */
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
/* from config descriptor bmAttributes */
#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
@@
-283,7
+283,7
@@
typedef struct usb_config_descriptor
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
/* Device interface descriptor */
#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
/* Device interface descriptor */
-typedef struct
usb_interface_descriptor
+typedef struct
UsbInterfaceDesc
{
uint8_t bLength;
uint8_t bDescriptorType;
{
uint8_t bLength;
uint8_t bDescriptorType;
@@
-294,10
+294,10
@@
typedef struct usb_interface_descriptor
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t iInterface;
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
uint8_t iInterface;
-} PACKED
usb_interface_descriptor_t
;
+} PACKED
UsbInterfaceDesc
;
/* Endpoint descriptor */
/* Endpoint descriptor */
-typedef struct
usb_endpoint_descriptor
+typedef struct
UsbEndpointDesc
{
uint8_t bLength;
uint8_t bDescriptorType;
{
uint8_t bLength;
uint8_t bDescriptorType;
@@
-305,7
+305,7
@@
typedef struct usb_endpoint_descriptor
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
uint8_t bmAttributes;
uint16_t wMaxPacketSize;
uint8_t bInterval;
-} PACKED
usb_endpoint_descriptor_t
;
+} PACKED
UsbEndpointDesc
;
/*
* Endpoints
/*
* Endpoints
@@
-327,133
+327,133
@@
typedef struct usb_endpoint_descriptor
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
/* USB: generic device descriptor */
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
/* USB: generic device descriptor */
-
struct usb_d
evice
+
typedef struct UsbD
evice
{
{
-
usb_device_descriptor_t
*device;
- const
usb_descriptor_header_t
**config;
- const
usb_string_descriptor_t
**strings;
+
UsbDeviceDesc
*device;
+ const
UsbDescHeader
**config;
+ const
UsbStringDesc
**strings;
/* Callbacks */
/* Callbacks */
- void (*event_cb)(
usb_ctrlrequest_
t *);
+ void (*event_cb)(
UsbCtrlReques
t *);
/* Private data */
bool configured;
/* Private data */
bool configured;
-};
+}
UsbDevice
;
/*
/*
- * usb_endpoint
_n
um - get the endpoint's number
+ * usb_endpoint
N
um - get the endpoint's number
*/
*/
-INLINE int usb_endpoint
_num(const usb_endpoint_descriptor_t
*epd)
+INLINE int usb_endpoint
Num(const UsbEndpointDesc
*epd)
{
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
}
/*
{
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
}
/*
- * usb_endpoint
_t
ype - get the endpoint's transfer type
+ * usb_endpoint
T
ype - get the endpoint's transfer type
*/
*/
-INLINE int usb_endpoint
_type(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
Type(const struct UsbEndpointDesc
*epd)
{
return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
}
/*
{
return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
}
/*
- * usb_endpoint
_dir_i
n - check if the endpoint has IN direction
+ * usb_endpoint
DirI
n - check if the endpoint has IN direction
*/
*/
-INLINE int usb_endpoint
_dir_in(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
DirIn(const struct UsbEndpointDesc
*epd)
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
}
/*
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
}
/*
- * usb_endpoint
_dir_o
ut - check if the endpoint has OUT direction
+ * usb_endpoint
DirO
ut - check if the endpoint has OUT direction
*/
*/
-INLINE int usb_endpoint
_dir_out(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
DirOut(const struct UsbEndpointDesc
*epd)
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
}
/*
{
return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
}
/*
- * usb_endpoint
_xfer_b
ulk - check if the endpoint has bulk transfer type
+ * usb_endpoint
XferB
ulk - check if the endpoint has bulk transfer type
*/
*/
-INLINE int usb_endpoint
_xfer_bulk(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
XferBulk(const struct UsbEndpointDesc
*epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_BULK);
}
/*
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_BULK);
}
/*
- * usb_endpoint
_xfer_c
ontrol - check if the endpoint has control transfer type
+ * usb_endpoint
XferC
ontrol - check if the endpoint has control transfer type
*/
*/
-INLINE int usb_endpoint
_xfer_control(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
XferControl(const struct UsbEndpointDesc
*epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_CONTROL);
}
/*
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_CONTROL);
}
/*
- * usb_endpoint
_xfer_i
nt - check if the endpoint has interrupt transfer type
+ * usb_endpoint
XferI
nt - check if the endpoint has interrupt transfer type
*/
*/
-INLINE int usb_endpoint
_xfer_int(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
XferInt(const struct UsbEndpointDesc
*epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_INT);
}
/*
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_INT);
}
/*
- * usb_endpoint
_xfer_i
soc - check if the endpoint has isochronous transfer type
+ * usb_endpoint
XferI
soc - check if the endpoint has isochronous transfer type
*/
*/
-INLINE int usb_endpoint
_xfer_isoc(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
XferIsoc(const struct UsbEndpointDesc
*epd)
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_ISOC);
}
/*
{
return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
USB_ENDPOINT_XFER_ISOC);
}
/*
- * usb_endpoint
_is_bulk_i
n - check if the endpoint is bulk IN
+ * usb_endpoint
IsBulkI
n - check if the endpoint is bulk IN
*/
*/
-INLINE int usb_endpoint
_is_bulk_in(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
IsBulkIn(const struct UsbEndpointDesc
*epd)
{
{
- return usb_endpoint
_xfer_bulk(epd) && usb_endpoint_dir_i
n(epd);
+ return usb_endpoint
XferBulk(epd) && usb_endpointDirI
n(epd);
}
/*
}
/*
- * usb_endpoint
_is_bulk_o
ut - check if the endpoint is bulk OUT
+ * usb_endpoint
IsBulkO
ut - check if the endpoint is bulk OUT
*/
*/
-INLINE int usb_endpoint
_is_bulk_out(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
IsBulkOut(const struct UsbEndpointDesc
*epd)
{
{
- return usb_endpoint
_xfer_bulk(epd) && usb_endpoint_dir_o
ut(epd);
+ return usb_endpoint
XferBulk(epd) && usb_endpointDirO
ut(epd);
}
/*
}
/*
- * usb_endpoint
_is_int_i
n - check if the endpoint is interrupt IN
+ * usb_endpoint
IsIntI
n - check if the endpoint is interrupt IN
*/
*/
-INLINE int usb_endpoint
_is_int_in(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
IsIntIn(const struct UsbEndpointDesc
*epd)
{
{
- return usb_endpoint
_xfer_int(epd) && usb_endpoint_dir_i
n(epd);
+ return usb_endpoint
XferInt(epd) && usb_endpointDirI
n(epd);
}
/*
}
/*
- * usb_endpoint
_is_int_o
ut - check if the endpoint is interrupt OUT
+ * usb_endpoint
IsIntO
ut - check if the endpoint is interrupt OUT
*/
*/
-INLINE int usb_endpoint
_is_int_out(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
IsIntOut(const struct UsbEndpointDesc
*epd)
{
{
- return usb_endpoint
_xfer_int(epd) && usb_endpoint_dir_o
ut(epd);
+ return usb_endpoint
XferInt(epd) && usb_endpointDirO
ut(epd);
}
/*
}
/*
- * usb_endpoint
_is_isoc_i
n - check if the endpoint is isochronous IN
+ * usb_endpoint
IsIsocI
n - check if the endpoint is isochronous IN
*/
*/
-INLINE int usb_endpoint
_is_isoc_in(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
IsIsocIn(const struct UsbEndpointDesc
*epd)
{
{
- return usb_endpoint
_xfer_isoc(epd) && usb_endpoint_dir_i
n(epd);
+ return usb_endpoint
XferIsoc(epd) && usb_endpointDirI
n(epd);
}
/*
}
/*
- * usb_endpoint
_is_isoc_o
ut - check if the endpoint is isochronous OUT
+ * usb_endpoint
IsIsocO
ut - check if the endpoint is isochronous OUT
*/
*/
-INLINE int usb_endpoint
_is_isoc_out(const struct usb_endpoint_descriptor
*epd)
+INLINE int usb_endpoint
IsIsocOut(const struct UsbEndpointDesc
*epd)
{
{
- return usb_endpoint
_xfer_isoc(epd) && usb_endpoint_dir_o
ut(epd);
+ return usb_endpoint
XferIsoc(epd) && usb_endpointDirO
ut(epd);
}
/*
}
/*
@@
-469,6
+469,6
@@
ssize_t usb_ep_write(int ep, const void *buffer, ssize_t size);
/*
* usb_device_register - register a generic USB device driver
*/
/*
* usb_device_register - register a generic USB device driver
*/
-int usb_device_register(
struct usb_d
evice *dev);
+int usb_device_register(
UsbD
evice *dev);
#endif /* USB_H */
#endif /* USB_H */