|
| 1 | +.. zephyr:board:: rp2040_keyboard_3 |
| 2 | +
|
| 3 | +Overview |
| 4 | +******** |
| 5 | + |
| 6 | +The `Waveshare 3-Key Shortcut Keyboard Development Board`_ is based on the RP2040 microcontroller |
| 7 | +from Raspberry Pi Ltd. It has three keys with the default values "CTRL", "C" and "V". The board |
| 8 | +is equipped with two USB type C connectors. There are two versions of the keyboard, where the |
| 9 | +diffence is in the housing (plastic or metal). This board definition can be used with both versions. |
| 10 | + |
| 11 | + |
| 12 | +Hardware |
| 13 | +******** |
| 14 | + |
| 15 | +- Microcontroller Raspberry Pi RP2040, with a max frequency of 133 MHz |
| 16 | +- Dual ARM Cortex M0+ cores |
| 17 | +- 264 kByte SRAM |
| 18 | +- 2 Mbyte QSPI flash |
| 19 | +- 3 user keys |
| 20 | +- 3 RGB LEDs (Neopixels); one in each user key |
| 21 | +- Dual USB type C connectors (use one at a time) |
| 22 | +- RESET and BOOT buttons |
| 23 | + |
| 24 | +The RESET and BOOT buttons are located on the back side of the board, on separate long edges |
| 25 | +of the board. The BOOT button is located at the long edge with a USB connector, and the RESET |
| 26 | +is located at the other long edge of the board. |
| 27 | + |
| 28 | + |
| 29 | +Default Zephyr Peripheral Mapping |
| 30 | +================================= |
| 31 | + |
| 32 | +.. rst-class:: rst-columns |
| 33 | + |
| 34 | + - Button CTRL (left) : GPIO14 |
| 35 | + - Button C (center) : GPIO13 |
| 36 | + - Button V (right) : GPIO12 |
| 37 | + - RGB LEDs: GPIO18 |
| 38 | + |
| 39 | +Note that no serial port pins (RX or TX) are exposed. By default this board uses USB for |
| 40 | +terminal output. |
| 41 | + |
| 42 | +See also `Waveshare P2040-Keyboard-3 wiki`_ and `schematic`_. |
| 43 | + |
| 44 | + |
| 45 | +Supported Features |
| 46 | +================== |
| 47 | + |
| 48 | +.. zephyr:board-supported-hw:: |
| 49 | +
|
| 50 | +
|
| 51 | +Programming and Debugging |
| 52 | +************************* |
| 53 | + |
| 54 | +.. zephyr:board-supported-runners:: |
| 55 | +
|
| 56 | +The board does not expose the SWDIO and SWCLK pins, so programming must be done via the USB port. |
| 57 | +Press and hold the BOOT button, and then press the RESET button, and the device will appear as |
| 58 | +a USB mass storage unit. Building your application will result in a :file:`build/zephyr/zephyr.uf2` |
| 59 | +file. Drag and drop the file to the USB mass storage unit, and the board will be reprogrammed. |
| 60 | + |
| 61 | +For more details on programming RP2040-based boards, see :zephyr:board:`rpi_pico` and especially |
| 62 | +:ref:`rpi_pico_programming_and_debugging`. |
| 63 | + |
| 64 | + |
| 65 | +Flashing |
| 66 | +======== |
| 67 | + |
| 68 | +To run the :zephyr:code-sample:`led-strip` sample: |
| 69 | + |
| 70 | +.. zephyr-app-commands:: |
| 71 | + :zephyr-app: samples/drivers/led/led_strip/ |
| 72 | + :board: rp2040_keyboard_3 |
| 73 | + :goals: build flash |
| 74 | + |
| 75 | +Try also the :zephyr:code-sample:`dining-philosophers`, :zephyr:code-sample:`input-dump` and |
| 76 | +:zephyr:code-sample:`button` samples. |
| 77 | + |
| 78 | +Samples where text is printed only just at startup, for example :zephyr:code-sample:`hello_world`, |
| 79 | +are difficult to use as the text is already printed once you connect to the newly created |
| 80 | +USB console endpoint. |
| 81 | + |
| 82 | +To run a program that acts as a keyboard (with the keys CTRL, C and V), use the |
| 83 | +:zephyr:code-sample:`usb-hid-keyboard` sample with some modifications. First remove the line |
| 84 | +``source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig"`` from the |
| 85 | +:zephyr_file:`boards/waveshare/rp2040_keyboard_3/Kconfig.defconfig` file. Then do the |
| 86 | +modifications below to the :zephyr_file:`samples/subsys/usb/hid-keyboard/src/main.c` file. |
| 87 | + |
| 88 | +Change: |
| 89 | + |
| 90 | +.. code-block:: c |
| 91 | +
|
| 92 | + case INPUT_KEY_0: |
| 93 | + if (kb_evt.value) { |
| 94 | + report[KB_KEY_CODE1] = HID_KEY_NUMLOCK; |
| 95 | + } else { |
| 96 | + report[KB_KEY_CODE1] = 0; |
| 97 | + } |
| 98 | +
|
| 99 | + break; |
| 100 | + case INPUT_KEY_1: |
| 101 | + if (kb_evt.value) { |
| 102 | + report[KB_KEY_CODE2] = HID_KEY_CAPSLOCK; |
| 103 | + } else { |
| 104 | + report[KB_KEY_CODE2] = 0; |
| 105 | + } |
| 106 | +
|
| 107 | + break; |
| 108 | + case INPUT_KEY_2: |
| 109 | + if (kb_evt.value) { |
| 110 | + report[KB_KEY_CODE3] = HID_KEY_SCROLLLOCK; |
| 111 | + } else { |
| 112 | + report[KB_KEY_CODE3] = 0; |
| 113 | + } |
| 114 | +
|
| 115 | + break; |
| 116 | +
|
| 117 | +to: |
| 118 | + |
| 119 | +.. code-block:: c |
| 120 | +
|
| 121 | + case INPUT_KEY_LEFTCTRL: |
| 122 | + if (kb_evt.value) { |
| 123 | + report[KB_MOD_KEY] = HID_KBD_MODIFIER_LEFT_CTRL; |
| 124 | + } else { |
| 125 | + report[KB_MOD_KEY] = 0; |
| 126 | + } |
| 127 | +
|
| 128 | + break; |
| 129 | + case INPUT_KEY_C: |
| 130 | + if (kb_evt.value) { |
| 131 | + report[KB_KEY_CODE1] = HID_KEY_C; |
| 132 | + } else { |
| 133 | + report[KB_KEY_CODE1] = 0; |
| 134 | + } |
| 135 | +
|
| 136 | + break; |
| 137 | + case INPUT_KEY_V: |
| 138 | + if (kb_evt.value) { |
| 139 | + report[KB_KEY_CODE1] = HID_KEY_V; |
| 140 | + } else { |
| 141 | + report[KB_KEY_CODE1] = 0; |
| 142 | + } |
| 143 | +
|
| 144 | + break; |
| 145 | +
|
| 146 | +
|
| 147 | +References |
| 148 | +********** |
| 149 | + |
| 150 | +.. target-notes:: |
| 151 | + |
| 152 | +.. _Waveshare 3-Key Shortcut Keyboard Development Board: |
| 153 | + https://www.waveshare.com/rp2040-keyboard-3.htm |
| 154 | + |
| 155 | +.. _Waveshare P2040-Keyboard-3 wiki: |
| 156 | + https://www.waveshare.com/wiki/RP2040-Keyboard-3 |
| 157 | + |
| 158 | +.. _schematic: |
| 159 | + https://files.waveshare.com/wiki/RP2040-Keyboard-3/RP2040-Keyboard-3-Schematic.pdf |
0 commit comments