ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers USBEndpoints_NUC472.h Source File

USBEndpoints_NUC472.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2015-2016 Nuvoton
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #define NU_MAX_EPX_BUFSIZE      4096
00017 #define NU_EP2EPL(ep)           ((ep) >> 1)
00018 #define NU_EP2EPH(ep)           (((ep) >> 1) - 1)
00019 #define NU_EPX2EP(ep)           ((ep == CEP) ? EP0OUT : ((ep) - EPA + EP1OUT))
00020 #define NU_EPL2EPH(ep)          ((ep) - 1)
00021 #define NU_EPH2EPL(ep)          ((ep) + 1)
00022 #define NU_EP_DIR_Pos           0
00023 #define NU_EP_DIR_Msk           (1 << NU_EP_DIR_Pos)
00024 #define NU_EP_DIR_OUT           0
00025 #define NU_EP_DIR_IN            1
00026 
00027 #define NU_EP_TYPE(ep)          (((ep) & NU_EP_TYPE_Msk) >> NU_EP_TYPE_Pos)
00028 #define NU_EP_NUM(ep)           (((ep) & NU_EP_NUM_Msk) >> NU_EP_NUM_Pos)
00029 #define NU_EP_DIR(ep)           (((ep) & NU_EP_DIR_Msk) >> NU_EP_DIR_Pos)
00030 #define NU_EP_NUM_DIR(ep)       ((NU_EP_NUM(ep) << 1) | NU_EP_DIR(ep))
00031 
00032 #define NUMBER_OF_PHYSICAL_ENDPOINTS    12
00033 
00034 #define EP0OUT      (0)
00035 #define EP0IN       (1)
00036 #define EP1OUT      (2)
00037 #define EP1IN       (3)
00038 #define EP2OUT      (4)
00039 #define EP2IN       (5)
00040 #define EP3OUT      (6)
00041 #define EP3IN       (7)
00042 #define EP4OUT      (8)
00043 #define EP4IN       (9)
00044 #define EP5OUT     (10)
00045 #define EP5IN      (11)
00046 #define EP6OUT     (12)
00047 #define EP6IN      (13)
00048 
00049 /* Maximum Packet sizes */
00050 #define MAX_PACKET_SIZE_EP0     64
00051 #define MAX_PACKET_SIZE_EP1     64
00052 #define MAX_PACKET_SIZE_EP2     64
00053 #define MAX_PACKET_SIZE_EP3     0x60
00054 #define MAX_PACKET_SIZE_EP4     64
00055 #define MAX_PACKET_SIZE_EP5     64
00056 #define MAX_PACKET_SIZE_EP6     64
00057 #define MAX_PACKET_SIZE_EP7     64
00058 #define MAX_PACKET_SIZE_EP8     64
00059 #define MAX_PACKET_SIZE_EP9     64
00060 #define MAX_PACKET_SIZE_EP10    64
00061 #define MAX_PACKET_SIZE_EP11    64
00062 
00063 /* Generic endpoints - intended to be portable accross devices */
00064 /* and be suitable for simple USB devices. */
00065 
00066 /* Bulk endpoints */
00067 #define EPBULK_OUT            EP5OUT
00068 #define EPBULK_IN             EP6IN
00069 #define EPBULK_OUT_callback   EP5_OUT_callback
00070 #define EPBULK_IN_callback    EP6_IN_callback
00071 /* Interrupt endpoints */
00072 #define EPINT_OUT             EP1OUT
00073 #define EPINT_IN              EP2IN
00074 #define EPINT_OUT_callback    EP1_OUT_callback
00075 #define EPINT_IN_callback     EP2_IN_callback
00076 /* Isochronous endpoints */
00077 #define EPISO_OUT             EP3OUT
00078 #define EPISO_IN              EP4IN
00079 #define EPISO_OUT_callback    EP3_OUT_callback
00080 #define EPISO_IN_callback     EP4_IN_callback
00081 
00082 #define MAX_PACKET_SIZE_EPBULK  64
00083 #define MAX_PACKET_SIZE_EPINT   64
00084 #define MAX_PACKET_SIZE_EPISO   1023
00085 
00086 #define USBD_GET_EP_MAX_PAYLOAD(ep)     (*((__IO uint32_t *) ((uint32_t)&USBD->EPAMPS + (uint32_t)((ep)*0x28)))) 
00087 #define USBD_GET_EP_DATA_COUNT(ep)      ((*((__IO uint32_t *) ((uint32_t)&USBD->EPADATCNT + (uint32_t)((ep)*0x28)))) & 0xFFFFF)
00088 #define USBD_SET_EP_SHORT_PACKET(ep)    (*((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)((ep)*0x28))) = (*((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)((ep)*0x28)))) & 0x10 | 0x40)
00089 #define USBD_GET_EP_INT_EN(ep)          (*((__IO uint32_t *) ((uint32_t)&USBD->EPAINTEN + (uint32_t)((ep)*0x28))))