![](/media/cache/group/site_id.gif.50x50_q85.jpg)
Transistor Gijutsu, October 2014, Special Features Chapter 9, Software of the Function Generator トランジスタ技術2014年10月号 特集第9章のソフトウェア わがまま波形発生器のソフトウェア
Information
tg_201410s8_AD7714 トランジスタ技術 2014年 10月号 第9章のソフトウェア
Program for Section 9 in October. 2014 issue of the Transistor Gijutsu
(Japanese electronics magazine)
概要
このプログラムは、ソフトウエアDDSにより、任意の波形を出力(2ch)します。 特徴は次のとおりです。
- PWM出力をDAコンバータとして利用します。
- 周波数や波形、バースト条件などを個別に設定できる独立した出力を2チャネル持っています。
- 周波数分解能0.023mHz
- 周波数範囲0.023mHz~10kHz
- 各チャネルにそれぞれ、波形の先頭で出力されるトリガ出力があります。
- 出力波形を関数で定義できます。
- 休止波数、出力波数、を設定することでバースト波形が出力できます。
ファイル
このソフトウエアは、次のファイルから構成されています。
- DDS.cpp - DDSによる波形発生
- main.cpp - main()関数
詳細については、10月号の記事および上記ファイル中のコメントを参照してください。
USBDevice/USBHID/USBKeyboard.cpp@0:f1ecca559ec3, 2014-08-29 (annotated)
- Committer:
- Dance
- Date:
- Fri Aug 29 08:33:17 2014 +0000
- Revision:
- 0:f1ecca559ec3
Transistor Gijutsu, October 2014, Special Features Chapter 9; ????????2014?10??????9????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Dance | 0:f1ecca559ec3 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
Dance | 0:f1ecca559ec3 | 2 | * |
Dance | 0:f1ecca559ec3 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
Dance | 0:f1ecca559ec3 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
Dance | 0:f1ecca559ec3 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
Dance | 0:f1ecca559ec3 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
Dance | 0:f1ecca559ec3 | 7 | * Software is furnished to do so, subject to the following conditions: |
Dance | 0:f1ecca559ec3 | 8 | * |
Dance | 0:f1ecca559ec3 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
Dance | 0:f1ecca559ec3 | 10 | * substantial portions of the Software. |
Dance | 0:f1ecca559ec3 | 11 | * |
Dance | 0:f1ecca559ec3 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
Dance | 0:f1ecca559ec3 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
Dance | 0:f1ecca559ec3 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
Dance | 0:f1ecca559ec3 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
Dance | 0:f1ecca559ec3 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Dance | 0:f1ecca559ec3 | 17 | */ |
Dance | 0:f1ecca559ec3 | 18 | |
Dance | 0:f1ecca559ec3 | 19 | #include "stdint.h" |
Dance | 0:f1ecca559ec3 | 20 | |
Dance | 0:f1ecca559ec3 | 21 | #include "USBKeyboard.h" |
Dance | 0:f1ecca559ec3 | 22 | |
Dance | 0:f1ecca559ec3 | 23 | #define REPORT_ID_KEYBOARD 1 |
Dance | 0:f1ecca559ec3 | 24 | #define REPORT_ID_VOLUME 3 |
Dance | 0:f1ecca559ec3 | 25 | |
Dance | 0:f1ecca559ec3 | 26 | |
Dance | 0:f1ecca559ec3 | 27 | typedef struct { |
Dance | 0:f1ecca559ec3 | 28 | unsigned char usage; |
Dance | 0:f1ecca559ec3 | 29 | unsigned char modifier; |
Dance | 0:f1ecca559ec3 | 30 | } KEYMAP; |
Dance | 0:f1ecca559ec3 | 31 | |
Dance | 0:f1ecca559ec3 | 32 | #ifdef US_KEYBOARD |
Dance | 0:f1ecca559ec3 | 33 | /* US keyboard (as HID standard) */ |
Dance | 0:f1ecca559ec3 | 34 | #define KEYMAP_SIZE (152) |
Dance | 0:f1ecca559ec3 | 35 | const KEYMAP keymap[KEYMAP_SIZE] = { |
Dance | 0:f1ecca559ec3 | 36 | {0, 0}, /* NUL */ |
Dance | 0:f1ecca559ec3 | 37 | {0, 0}, /* SOH */ |
Dance | 0:f1ecca559ec3 | 38 | {0, 0}, /* STX */ |
Dance | 0:f1ecca559ec3 | 39 | {0, 0}, /* ETX */ |
Dance | 0:f1ecca559ec3 | 40 | {0, 0}, /* EOT */ |
Dance | 0:f1ecca559ec3 | 41 | {0, 0}, /* ENQ */ |
Dance | 0:f1ecca559ec3 | 42 | {0, 0}, /* ACK */ |
Dance | 0:f1ecca559ec3 | 43 | {0, 0}, /* BEL */ |
Dance | 0:f1ecca559ec3 | 44 | {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */ |
Dance | 0:f1ecca559ec3 | 45 | {0x2b, 0}, /* TAB */ /* Keyboard Tab */ |
Dance | 0:f1ecca559ec3 | 46 | {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */ |
Dance | 0:f1ecca559ec3 | 47 | {0, 0}, /* VT */ |
Dance | 0:f1ecca559ec3 | 48 | {0, 0}, /* FF */ |
Dance | 0:f1ecca559ec3 | 49 | {0, 0}, /* CR */ |
Dance | 0:f1ecca559ec3 | 50 | {0, 0}, /* SO */ |
Dance | 0:f1ecca559ec3 | 51 | {0, 0}, /* SI */ |
Dance | 0:f1ecca559ec3 | 52 | {0, 0}, /* DEL */ |
Dance | 0:f1ecca559ec3 | 53 | {0, 0}, /* DC1 */ |
Dance | 0:f1ecca559ec3 | 54 | {0, 0}, /* DC2 */ |
Dance | 0:f1ecca559ec3 | 55 | {0, 0}, /* DC3 */ |
Dance | 0:f1ecca559ec3 | 56 | {0, 0}, /* DC4 */ |
Dance | 0:f1ecca559ec3 | 57 | {0, 0}, /* NAK */ |
Dance | 0:f1ecca559ec3 | 58 | {0, 0}, /* SYN */ |
Dance | 0:f1ecca559ec3 | 59 | {0, 0}, /* ETB */ |
Dance | 0:f1ecca559ec3 | 60 | {0, 0}, /* CAN */ |
Dance | 0:f1ecca559ec3 | 61 | {0, 0}, /* EM */ |
Dance | 0:f1ecca559ec3 | 62 | {0, 0}, /* SUB */ |
Dance | 0:f1ecca559ec3 | 63 | {0, 0}, /* ESC */ |
Dance | 0:f1ecca559ec3 | 64 | {0, 0}, /* FS */ |
Dance | 0:f1ecca559ec3 | 65 | {0, 0}, /* GS */ |
Dance | 0:f1ecca559ec3 | 66 | {0, 0}, /* RS */ |
Dance | 0:f1ecca559ec3 | 67 | {0, 0}, /* US */ |
Dance | 0:f1ecca559ec3 | 68 | {0x2c, 0}, /* */ |
Dance | 0:f1ecca559ec3 | 69 | {0x1e, KEY_SHIFT}, /* ! */ |
Dance | 0:f1ecca559ec3 | 70 | {0x34, KEY_SHIFT}, /* " */ |
Dance | 0:f1ecca559ec3 | 71 | {0x20, KEY_SHIFT}, /* # */ |
Dance | 0:f1ecca559ec3 | 72 | {0x21, KEY_SHIFT}, /* $ */ |
Dance | 0:f1ecca559ec3 | 73 | {0x22, KEY_SHIFT}, /* % */ |
Dance | 0:f1ecca559ec3 | 74 | {0x24, KEY_SHIFT}, /* & */ |
Dance | 0:f1ecca559ec3 | 75 | {0x34, 0}, /* ' */ |
Dance | 0:f1ecca559ec3 | 76 | {0x26, KEY_SHIFT}, /* ( */ |
Dance | 0:f1ecca559ec3 | 77 | {0x27, KEY_SHIFT}, /* ) */ |
Dance | 0:f1ecca559ec3 | 78 | {0x25, KEY_SHIFT}, /* * */ |
Dance | 0:f1ecca559ec3 | 79 | {0x2e, KEY_SHIFT}, /* + */ |
Dance | 0:f1ecca559ec3 | 80 | {0x36, 0}, /* , */ |
Dance | 0:f1ecca559ec3 | 81 | {0x2d, 0}, /* - */ |
Dance | 0:f1ecca559ec3 | 82 | {0x37, 0}, /* . */ |
Dance | 0:f1ecca559ec3 | 83 | {0x38, 0}, /* / */ |
Dance | 0:f1ecca559ec3 | 84 | {0x27, 0}, /* 0 */ |
Dance | 0:f1ecca559ec3 | 85 | {0x1e, 0}, /* 1 */ |
Dance | 0:f1ecca559ec3 | 86 | {0x1f, 0}, /* 2 */ |
Dance | 0:f1ecca559ec3 | 87 | {0x20, 0}, /* 3 */ |
Dance | 0:f1ecca559ec3 | 88 | {0x21, 0}, /* 4 */ |
Dance | 0:f1ecca559ec3 | 89 | {0x22, 0}, /* 5 */ |
Dance | 0:f1ecca559ec3 | 90 | {0x23, 0}, /* 6 */ |
Dance | 0:f1ecca559ec3 | 91 | {0x24, 0}, /* 7 */ |
Dance | 0:f1ecca559ec3 | 92 | {0x25, 0}, /* 8 */ |
Dance | 0:f1ecca559ec3 | 93 | {0x26, 0}, /* 9 */ |
Dance | 0:f1ecca559ec3 | 94 | {0x33, KEY_SHIFT}, /* : */ |
Dance | 0:f1ecca559ec3 | 95 | {0x33, 0}, /* ; */ |
Dance | 0:f1ecca559ec3 | 96 | {0x36, KEY_SHIFT}, /* < */ |
Dance | 0:f1ecca559ec3 | 97 | {0x2e, 0}, /* = */ |
Dance | 0:f1ecca559ec3 | 98 | {0x37, KEY_SHIFT}, /* > */ |
Dance | 0:f1ecca559ec3 | 99 | {0x38, KEY_SHIFT}, /* ? */ |
Dance | 0:f1ecca559ec3 | 100 | {0x1f, KEY_SHIFT}, /* @ */ |
Dance | 0:f1ecca559ec3 | 101 | {0x04, KEY_SHIFT}, /* A */ |
Dance | 0:f1ecca559ec3 | 102 | {0x05, KEY_SHIFT}, /* B */ |
Dance | 0:f1ecca559ec3 | 103 | {0x06, KEY_SHIFT}, /* C */ |
Dance | 0:f1ecca559ec3 | 104 | {0x07, KEY_SHIFT}, /* D */ |
Dance | 0:f1ecca559ec3 | 105 | {0x08, KEY_SHIFT}, /* E */ |
Dance | 0:f1ecca559ec3 | 106 | {0x09, KEY_SHIFT}, /* F */ |
Dance | 0:f1ecca559ec3 | 107 | {0x0a, KEY_SHIFT}, /* G */ |
Dance | 0:f1ecca559ec3 | 108 | {0x0b, KEY_SHIFT}, /* H */ |
Dance | 0:f1ecca559ec3 | 109 | {0x0c, KEY_SHIFT}, /* I */ |
Dance | 0:f1ecca559ec3 | 110 | {0x0d, KEY_SHIFT}, /* J */ |
Dance | 0:f1ecca559ec3 | 111 | {0x0e, KEY_SHIFT}, /* K */ |
Dance | 0:f1ecca559ec3 | 112 | {0x0f, KEY_SHIFT}, /* L */ |
Dance | 0:f1ecca559ec3 | 113 | {0x10, KEY_SHIFT}, /* M */ |
Dance | 0:f1ecca559ec3 | 114 | {0x11, KEY_SHIFT}, /* N */ |
Dance | 0:f1ecca559ec3 | 115 | {0x12, KEY_SHIFT}, /* O */ |
Dance | 0:f1ecca559ec3 | 116 | {0x13, KEY_SHIFT}, /* P */ |
Dance | 0:f1ecca559ec3 | 117 | {0x14, KEY_SHIFT}, /* Q */ |
Dance | 0:f1ecca559ec3 | 118 | {0x15, KEY_SHIFT}, /* R */ |
Dance | 0:f1ecca559ec3 | 119 | {0x16, KEY_SHIFT}, /* S */ |
Dance | 0:f1ecca559ec3 | 120 | {0x17, KEY_SHIFT}, /* T */ |
Dance | 0:f1ecca559ec3 | 121 | {0x18, KEY_SHIFT}, /* U */ |
Dance | 0:f1ecca559ec3 | 122 | {0x19, KEY_SHIFT}, /* V */ |
Dance | 0:f1ecca559ec3 | 123 | {0x1a, KEY_SHIFT}, /* W */ |
Dance | 0:f1ecca559ec3 | 124 | {0x1b, KEY_SHIFT}, /* X */ |
Dance | 0:f1ecca559ec3 | 125 | {0x1c, KEY_SHIFT}, /* Y */ |
Dance | 0:f1ecca559ec3 | 126 | {0x1d, KEY_SHIFT}, /* Z */ |
Dance | 0:f1ecca559ec3 | 127 | {0x2f, 0}, /* [ */ |
Dance | 0:f1ecca559ec3 | 128 | {0x31, 0}, /* \ */ |
Dance | 0:f1ecca559ec3 | 129 | {0x30, 0}, /* ] */ |
Dance | 0:f1ecca559ec3 | 130 | {0x23, KEY_SHIFT}, /* ^ */ |
Dance | 0:f1ecca559ec3 | 131 | {0x2d, KEY_SHIFT}, /* _ */ |
Dance | 0:f1ecca559ec3 | 132 | {0x35, 0}, /* ` */ |
Dance | 0:f1ecca559ec3 | 133 | {0x04, 0}, /* a */ |
Dance | 0:f1ecca559ec3 | 134 | {0x05, 0}, /* b */ |
Dance | 0:f1ecca559ec3 | 135 | {0x06, 0}, /* c */ |
Dance | 0:f1ecca559ec3 | 136 | {0x07, 0}, /* d */ |
Dance | 0:f1ecca559ec3 | 137 | {0x08, 0}, /* e */ |
Dance | 0:f1ecca559ec3 | 138 | {0x09, 0}, /* f */ |
Dance | 0:f1ecca559ec3 | 139 | {0x0a, 0}, /* g */ |
Dance | 0:f1ecca559ec3 | 140 | {0x0b, 0}, /* h */ |
Dance | 0:f1ecca559ec3 | 141 | {0x0c, 0}, /* i */ |
Dance | 0:f1ecca559ec3 | 142 | {0x0d, 0}, /* j */ |
Dance | 0:f1ecca559ec3 | 143 | {0x0e, 0}, /* k */ |
Dance | 0:f1ecca559ec3 | 144 | {0x0f, 0}, /* l */ |
Dance | 0:f1ecca559ec3 | 145 | {0x10, 0}, /* m */ |
Dance | 0:f1ecca559ec3 | 146 | {0x11, 0}, /* n */ |
Dance | 0:f1ecca559ec3 | 147 | {0x12, 0}, /* o */ |
Dance | 0:f1ecca559ec3 | 148 | {0x13, 0}, /* p */ |
Dance | 0:f1ecca559ec3 | 149 | {0x14, 0}, /* q */ |
Dance | 0:f1ecca559ec3 | 150 | {0x15, 0}, /* r */ |
Dance | 0:f1ecca559ec3 | 151 | {0x16, 0}, /* s */ |
Dance | 0:f1ecca559ec3 | 152 | {0x17, 0}, /* t */ |
Dance | 0:f1ecca559ec3 | 153 | {0x18, 0}, /* u */ |
Dance | 0:f1ecca559ec3 | 154 | {0x19, 0}, /* v */ |
Dance | 0:f1ecca559ec3 | 155 | {0x1a, 0}, /* w */ |
Dance | 0:f1ecca559ec3 | 156 | {0x1b, 0}, /* x */ |
Dance | 0:f1ecca559ec3 | 157 | {0x1c, 0}, /* y */ |
Dance | 0:f1ecca559ec3 | 158 | {0x1d, 0}, /* z */ |
Dance | 0:f1ecca559ec3 | 159 | {0x2f, KEY_SHIFT}, /* { */ |
Dance | 0:f1ecca559ec3 | 160 | {0x31, KEY_SHIFT}, /* | */ |
Dance | 0:f1ecca559ec3 | 161 | {0x30, KEY_SHIFT}, /* } */ |
Dance | 0:f1ecca559ec3 | 162 | {0x35, KEY_SHIFT}, /* ~ */ |
Dance | 0:f1ecca559ec3 | 163 | {0,0}, /* DEL */ |
Dance | 0:f1ecca559ec3 | 164 | |
Dance | 0:f1ecca559ec3 | 165 | {0x3a, 0}, /* F1 */ |
Dance | 0:f1ecca559ec3 | 166 | {0x3b, 0}, /* F2 */ |
Dance | 0:f1ecca559ec3 | 167 | {0x3c, 0}, /* F3 */ |
Dance | 0:f1ecca559ec3 | 168 | {0x3d, 0}, /* F4 */ |
Dance | 0:f1ecca559ec3 | 169 | {0x3e, 0}, /* F5 */ |
Dance | 0:f1ecca559ec3 | 170 | {0x3f, 0}, /* F6 */ |
Dance | 0:f1ecca559ec3 | 171 | {0x40, 0}, /* F7 */ |
Dance | 0:f1ecca559ec3 | 172 | {0x41, 0}, /* F8 */ |
Dance | 0:f1ecca559ec3 | 173 | {0x42, 0}, /* F9 */ |
Dance | 0:f1ecca559ec3 | 174 | {0x43, 0}, /* F10 */ |
Dance | 0:f1ecca559ec3 | 175 | {0x44, 0}, /* F11 */ |
Dance | 0:f1ecca559ec3 | 176 | {0x45, 0}, /* F12 */ |
Dance | 0:f1ecca559ec3 | 177 | |
Dance | 0:f1ecca559ec3 | 178 | {0x46, 0}, /* PRINT_SCREEN */ |
Dance | 0:f1ecca559ec3 | 179 | {0x47, 0}, /* SCROLL_LOCK */ |
Dance | 0:f1ecca559ec3 | 180 | {0x39, 0}, /* CAPS_LOCK */ |
Dance | 0:f1ecca559ec3 | 181 | {0x53, 0}, /* NUM_LOCK */ |
Dance | 0:f1ecca559ec3 | 182 | {0x49, 0}, /* INSERT */ |
Dance | 0:f1ecca559ec3 | 183 | {0x4a, 0}, /* HOME */ |
Dance | 0:f1ecca559ec3 | 184 | {0x4b, 0}, /* PAGE_UP */ |
Dance | 0:f1ecca559ec3 | 185 | {0x4e, 0}, /* PAGE_DOWN */ |
Dance | 0:f1ecca559ec3 | 186 | |
Dance | 0:f1ecca559ec3 | 187 | {0x4f, 0}, /* RIGHT_ARROW */ |
Dance | 0:f1ecca559ec3 | 188 | {0x50, 0}, /* LEFT_ARROW */ |
Dance | 0:f1ecca559ec3 | 189 | {0x51, 0}, /* DOWN_ARROW */ |
Dance | 0:f1ecca559ec3 | 190 | {0x52, 0}, /* UP_ARROW */ |
Dance | 0:f1ecca559ec3 | 191 | }; |
Dance | 0:f1ecca559ec3 | 192 | |
Dance | 0:f1ecca559ec3 | 193 | #else |
Dance | 0:f1ecca559ec3 | 194 | /* UK keyboard */ |
Dance | 0:f1ecca559ec3 | 195 | #define KEYMAP_SIZE (152) |
Dance | 0:f1ecca559ec3 | 196 | const KEYMAP keymap[KEYMAP_SIZE] = { |
Dance | 0:f1ecca559ec3 | 197 | {0, 0}, /* NUL */ |
Dance | 0:f1ecca559ec3 | 198 | {0, 0}, /* SOH */ |
Dance | 0:f1ecca559ec3 | 199 | {0, 0}, /* STX */ |
Dance | 0:f1ecca559ec3 | 200 | {0, 0}, /* ETX */ |
Dance | 0:f1ecca559ec3 | 201 | {0, 0}, /* EOT */ |
Dance | 0:f1ecca559ec3 | 202 | {0, 0}, /* ENQ */ |
Dance | 0:f1ecca559ec3 | 203 | {0, 0}, /* ACK */ |
Dance | 0:f1ecca559ec3 | 204 | {0, 0}, /* BEL */ |
Dance | 0:f1ecca559ec3 | 205 | {0x2a, 0}, /* BS */ /* Keyboard Delete (Backspace) */ |
Dance | 0:f1ecca559ec3 | 206 | {0x2b, 0}, /* TAB */ /* Keyboard Tab */ |
Dance | 0:f1ecca559ec3 | 207 | {0x28, 0}, /* LF */ /* Keyboard Return (Enter) */ |
Dance | 0:f1ecca559ec3 | 208 | {0, 0}, /* VT */ |
Dance | 0:f1ecca559ec3 | 209 | {0, 0}, /* FF */ |
Dance | 0:f1ecca559ec3 | 210 | {0, 0}, /* CR */ |
Dance | 0:f1ecca559ec3 | 211 | {0, 0}, /* SO */ |
Dance | 0:f1ecca559ec3 | 212 | {0, 0}, /* SI */ |
Dance | 0:f1ecca559ec3 | 213 | {0, 0}, /* DEL */ |
Dance | 0:f1ecca559ec3 | 214 | {0, 0}, /* DC1 */ |
Dance | 0:f1ecca559ec3 | 215 | {0, 0}, /* DC2 */ |
Dance | 0:f1ecca559ec3 | 216 | {0, 0}, /* DC3 */ |
Dance | 0:f1ecca559ec3 | 217 | {0, 0}, /* DC4 */ |
Dance | 0:f1ecca559ec3 | 218 | {0, 0}, /* NAK */ |
Dance | 0:f1ecca559ec3 | 219 | {0, 0}, /* SYN */ |
Dance | 0:f1ecca559ec3 | 220 | {0, 0}, /* ETB */ |
Dance | 0:f1ecca559ec3 | 221 | {0, 0}, /* CAN */ |
Dance | 0:f1ecca559ec3 | 222 | {0, 0}, /* EM */ |
Dance | 0:f1ecca559ec3 | 223 | {0, 0}, /* SUB */ |
Dance | 0:f1ecca559ec3 | 224 | {0, 0}, /* ESC */ |
Dance | 0:f1ecca559ec3 | 225 | {0, 0}, /* FS */ |
Dance | 0:f1ecca559ec3 | 226 | {0, 0}, /* GS */ |
Dance | 0:f1ecca559ec3 | 227 | {0, 0}, /* RS */ |
Dance | 0:f1ecca559ec3 | 228 | {0, 0}, /* US */ |
Dance | 0:f1ecca559ec3 | 229 | {0x2c, 0}, /* */ |
Dance | 0:f1ecca559ec3 | 230 | {0x1e, KEY_SHIFT}, /* ! */ |
Dance | 0:f1ecca559ec3 | 231 | {0x1f, KEY_SHIFT}, /* " */ |
Dance | 0:f1ecca559ec3 | 232 | {0x32, 0}, /* # */ |
Dance | 0:f1ecca559ec3 | 233 | {0x21, KEY_SHIFT}, /* $ */ |
Dance | 0:f1ecca559ec3 | 234 | {0x22, KEY_SHIFT}, /* % */ |
Dance | 0:f1ecca559ec3 | 235 | {0x24, KEY_SHIFT}, /* & */ |
Dance | 0:f1ecca559ec3 | 236 | {0x34, 0}, /* ' */ |
Dance | 0:f1ecca559ec3 | 237 | {0x26, KEY_SHIFT}, /* ( */ |
Dance | 0:f1ecca559ec3 | 238 | {0x27, KEY_SHIFT}, /* ) */ |
Dance | 0:f1ecca559ec3 | 239 | {0x25, KEY_SHIFT}, /* * */ |
Dance | 0:f1ecca559ec3 | 240 | {0x2e, KEY_SHIFT}, /* + */ |
Dance | 0:f1ecca559ec3 | 241 | {0x36, 0}, /* , */ |
Dance | 0:f1ecca559ec3 | 242 | {0x2d, 0}, /* - */ |
Dance | 0:f1ecca559ec3 | 243 | {0x37, 0}, /* . */ |
Dance | 0:f1ecca559ec3 | 244 | {0x38, 0}, /* / */ |
Dance | 0:f1ecca559ec3 | 245 | {0x27, 0}, /* 0 */ |
Dance | 0:f1ecca559ec3 | 246 | {0x1e, 0}, /* 1 */ |
Dance | 0:f1ecca559ec3 | 247 | {0x1f, 0}, /* 2 */ |
Dance | 0:f1ecca559ec3 | 248 | {0x20, 0}, /* 3 */ |
Dance | 0:f1ecca559ec3 | 249 | {0x21, 0}, /* 4 */ |
Dance | 0:f1ecca559ec3 | 250 | {0x22, 0}, /* 5 */ |
Dance | 0:f1ecca559ec3 | 251 | {0x23, 0}, /* 6 */ |
Dance | 0:f1ecca559ec3 | 252 | {0x24, 0}, /* 7 */ |
Dance | 0:f1ecca559ec3 | 253 | {0x25, 0}, /* 8 */ |
Dance | 0:f1ecca559ec3 | 254 | {0x26, 0}, /* 9 */ |
Dance | 0:f1ecca559ec3 | 255 | {0x33, KEY_SHIFT}, /* : */ |
Dance | 0:f1ecca559ec3 | 256 | {0x33, 0}, /* ; */ |
Dance | 0:f1ecca559ec3 | 257 | {0x36, KEY_SHIFT}, /* < */ |
Dance | 0:f1ecca559ec3 | 258 | {0x2e, 0}, /* = */ |
Dance | 0:f1ecca559ec3 | 259 | {0x37, KEY_SHIFT}, /* > */ |
Dance | 0:f1ecca559ec3 | 260 | {0x38, KEY_SHIFT}, /* ? */ |
Dance | 0:f1ecca559ec3 | 261 | {0x34, KEY_SHIFT}, /* @ */ |
Dance | 0:f1ecca559ec3 | 262 | {0x04, KEY_SHIFT}, /* A */ |
Dance | 0:f1ecca559ec3 | 263 | {0x05, KEY_SHIFT}, /* B */ |
Dance | 0:f1ecca559ec3 | 264 | {0x06, KEY_SHIFT}, /* C */ |
Dance | 0:f1ecca559ec3 | 265 | {0x07, KEY_SHIFT}, /* D */ |
Dance | 0:f1ecca559ec3 | 266 | {0x08, KEY_SHIFT}, /* E */ |
Dance | 0:f1ecca559ec3 | 267 | {0x09, KEY_SHIFT}, /* F */ |
Dance | 0:f1ecca559ec3 | 268 | {0x0a, KEY_SHIFT}, /* G */ |
Dance | 0:f1ecca559ec3 | 269 | {0x0b, KEY_SHIFT}, /* H */ |
Dance | 0:f1ecca559ec3 | 270 | {0x0c, KEY_SHIFT}, /* I */ |
Dance | 0:f1ecca559ec3 | 271 | {0x0d, KEY_SHIFT}, /* J */ |
Dance | 0:f1ecca559ec3 | 272 | {0x0e, KEY_SHIFT}, /* K */ |
Dance | 0:f1ecca559ec3 | 273 | {0x0f, KEY_SHIFT}, /* L */ |
Dance | 0:f1ecca559ec3 | 274 | {0x10, KEY_SHIFT}, /* M */ |
Dance | 0:f1ecca559ec3 | 275 | {0x11, KEY_SHIFT}, /* N */ |
Dance | 0:f1ecca559ec3 | 276 | {0x12, KEY_SHIFT}, /* O */ |
Dance | 0:f1ecca559ec3 | 277 | {0x13, KEY_SHIFT}, /* P */ |
Dance | 0:f1ecca559ec3 | 278 | {0x14, KEY_SHIFT}, /* Q */ |
Dance | 0:f1ecca559ec3 | 279 | {0x15, KEY_SHIFT}, /* R */ |
Dance | 0:f1ecca559ec3 | 280 | {0x16, KEY_SHIFT}, /* S */ |
Dance | 0:f1ecca559ec3 | 281 | {0x17, KEY_SHIFT}, /* T */ |
Dance | 0:f1ecca559ec3 | 282 | {0x18, KEY_SHIFT}, /* U */ |
Dance | 0:f1ecca559ec3 | 283 | {0x19, KEY_SHIFT}, /* V */ |
Dance | 0:f1ecca559ec3 | 284 | {0x1a, KEY_SHIFT}, /* W */ |
Dance | 0:f1ecca559ec3 | 285 | {0x1b, KEY_SHIFT}, /* X */ |
Dance | 0:f1ecca559ec3 | 286 | {0x1c, KEY_SHIFT}, /* Y */ |
Dance | 0:f1ecca559ec3 | 287 | {0x1d, KEY_SHIFT}, /* Z */ |
Dance | 0:f1ecca559ec3 | 288 | {0x2f, 0}, /* [ */ |
Dance | 0:f1ecca559ec3 | 289 | {0x64, 0}, /* \ */ |
Dance | 0:f1ecca559ec3 | 290 | {0x30, 0}, /* ] */ |
Dance | 0:f1ecca559ec3 | 291 | {0x23, KEY_SHIFT}, /* ^ */ |
Dance | 0:f1ecca559ec3 | 292 | {0x2d, KEY_SHIFT}, /* _ */ |
Dance | 0:f1ecca559ec3 | 293 | {0x35, 0}, /* ` */ |
Dance | 0:f1ecca559ec3 | 294 | {0x04, 0}, /* a */ |
Dance | 0:f1ecca559ec3 | 295 | {0x05, 0}, /* b */ |
Dance | 0:f1ecca559ec3 | 296 | {0x06, 0}, /* c */ |
Dance | 0:f1ecca559ec3 | 297 | {0x07, 0}, /* d */ |
Dance | 0:f1ecca559ec3 | 298 | {0x08, 0}, /* e */ |
Dance | 0:f1ecca559ec3 | 299 | {0x09, 0}, /* f */ |
Dance | 0:f1ecca559ec3 | 300 | {0x0a, 0}, /* g */ |
Dance | 0:f1ecca559ec3 | 301 | {0x0b, 0}, /* h */ |
Dance | 0:f1ecca559ec3 | 302 | {0x0c, 0}, /* i */ |
Dance | 0:f1ecca559ec3 | 303 | {0x0d, 0}, /* j */ |
Dance | 0:f1ecca559ec3 | 304 | {0x0e, 0}, /* k */ |
Dance | 0:f1ecca559ec3 | 305 | {0x0f, 0}, /* l */ |
Dance | 0:f1ecca559ec3 | 306 | {0x10, 0}, /* m */ |
Dance | 0:f1ecca559ec3 | 307 | {0x11, 0}, /* n */ |
Dance | 0:f1ecca559ec3 | 308 | {0x12, 0}, /* o */ |
Dance | 0:f1ecca559ec3 | 309 | {0x13, 0}, /* p */ |
Dance | 0:f1ecca559ec3 | 310 | {0x14, 0}, /* q */ |
Dance | 0:f1ecca559ec3 | 311 | {0x15, 0}, /* r */ |
Dance | 0:f1ecca559ec3 | 312 | {0x16, 0}, /* s */ |
Dance | 0:f1ecca559ec3 | 313 | {0x17, 0}, /* t */ |
Dance | 0:f1ecca559ec3 | 314 | {0x18, 0}, /* u */ |
Dance | 0:f1ecca559ec3 | 315 | {0x19, 0}, /* v */ |
Dance | 0:f1ecca559ec3 | 316 | {0x1a, 0}, /* w */ |
Dance | 0:f1ecca559ec3 | 317 | {0x1b, 0}, /* x */ |
Dance | 0:f1ecca559ec3 | 318 | {0x1c, 0}, /* y */ |
Dance | 0:f1ecca559ec3 | 319 | {0x1d, 0}, /* z */ |
Dance | 0:f1ecca559ec3 | 320 | {0x2f, KEY_SHIFT}, /* { */ |
Dance | 0:f1ecca559ec3 | 321 | {0x64, KEY_SHIFT}, /* | */ |
Dance | 0:f1ecca559ec3 | 322 | {0x30, KEY_SHIFT}, /* } */ |
Dance | 0:f1ecca559ec3 | 323 | {0x32, KEY_SHIFT}, /* ~ */ |
Dance | 0:f1ecca559ec3 | 324 | {0,0}, /* DEL */ |
Dance | 0:f1ecca559ec3 | 325 | |
Dance | 0:f1ecca559ec3 | 326 | {0x3a, 0}, /* F1 */ |
Dance | 0:f1ecca559ec3 | 327 | {0x3b, 0}, /* F2 */ |
Dance | 0:f1ecca559ec3 | 328 | {0x3c, 0}, /* F3 */ |
Dance | 0:f1ecca559ec3 | 329 | {0x3d, 0}, /* F4 */ |
Dance | 0:f1ecca559ec3 | 330 | {0x3e, 0}, /* F5 */ |
Dance | 0:f1ecca559ec3 | 331 | {0x3f, 0}, /* F6 */ |
Dance | 0:f1ecca559ec3 | 332 | {0x40, 0}, /* F7 */ |
Dance | 0:f1ecca559ec3 | 333 | {0x41, 0}, /* F8 */ |
Dance | 0:f1ecca559ec3 | 334 | {0x42, 0}, /* F9 */ |
Dance | 0:f1ecca559ec3 | 335 | {0x43, 0}, /* F10 */ |
Dance | 0:f1ecca559ec3 | 336 | {0x44, 0}, /* F11 */ |
Dance | 0:f1ecca559ec3 | 337 | {0x45, 0}, /* F12 */ |
Dance | 0:f1ecca559ec3 | 338 | |
Dance | 0:f1ecca559ec3 | 339 | {0x46, 0}, /* PRINT_SCREEN */ |
Dance | 0:f1ecca559ec3 | 340 | {0x47, 0}, /* SCROLL_LOCK */ |
Dance | 0:f1ecca559ec3 | 341 | {0x39, 0}, /* CAPS_LOCK */ |
Dance | 0:f1ecca559ec3 | 342 | {0x53, 0}, /* NUM_LOCK */ |
Dance | 0:f1ecca559ec3 | 343 | {0x49, 0}, /* INSERT */ |
Dance | 0:f1ecca559ec3 | 344 | {0x4a, 0}, /* HOME */ |
Dance | 0:f1ecca559ec3 | 345 | {0x4b, 0}, /* PAGE_UP */ |
Dance | 0:f1ecca559ec3 | 346 | {0x4e, 0}, /* PAGE_DOWN */ |
Dance | 0:f1ecca559ec3 | 347 | |
Dance | 0:f1ecca559ec3 | 348 | {0x4f, 0}, /* RIGHT_ARROW */ |
Dance | 0:f1ecca559ec3 | 349 | {0x50, 0}, /* LEFT_ARROW */ |
Dance | 0:f1ecca559ec3 | 350 | {0x51, 0}, /* DOWN_ARROW */ |
Dance | 0:f1ecca559ec3 | 351 | {0x52, 0}, /* UP_ARROW */ |
Dance | 0:f1ecca559ec3 | 352 | }; |
Dance | 0:f1ecca559ec3 | 353 | #endif |
Dance | 0:f1ecca559ec3 | 354 | |
Dance | 0:f1ecca559ec3 | 355 | uint8_t * USBKeyboard::reportDesc() { |
Dance | 0:f1ecca559ec3 | 356 | static uint8_t reportDescriptor[] = { |
Dance | 0:f1ecca559ec3 | 357 | USAGE_PAGE(1), 0x01, // Generic Desktop |
Dance | 0:f1ecca559ec3 | 358 | USAGE(1), 0x06, // Keyboard |
Dance | 0:f1ecca559ec3 | 359 | COLLECTION(1), 0x01, // Application |
Dance | 0:f1ecca559ec3 | 360 | REPORT_ID(1), REPORT_ID_KEYBOARD, |
Dance | 0:f1ecca559ec3 | 361 | |
Dance | 0:f1ecca559ec3 | 362 | USAGE_PAGE(1), 0x07, // Key Codes |
Dance | 0:f1ecca559ec3 | 363 | USAGE_MINIMUM(1), 0xE0, |
Dance | 0:f1ecca559ec3 | 364 | USAGE_MAXIMUM(1), 0xE7, |
Dance | 0:f1ecca559ec3 | 365 | LOGICAL_MINIMUM(1), 0x00, |
Dance | 0:f1ecca559ec3 | 366 | LOGICAL_MAXIMUM(1), 0x01, |
Dance | 0:f1ecca559ec3 | 367 | REPORT_SIZE(1), 0x01, |
Dance | 0:f1ecca559ec3 | 368 | REPORT_COUNT(1), 0x08, |
Dance | 0:f1ecca559ec3 | 369 | INPUT(1), 0x02, // Data, Variable, Absolute |
Dance | 0:f1ecca559ec3 | 370 | REPORT_COUNT(1), 0x01, |
Dance | 0:f1ecca559ec3 | 371 | REPORT_SIZE(1), 0x08, |
Dance | 0:f1ecca559ec3 | 372 | INPUT(1), 0x01, // Constant |
Dance | 0:f1ecca559ec3 | 373 | |
Dance | 0:f1ecca559ec3 | 374 | |
Dance | 0:f1ecca559ec3 | 375 | REPORT_COUNT(1), 0x05, |
Dance | 0:f1ecca559ec3 | 376 | REPORT_SIZE(1), 0x01, |
Dance | 0:f1ecca559ec3 | 377 | USAGE_PAGE(1), 0x08, // LEDs |
Dance | 0:f1ecca559ec3 | 378 | USAGE_MINIMUM(1), 0x01, |
Dance | 0:f1ecca559ec3 | 379 | USAGE_MAXIMUM(1), 0x05, |
Dance | 0:f1ecca559ec3 | 380 | OUTPUT(1), 0x02, // Data, Variable, Absolute |
Dance | 0:f1ecca559ec3 | 381 | REPORT_COUNT(1), 0x01, |
Dance | 0:f1ecca559ec3 | 382 | REPORT_SIZE(1), 0x03, |
Dance | 0:f1ecca559ec3 | 383 | OUTPUT(1), 0x01, // Constant |
Dance | 0:f1ecca559ec3 | 384 | |
Dance | 0:f1ecca559ec3 | 385 | |
Dance | 0:f1ecca559ec3 | 386 | REPORT_COUNT(1), 0x06, |
Dance | 0:f1ecca559ec3 | 387 | REPORT_SIZE(1), 0x08, |
Dance | 0:f1ecca559ec3 | 388 | LOGICAL_MINIMUM(1), 0x00, |
Dance | 0:f1ecca559ec3 | 389 | LOGICAL_MAXIMUM(1), 0x65, |
Dance | 0:f1ecca559ec3 | 390 | USAGE_PAGE(1), 0x07, // Key Codes |
Dance | 0:f1ecca559ec3 | 391 | USAGE_MINIMUM(1), 0x00, |
Dance | 0:f1ecca559ec3 | 392 | USAGE_MAXIMUM(1), 0x65, |
Dance | 0:f1ecca559ec3 | 393 | INPUT(1), 0x00, // Data, Array |
Dance | 0:f1ecca559ec3 | 394 | END_COLLECTION(0), |
Dance | 0:f1ecca559ec3 | 395 | |
Dance | 0:f1ecca559ec3 | 396 | // Media Control |
Dance | 0:f1ecca559ec3 | 397 | USAGE_PAGE(1), 0x0C, |
Dance | 0:f1ecca559ec3 | 398 | USAGE(1), 0x01, |
Dance | 0:f1ecca559ec3 | 399 | COLLECTION(1), 0x01, |
Dance | 0:f1ecca559ec3 | 400 | REPORT_ID(1), REPORT_ID_VOLUME, |
Dance | 0:f1ecca559ec3 | 401 | USAGE_PAGE(1), 0x0C, |
Dance | 0:f1ecca559ec3 | 402 | LOGICAL_MINIMUM(1), 0x00, |
Dance | 0:f1ecca559ec3 | 403 | LOGICAL_MAXIMUM(1), 0x01, |
Dance | 0:f1ecca559ec3 | 404 | REPORT_SIZE(1), 0x01, |
Dance | 0:f1ecca559ec3 | 405 | REPORT_COUNT(1), 0x07, |
Dance | 0:f1ecca559ec3 | 406 | USAGE(1), 0xB5, // Next Track |
Dance | 0:f1ecca559ec3 | 407 | USAGE(1), 0xB6, // Previous Track |
Dance | 0:f1ecca559ec3 | 408 | USAGE(1), 0xB7, // Stop |
Dance | 0:f1ecca559ec3 | 409 | USAGE(1), 0xCD, // Play / Pause |
Dance | 0:f1ecca559ec3 | 410 | USAGE(1), 0xE2, // Mute |
Dance | 0:f1ecca559ec3 | 411 | USAGE(1), 0xE9, // Volume Up |
Dance | 0:f1ecca559ec3 | 412 | USAGE(1), 0xEA, // Volume Down |
Dance | 0:f1ecca559ec3 | 413 | INPUT(1), 0x02, // Input (Data, Variable, Absolute) |
Dance | 0:f1ecca559ec3 | 414 | REPORT_COUNT(1), 0x01, |
Dance | 0:f1ecca559ec3 | 415 | INPUT(1), 0x01, |
Dance | 0:f1ecca559ec3 | 416 | END_COLLECTION(0), |
Dance | 0:f1ecca559ec3 | 417 | }; |
Dance | 0:f1ecca559ec3 | 418 | reportLength = sizeof(reportDescriptor); |
Dance | 0:f1ecca559ec3 | 419 | return reportDescriptor; |
Dance | 0:f1ecca559ec3 | 420 | } |
Dance | 0:f1ecca559ec3 | 421 | |
Dance | 0:f1ecca559ec3 | 422 | |
Dance | 0:f1ecca559ec3 | 423 | bool USBKeyboard::EP1_OUT_callback() { |
Dance | 0:f1ecca559ec3 | 424 | uint32_t bytesRead = 0; |
Dance | 0:f1ecca559ec3 | 425 | uint8_t led[65]; |
Dance | 0:f1ecca559ec3 | 426 | USBDevice::readEP(EPINT_OUT, led, &bytesRead, MAX_HID_REPORT_SIZE); |
Dance | 0:f1ecca559ec3 | 427 | |
Dance | 0:f1ecca559ec3 | 428 | // we take led[1] because led[0] is the report ID |
Dance | 0:f1ecca559ec3 | 429 | lock_status = led[1] & 0x07; |
Dance | 0:f1ecca559ec3 | 430 | |
Dance | 0:f1ecca559ec3 | 431 | // We activate the endpoint to be able to recceive data |
Dance | 0:f1ecca559ec3 | 432 | if (!readStart(EPINT_OUT, MAX_HID_REPORT_SIZE)) |
Dance | 0:f1ecca559ec3 | 433 | return false; |
Dance | 0:f1ecca559ec3 | 434 | return true; |
Dance | 0:f1ecca559ec3 | 435 | } |
Dance | 0:f1ecca559ec3 | 436 | |
Dance | 0:f1ecca559ec3 | 437 | uint8_t USBKeyboard::lockStatus() { |
Dance | 0:f1ecca559ec3 | 438 | return lock_status; |
Dance | 0:f1ecca559ec3 | 439 | } |
Dance | 0:f1ecca559ec3 | 440 | |
Dance | 0:f1ecca559ec3 | 441 | int USBKeyboard::_putc(int c) { |
Dance | 0:f1ecca559ec3 | 442 | return keyCode(c, keymap[c].modifier); |
Dance | 0:f1ecca559ec3 | 443 | } |
Dance | 0:f1ecca559ec3 | 444 | |
Dance | 0:f1ecca559ec3 | 445 | bool USBKeyboard::keyCode(uint8_t key, uint8_t modifier) { |
Dance | 0:f1ecca559ec3 | 446 | // Send a simulated keyboard keypress. Returns true if successful. |
Dance | 0:f1ecca559ec3 | 447 | HID_REPORT report; |
Dance | 0:f1ecca559ec3 | 448 | |
Dance | 0:f1ecca559ec3 | 449 | report.data[0] = REPORT_ID_KEYBOARD; |
Dance | 0:f1ecca559ec3 | 450 | report.data[1] = modifier; |
Dance | 0:f1ecca559ec3 | 451 | report.data[2] = 0; |
Dance | 0:f1ecca559ec3 | 452 | report.data[3] = keymap[key].usage; |
Dance | 0:f1ecca559ec3 | 453 | report.data[4] = 0; |
Dance | 0:f1ecca559ec3 | 454 | report.data[5] = 0; |
Dance | 0:f1ecca559ec3 | 455 | report.data[6] = 0; |
Dance | 0:f1ecca559ec3 | 456 | report.data[7] = 0; |
Dance | 0:f1ecca559ec3 | 457 | report.data[8] = 0; |
Dance | 0:f1ecca559ec3 | 458 | |
Dance | 0:f1ecca559ec3 | 459 | report.length = 9; |
Dance | 0:f1ecca559ec3 | 460 | |
Dance | 0:f1ecca559ec3 | 461 | if (!send(&report)) { |
Dance | 0:f1ecca559ec3 | 462 | return false; |
Dance | 0:f1ecca559ec3 | 463 | } |
Dance | 0:f1ecca559ec3 | 464 | |
Dance | 0:f1ecca559ec3 | 465 | report.data[1] = 0; |
Dance | 0:f1ecca559ec3 | 466 | report.data[3] = 0; |
Dance | 0:f1ecca559ec3 | 467 | |
Dance | 0:f1ecca559ec3 | 468 | if (!send(&report)) { |
Dance | 0:f1ecca559ec3 | 469 | return false; |
Dance | 0:f1ecca559ec3 | 470 | } |
Dance | 0:f1ecca559ec3 | 471 | |
Dance | 0:f1ecca559ec3 | 472 | return true; |
Dance | 0:f1ecca559ec3 | 473 | |
Dance | 0:f1ecca559ec3 | 474 | } |
Dance | 0:f1ecca559ec3 | 475 | |
Dance | 0:f1ecca559ec3 | 476 | |
Dance | 0:f1ecca559ec3 | 477 | bool USBKeyboard::mediaControl(MEDIA_KEY key) { |
Dance | 0:f1ecca559ec3 | 478 | HID_REPORT report; |
Dance | 0:f1ecca559ec3 | 479 | |
Dance | 0:f1ecca559ec3 | 480 | report.data[0] = REPORT_ID_VOLUME; |
Dance | 0:f1ecca559ec3 | 481 | report.data[1] = (1 << key) & 0x7f; |
Dance | 0:f1ecca559ec3 | 482 | |
Dance | 0:f1ecca559ec3 | 483 | report.length = 2; |
Dance | 0:f1ecca559ec3 | 484 | |
Dance | 0:f1ecca559ec3 | 485 | if (!send(&report)) { |
Dance | 0:f1ecca559ec3 | 486 | return false; |
Dance | 0:f1ecca559ec3 | 487 | } |
Dance | 0:f1ecca559ec3 | 488 | |
Dance | 0:f1ecca559ec3 | 489 | report.data[0] = REPORT_ID_VOLUME; |
Dance | 0:f1ecca559ec3 | 490 | report.data[1] = 0; |
Dance | 0:f1ecca559ec3 | 491 | |
Dance | 0:f1ecca559ec3 | 492 | report.length = 2; |
Dance | 0:f1ecca559ec3 | 493 | |
Dance | 0:f1ecca559ec3 | 494 | return send(&report); |
Dance | 0:f1ecca559ec3 | 495 | } |
Dance | 0:f1ecca559ec3 | 496 | |
Dance | 0:f1ecca559ec3 | 497 | |
Dance | 0:f1ecca559ec3 | 498 | #define DEFAULT_CONFIGURATION (1) |
Dance | 0:f1ecca559ec3 | 499 | #define TOTAL_DESCRIPTOR_LENGTH ((1 * CONFIGURATION_DESCRIPTOR_LENGTH) \ |
Dance | 0:f1ecca559ec3 | 500 | + (1 * INTERFACE_DESCRIPTOR_LENGTH) \ |
Dance | 0:f1ecca559ec3 | 501 | + (1 * HID_DESCRIPTOR_LENGTH) \ |
Dance | 0:f1ecca559ec3 | 502 | + (2 * ENDPOINT_DESCRIPTOR_LENGTH)) |
Dance | 0:f1ecca559ec3 | 503 | |
Dance | 0:f1ecca559ec3 | 504 | uint8_t * USBKeyboard::configurationDesc() { |
Dance | 0:f1ecca559ec3 | 505 | static uint8_t configurationDescriptor[] = { |
Dance | 0:f1ecca559ec3 | 506 | CONFIGURATION_DESCRIPTOR_LENGTH,// bLength |
Dance | 0:f1ecca559ec3 | 507 | CONFIGURATION_DESCRIPTOR, // bDescriptorType |
Dance | 0:f1ecca559ec3 | 508 | LSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (LSB) |
Dance | 0:f1ecca559ec3 | 509 | MSB(TOTAL_DESCRIPTOR_LENGTH), // wTotalLength (MSB) |
Dance | 0:f1ecca559ec3 | 510 | 0x01, // bNumInterfaces |
Dance | 0:f1ecca559ec3 | 511 | DEFAULT_CONFIGURATION, // bConfigurationValue |
Dance | 0:f1ecca559ec3 | 512 | 0x00, // iConfiguration |
Dance | 0:f1ecca559ec3 | 513 | C_RESERVED | C_SELF_POWERED, // bmAttributes |
Dance | 0:f1ecca559ec3 | 514 | C_POWER(0), // bMaxPowerHello World from Mbed |
Dance | 0:f1ecca559ec3 | 515 | |
Dance | 0:f1ecca559ec3 | 516 | INTERFACE_DESCRIPTOR_LENGTH, // bLength |
Dance | 0:f1ecca559ec3 | 517 | INTERFACE_DESCRIPTOR, // bDescriptorType |
Dance | 0:f1ecca559ec3 | 518 | 0x00, // bInterfaceNumber |
Dance | 0:f1ecca559ec3 | 519 | 0x00, // bAlternateSetting |
Dance | 0:f1ecca559ec3 | 520 | 0x02, // bNumEndpoints |
Dance | 0:f1ecca559ec3 | 521 | HID_CLASS, // bInterfaceClass |
Dance | 0:f1ecca559ec3 | 522 | 1, // bInterfaceSubClass |
Dance | 0:f1ecca559ec3 | 523 | 1, // bInterfaceProtocol (keyboard) |
Dance | 0:f1ecca559ec3 | 524 | 0x00, // iInterface |
Dance | 0:f1ecca559ec3 | 525 | |
Dance | 0:f1ecca559ec3 | 526 | HID_DESCRIPTOR_LENGTH, // bLength |
Dance | 0:f1ecca559ec3 | 527 | HID_DESCRIPTOR, // bDescriptorType |
Dance | 0:f1ecca559ec3 | 528 | LSB(HID_VERSION_1_11), // bcdHID (LSB) |
Dance | 0:f1ecca559ec3 | 529 | MSB(HID_VERSION_1_11), // bcdHID (MSB) |
Dance | 0:f1ecca559ec3 | 530 | 0x00, // bCountryCode |
Dance | 0:f1ecca559ec3 | 531 | 0x01, // bNumDescriptors |
Dance | 0:f1ecca559ec3 | 532 | REPORT_DESCRIPTOR, // bDescriptorType |
Dance | 0:f1ecca559ec3 | 533 | (uint8_t)(LSB(reportDescLength())), // wDescriptorLength (LSB) |
Dance | 0:f1ecca559ec3 | 534 | (uint8_t)(MSB(reportDescLength())), // wDescriptorLength (MSB) |
Dance | 0:f1ecca559ec3 | 535 | |
Dance | 0:f1ecca559ec3 | 536 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
Dance | 0:f1ecca559ec3 | 537 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
Dance | 0:f1ecca559ec3 | 538 | PHY_TO_DESC(EPINT_IN), // bEndpointAddress |
Dance | 0:f1ecca559ec3 | 539 | E_INTERRUPT, // bmAttributes |
Dance | 0:f1ecca559ec3 | 540 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
Dance | 0:f1ecca559ec3 | 541 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
Dance | 0:f1ecca559ec3 | 542 | 1, // bInterval (milliseconds) |
Dance | 0:f1ecca559ec3 | 543 | |
Dance | 0:f1ecca559ec3 | 544 | ENDPOINT_DESCRIPTOR_LENGTH, // bLength |
Dance | 0:f1ecca559ec3 | 545 | ENDPOINT_DESCRIPTOR, // bDescriptorType |
Dance | 0:f1ecca559ec3 | 546 | PHY_TO_DESC(EPINT_OUT), // bEndpointAddress |
Dance | 0:f1ecca559ec3 | 547 | E_INTERRUPT, // bmAttributes |
Dance | 0:f1ecca559ec3 | 548 | LSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (LSB) |
Dance | 0:f1ecca559ec3 | 549 | MSB(MAX_PACKET_SIZE_EPINT), // wMaxPacketSize (MSB) |
Dance | 0:f1ecca559ec3 | 550 | 1, // bInterval (milliseconds) |
Dance | 0:f1ecca559ec3 | 551 | }; |
Dance | 0:f1ecca559ec3 | 552 | return configurationDescriptor; |
Dance | 0:f1ecca559ec3 | 553 | } |