There is no need to define descriptors for all the supported hardware
endpoints, but just for the ones that are actually used.
Also check the validity of the endpoint addresses considering the
allocated endpoints.
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4383
38d2e660-2303-0410-9eaa-
f027e97ec537
static struct stm32_usb *usb = (struct stm32_usb *)USB_BASE_ADDR;
/* Endpoint descriptors: used for handling requests to use with endpoints */
static struct stm32_usb *usb = (struct stm32_usb *)USB_BASE_ADDR;
/* Endpoint descriptors: used for handling requests to use with endpoints */
-static stm32_UsbEp ep_cnfg[ENP_MAX_NUMB];
+static stm32_UsbEp ep_cnfg[EP_MAX_NUM];
/* USB EP0 control descriptor */
static const UsbEndpointDesc USB_CtrlEpDescr0 =
/* USB EP0 control descriptor */
static const UsbEndpointDesc USB_CtrlEpDescr0 =
static stm32_UsbMemSlot *mem_use;
/* USB packet memory management: memory buffer metadata */
static stm32_UsbMemSlot *mem_use;
/* USB packet memory management: memory buffer metadata */
-#define EP_MAX_SLOTS 16
-static stm32_UsbMemSlot memory_buffer[EP_MAX_SLOTS];
+static stm32_UsbMemSlot memory_buffer[EP_MAX_HW_NUM >> 1];
/* Endpoint TX and RX buffers */
/// \cond
/* Endpoint TX and RX buffers */
/// \cond
static stm32_UsbIoStatus
__usb_ep_read(int ep, void *buffer, ssize_t size, void (*complete)(int))
{
static stm32_UsbIoStatus
__usb_ep_read(int ep, void *buffer, ssize_t size, void (*complete)(int))
{
- if (UNLIKELY((ep >= ENP_MAX_NUMB) || (ep & 0x01)))
+ if (UNLIKELY((ep >= EP_MAX_NUM) || (ep & 0x01)))
{
LOG_ERR("%s: invalid EP number %d\n", __func__, ep);
ASSERT(0);
{
LOG_ERR("%s: invalid EP number %d\n", __func__, ep);
ASSERT(0);
static stm32_UsbIoStatus
__usb_ep_write(int ep, const void *buffer, ssize_t size, void (*complete)(int))
{
static stm32_UsbIoStatus
__usb_ep_write(int ep, const void *buffer, ssize_t size, void (*complete)(int))
{
- if (UNLIKELY((ep >= ENP_MAX_NUMB) || !(ep & 0x01)))
+ if (UNLIKELY((ep >= EP_MAX_NUM) || !(ep & 0x01)))
{
LOG_ERR("%s: invalid EP number %d\n", __func__, ep);
ASSERT(0);
{
LOG_ERR("%s: invalid EP number %d\n", __func__, ep);
ASSERT(0);
static void usb_endpointRead_complete(int ep)
{
static void usb_endpointRead_complete(int ep)
{
- if (UNLIKELY(ep >= ENP_MAX_NUMB))
+ if (UNLIKELY(ep >= EP_MAX_NUM))
static void usb_endpointWrite_complete(int ep)
{
static void usb_endpointWrite_complete(int ep)
{
- if (UNLIKELY(ep >= ENP_MAX_NUMB))
+ if (UNLIKELY(ep >= EP_MAX_NUM))
#include <cfg/compiler.h>
#include <drv/usb.h>
#include <cfg/compiler.h>
#include <drv/usb.h>
+#include <drv/usb_endpoint.h>
#define USB_BASE_ADDR 0x40005C00
#define USB_BASE_ADDR 0x40005C00
#define USB_EP0_MAX_SIZE 8
#define USB_XFER_MAX_SIZE 64
#define USB_EP0_MAX_SIZE 8
#define USB_XFER_MAX_SIZE 64
+#define EP_MAX_SLOTS USB_EP_MAX
+#define EP_MAX_NUM (EP_MAX_SLOTS << 1)
+
/* USB packet memory organization */
#define USB_PACKET_MEMORY_BASE 0x40006000
#define USB_PACKET_MEMORY_SIZE 512
/* Offset of the buffer descriptor table inside the packet memory */
#define USB_BDT_OFFSET \
/* USB packet memory organization */
#define USB_PACKET_MEMORY_BASE 0x40006000
#define USB_PACKET_MEMORY_SIZE 512
/* Offset of the buffer descriptor table inside the packet memory */
#define USB_BDT_OFFSET \
- ((USB_PACKET_MEMORY_SIZE - (sizeof(stm32_UsbBd) * ENP_MAX_NUMB)) & ~7)
+ ((USB_PACKET_MEMORY_SIZE - (sizeof(stm32_UsbBd) * EP_MAX_HW_NUM)) & ~7)
#define USB_MEM_ADDR(offset) \
(USB_PACKET_MEMORY_BASE + ((offset << 1) & ~3) + (offset & 1))
#define USB_MEM_ADDR(offset) \
(USB_PACKET_MEMORY_BASE + ((offset << 1) & ~3) + (offset & 1))
ENP14_OUT, ENP14_IN,
ENP15_OUT, ENP15_IN,
ENP14_OUT, ENP14_IN,
ENP15_OUT, ENP15_IN,
} stm32_UsbEP;
/* STM32 USB packet memory slot */
} stm32_UsbEP;
/* STM32 USB packet memory slot */