#ifndef CFG_USBKBD_H
#define CFG_USBKBD_H
+/**
+ * Enable the usbkbd module.
+ *
+ * $WIZ$ type = "autoenabled"
+ */
+#define CONFIG_USBKBD 0
+
/**
* Module logging level.
*
#ifndef CFG_USBMOUSE_H
#define CFG_USBMOUSE_H
+/**
+ * Enable the usbmouse module.
+ *
+ * $WIZ$ type = "autoenabled"
+ */
+#define CONFIG_USBMOUSE 0
+
/**
* Module logging level.
*
#ifndef CFG_USBSER_H
#define CFG_USBSER_H
+/**
+ * Enable the usb-serial module.
+ *
+ * $WIZ$ type = "autoenabled"
+ */
+#define CONFIG_USBSER 0
+
/**
* Module logging level.
*
#include "usb_stm32.h"
+/* XXX: consider to move this to cfg/compiler.h */
#define ALIGNED(x) __attribute__ ((__aligned__(x)))
+
+/* XXX: consider to move this to cfg/macros.h */
#define ALIGN_UP(value, align) (((value) & ((align) - 1)) ? \
(((value) + ((align) - 1)) & ~((align) - 1)) : \
(value))
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
+ *
+ * -->
+ *
+ * \author Andrea Righi <arighi@develer.com>
+ *
+ * \brief USB endpoint allocations
+ *
+ * This file defines how the endpoints are allocated among the supported USB
+ * device drivers in BeRTOs.
+ *
+ */
+
+#ifndef USB_ENDPOINT_H
+#define USB_ENDPOINT_H
+
+/* Enpoint allocation (according to the compile-time options) */
+enum {
+ USB_CTRL_ENDPOINT = 0, /* This must be always allocated */
+#if (defined(CONFIG_USBSER) && CONFIG_USBSER)
+ USB_SERIAL_EP_REPORT,
+ USB_SERIAL_EP_OUT,
+ USB_SERIAL_EP_IN,
+#endif
+#if (defined(CONFIG_USBKBD) && CONFIG_USBKBD)
+ USB_KBD_EP_REPORT,
+#endif
+#if (defined(CONFIG_USBMOUSE) && CONFIG_USBMOUSE)
+ USB_MOUSE_EP_REPORT,
+#endif
+ USB_EP_MAX, /* Number of allocated endpoints */
+};
+
+#endif /* USB_ENDPOINT_H */
#include <cpu/power.h> // cpu_relax()
#include <drv/usb.h>
+#include <drv/usb_endpoint.h>
#include "drv/usb_hid.h"
#include "drv/usbkbd.h"
#define USB_STRING_MANUFACTURER 1
#define USB_STRING_PRODUCT 2
-#define USB_HID_REPORT_EP (USB_DIR_IN | 1)
+#define USB_HID_REPORT_EP (USB_DIR_IN | USB_KBD_EP_REPORT)
static UsbDeviceDesc usb_hid_device_descriptor =
{
#include <cpu/power.h> // cpu_relax()
#include <drv/usb.h>
+#include <drv/usb_endpoint.h>
#include "drv/usb_hid.h"
#include "drv/usbmouse.h"
#define USB_STRING_MANUFACTURER 1
#define USB_STRING_PRODUCT 2
-#define USB_HID_REPORT_EP (USB_DIR_IN | 1)
+#define USB_HID_REPORT_EP (USB_DIR_IN | USB_MOUSE_EP_REPORT)
static UsbDeviceDesc usb_hid_device_descriptor =
{
#include <cpu/power.h> /* cpu_relax() */
#include <drv/usb.h>
+#include <drv/usb_endpoint.h>
#include <string.h> /* memcpy() */
{
.bLength = sizeof(usb_serial_ep_report_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
- .bEndpointAddress = USB_DIR_IN | 1,
+ .bEndpointAddress = USB_DIR_IN | USB_SERIAL_EP_REPORT,
.bmAttributes = USB_ENDPOINT_XFER_INT,
.wMaxPacketSize = usb_cpu_to_le16((uint16_t)8),
.bInterval = 1,
{
.bLength = sizeof(usb_serial_ep_in_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
- .bEndpointAddress = USB_DIR_IN | 3,
+ .bEndpointAddress = USB_DIR_IN | USB_SERIAL_EP_IN,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = usb_cpu_to_le16((uint16_t)64),
.bInterval = 0,
{
.bLength = sizeof(usb_serial_ep_in_descriptor),
.bDescriptorType = USB_DT_ENDPOINT,
- .bEndpointAddress = USB_DIR_OUT | 2,
+ .bEndpointAddress = USB_DIR_OUT | USB_SERIAL_EP_OUT,
.bmAttributes = USB_ENDPOINT_XFER_BULK,
.wMaxPacketSize = usb_cpu_to_le16((uint16_t)64),
.bInterval = 0,