|
26 | 26 | /* Private typedef -----------------------------------------------------------*/
|
27 | 27 | /* Private define ------------------------------------------------------------*/
|
28 | 28 |
|
29 |
| -/* USB VID and PID: Either both or neither must be specified. If not |
30 |
| - * specified, default to the ST VID, with a PID assigned to HID or a PID |
31 |
| - * assigned to CDC devices. */ |
32 |
| -#if !USBD_PID && !USBD_VID |
33 |
| - // Undef the default zero values |
34 |
| - #undef USBD_PID |
| 29 | +/* USB VID and PID have to be specified to correct values. |
| 30 | + * They can be defined thanks: |
| 31 | + * - boards.txt: *.build.vid or *.build.pid |
| 32 | + * - build_opt.h: define CUSTOM_USBD_VID or CUSTOM_USBD_PID |
| 33 | + * Else if not defined or specified, default to the ST VID, |
| 34 | + * with PID assigned to HID or CDC devices. |
| 35 | + */ |
| 36 | +#if !defined(USBD_VID) || USBD_VID == 0 |
| 37 | + // Undef the default definition |
35 | 38 | #undef USBD_VID
|
36 |
| - // Define default values, based on the USB class used |
37 |
| - #define USBD_VID 0x0483 |
38 |
| - #if defined(USBD_USE_HID_COMPOSITE) |
39 |
| - #define USBD_PID 0x5711 |
40 |
| - #elif defined(USBD_USE_CDC) |
41 |
| - #define USBD_PID 0x5740 |
| 39 | + #if defined(CUSTOM_USBD_VID) |
| 40 | + #define USBD_VID CUSTOM_USBD_VID |
| 41 | + #else |
| 42 | + // Define default values |
| 43 | + #define USBD_VID 0x0483 |
| 44 | + #endif |
| 45 | +#endif /* USBD_VID */ |
| 46 | + |
| 47 | +#if !defined(USBD_PID) || USBD_PID == -1 |
| 48 | + // Undef the default definition |
| 49 | + #undef USBD_PID |
| 50 | + #if defined(CUSTOM_USBD_PID) |
| 51 | + #define USBD_PID CUSTOM_USBD_PID |
| 52 | + #else |
| 53 | + // Define default values, based on the USB class used |
| 54 | + #if defined(USBD_USE_HID_COMPOSITE) |
| 55 | + #define USBD_PID 0x5711 |
| 56 | + #elif defined(USBD_USE_CDC) |
| 57 | + #define USBD_PID 0x5740 |
| 58 | + #else |
| 59 | + #error "USB PID not specified" |
| 60 | + #endif |
42 | 61 | #endif
|
43 |
| -#endif /* !USBD_PID && !USBD_VID */ |
| 62 | +#endif /* USBD_VID */ |
44 | 63 |
|
45 |
| -#if !USBD_VID || !USBD_PID |
46 |
| - #error "USB VID or PID not specified" |
| 64 | +#if USBD_VID == 0 |
| 65 | + #error "USB VID not properly specified" |
47 | 66 | #endif
|
48 | 67 |
|
49 | 68 | /* Manufacturer string: Use the specified string if specified, guess
|
|
0 commit comments