|
68 | 68 | #if defined(USBD_DETACH_PIN) && !defined(USBD_DETACH_LEVEL) |
69 | 69 | #error "USBD_DETACH_PIN also needs USBD_DETACH_LEVEL defined" |
70 | 70 | #endif /* defined(USBD_DETACH_PIN) && !defined(USBD_DETACH_LEVEL) */ |
| 71 | +#if (defined(USBD_DETACH_PIN) || defined(USBD_ATTACH_PIN)) && defined(USBD_FIXED_PULLUP) |
| 72 | + #error "Cannot define both USBD_FIXED_PULLUP and USBD_ATTACH_PIN or USBD_DETACH_PIN" |
| 73 | +#endif /* (defined(USBD_DETACH_PIN) || defined(USBD_ATTACH_PIN)) && defined(USBD_FIXED_PULLUP) */ |
71 | 74 |
|
72 | 75 | /* Either of these bits indicate that there are internal pullups */ |
73 | 76 | #if defined(USB_BCDR_DPPU) || defined(USB_OTG_DCTL_SDIS) |
|
78 | 81 | * in USBD_LL_Init in usbd_conf.c. */ |
79 | 82 | #if defined(USE_USB_HS) |
80 | 83 | #define USBD_USB_INSTANCE USB_OTG_HS |
| 84 | + #define USBD_DP_PINNAME USB_OTG_HS_DP |
81 | 85 | #elif defined(USB_OTG_FS) |
82 | 86 | #define USBD_USB_INSTANCE USB_OTG_FS |
| 87 | + #define USBD_DP_PINNAME USB_OTG_FS_DP |
83 | 88 | #elif defined(USB) |
84 | 89 | #define USBD_USB_INSTANCE USB |
| 90 | + #define USBD_DP_PINNAME USB_DP |
85 | 91 | #endif |
86 | 92 |
|
87 | 93 | /* |
|
97 | 103 | #elif defined(USBD_DETACH_PIN) |
98 | 104 | #define USBD_PULLUP_CONTROL_PINNAME digitalPinToPinName(USBD_DETACH_PIN) |
99 | 105 | #define USBD_ATTACH_LEVEL !(USBD_DETACH_LEVEL) |
100 | | -#elif !defined(USBD_HAVE_INTERNAL_PULLUPS) |
| 106 | +#elif !defined(USBD_HAVE_INTERNAL_PULLUPS) || defined(USBD_FIXED_PULLUP) |
101 | 107 | /* When no USB attach and detach pins were defined, and there are also |
102 | 108 | * no internal pullups, assume there is a fixed external pullup and apply |
103 | | - * the D+ trick. This should happen only for the USB peripheral, since |
104 | | - * USB_OTG_HS and USB_OTG_FS always have internal pullups. */ |
105 | | - #if !defined(USB) |
106 | | - #error "Unexpected USB configuration" |
107 | | - #endif |
108 | | - #define USBD_PULLUP_CONTROL_PINNAME USB_DP |
| 109 | + * the D+ trick. Also do this when there are internal *and* external |
| 110 | + * pulups (which is a hardware bug, but there are boards out there with |
| 111 | + * this). */ |
| 112 | + #define USBD_PULLUP_CONTROL_PINNAME USBD_DP_PINNAME |
109 | 113 | #define USBD_DETACH_LEVEL LOW |
110 | 114 | // USBD_ATTACH_LEVEL not needed. |
111 | 115 | #define USBD_DP_TRICK |
|
0 commit comments