|
| 1 | + |
| 2 | +#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 0) |
| 3 | +#define NU_MAX_EPX_BUFSIZE 4096 |
| 4 | +#else |
| 5 | +#define NU_MAX_EPX_BUFSIZE 4096 |
| 6 | +#endif |
| 7 | + |
| 8 | +#define NU_EP2EPL(ep) ((ep) >> 1) |
| 9 | + |
| 10 | +#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 0) |
| 11 | +#define NU_EP2EPH(ep) (((ep) >> 1) + 1) |
| 12 | +#define NU_EPL2EPH(ep) ((ep) + 1) |
| 13 | +#define NU_EPH2EPL(ep) ((ep) - 1) |
| 14 | +#define NUMBER_OF_PHYSICAL_ENDPOINTS 8 |
| 15 | +#else |
| 16 | +#define NU_EP2EPH(ep) (((ep) >> 1) - 1) |
| 17 | +#define NU_EPX2EP(ep) ((ep == CEP) ? EP0OUT : ((ep) - EPA + EP1OUT)) |
| 18 | +#define NU_EPL2EPH(ep) ((ep) - 1) |
| 19 | +#define NU_EPH2EPL(ep) ((ep) + 1) |
| 20 | +#define NUMBER_OF_PHYSICAL_ENDPOINTS 12 |
| 21 | +#endif |
| 22 | + |
| 23 | +#define NU_EP_DIR_Pos 0 |
| 24 | +#define NU_EP_DIR_Msk (1 << NU_EP_DIR_Pos) |
| 25 | +#define NU_EP_DIR_OUT 0 |
| 26 | +#define NU_EP_DIR_IN 1 |
| 27 | + |
| 28 | +#define NU_EP_TYPE(ep) (((ep) & NU_EP_TYPE_Msk) >> NU_EP_TYPE_Pos) |
| 29 | +#define NU_EP_NUM(ep) (((ep) & NU_EP_NUM_Msk) >> NU_EP_NUM_Pos) |
| 30 | +#define NU_EP_DIR(ep) (((ep) & NU_EP_DIR_Msk) >> NU_EP_DIR_Pos) |
| 31 | +#define NU_EP_NUM_DIR(ep) ((NU_EP_NUM(ep) << 1) | NU_EP_DIR(ep)) |
| 32 | + |
| 33 | +#define EP0OUT (0) |
| 34 | +#define EP0IN (1) |
| 35 | +#define EP1OUT (2) |
| 36 | +#define EP1IN (3) |
| 37 | +#define EP2OUT (4) |
| 38 | +#define EP2IN (5) |
| 39 | +#define EP3OUT (6) |
| 40 | +#define EP3IN (7) |
| 41 | +#define EP4OUT (8) |
| 42 | +#define EP4IN (9) |
| 43 | +#define EP5OUT (10) |
| 44 | +#define EP5IN (11) |
| 45 | +#define EP6OUT (12) |
| 46 | +#define EP6IN (13) |
| 47 | + |
| 48 | +/* Maximum Packet sizes */ |
| 49 | +#define MAX_PACKET_SIZE_EP0 64 |
| 50 | +#define MAX_PACKET_SIZE_EP1 64 |
| 51 | +#define MAX_PACKET_SIZE_EP2 64 |
| 52 | +#define MAX_PACKET_SIZE_EP3 0x60 |
| 53 | +#define MAX_PACKET_SIZE_EP4 64 |
| 54 | +#define MAX_PACKET_SIZE_EP5 64 |
| 55 | +#define MAX_PACKET_SIZE_EP6 64 |
| 56 | +#define MAX_PACKET_SIZE_EP7 64 |
| 57 | + |
| 58 | +#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 1) |
| 59 | +#define MAX_PACKET_SIZE_EP8 64 |
| 60 | +#define MAX_PACKET_SIZE_EP9 64 |
| 61 | +#define MAX_PACKET_SIZE_EP10 64 |
| 62 | +#define MAX_PACKET_SIZE_EP11 64 |
| 63 | +#endif |
| 64 | + |
| 65 | +/* Generic endpoints - intended to be portable accross devices */ |
| 66 | +/* and be suitable for simple USB devices. */ |
| 67 | + |
| 68 | +/* Bulk endpoints */ |
| 69 | +#define EPBULK_OUT EP5OUT |
| 70 | +#define EPBULK_IN EP6IN |
| 71 | +#define EPBULK_OUT_callback EP5_OUT_callback |
| 72 | +#define EPBULK_IN_callback EP6_IN_callback |
| 73 | +/* Interrupt endpoints */ |
| 74 | +#define EPINT_OUT EP1OUT |
| 75 | +#define EPINT_IN EP2IN |
| 76 | +#define EPINT_OUT_callback EP1_OUT_callback |
| 77 | +#define EPINT_IN_callback EP2_IN_callback |
| 78 | +/* Isochronous endpoints */ |
| 79 | +#define EPISO_OUT EP3OUT |
| 80 | +#define EPISO_IN EP4IN |
| 81 | +#define EPISO_OUT_callback EP3_OUT_callback |
| 82 | +#define EPISO_IN_callback EP4_IN_callback |
| 83 | + |
| 84 | +#define MAX_PACKET_SIZE_EPBULK 64 |
| 85 | +#define MAX_PACKET_SIZE_EPINT 64 |
| 86 | +#define MAX_PACKET_SIZE_EPISO 1023 |
| 87 | + |
| 88 | +#if (MBED_CONF_TARGET_USB_DEVICE_HSUSBD == 1) |
| 89 | +#define HSUSBD_GET_EP_MAX_PAYLOAD(ep) HSUSBD->EP[ep].EPMPS |
| 90 | +#define HSUSBD_GET_EP_DATA_COUNT(ep) (HSUSBD->EP[ep].EPDATCNT & 0xFFFFF) |
| 91 | +#define HSUSBD_SET_EP_SHORT_PACKET(ep) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10) | 0x40) |
| 92 | +#define HSUSBD_GET_EP_INT_EN(ep) HSUSBD->EP[ep].EPINTEN |
| 93 | +#endif |
0 commit comments