4802 views|0 replies

1w

Posts

16

Resources
The OP
 

[New CH554 Review] III. Formation Procedure [Copy link]

This post was last edited by ddllxxrr on 2018-4-6 17:16 According to the evaluation plan, this evaluation should be formed into a program. My idea is to merge the USB HID composite device program with the TOUCHKEY program. Of course, it is better to use the composite device as a template, and just copy TOUCHKEY.c and .h. Then add it to the project: Add the touch button declaration in the main function
  1. TK_Init( BIT4+BIT5+BIT6+BIT7, 1, 1 ); /* Choose TIN2, TIN3, TIN4, TIN5 for touchkey input. enable interrupt. */ TK_SelectChannel(0); /* NOTICE: ch is not compatible with the IO actually. */
复制代码
Then add the touch button judgment in the HID processing function:
  1. void HIDValueHandle() { UINT8 i; // if(MISO == 0) // { // //printf( "%c", 1 ); // //HIDMouse[2] = 1; // //Enp2IntIn(); // i = 1; // } // else if(SCK == 0) // { // //HIDMouse[2] = -1; // //Enp2IntIn(); // i = 2; // // } // else // i = 'A'; if( Touch_IN != 0 ) { printf("come here 1...\n"); if( Touch_IN & CH2 ) { i = 'a'; } if( Touch_IN & CH3 ) { i = 'w'; } if( Touch_IN & CH4 ) { i = 'd'; } if( Touch_IN & CH5 ) { i = 's'; } Touch_IN = 0; } else i=0; switch(i) { //êó±êêyYé′êày case 1: //×óü HIDMouse[2] = -1; Enp2IntIn(); i=0; //HIDMouse[0] = 0; break; case 2: //óòü HIDMouse[2] = 1; Enp2IntIn(); i=0; //HIDMouse[0] = 0; break; //üìêyYé′êày case 'a'://Aü FLAG = 0; HIDKey[2] = 0x04; //°′ü aê Enp1IntIn(); HIDKey[2] = 0; //°′üáê while(FLAG == 0) { ; /*μè′yéò°ü′êíê3é*/ } Enp1IntIn(); i=0; break; case 'w': //Pü FLAG = 0; HIDKey[2] = 0x1a; Enp1IntIn(); HIDKey[2] = 0; //°′üáê while(FLAG == 0) { ; /*μè′yéò°ü′êíê3é*/ } Enp1IntIn(); i=0; break; case 's': //Pü FLAG = 0; HIDKey[2] = 0x16; Enp1IntIn(); HIDKey[2] = 0; //°′üáê while(FLAG == 0) { ; /*μè′yéò°ü′êíê3é*/ } Enp1IntIn(); i=0; break; case 'd': //Num Lockü FLAG = 0; HIDKey[2] = 0x07; Enp1IntIn(); HIDKey[2] = 0; //°′üáê while(FLAG == 0) {; èó|′eNAK UEP2_CTRL = UEP2_CTRL & ~ MASK_UEP_T_RES | UEP_T_RES_NAK; //èó|′eNAK break; } }
复制代码
Therefore, we add a judgment above, because the main function normally loops in the above function:
  1. main() { CfgFsys( ); //CH559ê±ó  mDelaymS(25); //DT÷μμè′yú2 §è¨,±ó mInitSTDIO( ); //′ ú03êˉ #ifdef DE_PRINTF printf("start ...\n"); #endif printf("start ddllxxrr ...\n"); USBDeviceInit(); //USBéè±£ê3êˉ TK_Init( BIT4 +BIT5+BIT6+BIT7, 1, 1 ); /* Choose TIN2, TIN3, TIN4, TIN5 for touchkey input. enable interrupt.*/ TK_SelectChannel(0); /* NOTICE: ch is not compatible with the IO actually. */ printf("come here ...\n"); EA = 1; //êDíμ¥úD UEP1_T_LEN = 0; //¤ê1ó·¢í3¤èò¨òa  UEP2_T_LEN = 0; //¤ê1ó·¢í3¤èò¨òa  FLAG = 0; Ready = 0; //Port1Cfg(1,6); //Port1Cfg(1,7); while(1) { if(Ready) { while(1) { HIDValueHandle(); } } if( Ready&&(Ep2InKey == 0)){ #ifdef DE_PRINTF //áè DIDo printf("ID0 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFA),(UINT16)*(PUINT8C)(0x3FFB)); printf("ID1 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFC),(UINT16)*(PUINT8C)(0x3FFD)); printf("ID2 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFE) ,(UINT16)*(PUINT8C)(0x3FFF)); #endif CH554USBDevWakeup(); // mDelaymS( 10 ); Enp1IntIn(); } mDelaymS( 100 ); //£aμ¥ú×üê } }
复制代码
The key value above is found on Baidu: Then, plug the development board into the computer via USB. , two keyboards appeared, I opened Notepad and took a look: The only thing I am not satisfied with is that I can't stop. If I want to stop, I have to press another key first [ This content is originally created by EEWORLD forum user ddllxxrr. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source[/b ](UINT16)*(PUINT8C)(0x3FFB)); printf("ID1 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFC),(UINT16)*(PUINT8C)(0x3FFD)); printf("ID2 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFE),(UINT16)*(PUINT8C)(0x3FFF)); #endif CH554USBDevWakeup(); // mDelaymS( 10 ); Enp1IntIn(); } mDelaymS( 100 ); //£aμ¥ú×üê } } [/code] The above key values are found on Baidu: Then, I plugged the development board into the computer via USB. Two keyboards appeared. I opened Notepad and took a look: The only thing I am not satisfied with is that I cannot stop the program. If I want to stop the program, I have to press another key first. This content was originally created by ddllxxrr, a user of EEWORLD forum. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source. (UINT16)*(PUINT8C)(0x3FFB)); printf("ID1 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFC),(UINT16)*(PUINT8C)(0x3FFD)); printf("ID2 = %02x %02x \n",(UINT16)*(PUINT8C)(0x3FFE),(UINT16)*(PUINT8C)(0x3FFF)); #endif CH554USBDevWakeup(); // mDelaymS( 10 ); Enp1IntIn(); } mDelaymS( 100 ); //£aμ¥ú×üê } } [/code] The above key values are found on Baidu: Then, I plugged the development board into the computer via USB. Two keyboards appeared. I opened Notepad and took a look: The only thing I am not satisfied with is that I cannot stop the program. If I want to stop the program, I have to press another key first. This content was originally created by ddllxxrr, a user of EEWORLD forum. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source.




This post is from MCU
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list