usb_keyboard.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. // Copyright 2021 IOsetting <iosetting(at)outlook.com>
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * USB Keyboard Demo
  16. *
  17. * P0: 8 bits for 4x4 Key matrix
  18. * P6.0: NumLock
  19. * P6.1: CapsLock
  20. */
  21. #include "fw_hal.h"
  22. #include <string.h>
  23. #define KeyIO P0
  24. __BIT B_1ms; // 1ms flag
  25. __BIT KeyChangeTemp;
  26. __BIT KeyChangeFlag;
  27. uint16_t cnt50ms;
  28. uint16_t KeyCode; // code of key pressed
  29. uint16_t OldKeyCode; // for key status changing check
  30. uint16_t NewKeyCode; // new key status
  31. uint16_t KeyHoldTime;
  32. __CODE uint8_t DEVICEDESC[18];
  33. __CODE uint8_t CONFIGDESC[41];
  34. __CODE uint8_t HIDREPORTDESC[63];
  35. __CODE uint8_t LANGIDDESC[4];
  36. __CODE uint8_t MANUFACTDESC[8];
  37. __CODE uint8_t PRODUCTDESC[30];
  38. __CODE uint8_t KeyMap[16];
  39. __XDATA uint8_t HidFreature[64];
  40. __XDATA uint8_t HidInput[64];
  41. __XDATA uint8_t HidOutput[64];
  42. USB_Request_t usb_request;
  43. USB_EP0_Stage_t usb_ep0_stage;
  44. void USB_Init(void);
  45. void KeyScan(void);
  46. void SendKeyStatus(void);
  47. void main()
  48. {
  49. uint8_t i;
  50. GPIO_P1_SetMode(GPIO_Pin_All, GPIO_Mode_InOut_QBD);
  51. GPIO_P3_SetMode(GPIO_Pin_0 | GPIO_Pin_1, GPIO_Mode_Input_HIP);
  52. GPIO_P6_SetMode(GPIO_Pin_All, GPIO_Mode_Output_PP);
  53. USB_Init();
  54. TIM_Timer0_Config(HAL_State_ON, TIM_TimerMode_16BitAuto, 1000);
  55. EXTI_Timer0_SetIntState(HAL_State_ON);
  56. EXTI_Timer0_SetIntPriority(EXTI_IntPriority_High);
  57. TIM_Timer0_SetRunState(HAL_State_ON);
  58. EXTI_Global_SetIntState(HAL_State_ON);
  59. for (i = 0; i < 8; i++)
  60. {
  61. HidInput[i] = 0;
  62. }
  63. while (1)
  64. {
  65. if (B_1ms) // every 1 ms
  66. {
  67. B_1ms = 0;
  68. if (++cnt50ms >= 50) // scan every 50 ms
  69. {
  70. cnt50ms = 0;
  71. KeyScan();
  72. }
  73. if (KeyChangeFlag) // if key status changed
  74. {
  75. KeyChangeFlag = 0;
  76. SendKeyStatus();
  77. }
  78. }
  79. }
  80. }
  81. void USB_Init()
  82. {
  83. SYS_EnableOscillator48M();
  84. USB_SetClockSource(USB_ClockSource_6M);
  85. USB_SetEnabled(HAL_State_ON);
  86. USB_SetDpDmPullUp(HAL_State_ON);
  87. EXTI_USB_SetIntPriority(EXTI_IntPriority_Highest);
  88. USB_WriteReg(FADDR, 0x00);
  89. USB_WriteReg(POWER, 0x08);
  90. USB_WriteReg(INTRIN1E, 0x3f);
  91. USB_WriteReg(INTROUT1E, 0x3f);
  92. USB_WriteReg(INTRUSBE, 0x00);
  93. USB_WriteReg(POWER, 0x01);
  94. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  95. EXTI_USB_SetIntState(HAL_State_ON);
  96. }
  97. INTERRUPT(USB_Routine, EXTI_VectUSB)
  98. {
  99. uint8_t intrusb;
  100. uint8_t intrin;
  101. uint8_t introut;
  102. uint8_t csr;
  103. uint8_t cnt;
  104. uint16_t len = 0;
  105. intrusb = USB_ReadReg(INTRUSB);
  106. intrin = USB_ReadReg(INTRIN1);
  107. introut = USB_ReadReg(INTROUT1);
  108. if (intrusb & RSTIF)
  109. {
  110. USB_SelectEndPoint(1);
  111. USB_WriteReg(INCSR1, INCLRDT);
  112. USB_SelectEndPoint(1);
  113. USB_WriteReg(OUTCSR1, OUTCLRDT);
  114. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  115. }
  116. if (intrin & EP0IF)
  117. {
  118. USB_SelectEndPoint(0);
  119. csr = USB_ReadReg(CSR0);
  120. if (csr & STSTL)
  121. {
  122. USB_WriteReg(CSR0, csr & ~STSTL);
  123. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  124. }
  125. if (csr & SUEND)
  126. {
  127. USB_WriteReg(CSR0, csr | SSUEND);
  128. }
  129. switch (usb_ep0_stage.bStage)
  130. {
  131. case USB_CtrlState_Idle:
  132. if (csr & OPRDY)
  133. {
  134. usb_ep0_stage.bStage = USB_CtrlState_SettingUp;
  135. USB_ReadFIFO(FIFO0, (uint8_t *)&usb_request);
  136. ((uint8_t *)&usb_ep0_stage.wResidue)[0] = usb_request.wLength.bb.bh;
  137. ((uint8_t *)&usb_ep0_stage.wResidue)[1] = usb_request.wLength.bb.bl;
  138. switch (usb_request.bmRequestType & REQUEST_TYPE_MASK)
  139. {
  140. case USB_RequestType_Standard:
  141. switch (usb_request.bRequest)
  142. {
  143. case USB_StdReq_SetAddress:
  144. USB_WriteReg(FADDR, usb_request.wValue.bb.bl);
  145. break;
  146. case USB_StdReq_SetConfiguration:
  147. USB_SelectEndPoint(1);
  148. USB_WriteReg(INCSR2, INMODEIN);
  149. USB_WriteReg(INMAXP, 8);
  150. USB_SelectEndPoint(1);
  151. USB_WriteReg(INCSR2, INMODEOUT);
  152. USB_WriteReg(OUTMAXP, 8);
  153. USB_SelectEndPoint(0);
  154. break;
  155. case USB_StdReq_GetDescriptor:
  156. usb_ep0_stage.bStage = USB_CtrlState_DataIn;
  157. switch (usb_request.wValue.bb.bh)
  158. {
  159. case USB_DescriptorType_Device:
  160. usb_ep0_stage.pData = (uint8_t *)DEVICEDESC;
  161. len = sizeof(DEVICEDESC);
  162. break;
  163. case USB_DescriptorType_Configuration:
  164. usb_ep0_stage.pData = (uint8_t *)CONFIGDESC;
  165. len = sizeof(CONFIGDESC);
  166. break;
  167. case USB_DescriptorType_String:
  168. switch (usb_request.wValue.bb.bl)
  169. {
  170. case 0:
  171. usb_ep0_stage.pData = (uint8_t *)LANGIDDESC;
  172. len = sizeof(LANGIDDESC);
  173. break;
  174. case 1:
  175. usb_ep0_stage.pData = (uint8_t *)MANUFACTDESC;
  176. len = sizeof(MANUFACTDESC);
  177. break;
  178. case 2:
  179. usb_ep0_stage.pData = (uint8_t *)PRODUCTDESC;
  180. len = sizeof(PRODUCTDESC);
  181. break;
  182. default:
  183. usb_ep0_stage.bStage = USB_CtrlState_Stalled;
  184. break;
  185. }
  186. break;
  187. case USB_DescriptorType_Report:
  188. usb_ep0_stage.pData = (uint8_t *)HIDREPORTDESC;
  189. len = sizeof(HIDREPORTDESC);
  190. break;
  191. default:
  192. usb_ep0_stage.bStage = USB_CtrlState_Stalled;
  193. break;
  194. }
  195. if (len < usb_ep0_stage.wResidue)
  196. {
  197. usb_ep0_stage.wResidue = len;
  198. }
  199. break;
  200. default:
  201. usb_ep0_stage.bStage = USB_CtrlState_Stalled;
  202. break;
  203. }
  204. break;
  205. case USB_RequestType_Class:
  206. switch (usb_request.bRequest)
  207. {
  208. case USB_HidReq_GetReport:
  209. usb_ep0_stage.pData = HidFreature;
  210. usb_ep0_stage.bStage = USB_CtrlState_DataIn;
  211. break;
  212. case USB_HidReq_SetReport:
  213. usb_ep0_stage.pData = HidFreature;
  214. usb_ep0_stage.bStage = USB_CtrlState_DataOut;
  215. break;
  216. case USB_HidReq_SetIdle:
  217. break;
  218. // case USB_HidReq_GetIdle:
  219. // case USB_HidReq_GetProtocol:
  220. // case USB_HidReq_SetProtocol:
  221. default:
  222. usb_ep0_stage.bStage = USB_CtrlState_Stalled;
  223. break;
  224. }
  225. break;
  226. default:
  227. usb_ep0_stage.bStage = USB_CtrlState_Stalled;
  228. break;
  229. }
  230. switch (usb_ep0_stage.bStage)
  231. {
  232. case USB_CtrlState_DataIn:
  233. USB_WriteReg(CSR0, SOPRDY);
  234. goto L_Ep0SendData;
  235. break;
  236. case USB_CtrlState_DataOut:
  237. USB_WriteReg(CSR0, SOPRDY);
  238. break;
  239. case USB_CtrlState_SettingUp:
  240. USB_WriteReg(CSR0, SOPRDY | DATEND);
  241. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  242. break;
  243. case USB_CtrlState_Stalled:
  244. USB_WriteReg(CSR0, SOPRDY | SDSTL);
  245. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  246. break;
  247. }
  248. }
  249. break;
  250. case USB_CtrlState_DataIn:
  251. if (!(csr & IPRDY))
  252. {
  253. L_Ep0SendData:
  254. cnt = usb_ep0_stage.wResidue > 64 ? 64 : usb_ep0_stage.wResidue;
  255. USB_WriteFIFO(FIFO0, usb_ep0_stage.pData, cnt);
  256. usb_ep0_stage.wResidue -= cnt;
  257. usb_ep0_stage.pData += cnt;
  258. if (usb_ep0_stage.wResidue == 0)
  259. {
  260. USB_WriteReg(CSR0, IPRDY | DATEND);
  261. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  262. }
  263. else
  264. {
  265. USB_WriteReg(CSR0, IPRDY);
  266. }
  267. }
  268. break;
  269. case USB_CtrlState_DataOut:
  270. if (csr & OPRDY)
  271. {
  272. cnt = USB_ReadFIFO(FIFO0, usb_ep0_stage.pData);
  273. usb_ep0_stage.wResidue -= cnt;
  274. usb_ep0_stage.pData += cnt;
  275. if (usb_ep0_stage.wResidue == 0)
  276. {
  277. USB_WriteReg(CSR0, SOPRDY | DATEND);
  278. usb_ep0_stage.bStage = USB_CtrlState_Idle;
  279. }
  280. else
  281. {
  282. USB_WriteReg(CSR0, SOPRDY);
  283. }
  284. }
  285. break;
  286. }
  287. }
  288. if (intrin & EP1INIF)
  289. {
  290. USB_SelectEndPoint(1);
  291. csr = USB_ReadReg(INCSR1);
  292. if (csr & INSTSTL)
  293. {
  294. USB_WriteReg(INCSR1, INCLRDT);
  295. }
  296. if (csr & INUNDRUN)
  297. {
  298. USB_WriteReg(INCSR1, 0);
  299. }
  300. }
  301. if (introut & EP1OUTIF)
  302. {
  303. USB_SelectEndPoint(1);
  304. csr = USB_ReadReg(OUTCSR1);
  305. if (csr & OUTSTSTL)
  306. {
  307. USB_WriteReg(OUTCSR1, OUTCLRDT);
  308. }
  309. if (csr & OUTOPRDY)
  310. {
  311. USB_ReadFIFO(FIFO1, HidOutput);
  312. USB_WriteReg(OUTCSR1, 0);
  313. P6 = ~HidOutput[0]; // update LED status
  314. }
  315. }
  316. }
  317. uint8_t KeyCount(uint16_t dat)
  318. {
  319. uint8_t i;
  320. i = 0;
  321. while (dat)
  322. {
  323. if (dat & 0x8000) i++;
  324. dat <<= 1;
  325. }
  326. return i;
  327. }
  328. //HidInput first byte for special keys,second byte is reserved,the reset 6 bytes for normal keys
  329. void SendKeyStatus(void)
  330. {
  331. uint8_t i,n;
  332. if(KeyCode) // if key pressed
  333. {
  334. // allow 3 keys pressed simultaneously
  335. if(KeyCount(KeyCode) > 3)
  336. {
  337. return; // too many keys
  338. }
  339. else
  340. {
  341. n = 2;
  342. for (i = 0; i < 16; i++)
  343. {
  344. if (i == 1)
  345. {
  346. if (KeyCode & (1 << i)) // left Ctrl
  347. {
  348. HidInput[0] |= 1;
  349. }
  350. else
  351. {
  352. HidInput[0] &= ~1;
  353. }
  354. }
  355. else if (i == 2)
  356. {
  357. if (KeyCode & (1 << i)) // left alt
  358. {
  359. HidInput[0] |= 1 << 2;
  360. }
  361. else
  362. {
  363. HidInput[0] &= ~(1 << 2);
  364. }
  365. }
  366. else
  367. {
  368. if (KeyCode & (1 << i))
  369. {
  370. HidInput[n++] = KeyMap[i];
  371. }
  372. }
  373. }
  374. for(; n<8; n++)
  375. {
  376. HidInput[n]=0; // fill 0 to the rest
  377. }
  378. }
  379. }
  380. else // if no key pressed, return 0
  381. {
  382. for (i = 0; i < 8; i++)
  383. {
  384. HidInput[i] = 0;
  385. }
  386. }
  387. // return 8 bytes data
  388. USB_SelectEndPoint(1);
  389. for (i = 0; i < 8; i++)
  390. {
  391. USB_WriteReg(FIFO1, HidInput[i]);
  392. }
  393. USB_WriteReg(INCSR1, INIPRDY);
  394. }
  395. INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
  396. {
  397. B_1ms = 1;
  398. }
  399. /*****************************************************
  400. Key Matrix Scan
  401. Y P04 P05 P06 P07
  402. | | | |
  403. X | | | |
  404. P00 ---- K00 ---- K01 ---- K02 ---- K03 ----
  405. | | | |
  406. P01 ---- K04 ---- K05 ---- K06 ---- K07 ----
  407. | | | |
  408. P02 ---- K08 ---- K09 ---- K10 ---- K11 ----
  409. | | | |
  410. P03 ---- K12 ---- K13 ---- K14 ---- K15 ----
  411. | | | |
  412. ******************************************************/
  413. void KeyScan(void)
  414. {
  415. uint8_t temp;
  416. KeyIO = 0x0F;
  417. SYS_DelayUs(1);
  418. if ((KeyIO & 0x0F) == 0x0F) // no key pressed
  419. {
  420. NewKeyCode = 0;
  421. }
  422. else // start scan
  423. {
  424. // scan first line
  425. KeyIO = (uint8_t)~0x10;
  426. SYS_DelayUs(1);
  427. // save 4 keys status
  428. temp = KeyIO & 0x0F;
  429. // second line
  430. KeyIO = (uint8_t)~0x20;
  431. SYS_DelayUs(1);
  432. temp |= KeyIO << 4;
  433. // save current key status
  434. NewKeyCode = (~temp) & 0xFF;
  435. // third line
  436. KeyIO = (uint8_t)~0x40;
  437. SYS_DelayUs(1);
  438. temp = KeyIO & 0x0F;
  439. // 4th line
  440. KeyIO = (uint8_t)~0x80;
  441. SYS_DelayUs(1);
  442. temp |= KeyIO << 4;
  443. // save all 16 keys' status in 2 bytes, 1 indicates key pressed
  444. NewKeyCode |= (((uint16_t)~temp) << 8);
  445. }
  446. if (NewKeyCode != OldKeyCode)
  447. {
  448. KeyHoldTime = 0;
  449. OldKeyCode = NewKeyCode;
  450. KeyChangeTemp = 1;
  451. }
  452. else
  453. {
  454. KeyHoldTime++;
  455. if (KeyHoldTime >= 1)
  456. {
  457. KeyHoldTime = 1;
  458. KeyCode = OldKeyCode;
  459. if (KeyChangeTemp)
  460. {
  461. KeyChangeTemp = 0;
  462. KeyChangeFlag = 1; // Set send flag
  463. }
  464. }
  465. }
  466. }
  467. __CODE uint8_t DEVICEDESC[18] =
  468. {
  469. 0x12, //bLength(18);
  470. 0x01, //bDescriptorType(Device);
  471. 0x00,0x02, //bcdUSB(2.00);
  472. 0x00, //bDeviceClass(0);
  473. 0x00, //bDeviceSubClass0);
  474. 0x00, //bDeviceProtocol(0);
  475. 0x40, //bMaxPacketSize0(64);
  476. 0x54,0x53, //idVendor(5354);
  477. 0x80,0x44, //idProduct(4480);
  478. 0x00,0x01, //bcdDevice(1.00);
  479. 0x01, //iManufacturer(1);
  480. 0x02, //iProduct(2);
  481. 0x03, //iSerialNumber(3);
  482. 0x01, //bNumConfigurations(1);
  483. };
  484. __CODE uint8_t CONFIGDESC[41] =
  485. {
  486. 0x09, //bLength(9);
  487. 0x02, //bDescriptorType(Configuration);
  488. 0x29,0x00, //wTotalLength(41);
  489. 0x01, //bNumInterfaces(1);
  490. 0x01, //bConfigurationValue(1);
  491. 0x00, //iConfiguration(0);
  492. 0xa0, //bmAttributes(BUSPower);
  493. 0xc8, //MaxPower(400mA);
  494. 0x09, //bLength(9);
  495. 0x04, //bDescriptorType(Interface);
  496. 0x00, //bInterfaceNumber(0);
  497. 0x00, //bAlternateSetting(0);
  498. 0x02, //bNumEndpoints(2);
  499. 0x03, //bInterfaceClass(HID);
  500. 0x01, //bInterfaceSubClass(1);
  501. 0x01, //bInterfaceProtocol(1);
  502. 0x00, //iInterface(0);
  503. 0x09, //bLength(9);
  504. 0x21, //bDescriptorType(HID);
  505. 0x01,0x10, //bcdHID(1.01);
  506. 0x00, //bCountryCode(0);
  507. 0x01, //bNumDescriptors(1);
  508. 0x22, //bDescriptorType(HID Report);
  509. 0x3f,0x00, //wDescriptorLength(63);
  510. 0x07, //bLength(7);
  511. 0x05, //bDescriptorType(Endpoint);
  512. 0x81, //bEndpointAddress(EndPoint1 as IN);
  513. 0x03, //bmAttributes(Interrupt);
  514. 0x40,0x00, //wMaxPacketSize(64);
  515. 0x0a, //bInterval(10ms);
  516. 0x07, //bLength(7);
  517. 0x05, //bDescriptorType(Endpoint);
  518. 0x01, //bEndpointAddress(EndPoint1 as OUT);
  519. 0x03, //bmAttributes(Interrupt);
  520. 0x40,0x00, //wMaxPacketSize(64);
  521. 0x0a, //bInterval(10ms);
  522. };
  523. __CODE uint8_t HIDREPORTDESC[63] =
  524. {
  525. 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
  526. 0x09, 0x06, // USAGE (Keyboard)
  527. 0xa1, 0x01, // COLLECTION (Application)
  528. 0x05, 0x07, // USAGE_PAGE (Keyboard)
  529. 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl)
  530. 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI)
  531. 0x15, 0x00, // LOGICAL_MINIMUM (0)
  532. 0x25, 0x01, // LOGICAL_MAXIMUM (1)
  533. 0x75, 0x01, // REPORT_SIZE (1)
  534. 0x95, 0x08, // REPORT_COUNT (8)
  535. 0x81, 0x02, // INPUT (Data,Var,Abs)
  536. 0x95, 0x01, // REPORT_COUNT (1)
  537. 0x75, 0x08, // REPORT_SIZE (8)
  538. 0x81, 0x03, // INPUT (Cnst,Var,Abs)
  539. 0x95, 0x05, // REPORT_COUNT (5)
  540. 0x75, 0x01, // REPORT_SIZE (1)
  541. 0x05, 0x08, // USAGE_PAGE (LEDs)
  542. 0x19, 0x01, // USAGE_MINIMUM (Num Lock)
  543. 0x29, 0x05, // USAGE_MAXIMUM (Kana)
  544. 0x91, 0x02, // OUTPUT (Data,Var,Abs)
  545. 0x95, 0x01, // REPORT_COUNT (1)
  546. 0x75, 0x03, // REPORT_SIZE (3)
  547. 0x91, 0x03, // OUTPUT (Cnst,Var,Abs)
  548. 0x95, 0x06, // REPORT_COUNT (6)
  549. 0x75, 0x08, // REPORT_SIZE (8)
  550. 0x15, 0x00, // LOGICAL_MINIMUM (0)
  551. 0x25, 0xFF, // LOGICAL_MAXIMUM (255)
  552. 0x05, 0x07, // USAGE_PAGE (Keyboard)
  553. 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated))
  554. 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application)
  555. 0x81, 0x00, // INPUT (Data,Ary,Abs)
  556. 0xc0 // END_COLLECTION
  557. };
  558. __CODE uint8_t LANGIDDESC[4] =
  559. {
  560. 0x04,0x03,
  561. 0x09,0x04,
  562. };
  563. __CODE uint8_t MANUFACTDESC[8] =
  564. {
  565. 0x08,0x03,
  566. 'S',0,
  567. 'T',0,
  568. 'C',0,
  569. };
  570. __CODE uint8_t PRODUCTDESC[30] =
  571. {
  572. 0x1e,0x03,
  573. 'S',0,
  574. 'T',0,
  575. 'C',0,
  576. ' ',0,
  577. 'U',0,
  578. 'S',0,
  579. 'B',0,
  580. ' ',0,
  581. 'D',0,
  582. 'e',0,
  583. 'v',0,
  584. 'i',0,
  585. 'c',0,
  586. 'e',0,
  587. };
  588. __CODE uint8_t KeyMap[16] = {
  589. 0x53, //0: Num Lock
  590. 0xFF, //1: NULL - Left Ctrl
  591. 0xFF, //2: NULL - Left ALT
  592. 0x2A, //3: BackSpace
  593. 0x5F, //4: 7
  594. 0x60, //5: 8
  595. 0x61, //6: 9
  596. 0x62, //7: 0
  597. 0x5C, //8: 4
  598. 0x5D, //9: 5
  599. 0x5E, //A: 6
  600. 0x63, //B: DEL
  601. 0x59, //C: 1
  602. 0x5A, //D: 2
  603. 0x5B, //E: 3
  604. 0x58, //F: Return
  605. };