#line 1 "usbAll.c" #line 1 "usbAll.c" #line 1 "./usbAll.h" #line 38 "./usbAll.h" #line 42 "./usbAll.h" #line 45 "./usbAll.h" #line 46 "./usbAll.h" #line 52 "./usbAll.h" #line 53 "./usbAll.h" #line 57 "./usbAll.h" #line 62 "./usbAll.h" #line 63 "./usbAll.h" #line 64 "./usbAll.h" #line 66 "./usbAll.h" #line 74 "./usbAll.h" #line 77 "./usbAll.h" #line 81 "./usbAll.h" #line 86 "./usbAll.h" #line 88 "./usbAll.h" #line 89 "./usbAll.h" #line 93 "./usbAll.h" #line 97 "./usbAll.h" #line 98 "./usbAll.h" #line 99 "./usbAll.h" #line 100 "./usbAll.h" #line 101 "./usbAll.h" #line 103 "./usbAll.h" #line 105 "./usbAll.h" #line 141 "./usbAll.h" #line 145 "./usbAll.h" #line 148 "./usbAll.h" #line 156 "./usbAll.h" #line 157 "./usbAll.h" #line 158 "./usbAll.h" #line 159 "./usbAll.h" #line 160 "./usbAll.h" #line 168 "./usbAll.h" #line 170 "./usbAll.h" #line 171 "./usbAll.h" #line 172 "./usbAll.h" #line 173 "./usbAll.h" #line 174 "./usbAll.h" #line 175 "./usbAll.h" #line 176 "./usbAll.h" #line 177 "./usbAll.h" #line 178 "./usbAll.h" #line 179 "./usbAll.h" #line 180 "./usbAll.h" #line 181 "./usbAll.h" #line 182 "./usbAll.h" #line 183 "./usbAll.h" #line 184 "./usbAll.h" #line 185 "./usbAll.h" #line 186 "./usbAll.h" #line 187 "./usbAll.h" #line 188 "./usbAll.h" #line 189 "./usbAll.h" #line 190 "./usbAll.h" #line 191 "./usbAll.h" #line 192 "./usbAll.h" #line 193 "./usbAll.h" #line 194 "./usbAll.h" #line 195 "./usbAll.h" #line 196 "./usbAll.h" #line 197 "./usbAll.h" #line 198 "./usbAll.h" #line 199 "./usbAll.h" #line 202 "./usbAll.h" #line 203 "./usbAll.h" #line 204 "./usbAll.h" #line 207 "./usbAll.h" #line 208 "./usbAll.h" #line 209 "./usbAll.h" #line 210 "./usbAll.h" #line 213 "./usbAll.h" #line 214 "./usbAll.h" #line 215 "./usbAll.h" #line 216 "./usbAll.h" #line 219 "./usbAll.h" #line 220 "./usbAll.h" #line 221 "./usbAll.h" #line 227 "./usbAll.h" typedef struct _USB_DEV_DSC { byte bLength; byte bDscType; word bcdUSB; byte bDevCls; byte bDevSubCls; byte bDevProtocol; byte bMaxPktSize0; word idVendor; word idProduct; word bcdDevice; byte iMFR; byte iProduct; byte iSerialNum; byte bNumCfg; } USB_DEV_DSC; #line 239 "./usbAll.h" typedef struct _USB_CFG_DSC { byte bLength; byte bDscType; word wTotalLength; byte bNumIntf; byte bCfgValue; byte iCfg; byte bmAttributes; byte bMaxPower; } USB_CFG_DSC; #line 249 "./usbAll.h" typedef struct _USB_INTF_DSC { byte bLength; byte bDscType; byte bIntfNum; byte bAltSetting; byte bNumEPs; byte bIntfCls; byte bIntfSubCls; byte bIntfProtocol; byte iIntf; } USB_INTF_DSC; #line 259 "./usbAll.h" typedef struct _USB_EP_DSC { byte bLength; byte bDscType; byte bEPAdr; byte bmAttributes; word wMaxPktSize; byte bInterval; } USB_EP_DSC; #line 267 "./usbAll.h" #line 299 "./usbAll.h" #line 304 "./usbAll.h" #line 308 "./usbAll.h" #line 322 "./usbAll.h" #line 323 "./usbAll.h" extern rom USB_DEV_DSC device_dsc; extern rom struct { USB_CFG_DSC cd01; USB_INTF_DSC i00a00; USB_EP_DSC ep01o_i00a00; USB_EP_DSC ep01i_i00a00; } cfg01 ; extern rom const unsigned char *rom USB_CD_Ptr[]; extern rom const unsigned char *rom USB_SD_Ptr[]; #line 331 "./usbAll.h" #line 366 "./usbAll.h" #line 370 "./usbAll.h" #line 373 "./usbAll.h" #line 389 "./usbAll.h" typedef union _CTRL_TRF_SETUP { struct { byte _byte[8 ]; }; struct { byte bmRequestType; byte bRequest; word wValue; word wIndex; word wLength; }; struct { unsigned :8; unsigned :8; WORD W_Value; WORD W_Index; WORD W_Length; }; struct { unsigned Recipient:5; unsigned RequestType:2; unsigned DataDir:1; unsigned :8; byte bFeature; unsigned :8; unsigned :8; unsigned :8; unsigned :8; unsigned :8; }; struct { unsigned :8; unsigned :8; byte bDscIndex; byte bDscType; word wLangID; unsigned :8; unsigned :8; }; struct { unsigned :8; unsigned :8; BYTE bDevADR; byte bDevADRH; unsigned :8; unsigned :8; unsigned :8; unsigned :8; }; struct { unsigned :8; unsigned :8; byte bCfgValue; byte bCfgRSD; unsigned :8; unsigned :8; unsigned :8; unsigned :8; }; struct { unsigned :8; unsigned :8; byte bAltID; byte bAltID_H; byte bIntfID; byte bIntfID_H; unsigned :8; unsigned :8; }; struct { unsigned :8; unsigned :8; unsigned :8; unsigned :8; byte bEPID; byte bEPID_H; unsigned :8; unsigned :8; }; struct { unsigned :8; unsigned :8; unsigned :8; unsigned :8; unsigned EPNum:4; unsigned :3; unsigned EPDir:1; unsigned :8; unsigned :8; unsigned :8; }; } CTRL_TRF_SETUP; #line 509 "./usbAll.h" typedef union _CTRL_TRF_DATA { struct { byte _byte[8 ]; }; struct { byte _byte0; byte _byte1; byte _byte2; byte _byte3; byte _byte4; byte _byte5; byte _byte6; byte _byte7; }; struct { word _word0; word _word1; word _word2; word _word3; }; } CTRL_TRF_DATA; #line 541 "./usbAll.h" #line 576 "./usbAll.h" #line 580 "./usbAll.h" #line 588 "./usbAll.h" #line 589 "./usbAll.h" #line 590 "./usbAll.h" #line 591 "./usbAll.h" #line 592 "./usbAll.h" #line 593 "./usbAll.h" #line 594 "./usbAll.h" #line 595 "./usbAll.h" #line 596 "./usbAll.h" #line 599 "./usbAll.h" #line 600 "./usbAll.h" #line 601 "./usbAll.h" #line 602 "./usbAll.h" #line 603 "./usbAll.h" #line 604 "./usbAll.h" #line 605 "./usbAll.h" typedef enum { _ROM = 0, _RAM = 1, _PROC = 2 } ECtrlTrfMem; typedef union _USB_DEVICE_STATUS { byte _byte; struct { unsigned RemoteWakeup:1; ECtrlTrfMem ctrl_trf_mem:2; }; } USB_DEVICE_STATUS; typedef union _BD_STAT { byte _byte; struct{ unsigned BC8:1; unsigned BC9:1; unsigned BSTALL:1; unsigned DTSEN:1; unsigned INCDIS:1; unsigned KEN:1; unsigned DTS:1; unsigned UOWN:1; }; struct{ unsigned BC8:1; unsigned BC9:1; unsigned PID0:1; unsigned PID1:1; unsigned PID2:1; unsigned PID3:1; unsigned :1; unsigned UOWN:1; }; struct{ unsigned :2; unsigned PID:4; unsigned :2; }; } BD_STAT; typedef union _BDT { struct { BD_STAT Stat; byte Cnt; byte ADRL; byte ADRH; }; struct { unsigned :8; unsigned :8; byte* ADR; }; } BDT; extern byte usb_device_state; extern USB_DEVICE_STATUS usb_stat; extern byte usb_active_cfg; extern byte usb_alt_intf[1 ]; extern volatile far BDT ep0Bo; extern volatile far BDT ep0Bi; extern volatile far BDT ep1Bo; extern volatile far BDT ep1Bi; extern volatile far BDT ep2Bo; extern volatile far BDT ep2Bi; extern volatile far BDT ep3Bo; extern volatile far BDT ep3Bi; extern volatile far BDT ep4Bo; extern volatile far BDT ep4Bi; extern volatile far BDT ep5Bo; extern volatile far BDT ep5Bi; extern volatile far BDT ep6Bo; extern volatile far BDT ep6Bi; extern volatile far BDT ep7Bo; extern volatile far BDT ep7Bi; extern volatile far BDT ep8Bo; extern volatile far BDT ep8Bi; extern volatile far BDT ep9Bo; extern volatile far BDT ep9Bi; extern volatile far BDT ep10Bo; extern volatile far BDT ep10Bi; extern volatile far BDT ep11Bo; extern volatile far BDT ep11Bi; extern volatile far BDT ep12Bo; extern volatile far BDT ep12Bi; extern volatile far BDT ep13Bo; extern volatile far BDT ep13Bi; extern volatile far BDT ep14Bo; extern volatile far BDT ep14Bi; extern volatile far BDT ep15Bo; extern volatile far BDT ep15Bi; extern volatile far CTRL_TRF_SETUP SetupPkt; extern volatile far CTRL_TRF_DATA CtrlTrfData; extern volatile far byte usbgen_out[64 ]; extern volatile far byte usbgen_in[64 ]; #line 721 "./usbAll.h" #line 756 "./usbAll.h" #line 760 "./usbAll.h" #line 769 "./usbAll.h" #line 770 "./usbAll.h" #line 771 "./usbAll.h" #line 772 "./usbAll.h" #line 773 "./usbAll.h" #line 774 "./usbAll.h" #line 775 "./usbAll.h" #line 776 "./usbAll.h" #line 777 "./usbAll.h" #line 778 "./usbAll.h" #line 781 "./usbAll.h" #line 782 "./usbAll.h" #line 783 "./usbAll.h" #line 784 "./usbAll.h" #line 785 "./usbAll.h" #line 795 "./usbAll.h" #line 797 "./usbAll.h" #line 798 "./usbAll.h" #line 800 "./usbAll.h" #line 801 "./usbAll.h" #line 803 "./usbAll.h" #line 804 "./usbAll.h" #line 805 "./usbAll.h" #line 806 "./usbAll.h" #line 807 "./usbAll.h" #line 808 "./usbAll.h" #line 809 "./usbAll.h" #line 810 "./usbAll.h" #line 811 "./usbAll.h" #line 812 "./usbAll.h" #line 813 "./usbAll.h" #line 814 "./usbAll.h" #line 815 "./usbAll.h" #line 816 "./usbAll.h" #line 817 "./usbAll.h" #line 818 "./usbAll.h" #line 819 "./usbAll.h" #line 820 "./usbAll.h" #line 821 "./usbAll.h" #line 822 "./usbAll.h" #line 823 "./usbAll.h" #line 824 "./usbAll.h" #line 825 "./usbAll.h" #line 826 "./usbAll.h" #line 827 "./usbAll.h" #line 828 "./usbAll.h" #line 829 "./usbAll.h" #line 830 "./usbAll.h" #line 831 "./usbAll.h" #line 832 "./usbAll.h" #line 833 "./usbAll.h" #line 834 "./usbAll.h" #line 855 "./usbAll.h" #line 859 "./usbAll.h" #line 860 "./usbAll.h" #line 877 "./usbAll.h" #line 879 "./usbAll.h" #line 883 "./usbAll.h" #line 884 "./usbAll.h" #line 908 "./usbAll.h" #line 914 "./usbAll.h" #line 915 "./usbAll.h" void USBCheckBusStatus(void); void USBDriverService(void); void USBRemoteWakeup(void); void USBSoftDetach(void); void ClearArray(byte* startAdr,byte count); #line 928 "./usbAll.h" #line 963 "./usbAll.h" #line 966 "./usbAll.h" #line 974 "./usbAll.h" #line 975 "./usbAll.h" #line 976 "./usbAll.h" #line 990 "./usbAll.h" #line 993 "./usbAll.h" #line 994 "./usbAll.h" #line 995 "./usbAll.h" #line 998 "./usbAll.h" #line 999 "./usbAll.h" #line 1000 "./usbAll.h" #line 1003 "./usbAll.h" #line 1004 "./usbAll.h" #line 1006 "./usbAll.h" #line 1007 "./usbAll.h" #line 1008 "./usbAll.h" #line 1010 "./usbAll.h" #line 1011 "./usbAll.h" #line 1012 "./usbAll.h" #line 1013 "./usbAll.h" extern byte ctrl_trf_session_owner; extern POINTER pSrc; extern POINTER pDst; extern WORD wCount; byte USBCtrlEPService(void); void USBCtrlTrfTxService(void); void USBCtrlTrfRxService(void); void USBCtrlEPServiceComplete(void); void USBPrepareForNextSetupTrf(void); #line 1030 "./usbAll.h" #line 1064 "./usbAll.h" #line 1067 "./usbAll.h" #line 1076 "./usbAll.h" #line 1078 "./usbAll.h" #line 1079 "./usbAll.h" #line 1080 "./usbAll.h" #line 1081 "./usbAll.h" #line 1082 "./usbAll.h" #line 1083 "./usbAll.h" #line 1084 "./usbAll.h" #line 1085 "./usbAll.h" #line 1086 "./usbAll.h" #line 1087 "./usbAll.h" #line 1088 "./usbAll.h" #line 1091 "./usbAll.h" #line 1092 "./usbAll.h" #line 1108 "./usbAll.h" #line 1116 "./usbAll.h" #line 1117 "./usbAll.h" void USBCheckStdRequest(void); #line 1124 "./usbAll.h" #line 1159 "./usbAll.h" #line 1162 "./usbAll.h" #line 1184 "./usbAll.h" #line 1186 "./usbAll.h" #line 1203 "./usbAll.h" #line 1205 "./usbAll.h" #line 1222 "./usbAll.h" #line 1224 "./usbAll.h" extern byte usbgen_rx_len; void USBGenInitEP(void); void USBGenWrite(byte *buffer, byte len); byte USBGenRead(byte *buffer, byte len); #line 1236 "./usbAll.h" #line 5 "usbAll.c" #line 41 "usbAll.c" #line 1 "C:/MCC18/h/p18cxxx.h" #line 3 "C:/MCC18/h/p18cxxx.h" #line 5 "C:/MCC18/h/p18cxxx.h" #line 7 "C:/MCC18/h/p18cxxx.h" #line 9 "C:/MCC18/h/p18cxxx.h" #line 11 "C:/MCC18/h/p18cxxx.h" #line 13 "C:/MCC18/h/p18cxxx.h" #line 15 "C:/MCC18/h/p18cxxx.h" #line 17 "C:/MCC18/h/p18cxxx.h" #line 19 "C:/MCC18/h/p18cxxx.h" #line 21 "C:/MCC18/h/p18cxxx.h" #line 23 "C:/MCC18/h/p18cxxx.h" #line 25 "C:/MCC18/h/p18cxxx.h" #line 27 "C:/MCC18/h/p18cxxx.h" #line 29 "C:/MCC18/h/p18cxxx.h" #line 31 "C:/MCC18/h/p18cxxx.h" #line 33 "C:/MCC18/h/p18cxxx.h" #line 35 "C:/MCC18/h/p18cxxx.h" #line 37 "C:/MCC18/h/p18cxxx.h" #line 39 "C:/MCC18/h/p18cxxx.h" #line 41 "C:/MCC18/h/p18cxxx.h" #line 43 "C:/MCC18/h/p18cxxx.h" #line 45 "C:/MCC18/h/p18cxxx.h" #line 47 "C:/MCC18/h/p18cxxx.h" #line 49 "C:/MCC18/h/p18cxxx.h" #line 51 "C:/MCC18/h/p18cxxx.h" #line 53 "C:/MCC18/h/p18cxxx.h" #line 55 "C:/MCC18/h/p18cxxx.h" #line 57 "C:/MCC18/h/p18cxxx.h" #line 59 "C:/MCC18/h/p18cxxx.h" #line 61 "C:/MCC18/h/p18cxxx.h" #line 63 "C:/MCC18/h/p18cxxx.h" #line 65 "C:/MCC18/h/p18cxxx.h" #line 67 "C:/MCC18/h/p18cxxx.h" #line 69 "C:/MCC18/h/p18cxxx.h" #line 71 "C:/MCC18/h/p18cxxx.h" #line 73 "C:/MCC18/h/p18cxxx.h" #line 75 "C:/MCC18/h/p18cxxx.h" #line 77 "C:/MCC18/h/p18cxxx.h" #line 79 "C:/MCC18/h/p18cxxx.h" #line 81 "C:/MCC18/h/p18cxxx.h" #line 83 "C:/MCC18/h/p18cxxx.h" #line 85 "C:/MCC18/h/p18cxxx.h" #line 87 "C:/MCC18/h/p18cxxx.h" #line 89 "C:/MCC18/h/p18cxxx.h" #line 91 "C:/MCC18/h/p18cxxx.h" #line 93 "C:/MCC18/h/p18cxxx.h" #line 95 "C:/MCC18/h/p18cxxx.h" #line 97 "C:/MCC18/h/p18cxxx.h" #line 99 "C:/MCC18/h/p18cxxx.h" #line 101 "C:/MCC18/h/p18cxxx.h" #line 103 "C:/MCC18/h/p18cxxx.h" #line 105 "C:/MCC18/h/p18cxxx.h" #line 107 "C:/MCC18/h/p18cxxx.h" #line 109 "C:/MCC18/h/p18cxxx.h" #line 111 "C:/MCC18/h/p18cxxx.h" #line 113 "C:/MCC18/h/p18cxxx.h" #line 115 "C:/MCC18/h/p18cxxx.h" #line 117 "C:/MCC18/h/p18cxxx.h" #line 119 "C:/MCC18/h/p18cxxx.h" #line 121 "C:/MCC18/h/p18cxxx.h" #line 123 "C:/MCC18/h/p18cxxx.h" #line 125 "C:/MCC18/h/p18cxxx.h" #line 127 "C:/MCC18/h/p18cxxx.h" #line 129 "C:/MCC18/h/p18cxxx.h" #line 131 "C:/MCC18/h/p18cxxx.h" #line 133 "C:/MCC18/h/p18cxxx.h" #line 135 "C:/MCC18/h/p18cxxx.h" #line 137 "C:/MCC18/h/p18cxxx.h" #line 139 "C:/MCC18/h/p18cxxx.h" #line 141 "C:/MCC18/h/p18cxxx.h" #line 143 "C:/MCC18/h/p18cxxx.h" #line 145 "C:/MCC18/h/p18cxxx.h" #line 147 "C:/MCC18/h/p18cxxx.h" #line 149 "C:/MCC18/h/p18cxxx.h" #line 151 "C:/MCC18/h/p18cxxx.h" #line 153 "C:/MCC18/h/p18cxxx.h" #line 155 "C:/MCC18/h/p18cxxx.h" #line 157 "C:/MCC18/h/p18cxxx.h" #line 159 "C:/MCC18/h/p18cxxx.h" #line 161 "C:/MCC18/h/p18cxxx.h" #line 163 "C:/MCC18/h/p18cxxx.h" #line 1 "C:/MCC18/h/p18f4550.h" #line 5 "C:/MCC18/h/p18f4550.h" #line 9 "C:/MCC18/h/p18f4550.h" extern volatile near unsigned char SPPDATA; extern volatile near unsigned char SPPCFG; extern volatile near struct { unsigned WS0:1; unsigned WS1:1; unsigned WS2:1; unsigned WS3:1; unsigned CLK1EN:1; unsigned CSEN:1; unsigned CLKCFG0:1; unsigned CLKCFG1:1; } SPPCFGbits; extern volatile near unsigned char SPPEPS; extern volatile near struct { unsigned ADDR0:1; unsigned ADDR1:1; unsigned ADDR2:1; unsigned ADDR3:1; unsigned SPPBUSY:1; unsigned :1; unsigned WRSPP:1; unsigned RDSPP:1; } SPPEPSbits; extern volatile near unsigned char SPPCON; extern volatile near struct { unsigned SPPEN:1; unsigned SPPOWN:1; } SPPCONbits; extern volatile near unsigned UFRM; extern volatile near unsigned char UFRML; extern volatile near struct { unsigned FRM0:1; unsigned FRM1:1; unsigned FRM2:1; unsigned FRM3:1; unsigned FRM4:1; unsigned FRM5:1; unsigned FRM6:1; unsigned FRM7:1; } UFRMLbits; extern volatile near unsigned char UFRMH; extern volatile near struct { unsigned FRM8:1; unsigned FRM9:1; unsigned FRM10:1; } UFRMHbits; extern volatile near unsigned char UIR; extern volatile near struct { unsigned URSTIF:1; unsigned UERRIF:1; unsigned ACTVIF:1; unsigned TRNIF:1; unsigned IDLEIF:1; unsigned STALLIF:1; unsigned SOFIF:1; } UIRbits; extern volatile near unsigned char UIE; extern volatile near struct { unsigned URSTIE:1; unsigned UERRIE:1; unsigned ACTVIE:1; unsigned TRNIE:1; unsigned IDLEIE:1; unsigned STALLIE:1; unsigned SOFIE:1; } UIEbits; extern volatile near unsigned char UEIR; extern volatile near struct { unsigned PIDEF:1; unsigned CRC5EF:1; unsigned CRC16EF:1; unsigned DFN8EF:1; unsigned BTOEF:1; unsigned :2; unsigned BTSEF:1; } UEIRbits; extern volatile near unsigned char UEIE; extern volatile near struct { unsigned PIDEE:1; unsigned CRC5EE:1; unsigned CRC16EE:1; unsigned DFN8EE:1; unsigned BTOEE:1; unsigned :2; unsigned BTSEE:1; } UEIEbits; extern volatile near unsigned char USTAT; extern volatile near struct { unsigned :1; unsigned PPBI:1; unsigned DIR:1; unsigned ENDP0:1; unsigned ENDP1:1; unsigned ENDP2:1; unsigned ENDP3:1; } USTATbits; extern volatile near unsigned char UCON; extern volatile near struct { unsigned :1; unsigned SUSPND:1; unsigned RESUME:1; unsigned USBEN:1; unsigned PKTDIS:1; unsigned SE0:1; unsigned PPBRST:1; } UCONbits; extern volatile near unsigned char UADDR; extern volatile near struct { unsigned ADDR0:1; unsigned ADDR1:1; unsigned ADDR2:1; unsigned ADDR3:1; unsigned ADDR4:1; unsigned ADDR5:1; unsigned ADDR6:1; } UADDRbits; extern volatile near unsigned char UCFG; extern volatile near struct { unsigned PPB0:1; unsigned PPB1:1; unsigned FSEN:1; unsigned UTRDIS:1; unsigned UPUEN:1; unsigned :1; unsigned UOEMON:1; unsigned UTEYE:1; } UCFGbits; extern volatile near unsigned char UEP0; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP0bits; extern volatile near unsigned char UEP1; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP1bits; extern volatile near unsigned char UEP2; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP2bits; extern volatile near unsigned char UEP3; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP3bits; extern volatile near unsigned char UEP4; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP4bits; extern volatile near unsigned char UEP5; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP5bits; extern volatile near unsigned char UEP6; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP6bits; extern volatile near unsigned char UEP7; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP7bits; extern volatile near unsigned char UEP8; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP8bits; extern volatile near unsigned char UEP9; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP9bits; extern volatile near unsigned char UEP10; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP10bits; extern volatile near unsigned char UEP11; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP11bits; extern volatile near unsigned char UEP12; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP12bits; extern volatile near unsigned char UEP13; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP13bits; extern volatile near unsigned char UEP14; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP14bits; extern volatile near unsigned char UEP15; extern volatile near struct { unsigned EPSTALL:1; unsigned EPINEN:1; unsigned EPOUTEN:1; unsigned EPCONDIS:1; unsigned EPHSHK:1; } UEP15bits; extern volatile near unsigned char PORTA; extern volatile near union { struct { unsigned RA0:1; unsigned RA1:1; unsigned RA2:1; unsigned RA3:1; unsigned RA4:1; unsigned RA5:1; unsigned RA6:1; }; struct { unsigned AN0:1; unsigned AN1:1; unsigned AN2:1; unsigned AN3:1; unsigned T0CKI:1; unsigned AN4:1; unsigned OSC2:1; }; struct { unsigned :2; unsigned VREFM:1; unsigned VREFP:1; unsigned :1; unsigned LVDIN:1; }; struct { unsigned :5; unsigned HLVDIN:1; }; } PORTAbits; extern volatile near unsigned char PORTB; extern volatile near union { struct { unsigned RB0:1; unsigned RB1:1; unsigned RB2:1; unsigned RB3:1; unsigned RB4:1; unsigned RB5:1; unsigned RB6:1; unsigned RB7:1; }; struct { unsigned INT0:1; unsigned INT1:1; unsigned INT2:1; }; struct { unsigned :5; unsigned PGM:1; unsigned PGC:1; unsigned PGD:1; }; } PORTBbits; extern volatile near unsigned char PORTC; extern volatile near union { struct { unsigned RC0:1; unsigned RC1:1; unsigned RC2:1; unsigned :1; unsigned RC4:1; unsigned RC5:1; unsigned RC6:1; unsigned RC7:1; }; struct { unsigned T1OSO:1; unsigned T1OSI:1; unsigned CCP1:1; unsigned :3; unsigned TX:1; unsigned RX:1; }; struct { unsigned T13CKI:1; unsigned :1; unsigned P1A:1; unsigned :3; unsigned CK:1; unsigned DT:1; }; } PORTCbits; extern volatile near unsigned char PORTD; extern volatile near union { struct { unsigned RD0:1; unsigned RD1:1; unsigned RD2:1; unsigned RD3:1; unsigned RD4:1; unsigned RD5:1; unsigned RD6:1; unsigned RD7:1; }; struct { unsigned SPP0:1; unsigned SPP1:1; unsigned SPP2:1; unsigned SPP3:1; unsigned SPP4:1; unsigned SPP5:1; unsigned SPP6:1; unsigned SPP7:1; }; } PORTDbits; extern volatile near unsigned char PORTE; extern volatile near union { struct { unsigned RE0:1; unsigned RE1:1; unsigned RE2:1; unsigned RE3:1; unsigned :3; unsigned RDPU:1; }; struct { unsigned CK1SPP:1; unsigned CK2SPP:1; unsigned OESPP:1; }; } PORTEbits; extern volatile near unsigned char LATA; extern volatile near struct { unsigned LATA0:1; unsigned LATA1:1; unsigned LATA2:1; unsigned LATA3:1; unsigned LATA4:1; unsigned LATA5:1; unsigned LATA6:1; } LATAbits; extern volatile near unsigned char LATB; extern volatile near struct { unsigned LATB0:1; unsigned LATB1:1; unsigned LATB2:1; unsigned LATB3:1; unsigned LATB4:1; unsigned LATB5:1; unsigned LATB6:1; unsigned LATB7:1; } LATBbits; extern volatile near unsigned char LATC; extern volatile near struct { unsigned LATC0:1; unsigned LATC1:1; unsigned LATC2:1; unsigned :3; unsigned LATC6:1; unsigned LATC7:1; } LATCbits; extern volatile near unsigned char LATD; extern volatile near struct { unsigned LATD0:1; unsigned LATD1:1; unsigned LATD2:1; unsigned LATD3:1; unsigned LATD4:1; unsigned LATD5:1; unsigned LATD6:1; unsigned LATD7:1; } LATDbits; extern volatile near unsigned char LATE; extern volatile near struct { unsigned LATE0:1; unsigned LATE1:1; unsigned LATE2:1; } LATEbits; extern volatile near unsigned char DDRA; extern volatile near struct { unsigned RA0:1; unsigned RA1:1; unsigned RA2:1; unsigned RA3:1; unsigned RA4:1; unsigned RA5:1; unsigned RA6:1; } DDRAbits; extern volatile near unsigned char TRISA; extern volatile near struct { unsigned TRISA0:1; unsigned TRISA1:1; unsigned TRISA2:1; unsigned TRISA3:1; unsigned TRISA4:1; unsigned TRISA5:1; unsigned TRISA6:1; } TRISAbits; extern volatile near unsigned char DDRB; extern volatile near struct { unsigned RB0:1; unsigned RB1:1; unsigned RB2:1; unsigned RB3:1; unsigned RB4:1; unsigned RB5:1; unsigned RB6:1; unsigned RB7:1; } DDRBbits; extern volatile near unsigned char TRISB; extern volatile near struct { unsigned TRISB0:1; unsigned TRISB1:1; unsigned TRISB2:1; unsigned TRISB3:1; unsigned TRISB4:1; unsigned TRISB5:1; unsigned TRISB6:1; unsigned TRISB7:1; } TRISBbits; extern volatile near unsigned char DDRC; extern volatile near struct { unsigned RC0:1; unsigned RC1:1; unsigned RC2:1; unsigned :3; unsigned RC6:1; unsigned RC7:1; } DDRCbits; extern volatile near unsigned char TRISC; extern volatile near struct { unsigned TRISC0:1; unsigned TRISC1:1; unsigned TRISC2:1; unsigned :3; unsigned TRISC6:1; unsigned TRISC7:1; } TRISCbits; extern volatile near unsigned char DDRD; extern volatile near struct { unsigned RD0:1; unsigned RD1:1; unsigned RD2:1; unsigned RD3:1; unsigned RD4:1; unsigned RD5:1; unsigned RD6:1; unsigned RD7:1; } DDRDbits; extern volatile near unsigned char TRISD; extern volatile near struct { unsigned TRISD0:1; unsigned TRISD1:1; unsigned TRISD2:1; unsigned TRISD3:1; unsigned TRISD4:1; unsigned TRISD5:1; unsigned TRISD6:1; unsigned TRISD7:1; } TRISDbits; extern volatile near unsigned char DDRE; extern volatile near struct { unsigned RE0:1; unsigned RE1:1; unsigned RE2:1; } DDREbits; extern volatile near unsigned char TRISE; extern volatile near struct { unsigned TRISE0:1; unsigned TRISE1:1; unsigned TRISE2:1; } TRISEbits; extern volatile near unsigned char OSCTUNE; extern volatile near struct { unsigned TUN0:1; unsigned TUN1:1; unsigned TUN2:1; unsigned TUN3:1; unsigned TUN4:1; unsigned :2; unsigned INTSRC:1; } OSCTUNEbits; extern volatile near unsigned char PIE1; extern volatile near struct { unsigned TMR1IE:1; unsigned TMR2IE:1; unsigned CCP1IE:1; unsigned SSPIE:1; unsigned TXIE:1; unsigned RCIE:1; unsigned ADIE:1; unsigned SPPIE:1; } PIE1bits; extern volatile near unsigned char PIR1; extern volatile near struct { unsigned TMR1IF:1; unsigned TMR2IF:1; unsigned CCP1IF:1; unsigned SSPIF:1; unsigned TXIF:1; unsigned RCIF:1; unsigned ADIF:1; unsigned SPPIF:1; } PIR1bits; extern volatile near unsigned char IPR1; extern volatile near struct { unsigned TMR1IP:1; unsigned TMR2IP:1; unsigned CCP1IP:1; unsigned SSPIP:1; unsigned TXIP:1; unsigned RCIP:1; unsigned ADIP:1; unsigned SPPIP:1; } IPR1bits; extern volatile near unsigned char PIE2; extern volatile near union { struct { unsigned CCP2IE:1; unsigned TMR3IE:1; unsigned LVDIE:1; unsigned BCLIE:1; unsigned EEIE:1; unsigned USBIE:1; unsigned CMIE:1; unsigned OSCFIE:1; }; struct { unsigned :2; unsigned HLVDIE:1; }; } PIE2bits; extern volatile near unsigned char PIR2; extern volatile near union { struct { unsigned CCP2IF:1; unsigned TMR3IF:1; unsigned LVDIF:1; unsigned BCLIF:1; unsigned EEIF:1; unsigned USBIF:1; unsigned CMIF:1; unsigned OSCFIF:1; }; struct { unsigned :2; unsigned HLVDIF:1; }; } PIR2bits; extern volatile near unsigned char IPR2; extern volatile near union { struct { unsigned CCP2IP:1; unsigned TMR3IP:1; unsigned LVDIP:1; unsigned BCLIP:1; unsigned EEIP:1; unsigned USBIP:1; unsigned CMIP:1; unsigned OSCFIP:1; }; struct { unsigned :2; unsigned HLVDIP:1; }; } IPR2bits; extern volatile near unsigned char EECON1; extern volatile near struct { unsigned RD:1; unsigned WR:1; unsigned WREN:1; unsigned WRERR:1; unsigned FREE:1; unsigned :1; unsigned CFGS:1; unsigned EEPGD:1; } EECON1bits; extern volatile near unsigned char EECON2; extern volatile near unsigned char EEDATA; extern volatile near unsigned char EEADR; extern volatile near unsigned char RCSTA; extern volatile near union { struct { unsigned RX9D:1; unsigned OERR:1; unsigned FERR:1; unsigned ADDEN:1; unsigned CREN:1; unsigned SREN:1; unsigned RX9:1; unsigned SPEN:1; }; struct { unsigned :3; unsigned ADEN:1; }; } RCSTAbits; extern volatile near unsigned char TXSTA; extern volatile near struct { unsigned TX9D:1; unsigned TRMT:1; unsigned BRGH:1; unsigned SENDB:1; unsigned SYNC:1; unsigned TXEN:1; unsigned TX9:1; unsigned CSRC:1; } TXSTAbits; extern volatile near unsigned char TXREG; extern volatile near unsigned char RCREG; extern volatile near unsigned char SPBRG; extern volatile near unsigned char SPBRGH; extern volatile near unsigned char T3CON; extern volatile near union { struct { unsigned TMR3ON:1; unsigned TMR3CS:1; unsigned T3SYNC:1; unsigned T3CCP1:1; unsigned T3CKPS0:1; unsigned T3CKPS1:1; unsigned T3CCP2:1; unsigned RD16:1; }; struct { unsigned :2; unsigned T3NSYNC:1; }; struct { unsigned :2; unsigned NOT_T3SYNC:1; }; } T3CONbits; extern volatile near unsigned char TMR3L; extern volatile near unsigned char TMR3H; extern volatile near unsigned char CMCON; extern volatile near struct { unsigned CM0:1; unsigned CM1:1; unsigned CM2:1; unsigned CIS:1; unsigned C1INV:1; unsigned C2INV:1; unsigned C1OUT:1; unsigned C2OUT:1; } CMCONbits; extern volatile near unsigned char CVRCON; extern volatile near union { struct { unsigned CVR0:1; unsigned CVR1:1; unsigned CVR2:1; unsigned CVR3:1; unsigned CVREF:1; unsigned CVRR:1; unsigned CVROE:1; unsigned CVREN:1; }; struct { unsigned :4; unsigned CVRSS:1; }; } CVRCONbits; extern volatile near unsigned char CCP1AS; extern volatile near struct { unsigned PSSBD0:1; unsigned PSSBD1:1; unsigned PSSAC0:1; unsigned PSSAC1:1; unsigned ECCPAS0:1; unsigned ECCPAS1:1; unsigned ECCPAS2:1; unsigned ECCPASE:1; } CCP1ASbits; extern volatile near unsigned char ECCP1AS; extern volatile near struct { unsigned PSSBD0:1; unsigned PSSBD1:1; unsigned PSSAC0:1; unsigned PSSAC1:1; unsigned ECCPAS0:1; unsigned ECCPAS1:1; unsigned ECCPAS2:1; unsigned ECCPASE:1; } ECCP1ASbits; extern volatile near unsigned char CCP1DEL; extern volatile near struct { unsigned PDC0:1; unsigned PDC1:1; unsigned PDC2:1; unsigned PDC3:1; unsigned PDC4:1; unsigned PDC5:1; unsigned PDC6:1; unsigned PRSEN:1; } CCP1DELbits; extern volatile near unsigned char ECCP1DEL; extern volatile near struct { unsigned PDC0:1; unsigned PDC1:1; unsigned PDC2:1; unsigned PDC3:1; unsigned PDC4:1; unsigned PDC5:1; unsigned PDC6:1; unsigned PRSEN:1; } ECCP1DELbits; extern volatile near unsigned char BAUDCON; extern volatile near union { struct { unsigned ABDEN:1; unsigned WUE:1; unsigned :1; unsigned BRG16:1; unsigned SCKP:1; unsigned :1; unsigned RCIDL:1; unsigned ABDOVF:1; }; struct { unsigned :4; unsigned TXCKP:1; unsigned RXDTP:1; unsigned RCMT:1; }; } BAUDCONbits; extern volatile near unsigned char CCP2CON; extern volatile near struct { unsigned CCP2M0:1; unsigned CCP2M1:1; unsigned CCP2M2:1; unsigned CCP2M3:1; unsigned DC2B0:1; unsigned DC2B1:1; } CCP2CONbits; extern volatile near unsigned CCPR2; extern volatile near unsigned char CCPR2L; extern volatile near unsigned char CCPR2H; extern volatile near unsigned char CCP1CON; extern volatile near struct { unsigned CCP1M0:1; unsigned CCP1M1:1; unsigned CCP1M2:1; unsigned CCP1M3:1; unsigned DC1B0:1; unsigned DC1B1:1; unsigned P1M0:1; unsigned P1M1:1; } CCP1CONbits; extern volatile near unsigned char ECCP1CON; extern volatile near struct { unsigned CCP1M0:1; unsigned CCP1M1:1; unsigned CCP1M2:1; unsigned CCP1M3:1; unsigned DC1B0:1; unsigned DC1B1:1; unsigned P1M0:1; unsigned P1M1:1; } ECCP1CONbits; extern volatile near unsigned CCPR1; extern volatile near unsigned char CCPR1L; extern volatile near unsigned char CCPR1H; extern volatile near unsigned char ADCON2; extern volatile near struct { unsigned ADCS0:1; unsigned ADCS1:1; unsigned ADCS2:1; unsigned ACQT0:1; unsigned ACQT1:1; unsigned ACQT2:1; unsigned :1; unsigned ADFM:1; } ADCON2bits; extern volatile near unsigned char ADCON1; extern volatile near struct { unsigned PCFG0:1; unsigned PCFG1:1; unsigned PCFG2:1; unsigned PCFG3:1; unsigned VCFG0:1; unsigned VCFG1:1; } ADCON1bits; extern volatile near unsigned char ADCON0; extern volatile near union { struct { unsigned ADON:1; unsigned GO_DONE:1; unsigned CHS0:1; unsigned CHS1:1; unsigned CHS2:1; unsigned CHS3:1; }; struct { unsigned :1; unsigned DONE:1; }; struct { unsigned :1; unsigned GO:1; }; struct { unsigned :1; unsigned NOT_DONE:1; }; } ADCON0bits; extern volatile near unsigned ADRES; extern volatile near unsigned char ADRESL; extern volatile near unsigned char ADRESH; extern volatile near unsigned char SSPCON2; extern volatile near struct { unsigned SEN:1; unsigned RSEN:1; unsigned PEN:1; unsigned RCEN:1; unsigned ACKEN:1; unsigned ACKDT:1; unsigned ACKSTAT:1; unsigned GCEN:1; } SSPCON2bits; extern volatile near unsigned char SSPCON1; extern volatile near struct { unsigned SSPM0:1; unsigned SSPM1:1; unsigned SSPM2:1; unsigned SSPM3:1; unsigned CKP:1; unsigned SSPEN:1; unsigned SSPOV:1; unsigned WCOL:1; } SSPCON1bits; extern volatile near unsigned char SSPSTAT; extern volatile near union { struct { unsigned BF:1; unsigned UA:1; unsigned R_W:1; unsigned S:1; unsigned P:1; unsigned D_A:1; unsigned CKE:1; unsigned SMP:1; }; struct { unsigned :2; unsigned I2C_READ:1; unsigned I2C_START:1; unsigned I2C_STOP:1; unsigned I2C_DAT:1; }; struct { unsigned :2; unsigned NOT_W:1; unsigned :2; unsigned NOT_A:1; }; struct { unsigned :2; unsigned NOT_WRITE:1; unsigned :2; unsigned NOT_ADDRESS:1; }; struct { unsigned :2; unsigned READ_WRITE:1; unsigned :2; unsigned DATA_ADDRESS:1; }; struct { unsigned :2; unsigned R:1; unsigned :2; unsigned D:1; }; } SSPSTATbits; extern volatile near unsigned char SSPADD; extern volatile near unsigned char SSPBUF; extern volatile near unsigned char T2CON; extern volatile near struct { unsigned T2CKPS0:1; unsigned T2CKPS1:1; unsigned TMR2ON:1; unsigned T2OUTPS0:1; unsigned T2OUTPS1:1; unsigned T2OUTPS2:1; unsigned T2OUTPS3:1; } T2CONbits; extern volatile near unsigned char PR2; extern volatile near unsigned char TMR2; extern volatile near unsigned char T1CON; extern volatile near union { struct { unsigned TMR1ON:1; unsigned TMR1CS:1; unsigned T1SYNC:1; unsigned T1OSCEN:1; unsigned T1CKPS0:1; unsigned T1CKPS1:1; unsigned T1RUN:1; unsigned RD16:1; }; struct { unsigned :2; unsigned NOT_T1SYNC:1; }; } T1CONbits; extern volatile near unsigned char TMR1L; extern volatile near unsigned char TMR1H; extern volatile near unsigned char RCON; extern volatile near union { struct { unsigned NOT_BOR:1; unsigned NOT_POR:1; unsigned NOT_PD:1; unsigned NOT_TO:1; unsigned NOT_RI:1; unsigned :1; unsigned SBOREN:1; unsigned NOT_IPEN:1; }; struct { unsigned BOR:1; unsigned POR:1; unsigned PD:1; unsigned TO:1; unsigned RI:1; unsigned :2; unsigned IPEN:1; }; } RCONbits; extern volatile near unsigned char WDTCON; extern volatile near union { struct { unsigned SWDTEN:1; }; struct { unsigned SWDTE:1; }; } WDTCONbits; extern volatile near unsigned char HLVDCON; extern volatile near union { struct { unsigned LVDL0:1; unsigned LVDL1:1; unsigned LVDL2:1; unsigned LVDL3:1; unsigned LVDEN:1; unsigned IRVST:1; }; struct { unsigned LVV0:1; unsigned LVV1:1; unsigned LVV2:1; unsigned LVV3:1; unsigned :1; unsigned BGST:1; }; struct { unsigned HLVDL0:1; unsigned HLVDL1:1; unsigned HLVDL2:1; unsigned HLVDL3:1; unsigned HLVDEN:1; unsigned :2; unsigned VDIRMAG:1; }; struct { unsigned :5; unsigned IVRST:1; }; } HLVDCONbits; extern volatile near unsigned char LVDCON; extern volatile near union { struct { unsigned LVDL0:1; unsigned LVDL1:1; unsigned LVDL2:1; unsigned LVDL3:1; unsigned LVDEN:1; unsigned IRVST:1; }; struct { unsigned LVV0:1; unsigned LVV1:1; unsigned LVV2:1; unsigned LVV3:1; unsigned :1; unsigned BGST:1; }; struct { unsigned HLVDL0:1; unsigned HLVDL1:1; unsigned HLVDL2:1; unsigned HLVDL3:1; unsigned HLVDEN:1; unsigned :2; unsigned VDIRMAG:1; }; struct { unsigned :5; unsigned IVRST:1; }; } LVDCONbits; extern volatile near unsigned char OSCCON; extern volatile near union { struct { unsigned SCS0:1; unsigned SCS1:1; unsigned IOFS:1; unsigned OSTS:1; unsigned IRCF0:1; unsigned IRCF1:1; unsigned IRCF2:1; unsigned IDLEN:1; }; struct { unsigned :2; unsigned FLTS:1; }; } OSCCONbits; extern volatile near unsigned char T0CON; extern volatile near struct { unsigned T0PS0:1; unsigned T0PS1:1; unsigned T0PS2:1; unsigned PSA:1; unsigned T0SE:1; unsigned T0CS:1; unsigned T08BIT:1; unsigned TMR0ON:1; } T0CONbits; extern volatile near unsigned char TMR0L; extern volatile near unsigned char TMR0H; extern near unsigned char STATUS; extern near struct { unsigned C:1; unsigned DC:1; unsigned Z:1; unsigned OV:1; unsigned N:1; } STATUSbits; extern near unsigned FSR2; extern near unsigned char FSR2L; extern near unsigned char FSR2H; extern volatile near unsigned char PLUSW2; extern volatile near unsigned char PREINC2; extern volatile near unsigned char POSTDEC2; extern volatile near unsigned char POSTINC2; extern near unsigned char INDF2; extern near unsigned char BSR; extern near unsigned FSR1; extern near unsigned char FSR1L; extern near unsigned char FSR1H; extern volatile near unsigned char PLUSW1; extern volatile near unsigned char PREINC1; extern volatile near unsigned char POSTDEC1; extern volatile near unsigned char POSTINC1; extern near unsigned char INDF1; extern near unsigned char WREG; extern near unsigned FSR0; extern near unsigned char FSR0L; extern near unsigned char FSR0H; extern volatile near unsigned char PLUSW0; extern volatile near unsigned char PREINC0; extern volatile near unsigned char POSTDEC0; extern volatile near unsigned char POSTINC0; extern near unsigned char INDF0; extern volatile near unsigned char INTCON3; extern volatile near union { struct { unsigned INT1IF:1; unsigned INT2IF:1; unsigned :1; unsigned INT1IE:1; unsigned INT2IE:1; unsigned :1; unsigned INT1IP:1; unsigned INT2IP:1; }; struct { unsigned INT1F:1; unsigned INT2F:1; unsigned :1; unsigned INT1E:1; unsigned INT2E:1; unsigned :1; unsigned INT1P:1; unsigned INT2P:1; }; } INTCON3bits; extern volatile near unsigned char INTCON2; extern volatile near union { struct { unsigned RBIP:1; unsigned :1; unsigned TMR0IP:1; unsigned :1; unsigned INTEDG2:1; unsigned INTEDG1:1; unsigned INTEDG0:1; unsigned NOT_RBPU:1; }; struct { unsigned :2; unsigned T0IP:1; unsigned :4; unsigned RBPU:1; }; } INTCON2bits; extern volatile near unsigned char INTCON; extern volatile near union { struct { unsigned RBIF:1; unsigned INT0IF:1; unsigned TMR0IF:1; unsigned RBIE:1; unsigned INT0IE:1; unsigned TMR0IE:1; unsigned PEIE:1; unsigned GIE:1; }; struct { unsigned :1; unsigned INT0F:1; unsigned T0IF:1; unsigned :1; unsigned INT0E:1; unsigned T0IE:1; unsigned GIEL:1; unsigned GIEH:1; }; } INTCONbits; extern near unsigned PROD; extern near unsigned char PRODL; extern near unsigned char PRODH; extern volatile near unsigned char TABLAT; extern volatile near unsigned short long TBLPTR; extern volatile near unsigned char TBLPTRL; extern volatile near unsigned char TBLPTRH; extern volatile near unsigned char TBLPTRU; extern volatile near unsigned short long PC; extern volatile near unsigned char PCL; extern volatile near unsigned char PCLATH; extern volatile near unsigned char PCLATU; extern volatile near unsigned char STKPTR; extern volatile near struct { unsigned STKPTR0:1; unsigned STKPTR1:1; unsigned STKPTR2:1; unsigned STKPTR3:1; unsigned STKPTR4:1; unsigned :1; unsigned STKUNF:1; unsigned STKFUL:1; } STKPTRbits; extern near unsigned short long TOS; extern near unsigned char TOSL; extern near unsigned char TOSH; extern near unsigned char TOSU; #line 1221 "C:/MCC18/h/p18f4550.h" #line 1223 "C:/MCC18/h/p18f4550.h" #line 1224 "C:/MCC18/h/p18f4550.h" #line 1227 "C:/MCC18/h/p18f4550.h" #line 1229 "C:/MCC18/h/p18f4550.h" #line 1230 "C:/MCC18/h/p18f4550.h" #line 1231 "C:/MCC18/h/p18f4550.h" #line 1232 "C:/MCC18/h/p18f4550.h" #line 1234 "C:/MCC18/h/p18f4550.h" #line 1235 "C:/MCC18/h/p18f4550.h" #line 1236 "C:/MCC18/h/p18f4550.h" #line 1237 "C:/MCC18/h/p18f4550.h" #line 1238 "C:/MCC18/h/p18f4550.h" #line 1242 "C:/MCC18/h/p18f4550.h" #line 1244 "C:/MCC18/h/p18f4550.h" #line 1247 "C:/MCC18/h/p18f4550.h" #line 163 "C:/MCC18/h/p18cxxx.h" #line 165 "C:/MCC18/h/p18cxxx.h" #line 167 "C:/MCC18/h/p18cxxx.h" #line 169 "C:/MCC18/h/p18cxxx.h" #line 171 "C:/MCC18/h/p18cxxx.h" #line 173 "C:/MCC18/h/p18cxxx.h" #line 175 "C:/MCC18/h/p18cxxx.h" #line 177 "C:/MCC18/h/p18cxxx.h" #line 179 "C:/MCC18/h/p18cxxx.h" #line 181 "C:/MCC18/h/p18cxxx.h" #line 183 "C:/MCC18/h/p18cxxx.h" #line 185 "C:/MCC18/h/p18cxxx.h" #line 187 "C:/MCC18/h/p18cxxx.h" #line 189 "C:/MCC18/h/p18cxxx.h" #line 191 "C:/MCC18/h/p18cxxx.h" #line 193 "C:/MCC18/h/p18cxxx.h" #line 195 "C:/MCC18/h/p18cxxx.h" #line 197 "C:/MCC18/h/p18cxxx.h" #line 199 "C:/MCC18/h/p18cxxx.h" #line 201 "C:/MCC18/h/p18cxxx.h" #line 203 "C:/MCC18/h/p18cxxx.h" #line 205 "C:/MCC18/h/p18cxxx.h" #line 207 "C:/MCC18/h/p18cxxx.h" #line 209 "C:/MCC18/h/p18cxxx.h" #line 211 "C:/MCC18/h/p18cxxx.h" #line 213 "C:/MCC18/h/p18cxxx.h" #line 215 "C:/MCC18/h/p18cxxx.h" #line 217 "C:/MCC18/h/p18cxxx.h" #line 219 "C:/MCC18/h/p18cxxx.h" #line 221 "C:/MCC18/h/p18cxxx.h" #line 223 "C:/MCC18/h/p18cxxx.h" #line 225 "C:/MCC18/h/p18cxxx.h" #line 227 "C:/MCC18/h/p18cxxx.h" #line 229 "C:/MCC18/h/p18cxxx.h" #line 231 "C:/MCC18/h/p18cxxx.h" #line 233 "C:/MCC18/h/p18cxxx.h" #line 235 "C:/MCC18/h/p18cxxx.h" #line 237 "C:/MCC18/h/p18cxxx.h" #line 239 "C:/MCC18/h/p18cxxx.h" #line 241 "C:/MCC18/h/p18cxxx.h" #line 243 "C:/MCC18/h/p18cxxx.h" #line 245 "C:/MCC18/h/p18cxxx.h" #line 247 "C:/MCC18/h/p18cxxx.h" #line 249 "C:/MCC18/h/p18cxxx.h" #line 251 "C:/MCC18/h/p18cxxx.h" #line 253 "C:/MCC18/h/p18cxxx.h" #line 255 "C:/MCC18/h/p18cxxx.h" #line 257 "C:/MCC18/h/p18cxxx.h" #line 259 "C:/MCC18/h/p18cxxx.h" #line 261 "C:/MCC18/h/p18cxxx.h" #line 263 "C:/MCC18/h/p18cxxx.h" #line 265 "C:/MCC18/h/p18cxxx.h" #line 267 "C:/MCC18/h/p18cxxx.h" #line 269 "C:/MCC18/h/p18cxxx.h" #line 271 "C:/MCC18/h/p18cxxx.h" #line 273 "C:/MCC18/h/p18cxxx.h" #line 275 "C:/MCC18/h/p18cxxx.h" #line 277 "C:/MCC18/h/p18cxxx.h" #line 279 "C:/MCC18/h/p18cxxx.h" #line 281 "C:/MCC18/h/p18cxxx.h" #line 283 "C:/MCC18/h/p18cxxx.h" #line 285 "C:/MCC18/h/p18cxxx.h" #line 287 "C:/MCC18/h/p18cxxx.h" #line 289 "C:/MCC18/h/p18cxxx.h" #line 291 "C:/MCC18/h/p18cxxx.h" #line 293 "C:/MCC18/h/p18cxxx.h" #line 295 "C:/MCC18/h/p18cxxx.h" #line 297 "C:/MCC18/h/p18cxxx.h" #line 299 "C:/MCC18/h/p18cxxx.h" #line 301 "C:/MCC18/h/p18cxxx.h" #line 303 "C:/MCC18/h/p18cxxx.h" #line 305 "C:/MCC18/h/p18cxxx.h" #line 307 "C:/MCC18/h/p18cxxx.h" #line 309 "C:/MCC18/h/p18cxxx.h" #line 311 "C:/MCC18/h/p18cxxx.h" #line 313 "C:/MCC18/h/p18cxxx.h" #line 315 "C:/MCC18/h/p18cxxx.h" #line 317 "C:/MCC18/h/p18cxxx.h" #line 319 "C:/MCC18/h/p18cxxx.h" #line 321 "C:/MCC18/h/p18cxxx.h" #line 323 "C:/MCC18/h/p18cxxx.h" #line 325 "C:/MCC18/h/p18cxxx.h" #line 327 "C:/MCC18/h/p18cxxx.h" #line 329 "C:/MCC18/h/p18cxxx.h" #line 331 "C:/MCC18/h/p18cxxx.h" #line 333 "C:/MCC18/h/p18cxxx.h" #line 335 "C:/MCC18/h/p18cxxx.h" #line 337 "C:/MCC18/h/p18cxxx.h" #line 339 "C:/MCC18/h/p18cxxx.h" #line 341 "C:/MCC18/h/p18cxxx.h" #line 343 "C:/MCC18/h/p18cxxx.h" #line 345 "C:/MCC18/h/p18cxxx.h" #line 347 "C:/MCC18/h/p18cxxx.h" #line 349 "C:/MCC18/h/p18cxxx.h" #line 351 "C:/MCC18/h/p18cxxx.h" #line 353 "C:/MCC18/h/p18cxxx.h" #line 355 "C:/MCC18/h/p18cxxx.h" #line 357 "C:/MCC18/h/p18cxxx.h" #line 359 "C:/MCC18/h/p18cxxx.h" #line 361 "C:/MCC18/h/p18cxxx.h" #line 363 "C:/MCC18/h/p18cxxx.h" #line 44 "usbAll.c" #pragma udata void USBStdGetDscHandler(void); void USBStdSetCfgHandler(void); void USBStdGetStatusHandler(void); void USBStdFeatureReqHandler(void); #pragma code #line 73 "usbAll.c" void USBCheckStdRequest(void) { if(SetupPkt.RequestType != 0x00 ) return; switch(SetupPkt.bRequest) { case 5 : ctrl_trf_session_owner = 1 ; usb_device_state = 4 ; break; case 6 : USBStdGetDscHandler(); break; case 9 : USBStdSetCfgHandler(); break; case 8 : ctrl_trf_session_owner = 1 ; pSrc.bRam = (byte*)&usb_active_cfg; usb_stat.ctrl_trf_mem = _RAM; LSB(wCount) = 1; break; case 0 : USBStdGetStatusHandler(); break; case 1 : case 3 : USBStdFeatureReqHandler(); break; case 10 : ctrl_trf_session_owner = 1 ; pSrc.bRam = (byte*)&usb_alt_intf+SetupPkt.bIntfID; usb_stat.ctrl_trf_mem = _RAM; LSB(wCount) = 1; break; case 11 : ctrl_trf_session_owner = 1 ; usb_alt_intf[SetupPkt.bIntfID] = SetupPkt.bAltID; break; case 7 : case 12 : default: break; } } #line 125 "usbAll.c" void stringToDescriptor(rom char *s,char *descOut) { char *w = descOut; w++; *w++ = 0x03 ; while(*s) { *w++ = *s++; *w++ = 0; } *descOut = w - descOut; } #line 156 "usbAll.c" void USBStdGetDscHandler(void) { static char gString[64]; if(SetupPkt.bmRequestType == 0x80) { switch(SetupPkt.bDscType) { case 0x01 : ctrl_trf_session_owner = 1 ; pSrc.bRom = (rom byte*)&device_dsc; wCount._word = sizeof(device_dsc); usb_stat.ctrl_trf_mem = _ROM; break; case 0x02 : ctrl_trf_session_owner = 1 ; pSrc.bRom = *(USB_CD_Ptr+SetupPkt.bDscIndex); wCount._word = *(pSrc.wRom+1); usb_stat.ctrl_trf_mem = _ROM; break; case 0x03 : ctrl_trf_session_owner = 1 ; pSrc.bRom = *(USB_SD_Ptr+SetupPkt.bDscIndex); wCount._word = *pSrc.bRom; usb_stat.ctrl_trf_mem = _ROM; if(1) { char *a = gString; if(SetupPkt.bDscIndex == 0) { gString[0] = 4; gString[1] = 0x03 ; gString[2] = 0x09; gString[3] = 0x04; } else { gString[0] = 6; gString[1] = 0x03 ; gString[2] = 'W'; gString[3] = 0; gString[4] = '0' + SetupPkt.bDscIndex % 10; gString[5] = 0; #line 204 "usbAll.c" if(SetupPkt.bDscIndex == 2) stringToDescriptor("the second",gString); } pSrc.bRam = (byte*)gString; wCount._word = gString[0]; usb_stat.ctrl_trf_mem = _RAM; } break; } } } #line 234 "usbAll.c" void USBStdSetCfgHandler(void) { ctrl_trf_session_owner = 1 ; ClearArray((byte*)&UEP1,15); ; ClearArray((byte*)&usb_alt_intf,1 ); usb_active_cfg = SetupPkt.bCfgValue; if(SetupPkt.bCfgValue == 0) usb_device_state = 5 ; else { usb_device_state = 6 ; #line 250 "usbAll.c" USBGenInitEP(); #line 252 "usbAll.c" } } #line 272 "usbAll.c" void USBStdGetStatusHandler(void) { CtrlTrfData._byte0 = 0; CtrlTrfData._byte1 = 0; switch(SetupPkt.Recipient) { case 0 : ctrl_trf_session_owner = 1 ; #line 285 "usbAll.c" if(self_power == 1) CtrlTrfData._byte0|=0b000000001; if(usb_stat.RemoteWakeup == 1) CtrlTrfData._byte0|=0b00000010; break; case 1 : ctrl_trf_session_owner = 1 ; break; case 2 : ctrl_trf_session_owner = 1 ; #line 299 "usbAll.c" pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); if(*pDst.bRam & 0x04 ) CtrlTrfData._byte0=0x01; break; } if(ctrl_trf_session_owner == 1 ) { pSrc.bRam = (byte*)&CtrlTrfData; usb_stat.ctrl_trf_mem = _RAM; LSB(wCount) = 2; } } #line 329 "usbAll.c" void USBStdFeatureReqHandler(void) { if((SetupPkt.bFeature == 0x01 )&& (SetupPkt.Recipient == 0 )) { ctrl_trf_session_owner = 1 ; if(SetupPkt.bRequest == 3 ) usb_stat.RemoteWakeup = 1; else usb_stat.RemoteWakeup = 0; } if((SetupPkt.bFeature == 0x00 )&& (SetupPkt.Recipient == 2 )&& (SetupPkt.EPNum != 0)) { ctrl_trf_session_owner = 1 ; pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); if(SetupPkt.bRequest == 3 ) *pDst.bRam = 0x80 |0x04 ; else { if(SetupPkt.EPDir == 1) *pDst.bRam = 0x00 ; else *pDst.bRam = 0x80 |0x00 |0x08 ; } } } #line 400 "usbAll.c" #pragma udata byte ctrl_trf_state; byte ctrl_trf_session_owner; POINTER pSrc; POINTER pDst; WORD wCount; #line 425 "usbAll.c" byte short_pkt_status; void USBCtrlTrfSetupHandler(void); void USBCtrlTrfOutHandler(void); void USBCtrlTrfInHandler(void); #pragma code #line 454 "usbAll.c" #line 457 "usbAll.c" byte USBCtrlEPService(void) { if(USTAT == ((0x00<<3)|(0 <<2)) ) { UIRbits.TRNIF = 0; if(ep0Bo.Stat.PID == 0b00001101 ) USBCtrlTrfSetupHandler(); else USBCtrlTrfOutHandler(); } else if(USTAT == ((0x00<<3)|(1 <<2)) ) { UIRbits.TRNIF = 0; USBCtrlTrfInHandler(); } else { return 0; } return 1; } #line 521 "usbAll.c" void USBCtrlTrfSetupHandler(void) { byte i; #line 539 "usbAll.c" if(ep0Bi.Stat.UOWN != 0) ep0Bi.Stat._byte = 0x00 ; short_pkt_status = 0 ; ctrl_trf_state = 0 ; ctrl_trf_session_owner = 0 ; wCount._word = 0; USBCheckStdRequest(); USBCtrlEPServiceComplete(); } #line 581 "usbAll.c" void USBCtrlTrfOutHandler(void) { if(ctrl_trf_state == 2 ) { USBCtrlTrfRxService(); #line 592 "usbAll.c" if(ep0Bo.Stat.DTS == 0) ep0Bo.Stat._byte = 0x80 |0x40 |0x08 ; else ep0Bo.Stat._byte = 0x80 |0x00 |0x08 ; } else USBPrepareForNextSetupTrf(); } #line 626 "usbAll.c" void USBCtrlTrfInHandler(void) { if(usb_device_state==4 ) { UADDR = SetupPkt.bDevADR._byte; if(UADDR > 0) usb_device_state=5 ; else usb_device_state=3 ; } ; if(ctrl_trf_state == 1 ) { USBCtrlTrfTxService(); #line 648 "usbAll.c" if(short_pkt_status == 2 ) { ep0Bi.Stat._byte = 0x80 |0x04 ; } else { if(ep0Bi.Stat.DTS == 0) ep0Bi.Stat._byte = 0x80 |0x40 |0x08 ; else ep0Bi.Stat._byte = 0x80 |0x00 |0x08 ; } } else USBPrepareForNextSetupTrf(); } #line 689 "usbAll.c" void USBCtrlTrfTxService(void) { WORD byte_to_send; #line 696 "usbAll.c" if(wCount._word < 8 ) { byte_to_send._word = wCount._word; #line 713 "usbAll.c" if(short_pkt_status == 0 ) { short_pkt_status = 1 ; } else if(short_pkt_status == 1 ) { short_pkt_status = 2 ; } } else byte_to_send._word = 8 ; #line 729 "usbAll.c" ep0Bi.Stat.BC9 = 0; ep0Bi.Stat.BC8 = 0; ep0Bi.Stat._byte |= MSB(byte_to_send); ep0Bi.Cnt = LSB(byte_to_send); #line 737 "usbAll.c" wCount._word = wCount._word - byte_to_send._word; pDst.bRam = (byte*)&CtrlTrfData; if(usb_stat.ctrl_trf_mem == _ROM) { while(byte_to_send._word) { *pDst.bRam = *pSrc.bRom; pDst.bRam++; pSrc.bRom++; byte_to_send._word--; } } else { while(byte_to_send._word) { *pDst.bRam = *pSrc.bRam; pDst.bRam++; pSrc.bRam++; byte_to_send._word--; } } } #line 784 "usbAll.c" void USBCtrlTrfRxService(void) { WORD byte_to_read; MSB(byte_to_read) = 0x03 & ep0Bo.Stat._byte; LSB(byte_to_read) = ep0Bo.Cnt; #line 794 "usbAll.c" wCount._word = wCount._word + byte_to_read._word; pSrc.bRam = (byte*)&CtrlTrfData; while(byte_to_read._word) { *pDst.bRam = *pSrc.bRam; pDst.bRam++; pSrc.bRam++; byte_to_read._word--; } } #line 836 "usbAll.c" void USBCtrlEPServiceComplete(void) { #line 844 "usbAll.c" #line 848 "usbAll.c" UCONbits.PKTDIS = 0; if(ctrl_trf_session_owner == 0 ) { #line 857 "usbAll.c" ep0Bo.Cnt = 8 ; ep0Bo.ADR = (byte*)&SetupPkt; ep0Bo.Stat._byte = 0x80 |0x04 ; ep0Bi.Stat._byte = 0x80 |0x04 ; } else { if(SetupPkt.DataDir == 1 ) { if(SetupPkt.wLength < wCount._word) wCount._word = SetupPkt.wLength; USBCtrlTrfTxService(); ctrl_trf_state = 1 ; #line 898 "usbAll.c" ep0Bo.Cnt = 8 ; ep0Bo.ADR = (byte*)&SetupPkt; ep0Bo.Stat._byte = 0x80 ; #line 906 "usbAll.c" ep0Bi.ADR = (byte*)&CtrlTrfData; ep0Bi.Stat._byte = 0x80 |0x40 |0x08 ; } else { ctrl_trf_state = 2 ; #line 921 "usbAll.c" ep0Bi.Cnt = 0; ep0Bi.Stat._byte = 0x80 |0x40 |0x08 ; #line 927 "usbAll.c" ep0Bo.Cnt = 8 ; ep0Bo.ADR = (byte*)&CtrlTrfData; ep0Bo.Stat._byte = 0x80 |0x40 |0x08 ; } } } #line 951 "usbAll.c" void USBPrepareForNextSetupTrf(void) { #line 976 "usbAll.c" if((ctrl_trf_state == 2 ) && (UCONbits.PKTDIS == 1) && (ep0Bo.Cnt == sizeof(CTRL_TRF_SETUP)) && (ep0Bo.Stat.PID == 0b00001101 ) && (ep0Bo.Stat.UOWN == 0)) { unsigned char setup_cnt; ep0Bo.ADR = (byte*)&SetupPkt; for(setup_cnt = 0; setup_cnt < sizeof(CTRL_TRF_SETUP); setup_cnt++) { *(((byte*)&SetupPkt)+setup_cnt) = *(((byte*)&CtrlTrfData)+setup_cnt); } } else { ctrl_trf_state = 0 ; ep0Bo.Cnt = 8 ; ep0Bo.ADR = (byte*)&SetupPkt; #line 1011 "usbAll.c" ep0Bo.Stat._byte = 0x80 |0x00 |0x08 |0x04 ; #line 1028 "usbAll.c" ep0Bi.Stat._byte = 0x00 ; } } #line 1072 "usbAll.c" #pragma udata byte bTRNIFCount; void USBModuleEnable(void); void USBModuleDisable(void); void USBSuspend(void); void USBWakeFromSuspend(void); void USBProtocolResetHandler(void); void USB_SOF_Handler(void); void USBStallHandler(void); void USBErrorHandler(void); #pragma code #line 1109 "usbAll.c" void USBCheckBusStatus(void) { #line 1115 "usbAll.c" #line 1117 "usbAll.c" #line 1118 "usbAll.c" if(usb_bus_sense == 1 ) { if(UCONbits.USBEN == 0) USBModuleEnable(); } else { if(UCONbits.USBEN == 1) USBModuleDisable(); } #line 1136 "usbAll.c" if(usb_device_state == 1 ) { if(!UCONbits.SE0) { UIR = 0; UIE = 0; UIEbits.URSTIE = 1; UIEbits.IDLEIE = 1; usb_device_state = 2 ; } } } #line 1168 "usbAll.c" void USBModuleEnable(void) { UCON = 0; UIE = 0; UCONbits.USBEN = 1; usb_device_state = 1 ; } #line 1194 "usbAll.c" void USBModuleDisable(void) { UCON = 0; UIE = 0; usb_device_state = 0 ; } #line 1225 "usbAll.c" void USBSoftDetach(void) { USBModuleDisable(); } #line 1248 "usbAll.c" void USBDriverService(void) { #line 1253 "usbAll.c" if(usb_device_state == 0 ) return; #line 1258 "usbAll.c" if(UIRbits.ACTVIF && UIEbits.ACTVIE) USBWakeFromSuspend(); #line 1264 "usbAll.c" if(UCONbits.SUSPND==1) return; #line 1272 "usbAll.c" if(UIRbits.URSTIF && UIEbits.URSTIE) USBProtocolResetHandler(); #line 1277 "usbAll.c" if(UIRbits.IDLEIF && UIEbits.IDLEIE) USBSuspend(); if(UIRbits.SOFIF && UIEbits.SOFIE) USB_SOF_Handler(); if(UIRbits.STALLIF && UIEbits.STALLIE) USBStallHandler(); if(UIRbits.UERRIF && UIEbits.UERRIE) USBErrorHandler(); #line 1287 "usbAll.c" if(usb_device_state < 3 ) return; #line 1292 "usbAll.c" #line 1295 "usbAll.c" for(bTRNIFCount = 0; bTRNIFCount < 4; bTRNIFCount++) { if(UIRbits.TRNIF && UIEbits.TRNIE) { #line 1303 "usbAll.c" if(USBCtrlEPService() == 0) { #line 1315 "usbAll.c" UIRbits.TRNIF = 0; #line 1327 "usbAll.c" } } else break; } } #line 1350 "usbAll.c" void USBSuspend(void) { #line 1375 "usbAll.c" UIEbits.ACTVIE = 1; UIRbits.IDLEIF = 0; UCONbits.SUSPND = 1; #line 1383 "usbAll.c" } #line 1408 "usbAll.c" void USBWakeFromSuspend(void) { #line 1414 "usbAll.c" UCONbits.SUSPND = 0; UIEbits.ACTVIE = 0; #line 1430 "usbAll.c" while(UIRbits.ACTVIF){UIRbits.ACTVIF = 0;} } #line 1473 "usbAll.c" void USBRemoteWakeup(void) { static word delay_count; if(usb_stat.RemoteWakeup == 1) { #line 1492 "usbAll.c" UCONbits.SUSPND = 0; UCONbits.RESUME = 1; delay_count = 1800U; do { delay_count--; }while(delay_count); UCONbits.RESUME = 0; } } #line 1531 "usbAll.c" void USB_SOF_Handler(void) { UIRbits.SOFIF = 0; } #line 1573 "usbAll.c" void USBStallHandler(void) { #line 1584 "usbAll.c" if(UEP0bits.EPSTALL == 1) { #line 1601 "usbAll.c" #line 1618 "usbAll.c" if((ep0Bo.Stat._byte == 0x80 ) && (ep0Bi.Stat._byte == (0x80 |0x04 ))) { ep0Bo.Stat._byte = 0x80 |0x00 |0x08 |0x04 ; } UEP0bits.EPSTALL = 0; } UIRbits.STALLIF = 0; } #line 1647 "usbAll.c" void USBErrorHandler(void) { #line 1657 "usbAll.c" UEIR = 0; } #line 1683 "usbAll.c" void USBProtocolResetHandler(void) { UEIR = 0; UIR = 0; UEIE = 0b10011111; UIE = 0b01111011; UADDR = 0x00; ClearArray((byte*)&UEP1,15); ; UEP0 = 0x06 |0x10 ; while(UIRbits.TRNIF == 1) { UIRbits.TRNIF = 0; #line 1707 "usbAll.c" {_asm nop _endasm} ; {_asm nop _endasm} ; {_asm nop _endasm} ; {_asm nop _endasm} ; {_asm nop _endasm} ; {_asm nop _endasm} ; } UCONbits.PKTDIS = 0; USBPrepareForNextSetupTrf(); usb_stat.RemoteWakeup = 0; usb_active_cfg = 0; usb_device_state = 3 ; } void ClearArray(byte* startAdr,byte count) { *startAdr; while(count) { _asm clrf POSTINC0,0 _endasm count--; } } #line 1766 "usbAll.c" #line 1806 "usbAll.c" #line 1896 "usbAll.c" #line 1904 "usbAll.c" #pragma romdata rom USB_DEV_DSC device_dsc= { sizeof(USB_DEV_DSC), 0x01 , 0x0200, 0x00, 0x00, 0x00, 8 , 0x04D8, 0x000C, 0x0001, 0x01, 0x02, 0x00, 0x01 }; rom struct { USB_CFG_DSC cd01; USB_INTF_DSC i00a00; USB_EP_DSC ep01o_i00a00; USB_EP_DSC ep01i_i00a00; } cfg01 = { sizeof(USB_CFG_DSC), 0x02 , sizeof(cfg01), 1, 1, 0, 0x01<<7 |0x01<<6 , 50, sizeof(USB_INTF_DSC), 0x04 , 0, 0, 2, 0x00, 0x00, 0x00, 0, sizeof(USB_EP_DSC),0x05 ,0x01 ,0x03 ,64 ,32, sizeof(USB_EP_DSC),0x05 ,0x81 ,0x03 ,64 ,32 }; rom struct{byte bLength;byte bDscType;word string[1];}sd000={ sizeof(sd000),0x03 ,0x0409}; rom struct{byte bLength;byte bDscType;word string[31];}sd001={ sizeof(sd001),0x03 , 'o','m','i','n','o',' ','M','i','c','r','o','c','h','i','p',' ', 'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'}; rom struct{byte bLength;byte bDscType;word string[39];}sd002={ sizeof(sd002),0x03 , 'o','m','i','n','o',' ','M','i','c','r','o','c','h','i','p',' ','U','S','B',' ', 'D','e','m','o',' ','B','o','a','r','d',' ','(','C',')', ' ','2','0','0','7'}; rom const unsigned char *rom USB_CD_Ptr[]= { (rom const unsigned char *rom)&cfg01, (rom const unsigned char *rom)&cfg01 }; rom const unsigned char *rom USB_SD_Ptr[]= { (rom const unsigned char *rom)&sd000, (rom const unsigned char *rom)&sd001, (rom const unsigned char *rom)&sd002 }; #pragma code #line 2024 "usbAll.c" #line 1 "C:/MCC18/h/p18cxxx.h" #line 5 "C:/MCC18/h/p18cxxx.h" #line 7 "C:/MCC18/h/p18cxxx.h" #line 9 "C:/MCC18/h/p18cxxx.h" #line 11 "C:/MCC18/h/p18cxxx.h" #line 13 "C:/MCC18/h/p18cxxx.h" #line 15 "C:/MCC18/h/p18cxxx.h" #line 17 "C:/MCC18/h/p18cxxx.h" #line 19 "C:/MCC18/h/p18cxxx.h" #line 21 "C:/MCC18/h/p18cxxx.h" #line 23 "C:/MCC18/h/p18cxxx.h" #line 25 "C:/MCC18/h/p18cxxx.h" #line 27 "C:/MCC18/h/p18cxxx.h" #line 29 "C:/MCC18/h/p18cxxx.h" #line 31 "C:/MCC18/h/p18cxxx.h" #line 33 "C:/MCC18/h/p18cxxx.h" #line 35 "C:/MCC18/h/p18cxxx.h" #line 37 "C:/MCC18/h/p18cxxx.h" #line 39 "C:/MCC18/h/p18cxxx.h" #line 41 "C:/MCC18/h/p18cxxx.h" #line 43 "C:/MCC18/h/p18cxxx.h" #line 45 "C:/MCC18/h/p18cxxx.h" #line 47 "C:/MCC18/h/p18cxxx.h" #line 49 "C:/MCC18/h/p18cxxx.h" #line 51 "C:/MCC18/h/p18cxxx.h" #line 53 "C:/MCC18/h/p18cxxx.h" #line 55 "C:/MCC18/h/p18cxxx.h" #line 57 "C:/MCC18/h/p18cxxx.h" #line 59 "C:/MCC18/h/p18cxxx.h" #line 61 "C:/MCC18/h/p18cxxx.h" #line 63 "C:/MCC18/h/p18cxxx.h" #line 65 "C:/MCC18/h/p18cxxx.h" #line 67 "C:/MCC18/h/p18cxxx.h" #line 69 "C:/MCC18/h/p18cxxx.h" #line 71 "C:/MCC18/h/p18cxxx.h" #line 73 "C:/MCC18/h/p18cxxx.h" #line 75 "C:/MCC18/h/p18cxxx.h" #line 77 "C:/MCC18/h/p18cxxx.h" #line 79 "C:/MCC18/h/p18cxxx.h" #line 81 "C:/MCC18/h/p18cxxx.h" #line 83 "C:/MCC18/h/p18cxxx.h" #line 85 "C:/MCC18/h/p18cxxx.h" #line 87 "C:/MCC18/h/p18cxxx.h" #line 89 "C:/MCC18/h/p18cxxx.h" #line 91 "C:/MCC18/h/p18cxxx.h" #line 93 "C:/MCC18/h/p18cxxx.h" #line 95 "C:/MCC18/h/p18cxxx.h" #line 97 "C:/MCC18/h/p18cxxx.h" #line 99 "C:/MCC18/h/p18cxxx.h" #line 101 "C:/MCC18/h/p18cxxx.h" #line 103 "C:/MCC18/h/p18cxxx.h" #line 105 "C:/MCC18/h/p18cxxx.h" #line 107 "C:/MCC18/h/p18cxxx.h" #line 109 "C:/MCC18/h/p18cxxx.h" #line 111 "C:/MCC18/h/p18cxxx.h" #line 113 "C:/MCC18/h/p18cxxx.h" #line 115 "C:/MCC18/h/p18cxxx.h" #line 117 "C:/MCC18/h/p18cxxx.h" #line 119 "C:/MCC18/h/p18cxxx.h" #line 121 "C:/MCC18/h/p18cxxx.h" #line 123 "C:/MCC18/h/p18cxxx.h" #line 125 "C:/MCC18/h/p18cxxx.h" #line 127 "C:/MCC18/h/p18cxxx.h" #line 129 "C:/MCC18/h/p18cxxx.h" #line 131 "C:/MCC18/h/p18cxxx.h" #line 133 "C:/MCC18/h/p18cxxx.h" #line 135 "C:/MCC18/h/p18cxxx.h" #line 137 "C:/MCC18/h/p18cxxx.h" #line 139 "C:/MCC18/h/p18cxxx.h" #line 141 "C:/MCC18/h/p18cxxx.h" #line 143 "C:/MCC18/h/p18cxxx.h" #line 145 "C:/MCC18/h/p18cxxx.h" #line 147 "C:/MCC18/h/p18cxxx.h" #line 149 "C:/MCC18/h/p18cxxx.h" #line 151 "C:/MCC18/h/p18cxxx.h" #line 153 "C:/MCC18/h/p18cxxx.h" #line 155 "C:/MCC18/h/p18cxxx.h" #line 157 "C:/MCC18/h/p18cxxx.h" #line 159 "C:/MCC18/h/p18cxxx.h" #line 161 "C:/MCC18/h/p18cxxx.h" #line 163 "C:/MCC18/h/p18cxxx.h" #line 165 "C:/MCC18/h/p18cxxx.h" #line 167 "C:/MCC18/h/p18cxxx.h" #line 169 "C:/MCC18/h/p18cxxx.h" #line 171 "C:/MCC18/h/p18cxxx.h" #line 173 "C:/MCC18/h/p18cxxx.h" #line 175 "C:/MCC18/h/p18cxxx.h" #line 177 "C:/MCC18/h/p18cxxx.h" #line 179 "C:/MCC18/h/p18cxxx.h" #line 181 "C:/MCC18/h/p18cxxx.h" #line 183 "C:/MCC18/h/p18cxxx.h" #line 185 "C:/MCC18/h/p18cxxx.h" #line 187 "C:/MCC18/h/p18cxxx.h" #line 189 "C:/MCC18/h/p18cxxx.h" #line 191 "C:/MCC18/h/p18cxxx.h" #line 193 "C:/MCC18/h/p18cxxx.h" #line 195 "C:/MCC18/h/p18cxxx.h" #line 197 "C:/MCC18/h/p18cxxx.h" #line 199 "C:/MCC18/h/p18cxxx.h" #line 201 "C:/MCC18/h/p18cxxx.h" #line 203 "C:/MCC18/h/p18cxxx.h" #line 205 "C:/MCC18/h/p18cxxx.h" #line 207 "C:/MCC18/h/p18cxxx.h" #line 209 "C:/MCC18/h/p18cxxx.h" #line 211 "C:/MCC18/h/p18cxxx.h" #line 213 "C:/MCC18/h/p18cxxx.h" #line 215 "C:/MCC18/h/p18cxxx.h" #line 217 "C:/MCC18/h/p18cxxx.h" #line 219 "C:/MCC18/h/p18cxxx.h" #line 221 "C:/MCC18/h/p18cxxx.h" #line 223 "C:/MCC18/h/p18cxxx.h" #line 225 "C:/MCC18/h/p18cxxx.h" #line 227 "C:/MCC18/h/p18cxxx.h" #line 229 "C:/MCC18/h/p18cxxx.h" #line 231 "C:/MCC18/h/p18cxxx.h" #line 233 "C:/MCC18/h/p18cxxx.h" #line 235 "C:/MCC18/h/p18cxxx.h" #line 237 "C:/MCC18/h/p18cxxx.h" #line 239 "C:/MCC18/h/p18cxxx.h" #line 241 "C:/MCC18/h/p18cxxx.h" #line 243 "C:/MCC18/h/p18cxxx.h" #line 245 "C:/MCC18/h/p18cxxx.h" #line 247 "C:/MCC18/h/p18cxxx.h" #line 249 "C:/MCC18/h/p18cxxx.h" #line 251 "C:/MCC18/h/p18cxxx.h" #line 253 "C:/MCC18/h/p18cxxx.h" #line 255 "C:/MCC18/h/p18cxxx.h" #line 257 "C:/MCC18/h/p18cxxx.h" #line 259 "C:/MCC18/h/p18cxxx.h" #line 261 "C:/MCC18/h/p18cxxx.h" #line 263 "C:/MCC18/h/p18cxxx.h" #line 265 "C:/MCC18/h/p18cxxx.h" #line 267 "C:/MCC18/h/p18cxxx.h" #line 269 "C:/MCC18/h/p18cxxx.h" #line 271 "C:/MCC18/h/p18cxxx.h" #line 273 "C:/MCC18/h/p18cxxx.h" #line 275 "C:/MCC18/h/p18cxxx.h" #line 277 "C:/MCC18/h/p18cxxx.h" #line 279 "C:/MCC18/h/p18cxxx.h" #line 281 "C:/MCC18/h/p18cxxx.h" #line 283 "C:/MCC18/h/p18cxxx.h" #line 285 "C:/MCC18/h/p18cxxx.h" #line 287 "C:/MCC18/h/p18cxxx.h" #line 289 "C:/MCC18/h/p18cxxx.h" #line 291 "C:/MCC18/h/p18cxxx.h" #line 293 "C:/MCC18/h/p18cxxx.h" #line 295 "C:/MCC18/h/p18cxxx.h" #line 297 "C:/MCC18/h/p18cxxx.h" #line 299 "C:/MCC18/h/p18cxxx.h" #line 301 "C:/MCC18/h/p18cxxx.h" #line 303 "C:/MCC18/h/p18cxxx.h" #line 305 "C:/MCC18/h/p18cxxx.h" #line 307 "C:/MCC18/h/p18cxxx.h" #line 309 "C:/MCC18/h/p18cxxx.h" #line 311 "C:/MCC18/h/p18cxxx.h" #line 313 "C:/MCC18/h/p18cxxx.h" #line 315 "C:/MCC18/h/p18cxxx.h" #line 317 "C:/MCC18/h/p18cxxx.h" #line 319 "C:/MCC18/h/p18cxxx.h" #line 321 "C:/MCC18/h/p18cxxx.h" #line 323 "C:/MCC18/h/p18cxxx.h" #line 325 "C:/MCC18/h/p18cxxx.h" #line 327 "C:/MCC18/h/p18cxxx.h" #line 329 "C:/MCC18/h/p18cxxx.h" #line 331 "C:/MCC18/h/p18cxxx.h" #line 333 "C:/MCC18/h/p18cxxx.h" #line 335 "C:/MCC18/h/p18cxxx.h" #line 337 "C:/MCC18/h/p18cxxx.h" #line 339 "C:/MCC18/h/p18cxxx.h" #line 341 "C:/MCC18/h/p18cxxx.h" #line 343 "C:/MCC18/h/p18cxxx.h" #line 345 "C:/MCC18/h/p18cxxx.h" #line 347 "C:/MCC18/h/p18cxxx.h" #line 349 "C:/MCC18/h/p18cxxx.h" #line 351 "C:/MCC18/h/p18cxxx.h" #line 353 "C:/MCC18/h/p18cxxx.h" #line 355 "C:/MCC18/h/p18cxxx.h" #line 357 "C:/MCC18/h/p18cxxx.h" #line 359 "C:/MCC18/h/p18cxxx.h" #line 361 "C:/MCC18/h/p18cxxx.h" #line 363 "C:/MCC18/h/p18cxxx.h" #line 2027 "usbAll.c" #pragma udata byte usbgen_rx_len; #pragma code #line 2062 "usbAll.c" void USBGenInitEP(void) { usbgen_rx_len = 0; UEP1 = 0x0E |0x10 ; #line 2079 "usbAll.c" ep1Bo .Cnt = sizeof(usbgen_out); ep1Bo .ADR = (byte*)&usbgen_out; ep1Bo .Stat._byte = 0x80 |0x00 |0x08 ; ep1Bi .ADR = (byte*)&usbgen_in; ep1Bi .Stat._byte = 0x00 |0x40 ; } #line 2118 "usbAll.c" void USBGenWrite(byte *buffer, byte len) { byte i; #line 2126 "usbAll.c" if(len > 64 ) len = 64 ; #line 2132 "usbAll.c" for (i = 0; i < len; i++) usbgen_in[i] = buffer[i]; ep1Bi .Cnt = len; { ep1Bi .Stat._byte &= 0x40 ; ep1Bi .Stat.DTS = !ep1Bi .Stat.DTS; ep1Bi .Stat._byte |= 0x80 |0x08 ; } ; } #line 2173 "usbAll.c" byte USBGenRead(byte *buffer, byte len) { usbgen_rx_len = 0; if(!ep1Bo .Stat.UOWN ) { #line 2183 "usbAll.c" if(len > ep1Bo .Cnt) len = ep1Bo .Cnt; #line 2189 "usbAll.c" for(usbgen_rx_len = 0; usbgen_rx_len < len; usbgen_rx_len++) buffer[usbgen_rx_len] = usbgen_out[usbgen_rx_len]; #line 2195 "usbAll.c" ep1Bo .Cnt = sizeof(usbgen_out); { ep1Bo .Stat._byte &= 0x40 ; ep1Bo .Stat.DTS = !ep1Bo .Stat.DTS; ep1Bo .Stat._byte |= 0x80 |0x08 ; } ; } return usbgen_rx_len; } #line 2205 "usbAll.c" #line 2241 "usbAll.c" #line 2355 "usbAll.c" #pragma udata byte usb_device_state; USB_DEVICE_STATUS usb_stat; byte usb_active_cfg; byte usb_alt_intf[1 ]; #pragma udata usbram4=0x400 #line 2377 "usbAll.c" #line 2380 "usbAll.c" volatile far BDT ep0Bo; volatile far BDT ep0Bi; #line 2383 "usbAll.c" #line 2385 "usbAll.c" volatile far BDT ep1Bo; volatile far BDT ep1Bi; #line 2388 "usbAll.c" #line 2390 "usbAll.c" volatile far BDT ep2Bo; volatile far BDT ep2Bi; #line 2393 "usbAll.c" #line 2395 "usbAll.c" #line 2398 "usbAll.c" #line 2400 "usbAll.c" #line 2403 "usbAll.c" #line 2405 "usbAll.c" #line 2408 "usbAll.c" #line 2410 "usbAll.c" #line 2413 "usbAll.c" #line 2415 "usbAll.c" #line 2418 "usbAll.c" #line 2420 "usbAll.c" #line 2423 "usbAll.c" #line 2425 "usbAll.c" #line 2428 "usbAll.c" #line 2430 "usbAll.c" #line 2433 "usbAll.c" #line 2435 "usbAll.c" #line 2438 "usbAll.c" #line 2440 "usbAll.c" #line 2443 "usbAll.c" #line 2445 "usbAll.c" #line 2448 "usbAll.c" #line 2450 "usbAll.c" #line 2453 "usbAll.c" #line 2455 "usbAll.c" #line 2458 "usbAll.c" #line 2473 "usbAll.c" volatile far CTRL_TRF_SETUP SetupPkt; volatile far CTRL_TRF_DATA CtrlTrfData; #line 2481 "usbAll.c" volatile far byte usbgen_out[64 ]; volatile far byte usbgen_in[64 ]; #pragma udata