aboutsummaryrefslogtreecommitdiff
path: root/include/usb
diff options
context:
space:
mode:
authorUwe Hermann2010-12-31 18:18:39 +0100
committerUwe Hermann2010-12-31 18:18:39 +0100
commit8f251e8a9d46634be4741f7f1aef3d52fb1b7dba (patch)
treefb3c17756e0b18fe19ca28f0f67b2ae636cac807 /include/usb
parent95793aa6cedeef06db9592602ecf3dc00edec610 (diff)
Some more file/path restructuring.
All #includes now explicitly use the "<libopencm3/stm32/rcc.h>" format. If you want to get rid of the "libopencm3" prefix in your local project you can add a respective -I entry in your Makefile (not recommended though). All .ld files and .a libs are installed in $(TOOLCHAIN_DIR)/lib directly (as before), but are now renamed to avoid potential conflicts now or in the future. Examples: libopencm3_lpc13xx.a libopencm3_lpc13xx.ld libopencm3_stm32.a libopencm3_stm32.ld
Diffstat (limited to 'include/usb')
-rw-r--r--include/usb/cdc.h127
-rw-r--r--include/usb/dfu.h81
-rw-r--r--include/usb/hid.h38
-rw-r--r--include/usb/usbd.h66
-rw-r--r--include/usb/usbstd.h204
5 files changed, 0 insertions, 516 deletions
diff --git a/include/usb/cdc.h b/include/usb/cdc.h
deleted file mode 100644
index 2bdc18b..0000000
--- a/include/usb/cdc.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * This file is part of the libopencm3 project.
- *
- * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __CDC_H
-#define __CDC_H
-
-/* Definitions of Communications Device Class from
- * "Universal Serial Bus Class Definitions for Communications Devices
- * Revision 1.2"
- */
-
-/* Table 2: Communications Device Class Code */
-#define USB_CLASS_CDC 0x02
-
-/* Table 4: Class Subclass Code */
-#define USB_CDC_SUBCLASS_DLCM 0x01
-#define USB_CDC_SUBCLASS_ACM 0x02
-/* ... */
-
-/* Table 5 Communications Interface Class Control Protocol Codes */
-#define USB_CDC_PROTOCOL_NONE 0x00
-#define USB_CDC_PROTOCOL_AT 0x01
-/* ... */
-
-/* Table 6: Data Interface Class Code */
-#define USB_CLASS_DATA 0x0A
-
-/* Table 12: Type Values for the bDescriptorType Field */
-#define CS_INTERFACE 0x24
-#define CS_ENDPOINT 0x25
-
-/* Table 13: bDescriptor SubType in Communications Class Functional
- * Descriptors */
-#define USB_CDC_TYPE_HEADER 0x00
-#define USB_CDC_TYPE_CALL_MANAGEMENT 0x01
-#define USB_CDC_TYPE_ACM 0x02
-/* ... */
-#define USB_CDC_TYPE_UNION 0x06
-/* ... */
-
-/* Table 15: Class-Specific Descriptor Header Format */
-struct usb_cdc_header_descriptor {
- u8 bFunctionLength;
- u8 bDescriptorType;
- u8 bDescriptorSubtype;
- u16 bcdCDC;
-} __attribute__((packed));
-
-/* Table 16: Union Interface Functional Descriptor */
-struct usb_cdc_union_descriptor {
- u8 bFunctionLength;
- u8 bDescriptorType;
- u8 bDescriptorSubtype;
- u8 bControlInterface;
- u8 bSubordinateInterface0;
- /* ... */
-} __attribute__((packed));
-
-
-/* Definitions for Abstract Control Model devices from:
- * "Universal Serial Bus Communications Class Subclass Specification for
- * PSTN Devices"
- */
-
-/* Table 3: Call Management Functional Descriptor */
-struct usb_cdc_call_management_descriptor {
- u8 bFunctionLength;
- u8 bDescriptorType;
- u8 bDescriptorSubtype;
- u8 bmCapabilities;
- u8 bDataInterface;
-} __attribute__((packed));
-
-/* Table 4: Abstract Control Management Functional Descriptor */
-struct usb_cdc_acm_descriptor {
- u8 bFunctionLength;
- u8 bDescriptorType;
- u8 bDescriptorSubtype;
- u8 bmCapabilities;
-} __attribute__((packed));
-
-/* Table 13: Class-Specific Request Codes for PSTN subclasses */
-/* ... */
-#define USB_CDC_REQ_SET_LINE_CODING 0x20
-/* ... */
-#define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
-/* ... */
-
-/* Table 17: Line Coding Structure */
-struct usb_cdc_line_coding {
- u32 dwDTERate;
- u8 bCharFormat;
- u8 bParityType;
- u8 bDataBits;
-} __attribute__((packed));
-
-/* Table 30: Class-Specific Notification Codes for PSTN subclasses */
-/* ... */
-#define USB_CDC_NOTIFY_SERIAL_STATE 0x28
-/* ... */
-
-/* Notification Structure */
-struct usb_cdc_notification {
- u8 bmRequestType;
- u8 bNotification;
- u16 wValue;
- u16 wIndex;
- u16 wLength;
-} __attribute__((packed));
-
-#endif
diff --git a/include/usb/dfu.h b/include/usb/dfu.h
deleted file mode 100644
index 0f4c090..0000000
--- a/include/usb/dfu.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * This file is part of the libopencm3 project.
- *
- * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __DFU_H
-#define __DFU_H
-
-enum dfu_req {
- DFU_DETACH,
- DFU_DNLOAD,
- DFU_UPLOAD,
- DFU_GETSTATUS,
- DFU_CLRSTATUS,
- DFU_GETSTATE,
- DFU_ABORT,
-};
-
-enum dfu_status {
- DFU_STATUS_OK,
- DFU_STATUS_ERR_TARGET,
- DFU_STATUS_ERR_FILE,
- DFU_STATUS_ERR_WRITE,
- DFU_STATUS_ERR_ERASE,
- DFU_STATUS_ERR_CHECK_ERASED,
- DFU_STATUS_ERR_PROG,
- DFU_STATUS_ERR_VERIFY,
- DFU_STATUS_ERR_ADDRESS,
- DFU_STATUS_ERR_NOTDONE,
- DFU_STATUS_ERR_FIRMWARE,
- DFU_STATUS_ERR_VENDOR,
- DFU_STATUS_ERR_USBR,
- DFU_STATUS_ERR_POR,
- DFU_STATUS_ERR_UNKNOWN,
- DFU_STATUS_ERR_STALLEDPKT,
-};
-
-enum dfu_state {
- STATE_APP_IDLE,
- STATE_APP_DETACH,
- STATE_DFU_IDLE,
- STATE_DFU_DNLOAD_SYNC,
- STATE_DFU_DNBUSY,
- STATE_DFU_DNLOAD_IDLE,
- STATE_DFU_MANIFEST_SYNC,
- STATE_DFU_MANIFEST,
- STATE_DFU_MANIFEST_WAIT_RESET,
- STATE_DFU_UPLOAD_IDLE,
- STATE_DFU_ERROR,
-};
-
-#define DFU_FUNCTIONAL 0x21
-struct usb_dfu_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u8 bmAttributes;
-#define USB_DFU_CAN_DOWNLOAD 0x01
-#define USB_DFU_CAN_UPLOAD 0x02
-#define USB_DFU_MANIFEST_TOLERANT 0x04
-#define USB_DFU_WILL_DETACH 0x08
-
- u16 wDetachTimeout;
- u16 wTransferSize;
- u16 bcdDFUVersion;
-} __attribute__((packed));
-
-#endif
diff --git a/include/usb/hid.h b/include/usb/hid.h
deleted file mode 100644
index e1d9835..0000000
--- a/include/usb/hid.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of the libopencm3 project.
- *
- * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __HID_H
-#define __HID_H
-
-#include <stdint.h>
-
-#define USB_CLASS_HID 3
-
-#define USB_DT_HID 0x21
-#define USB_DT_REPORT 0x22
-
-struct usb_hid_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u16 bcdHID;
- u8 bCountryCode;
- u8 bNumDescriptors;
-} __attribute__((packed));
-
-#endif
diff --git a/include/usb/usbd.h b/include/usb/usbd.h
deleted file mode 100644
index d861c17..0000000
--- a/include/usb/usbd.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This file is part of the libopencm3 project.
- *
- * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __USBD_H
-#define __USBD_H
-
-#include <usb/usbstd.h>
-
-/* Static buffer for control transactions:
- * This is defined as weak in the library, applicaiton
- * may provide if a larger buffer is requred. */
-extern u8 usbd_control_buffer[];
-
-/* <usb.c> */
-extern int usbd_init(const struct usb_device_descriptor *dev,
- const struct usb_config_descriptor *conf,
- const char **strings);
-extern void usbd_set_control_buffer_size(u16 size);
-
-extern void usbd_register_reset_callback(void (*callback)(void));
-extern void usbd_register_suspend_callback(void (*callback)(void));
-extern void usbd_register_resume_callback(void (*callback)(void));
-
-typedef int (*usbd_control_callback)(struct usb_setup_data *req, u8 **buf,
- u16 *len, void (**complete)(struct usb_setup_data *req));
-
-/* <usb_control.c> */
-extern int usbd_register_control_callback(u8 type, u8 type_mask,
- usbd_control_callback callback);
-
-/* <usb_standard.c> */
-extern void usbd_register_set_config_callback(void (*callback)(u16 wValue));
-
-/* Functions to be provided by the hardware abstraction layer */
-extern void usbd_poll(void);
-
-extern void usbd_ep_setup(u8 addr, u8 type, u16 max_size,
- void (*callback)(u8 ep));
-
-extern u16 usbd_ep_write_packet(u8 addr, const void *buf, u16 len);
-
-extern u16 usbd_ep_read_packet(u8 addr, void *buf, u16 len);
-
-extern void usbd_ep_stall_set(u8 addr, u8 stall);
-extern u8 usbd_ep_stall_get(u8 addr);
-
-/* Optional */
-extern void usbd_cable_connect(u8 on);
-
-#endif
diff --git a/include/usb/usbstd.h b/include/usb/usbstd.h
deleted file mode 100644
index f018289..0000000
--- a/include/usb/usbstd.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * This file is part of the libopencm3 project.
- *
- * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __USBSTD_H
-#define __USBSTD_H
-
-#include <stdint.h>
-#include <cm3/common.h>
-
-/*
- * This file contains structure definitions for the USB control structures
- * defined in chapter 9 of the "Univeral Serial Bus Specification Revision 2.0"
- * Available from the USB Implementers Forum - http://www.usb.org/
- */
-
-/* USB Setup Data structure - Table 9-2 */
-struct usb_setup_data {
- u8 bmRequestType;
- u8 bRequest;
- u16 wValue;
- u16 wIndex;
- u16 wLength;
-} __attribute__((packed));
-
-/* bmRequestType bit definitions */
-#define USB_REQ_TYPE_IN 0x80
-#define USB_REQ_TYPE_STANDARD 0x00
-#define USB_REQ_TYPE_CLASS 0x20
-#define USB_REQ_TYPE_VENDOR 0x40
-#define USB_REQ_TYPE_DEVICE 0x00
-#define USB_REQ_TYPE_INTERFACE 0x01
-#define USB_REQ_TYPE_ENDPOINT 0x02
-
-#define USB_REQ_TYPE_DIRECTION 0x80
-#define USB_REQ_TYPE_TYPE 0x60
-#define USB_REQ_TYPE_RECIPIENT 0x1F
-
-/* USB Standard Request Codes - Table 9-4 */
-#define USB_REQ_GET_STATUS 0
-#define USB_REQ_CLEAR_FEATURE 1
-/* Reserved for future use: 2 */
-#define USB_REQ_SET_FEATURE 3
-/* Reserved for future use: 3 */
-#define USB_REQ_SET_ADDRESS 5
-#define USB_REQ_GET_DESCRIPTOR 6
-#define USB_REQ_SET_DESCRIPTOR 7
-#define USB_REQ_GET_CONFIGURATION 8
-#define USB_REQ_SET_CONFIGURATION 9
-#define USB_REQ_GET_INTERFACE 10
-#define USB_REQ_SET_INTERFACE 11
-#define USB_REQ_SET_SYNCH_FRAME 12
-
-/* USB Descriptor Types - Table 9-5 */
-#define USB_DT_DEVICE 1
-#define USB_DT_CONFIGURATION 2
-#define USB_DT_STRING 3
-#define USB_DT_INTERFACE 4
-#define USB_DT_ENDPOINT 5
-#define USB_DT_DEVICE_QUALIFIER 6
-#define USB_DT_OTHER_SPEED_CONFIGURATION 7
-#define USB_DT_INTERFACE_POWER 8
-
-/* USB Standard Feature Selectors - Table 9-6 */
-#define USB_FEAT_ENDPOINT_HALT 0
-#define USB_FEAT_DEVICE_REMOTE_WAKEUP 1
-#define USB_FEAT_TEST_MODE 2
-
-/* Information Returned by a GetStatus() Request to a Device - Figure 9-4 */
-#define USB_DEV_STATUS_SELF_POWERED 0x01
-#define USB_DEV_STATUS_REMOTE_WAKEUP 0x02
-
-/* USB Standard Device Descriptor - Table 9-8 */
-struct usb_device_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u16 bcdUSB;
- u8 bDeviceClass;
- u8 bDeviceSubClass;
- u8 bDeviceProtocol;
- u8 bMaxPacketSize0;
- u16 idVendor;
- u16 idProduct;
- u16 bcdDevice;
- u8 iManufacturer;
- u8 iProduct;
- u8 iSerialNumber;
- u8 bNumConfigurations;
-} __attribute__((packed));
-
-#define USB_DT_DEVICE_SIZE sizeof(struct usb_device_descriptor)
-
-/* USB Device_Qualifier Descriptor - Table 9-9
- * Not used in this implementation.
- */
-struct usb_device_qualifier_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u16 bcdUSB;
- u8 bDeviceClass;
- u8 bDeviceSubClass;
- u8 bDeviceProtocol;
- u8 bMaxPacketSize0;
- u8 bNumConfigurations;
- u8 bReserved;
-} __attribute__((packed));
-
-/* USB Standard Configuration Descriptor - Table 9-10 */
-struct usb_config_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u16 wTotalLength;
- u8 bNumInterfaces;
- u8 bConfigurationValue;
- u8 iConfiguration;
- u8 bmAttributes;
- u8 bMaxPower;
-
- /* Descriptor ends here. The following are used internally: */
- const struct usb_interface {
- int num_altsetting;
- const struct usb_interface_descriptor *altsetting;
- } *interface;
-} __attribute__((packed));
-#define USB_DT_CONFIGURATION_SIZE 9
-
-/* USB Configuration Descriptor bmAttributes bit definitions */
-#define USB_CONFIG_ATTR_SELF_POWERED 0x40
-#define USB_CONFIG_ATTR_REMOTE_WAKEUP 0x20
-
-/* Other Speed Configuration is the same as Configuration Descriptor.
- * - Table 9-11
- */
-
-/* USB Standard Interface Descriptor - Table 9-12 */
-struct usb_interface_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u8 bInterfaceNumber;
- u8 bAlternateSetting;
- u8 bNumEndpoints;
- u8 bInterfaceClass;
- u8 bInterfaceSubClass;
- u8 bInterfaceProtocol;
- u8 iInterface;
-
- /* Descriptor ends here. The following are used internally: */
- const struct usb_endpoint_descriptor *endpoint;
- const void *extra;
- int extralen;
-} __attribute__((packed));
-#define USB_DT_INTERFACE_SIZE 9
-
-/* USB Standard Endpoint Descriptor - Table 9-13 */
-struct usb_endpoint_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u8 bEndpointAddress;
- u8 bmAttributes;
- u16 wMaxPacketSize;
- u8 bInterval;
-} __attribute__((packed));
-#define USB_DT_ENDPOINT_SIZE sizeof(struct usb_endpoint_descriptor)
-
-/* USB Endpoint Descriptor bmAttributes bit definitions */
-#define USB_ENDPOINT_ATTR_CONTROL 0x00
-#define USB_ENDPOINT_ATTR_ISOCHRONOUS 0x01
-#define USB_ENDPOINT_ATTR_BULK 0x02
-#define USB_ENDPOINT_ATTR_INTERRUPT 0x03
-
-#define USB_ENDPOINT_ATTR_NOSYNC 0x00
-#define USB_ENDPOINT_ATTR_ASYNC 0x04
-#define USB_ENDPOINT_ATTR_ADAPTIVE 0x08
-#define USB_ENDPOINT_ATTR_SYNC 0x0C
-
-#define USB_ENDPOINT_ATTR_DATA 0x00
-#define USB_ENDPOINT_ATTR_FEEDBACK 0x10
-#define USB_ENDPOINT_ATTR_IMPLICIT_FEEDBACK_DATA 0x20
-
-/* Table 9-15 specifies String Descriptor Zero.
- * Table 9-16 specified UNICODE String Descriptor.
- */
-struct usb_string_descriptor {
- u8 bLength;
- u8 bDescriptorType;
- u16 wData[];
-} __attribute__((packed));
-
-#endif