📄 main.lst
字号:
844 1
845 1
846 1
847 1
848 1 if (RXD0F) // If data received on EP0 OUT ...
849 1 {
850 2 // do not change this SETUP packet processing part up to else !!!
851 2 if (USTA & uSETUP) // If it's a SETUP packet ...
852 2 {
853 3
854 3 if (UCON0 & uSTALL0) // try to fix bug in uPSD
855 3 {
856 4 #pragma asm
*** ERROR C272 IN LINE 856 OF MAIN.C: 'asm/endasm' requires src-control to be active
857 4 anl UCON0,#255-uSTALL0 ;clear STALL0 bit when it hangs
858 4 #pragma endasm
*** ERROR C272 IN LINE 858 OF MAIN.C: 'asm/endasm' requires src-control to be active
C51 COMPILER V8.05a MAIN 04/15/2008 21:52:17 PAGE 15
859 4 }
860 3
861 3 if (ReadSetupPacket()) // Read the SETUP packet
862 3 {
863 4 //tady to nepomaha
864 4 if (!HandleReport()) // Test and handle HID type packets
865 4 {
866 5 // If this is not a HID report ... pass it on to the basic SETUP packet handler
867 5 OnSetupPacket();
868 5 }
869 4 else
870 4 {
871 5 }
872 4 }
873 3 else
874 3 {
875 4 //No Setup packet with DATA length = 8, STALLed automatically in ReadSetupPacket()
876 4 }
877 3
878 3 RXD0F = 0; // Clear interrupt flag so next packet can come in now
879 3 }
880 2
881 2 else
882 2 /*======== No SETUP packet, normal data packets ========*/
883 2 {
884 3 // If in the middle of receiving a report ...
885 3 if ((USTA & 0x0F) && (rcvIndex < OUTPUT_REPORT_SIZE))
886 3 {
887 4 cb = (USTA & 0x0F); // Read the next segment
888 4 if (cb > EP0_SIZE)
889 4 {
890 5 cb = EP0_SIZE; // fix bug
891 5 }
892 4 for (i = 0; i < cb; i++)
893 4 {
894 5 rcvReport.u.buffer[rcvIndex + i] = UDR0; //read received data
895 5 }
896 4 #pragma asm
*** ERROR C272 IN LINE 896 OF MAIN.C: 'asm/endasm' requires src-control to be active
897 4 xrl USTA,#uRSEQ; // Toggle data toggle bit
898 4 #pragma endasm
*** ERROR C272 IN LINE 898 OF MAIN.C: 'asm/endasm' requires src-control to be active
899 4 // Handle report as it comes in and/or when all done
900 4 OnReportSegmentReceived(cb);
901 4
902 4 if ((rcvIndex += cb) >= OUTPUT_REPORT_SIZE)
903 4 {
904 5 OnReportReceived();
905 5
906 5 #pragma asm //send a zero length packet
*** ERROR C272 IN LINE 906 OF MAIN.C: 'asm/endasm' requires src-control to be active
907 5
908 5 anl UCON0,#uTSEQ0+uRX0E
909 5 orl UCON0,#uTX0E ;enable trasmit
910 5 #pragma endasm
*** ERROR C272 IN LINE 910 OF MAIN.C: 'asm/endasm' requires src-control to be active
911 5
912 5 }
913 4 RXD0F = 0; // Clear interrupt flag so next packet can come in now
914 4 }
915 3 else
916 3 {
C51 COMPILER V8.05a MAIN 04/15/2008 21:52:17 PAGE 16
917 4 // Got 0 length ACK data packet; expecting a SETUP packet now.
918 4 USTA ^= uRSEQ; // Toggle data toggle bit
919 4 RXD0F = 0; // Clear interrupt flag so next packet can come in now
920 4 }
921 3 }
922 2 }
923 1
924 1
925 1
926 1
927 1
928 1 if (TXD0F)
929 1 {
930 2
931 2 TXD0F = 0; // Clear the interrupt flag
932 2 // Do not change this part up to call of BaseEp0Handler
933 2 // If in the middle of transmitting a report ...
934 2 if (txIndex < FEATURE_REPORT_SIZE)
935 2 {
936 3 // Transmit the next segment of outgoing report
937 3 cb = min(FEATURE_REPORT_SIZE - txIndex, EP0_SIZE);
938 3 TransmitDataEP0(txReport.u.buffer + txIndex, cb);
939 3 if ((txIndex += cb) >= FEATURE_REPORT_SIZE)
940 3 {
941 4 OnReportTransmitted();
942 4 }
943 3 else
944 3 {
945 4 // Prepare the next segment while that last one is going out
946 4 PrepareTransmitSegment(txIndex);
947 4 }
948 3 }
949 2 else
950 2 {
951 3 // This part can changed (or BaseEp0Handler directly)
952 3 BaseEp0TxHandler(); // Handle standard control requests
953 3 }
954 2 }
955 1
956 1
957 1
958 1 if (SUSPND) // Handle suspend interrupt
959 1 {
960 2 SUSPND = 0; // keep USB logic functional
961 2 GoOnSuspend = 1; // set global flag
962 2 UIEN &= ~uSUSPNDIE; // disable INT
963 2 DDCCON = 0x2; // generate DDC interrupt
964 2 DDCCONintc++; // aux. DDC cnt
965 2 }
966 1
967 1
968 1
969 1 if (TXD1F) // If data successfully transmitted on EP1 ...
970 1 {
971 2 UIEN &= ~uTXD1IE; // disable EP1,2 INT, serviced in OnIdle()
972 2 DDCCON = 0x2; // generate DDC interrupt
973 2 DDCCONintc++; // aux. DDC cnt
974 2 }
975 1
976 1
977 1 if (RSTF) // Handle USB bus reset, it must be at the end of USB ISR
978 1 {
C51 COMPILER V8.05a MAIN 04/15/2008 21:52:17 PAGE 17
979 2 USB_ISR_FLAGS = 0;
980 2 OnUSBReset(); //resets all the flags automatically
981 2 DDCCON = 0x2; // generate DDC interrupt
982 2 DDCCONintc++; // aux. DDC cnt
983 2 }
984 1 g_debugUSB_INT_CNT++; // increment USB ISR counter
985 1
986 1
987 1
988 1 }
989
990
991
992
993
994
995
996
997
998 static data char bufIndex = 0; // Current position in LCD buffer
999 static data char txBuf[8]; // Buffer to send back to PC
1000
1001
1002
1003 static void OnTransmitEP1()
1004 /******************************************************************************
1005 Function : static void OnTransmitEP1()
1006 Parameters : none
1007 Description: Transmits data to Endpoint1
1008 ******************************************************************************/
1009 {
1010 1 data unsigned char i,nBytes; // Num bytes of LCD data
1011 1
1012 1 // Store current index into LCD buffer in first byte of tx buffer
1013 1 if (bufIndex >= LCD_BUFFER_SIZE - 1) //one zero only, save packet size
1014 1 {
1015 2 bufIndex = 0; // Wrap around to start of LCD buffer for next transmission
1016 2 }
1017 1
1018 1 nBytes = LCD_BUFFER_SIZE - bufIndex - 1;
1019 1 if (nBytes>7)
1020 1 {
1021 2 nBytes = 7; //max. 1 info byte + 7 characters
1022 2 }
1023 1
1024 1 txBuf[0] = bufIndex; //save position at the first byte
1025 1
1026 1 i = 1;
1027 1 while (i<=nBytes)
1028 1 {
1029 2 txBuf[i++] = LCD_buffer[bufIndex++]; //fill buffer
1030 2 }
1031 1
1032 1 TransmitDataEPx(1, txBuf, nBytes+1); // Transmit input report to host
1033 1 }
1034
1035
1036
1037
1038
1039
1040
C51 COMPILER V8.05a MAIN 04/15/2008 21:52:17 PAGE 18
1041
1042
1043
1044 static void DDC_isr (void) interrupt 7 using 2
1045 /******************************************************************************
1046 Function : static void UsbIsr()
1047 Parameters : none
1048 Description: This is the rest of USB ISR. You can use other INT (except USB)
1049 if needed. Only USB must have the highest priority ...
1050 Remark: This part can be deleted if you do not use suspend mode or EP1/2.
1051 All the time-consuming operations (>200us) must be here to avoid
1052 possible problems with very long USB ISR.
1053 *******************************************************************************/
1054 {
1055 1 data uchar ddcint;
1056 1
1057 1 EA = 0; // disable int
1058 1 DDCCON = 0; // Clear DDCCON
1059 1 ddcint = S1STA; // Dummy Read DDC I2C S1STA to clear Interupt
1060 1 S1CON = 0; // Clear DDC I2C S1CON
1061 1 EA = 1; // enable int
1062 1
1063 1 while (DDCCONintc>0) // multiple DDC calls
1064 1 {
1065 2 DDCCONintc--; // aux. DDC cnt
1066 2
1067 2
1068 2
1069 2 if (TXD1F) //Service USB INT EP1
1070 2 {
1071 3 TXD1F = 0;
1072 3 OnTransmitEP1(); //service EP1
1073 3 }
1074 2
1075 2 /*====== All the time-consuming operations (>100us) must be here.
1076 2 Place your longer code (>450us) instead of CMD_ERASE. ======*/
1077 2 switch (currentCmd.u.cmd)
1078 2 {
1079 3 case CMD_ERASE:
1080 3
1081 3 if (currentCmd.u.erase.flash == PRIMARY_FLASH)
1082 3 {
1083 4 status.u.status.ret = flash_erase_sector(
1084 4 (volatile uchar xdata*) currentCmd.u.erase.address);
1085 4 }
1086 3 else
1087 3 {
1088 4 status.u.status.ret = flash_boot_erase_sector(
1089 4 (volatile uchar xdata*) currentCmd.u.erase.address);
1090 4 }
1091 3 currentCmd.u.cmd = 0; // Done
1092 3 break;
1093 3 default:
1094 3 break;
1095 3 }
1096 2
1097 2
1098 2 // The following 3 lines can be deleted if you don't plan to use Suspend
1099 2 if (GoOnSuspend) //Service USB INT Suspend
1100 2 {
1101 3 OnUSBSuspend();
1102 3 }
C51 COMPILER V8.05a MAIN 04/15/2008 21:52:17 PAGE 19
1103 2
1104 2 g_debugTimer2_INT_CNT++; // increment USB T2 counter
1105 2
1106 2 }
1107 1 }
1108
1109
1110 /* *************************************************************************
1111 *** ***
1112 ** *** End of File *** **
1113 *** ***
1114 *************************************************************************
1115 */
C51 COMPILATION COMPLETE. 0 WARNING(S), 6 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -