Demo for USBJoystick updated for 32 buttons.
Dependencies: USBDevice USBJoystick_SIM mbed USBJoystick_2
Fork of USBJoystick_HelloWorld2 by
config.h@1:b106cf2e99ba, 2018-07-22 (annotated)
- Committer:
- Cirrus01
- Date:
- Sun Jul 22 10:36:35 2018 +0000
- Revision:
- 1:b106cf2e99ba
- Child:
- 4:dc3556a31262
Inital
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Cirrus01 | 1:b106cf2e99ba | 1 | #define TARGET_STM32F4XX |
Cirrus01 | 1:b106cf2e99ba | 2 | #define NUM_OF_BUTTONS 32 |
Cirrus01 | 1:b106cf2e99ba | 3 | #define NUM_OF_HAT_BUTTONS 4 |
Cirrus01 | 1:b106cf2e99ba | 4 | #define SYSTEM_CLOCK_HZ 96000000 // 96MHz |
Cirrus01 | 1:b106cf2e99ba | 5 | |
Cirrus01 | 1:b106cf2e99ba | 6 | // Joystick button input pin assignments. |
Cirrus01 | 1:b106cf2e99ba | 7 | // |
Cirrus01 | 1:b106cf2e99ba | 8 | // You can wire up to 32 GPIO ports to buttons (equipped with |
Cirrus01 | 1:b106cf2e99ba | 9 | // momentary switches). Connect each switch between the desired |
Cirrus01 | 1:b106cf2e99ba | 10 | // GPIO port and ground (J9 pin 12 or 14). When the button is pressed, |
Cirrus01 | 1:b106cf2e99ba | 11 | // we'll tell the host PC that the corresponding joystick button is |
Cirrus01 | 1:b106cf2e99ba | 12 | // pressed. We debounce the keystrokes in software, so you can simply |
Cirrus01 | 1:b106cf2e99ba | 13 | // wire directly to pushbuttons with no additional external hardware. |
Cirrus01 | 1:b106cf2e99ba | 14 | // |
Cirrus01 | 1:b106cf2e99ba | 15 | // Note that we assign 24 buttons by default, even though the USB |
Cirrus01 | 1:b106cf2e99ba | 16 | // joystick interface can handle up to 32 buttons. VP itself only |
Cirrus01 | 1:b106cf2e99ba | 17 | // allows mapping of up to 24 buttons in the preferences dialog |
Cirrus01 | 1:b106cf2e99ba | 18 | // (although it can recognize 32 buttons internally). If you want |
Cirrus01 | 1:b106cf2e99ba | 19 | // more buttons, you can reassign pins that are assigned by default |
Cirrus01 | 1:b106cf2e99ba | 20 | // as LedWiz outputs. To reassign a pin, find the pin you wish to |
Cirrus01 | 1:b106cf2e99ba | 21 | // reassign in the LedWizPortMap array below, and change the pin name |
Cirrus01 | 1:b106cf2e99ba | 22 | // there to NC (for Not Connected). You can then change one of the |
Cirrus01 | 1:b106cf2e99ba | 23 | // "NC" entries below to the reallocated pin name. The limit is 32 |
Cirrus01 | 1:b106cf2e99ba | 24 | // buttons total. |
Cirrus01 | 1:b106cf2e99ba | 25 | // |
Cirrus01 | 1:b106cf2e99ba | 26 | // (If you're using TLC5940 chips to control outputs, many of the |
Cirrus01 | 1:b106cf2e99ba | 27 | // GPIO pins that are mapped to LedWiz outputs in the default |
Cirrus01 | 1:b106cf2e99ba | 28 | // mapping can be reassigned as keys, since the TLC5940 outputs |
Cirrus01 | 1:b106cf2e99ba | 29 | // take over for the GPIO pins. The exceptions are the pins that |
Cirrus01 | 1:b106cf2e99ba | 30 | // are reassigned to control the TLC5940 chips.) |
Cirrus01 | 1:b106cf2e99ba | 31 | // |
Cirrus01 | 1:b106cf2e99ba | 32 | // Note: PTD1 (pin J2-12) should NOT be assigned as a button input, |
Cirrus01 | 1:b106cf2e99ba | 33 | // as this pin is physically connected on the KL25Z to the on-board |
Cirrus01 | 1:b106cf2e99ba | 34 | // indicator LED's blue segment. |
Cirrus01 | 1:b106cf2e99ba | 35 | |
Cirrus01 | 1:b106cf2e99ba | 36 | PinName buttonMap[] = { |
Cirrus01 | 1:b106cf2e99ba | 37 | PB_3, // button 1 |
Cirrus01 | 1:b106cf2e99ba | 38 | PB_5, // button 2 |
Cirrus01 | 1:b106cf2e99ba | 39 | PB_10, // button 3 |
Cirrus01 | 1:b106cf2e99ba | 40 | PC_7, // button 4 |
Cirrus01 | 1:b106cf2e99ba | 41 | PB_6, // button 5 |
Cirrus01 | 1:b106cf2e99ba | 42 | PA_5, // button 6 |
Cirrus01 | 1:b106cf2e99ba | 43 | PB_4, // button 7 |
Cirrus01 | 1:b106cf2e99ba | 44 | PB_13, // button 8 |
Cirrus01 | 1:b106cf2e99ba | 45 | PB_14, // button 9 |
Cirrus01 | 1:b106cf2e99ba | 46 | PB_15, // button 10 |
Cirrus01 | 1:b106cf2e99ba | 47 | PB_1, // button 11 |
Cirrus01 | 1:b106cf2e99ba | 48 | PB_2, // button 12 |
Cirrus01 | 1:b106cf2e99ba | 49 | PC_5, // button 13 |
Cirrus01 | 1:b106cf2e99ba | 50 | PC_6, // button 14 |
Cirrus01 | 1:b106cf2e99ba | 51 | PC_8, // button 15 |
Cirrus01 | 1:b106cf2e99ba | 52 | PC_4, // button 16 |
Cirrus01 | 1:b106cf2e99ba | 53 | NC, // button 17 |
Cirrus01 | 1:b106cf2e99ba | 54 | NC, // button 18 |
Cirrus01 | 1:b106cf2e99ba | 55 | NC, // button 19 |
Cirrus01 | 1:b106cf2e99ba | 56 | NC, // button 20 |
Cirrus01 | 1:b106cf2e99ba | 57 | NC, // button 21 |
Cirrus01 | 1:b106cf2e99ba | 58 | NC, // button 22 |
Cirrus01 | 1:b106cf2e99ba | 59 | NC, // button 23 |
Cirrus01 | 1:b106cf2e99ba | 60 | NC, // button 24 |
Cirrus01 | 1:b106cf2e99ba | 61 | NC, // button 25 |
Cirrus01 | 1:b106cf2e99ba | 62 | NC, // button 26 |
Cirrus01 | 1:b106cf2e99ba | 63 | NC, // button 27 |
Cirrus01 | 1:b106cf2e99ba | 64 | NC, // button 28 |
Cirrus01 | 1:b106cf2e99ba | 65 | NC, // button 29 |
Cirrus01 | 1:b106cf2e99ba | 66 | NC, // button 30 |
Cirrus01 | 1:b106cf2e99ba | 67 | NC, // button 31 |
Cirrus01 | 1:b106cf2e99ba | 68 | NC // button 32 |
Cirrus01 | 1:b106cf2e99ba | 69 | }; |
Cirrus01 | 1:b106cf2e99ba | 70 | |
Cirrus01 | 1:b106cf2e99ba | 71 | PinName hatMap[] = { |
Cirrus01 | 1:b106cf2e99ba | 72 | PA_13, // button 1 |
Cirrus01 | 1:b106cf2e99ba | 73 | PA_14, // button 2 |
Cirrus01 | 1:b106cf2e99ba | 74 | PA_15, // button 3 |
Cirrus01 | 1:b106cf2e99ba | 75 | PB_7, // button 4 |
Cirrus01 | 1:b106cf2e99ba | 76 | NC, // button 5 |
Cirrus01 | 1:b106cf2e99ba | 77 | NC, // button 6 |
Cirrus01 | 1:b106cf2e99ba | 78 | NC, // button 7 |
Cirrus01 | 1:b106cf2e99ba | 79 | NC // button 8 |
Cirrus01 | 1:b106cf2e99ba | 80 | }; |
Cirrus01 | 1:b106cf2e99ba | 81 | |
Cirrus01 | 1:b106cf2e99ba | 82 | |
Cirrus01 | 1:b106cf2e99ba | 83 | // STANDARD ID SETTINGS. These provide full, transparent LedWiz compatibility. |
Cirrus01 | 1:b106cf2e99ba | 84 | const uint16_t USB_VENDOR_ID = 0x1209; |
Cirrus01 | 1:b106cf2e99ba | 85 | const uint16_t USB_PRODUCT_ID = 0xACDE; |
Cirrus01 | 1:b106cf2e99ba | 86 | const uint16_t USB_PRODUCT_VER = 0x0002; |