+
+
+
+
diff --git a/Source/CAN/CAN_USB4.HEX b/Source/CAN/CAN_USB4.HEX
new file mode 100644
index 0000000..88a040a
--- /dev/null
+++ b/Source/CAN/CAN_USB4.HEX
@@ -0,0 +1,60 @@
+:020000040000FA
+:06000000000017EF05F0FF
+:0400080020EF04F0F1
+:040018003EEF04F0C3
+:10084000000077BE03D077BA01D006D06F88779AC0
+:10085000779E769A779E11000F0177A009D0779046
+:100860007798108776900E017F87768800011100B7
+:1008700077980E017F97000176801100100071BEFD
+:1008800003D081B070D0FBD76F500F0B0C6E72503D
+:10089000F00B0C10726E0D0E126E0FEE61F010EE7A
+:1008A00061F0EECFE6FF122EFCD7609E00EE61F005
+:1008B00011EE00F03A0EE66E62B703D0530EE66E0C
+:1008C00002D0580EE66EEE508DEC05F07EC0E6FFCD
+:1008D0007FC0E6FFEE508DEC05F07EC0E6FF7FC0E6
+:1008E000E6FF62B703D0E92AE92A0ED0EE508DEC7C
+:1008F00005F07EC0E6FF7FC0E6FFEE508DEC05F010
+:100900007EC0E6FF7FC0E6FFEECF89F089BD03D051
+:100910004E0EE66E03D0520EE66E899D896701D0B9
+:1009200009D0EE508DEC05F07EC0E6FF7FC0E6FFFB
+:10093000892FF7D73B0EE66EE150136E11EE00F0F3
+:10094000000E946E81B2FED7818A81A2FDD7E6CFD8
+:1009500082FF00000000819A00000000132EF2D7F1
+:10096000FF0E946E8CD7866BFF0E946E81A05CD0C8
+:10097000818881B0FED7000081983A0E825C54E1F4
+:1009800081A0FED7818881B0FED700008198530EE8
+:10099000825C04E0580E825C03E046D0869701D06A
+:1009A0008687886B20EE18F081A0FED7818881B001
+:1009B000FED7000081983B0E825C03E082CFDEFF11
+:1009C000F3D782CFDEFF20EE18F010EE6FF0DECF0F
+:1009D0007CF0DECF7DF0A1EC05F0E66E4E0EDF5C24
+:1009E00005E0520EDF5C01E0F2D78685D92AE12AC4
+:1009F00086B702D0E12AE12A3B0EDF5C09E0DECFB8
+:100A00007CF0DECF7DF0A1EC05F0E66E882BF4D70C
+:100A1000885186B54009736F080E86B77013866BD0
+:100A20000A0E146E7AEC05F081983FEF04F0D19035
+:100A30000001F26A0F015D6B5C6B5F6B5E6B5B6963
+:100A40000001200E926E0B0E936E816A8184819854
+:100A5000819AFF0E946EE06A7F6A6F8EB00E726E9E
+:100A6000728A0F01606A306B208D108D0E017D6BD4
+:100A7000806B906BA06BB06BC06BD06B7F97030EDD
+:100A8000436F9E0E446F030E456F0001200E706E83
+:100A90000EEEF8F0EE6AE962FDD7719E719C776AFE
+:100AA0006F6ABB6A9F6AA26AA06A776A756A880ED3
+:100AB0006F6E0F01030E206F106F116B126B156BB1
+:100AC00000016F6A030E6E6F230EA56E9F6AA26A05
+:100AD000A06AF16AF06A9E6AA16A776AB10E786EBE
+:100AE000B10E766E819C818E3FEF04F00F0110876E
+:100AF000000112000F0120B7FED7000100EE6EF0DA
+:100B00001FEE20F0EE50E66E7C0EE962FBD70F017F
+:100B100020B7FED7208700011200816F81390F0BAB
+:100B2000300F7E6F390E7E6502D0070E7E270F0EC6
+:100B30008115300F7F6F390E7F6502D0070E7F273A
+:100B40001200300E7C5F090E7C6502D0070E7C5FC0
+:100B50007C51826F823B300E7D5F090E7D6502D035
+:0A0B6000070E7D5F7D518211120027
+:020000040030CA
+:040000001513661C52
+:020005008981EF
+:060008000FC00FE00F40E5
+:00000001FF
diff --git a/Source/CAN/CAN_USB4.asm b/Source/CAN/CAN_USB4.asm
new file mode 100644
index 0000000..4674c8d
--- /dev/null
+++ b/Source/CAN/CAN_USB4.asm
@@ -0,0 +1,785 @@
+ TITLE "Source for CAN-USB4 interface for CBUS"
+; filename CAN_USB4.asm 15/09/14
+;
+; Uses 4 MHz resonator and PLL for 16 MHz clock
+; This interface does not have a Node Number
+
+
+
+; The setup timer is TMR3. This should not be used for anything else
+; CAN bit rate of 125 Kbits/sec
+; Standard frame only
+; Uses 'Gridconnect' protocol for USB
+; Works with FTDI 245AM for now.
+
+;
+
+; added RUN LED switch on.
+; no full diagnostics yet.
+
+
+; Doesn't use interrupts - for speed.
+; Working at full speed with minimum CAN frames (no data bytes)
+; 390 uSec per frame
+; PC gets all frames 08/05/08
+; Mod so it sends response to RTR (FLiM compatibility)
+; Fixed CAN_ID at 7E to avoid conflict with CAN_RS
+; RTR response removed. Avoids possibility of buffer overflow
+; Allows true sniffer capability for checking self enum. of other modules.
+; FLiM should never have a CAN_ID of 7E
+
+; This version is based on the CAN_USBm code but changed for the 25K80 and
+; for use with the 14K50 as an altenative to Andrew's C code vrsion
+; Incorporates ECAN overflow and busy mechanism as in the CAN_CAN
+; Working with the 14K50 OK. 17/09/14
+
+;
+; Assembly options
+ LIST P=18F25K80,r=hex,N=75,C=120,T=ON
+
+ include "p18f25K80.inc"
+
+ ;definitions Change these to suit hardware.
+
+#DEFINE CDAV 5
+#DEFINE UREQ 4
+#DEFINE CREQ 1
+#DEFINE UDAV 0
+
+;set config registers
+
+ ;config for 18F25K80
+
+ CONFIG FCMEN = OFF, FOSC = HS1, IESO = OFF, PLLCFG = ON
+ CONFIG PWRTEN = ON, BOREN = SBORDIS, BORV=0, SOSCSEL = DIG
+ CONFIG WDTEN = OFF, WDTPS = 128 ;watchdog 512 mSec
+ CONFIG MCLRE = ON, CANMX = PORTB
+ CONFIG BBSIZ = BB1K
+
+ CONFIG XINST = OFF,STVREN = ON,CP0 = OFF
+ CONFIG CP1 = OFF, CPB = OFF, CPD = OFF,WRT0 = OFF,WRT1 = OFF, WRTB = OFF
+ CONFIG WRTC = OFF,WRTD = OFF, EBTR0 = OFF, EBTR1 = OFF, EBTRB = OFF
+
+
+
+; processor uses 4 MHz. Resonator
+
+
+
+
+;****************************************************************
+; define RAM storage
+
+ CBLOCK 0 ;file registers - access bank
+ ;interrupt stack for low priority
+ ;hpint uses fast stack
+ W_tempL
+ St_tempL
+ Bsr_tempL
+ PCH_tempH ;save PCH in hpint
+ PCH_tempL ;save PCH in lpint (if used)
+ Fsr_temp0L
+ Fsr_temp0H
+ Fsr_temp1L
+ Fsr_temp1H
+ Fsr_temp2L
+ Fsr_hold
+ Fsr_holx
+ TempCANCON
+ TempCANSTAT
+ CanID_tmp ;temp for CAN Node ID
+ IDtemph ;used in ID shuffle
+ IDtempl
+
+
+
+ Datmode ;flag for data waiting
+ Count ;counter for loading
+ Count1
+ Latcount ;latency counter
+
+ Temp ;temps
+ Temp1
+ ;the above variables must be in access space (00 to 5F)
+
+ Buffer ;temp buffer in access bank for data
+ RXbuf ;:0x1C USB serial receive packet buffer
+ RXbuf1
+ RXbuf2
+ RXbuf3
+ RXbuf4
+ RXbuf5
+ RXbuf6
+ RXbuf7
+ RXbuf8
+ RXbuf9
+ RXbufA
+ RXbufB
+ RXbufC
+ RXbufD
+ RXbufE
+ RxbufF
+ RXbuf10
+ RXbuf11
+ RXbuf12
+ RXbuf13
+ RXbuf14
+ RXbuf15
+ RXbuf16
+ RXbuf17
+ RXbuf18
+ RXbuf19
+
+
+
+ ENDC ;ends at 5F
+
+
+
+ CBLOCK h'60' ;rest of bank 0
+
+ Rx0con ;start of receive packet 0
+ Rx0sidh
+ Rx0sidl
+ Rx0eidh
+ Rx0eidl
+ Rx0dlc
+ Rx0d0
+ Rx0d1
+ Rx0d2
+ Rx0d3
+ Rx0d4
+ Rx0d5
+ Rx0d6
+ Rx0d7
+
+
+
+ Tx0con ;start of transmit frame 0
+ Tx0sidh
+ Tx0sidl
+ Tx0eidh
+ Tx0eidl
+ Tx0dlc
+ Tx0d0
+ Tx0d1
+ Tx0d2
+ Tx0d3
+ Tx0d4
+ Tx0d5
+ Tx0d6
+ Tx0d7
+
+
+
+
+
+
+
+
+
+
+ ;add variables to suit
+
+ ;****************************************************************
+ ; used in ASCII to HEX and HEX to ASCII and decimal conversions
+ Abyte1 ;first ascii char of a hex byte for ascii input
+ Abyte2 ;second ascii char of a hex byte
+ Hbyte1 ;first ascii char of a hex byte for ascii output
+ Hbyte2
+ Atemp ;temp store
+ Htemp
+ Hexcon ;answer to ascii to hex conversion
+ ;*************************************************************
+ ; used in USB transmit and receive
+ Srbyte_n ;number of serial bytes received in packet
+ Stbyte_n ;number of serial bytes to send
+ TXmode ;state during serial send
+ RXmode ;state during serial receive
+ RXtemp ;temp store for received byte
+ RXnum ;number of chars in receive string
+ Datnum ;no. of data bytes in a received frame
+
+ ;**************************************************************
+
+
+
+ ENDC
+
+ CBLOCK 0x100
+
+ TXbuf ;USB transmit packet buffer to PC
+ TXbuf1
+ TXbuf2
+ TXbuf3
+ TXbuf4
+ TXbuf5
+ TXbuf6
+ TXbuf7
+ TXbuf8
+ TXbuf9
+ TXbuf10
+ TXbuf11
+ TXbuf12
+ TXbuf13
+ TXbuf14
+ TXbuf15
+ TXbuf16
+ TXbuf17
+ Txbuf18
+ TXbuf19
+ TXbuf20
+ TXbuf21
+ TXbuf22
+ TXbuf23
+ TXbuf24
+ TXbuf25
+
+ ENDC
+
+;****************************************************************
+;
+; start of program code
+
+ ORG 0000h
+ nop ;for debug
+ goto setup
+
+ ORG 0008h
+ goto hpint ;high priority interrupt
+
+ ORG 0018h
+ goto lpint ;low priority interrupt
+
+
+;*******************************************************************
+
+ ORG 0840h ;start of program
+;
+;
+; high priority interrupt.
+
+hpint nop
+ btfsc PIR5,IRXIF ;a bus error?
+ bra err
+ btfsc PIR5,ERRIF
+ bra err
+ bra no_err
+err
+ bsf CANCON,ABAT ;abort transmission
+ bcf PIR5,ERRIF ;clear interrupts
+ bcf PIR5,IRXIF
+ bcf PIE5,ERRIF
+
+ bcf PIR5,IRXIF
+
+
+
+ retfie 1
+
+no_err
+ movlb .15
+ btfss PIR5,FIFOWMIF,0
+ bra no_fifo
+ bcf PIR5,FIFOWMIF,0 ;clear FIFO flag
+ bcf PIR5,4,0 ;clear busy frame flag
+ bsf TXB1CON,TXREQ ;send busy frame
+ bcf PIE5,FIFOWMIE,0 ;disable FIFO interrupt
+ movlb .14
+ bsf TXBIE,TXB1IE ;enable IRQ for busy frame sent
+ bsf PIE5,4,0 ;enable IRQ for busy frame sent
+ movlb 0
+ retfie 1
+
+no_fifo bcf PIR5,4,0 ;clear busy frame flag
+ movlb .14
+ bcf TXBIE,TXB1IE ;no busy frame IRQ
+ movlb 0
+ bsf PIE5,FIFOWMIE ;wait for next FIFO IRQ
+
+ retfie 1
+
+
+
+
+
+
+
+
+
+
+
+;**************************************************************
+;
+;
+; low priority interrupt. (if used)
+;
+
+lpint retfie
+
+
+
+
+
+
+;*********************************************************************
+
+
+
+
+main btfsc COMSTAT,7 ;fast loop for CAN detection
+ bra incan
+ btfsc PORTB,UDAV
+ bra inusb
+ bra main
+
+; move incoming CAN frame to serial output buffer
+
+incan movf CANCON,W ;sort out ECAN buffer
+ andlw B'00001111'
+ movwf TempCANCON
+ movf ECANCON,W
+ andlw B'11110000'
+ iorwf TempCANCON,W
+ movwf ECANCON
+ movlw .13
+ movwf Count
+ lfsr FSR0,RXB0SIDH ; ;start of CAN frame in RB0
+ lfsr FSR1,Rx0sidh
+incan1 movff POSTINC0,POSTINC1 ;save ECAN buffer
+ decfsz Count
+ bra incan1
+ bcf RXB0CON,RXFUL
+ lfsr FSR0,Rx0sidh
+ lfsr FSR1,TXbuf ;start of serial string for PC
+ movlw ":" ;serial start
+ movwf POSTINC1
+ btfsc Rx0sidl,3 ;is it extended
+ bra exide
+ movlw "S" ;standard frames only
+ movwf POSTINC1
+ bra serload
+exide movlw "X"
+ movwf POSTINC1
+
+serload movf POSTINC0,W ;get byte
+ call hexasc ;convert to acsii
+ movff Hbyte1,POSTINC1
+ movff Hbyte2,POSTINC1
+ movf POSTINC0,W ;get byte
+ call hexasc ;convert to acsii
+ movff Hbyte1,POSTINC1
+ movff Hbyte2,POSTINC1
+ btfsc Rx0sidl,3 ;is it extended
+ bra exload
+ incf FSR0L ;skip the extended ID bytes
+ incf FSR0L
+ bra serlo1
+exload movf POSTINC0,W ;get byte
+ call hexasc ;convert to acsii
+ movff Hbyte1,POSTINC1
+ movff Hbyte2,POSTINC1
+ movf POSTINC0,W ;get byte
+ call hexasc ;convert to acsii
+ movff Hbyte1,POSTINC1
+ movff Hbyte2,POSTINC1
+serlo1 movff POSTINC0,Datnum ;get dlc byte
+ btfsc Datnum,6 ;is it an RTR
+ bra rtrset
+ movlw "N"
+ movwf POSTINC1
+ bra datbyte
+rtrset movlw "R"
+ movwf POSTINC1
+ bcf Datnum,6 ;Datnum now has just the number
+datbyte tstfsz Datnum
+ bra datload
+ bra back2
+datload movf POSTINC0,W ;get byte
+ call hexasc ;convert to acsii
+ movff Hbyte1,POSTINC1
+ movff Hbyte2,POSTINC1
+ decfsz Datnum
+ bra datload
+back2 movlw ";"
+ movwf POSTINC1
+ movf FSR1L,W ;get last
+ movwf Count1 ;number of bytes to send
+
+
+ lfsr FSR1,TXbuf
+
+
+ ;set to output
+
+
+usbwr movlw B'00000000'
+ movwf TRISC
+
+
+notwr1 btfsc PORTB,CREQ ;CREQ must be lo to write to USB initially
+ bra notwr1
+
+
+notwr bsf PORTB,CDAV
+ btfss PORTB,CREQ ;CREQ must be hi to write to USB
+ bra notwr
+ movff POSTINC1,PORTC ;output byte
+ nop ;settling time
+ nop
+
+ bcf PORTB,CDAV ;flag to USB
+ nop
+ nop
+
+ decfsz Count1
+ bra notwr1
+ movlw B'11111111'
+ movwf TRISC ;back to inputs
+
+
+
+endwr bra main
+
+inusb clrf RXmode ;clear receive mode flags
+ movlw B'11111111'
+ movwf TRISC ;set to input
+ btfss PORTB,UDAV ;any USB data?
+ bra notin ;loop
+
+ bsf PORTB,UREQ ;can take
+inusb1 btfsc PORTB,UDAV ;is data
+ bra inusb1
+ nop
+ bcf PORTB,UREQ
+
+ movlw ":"
+ subwf PORTC,W
+ bnz notin ;not start of frame
+
+inusb2 btfss PORTB,UDAV ;is data
+ bra inusb2
+ bsf PORTB,UREQ
+inusb3 btfsc PORTB,UDAV
+ bra inusb3
+ nop
+ bcf PORTB,UREQ
+
+ movlw "S" ;is it S (standard) or X (extended)
+ subwf PORTC,W
+ bz instd
+ movlw "X"
+ subwf PORTC,W
+ bz inext
+ bra notin ;neither so abort
+instd bcf RXmode,3 ;flag standard
+ bra instart
+inext bsf RXmode,3 ;flag extended
+instart clrf RXnum ;byte counter
+ lfsr FSR2,RXbuf ;set to start
+
+
+inloop btfss PORTB,UDAV ;read all USB till end
+ bra inloop
+ bsf PORTB,UREQ ;can take
+inloop1 btfsc PORTB,UDAV ;data?
+ bra inloop1
+ nop
+ bcf PORTB,UREQ
+
+
+ movlw ";" ;end?
+ subwf PORTC,W
+ bz lastin
+ movff PORTC,POSTINC2 ;bug fix
+ bra inloop
+
+lastin movff PORTC,POSTINC2
+
+
+ lfsr FSR2,RXbuf ;point to serial receive buffer
+ lfsr FSR1,Tx0sidh ;point to CAN TX buffer 1 - lowest priority
+txload movff POSTINC2,Abyte1
+ movff POSTINC2,Abyte2
+ call aschex
+ movwf POSTINC1 ;put in CAN TX buffer
+ movlw "N"
+ subwf INDF2,W
+ bz txload1
+ movlw "R"
+ subwf INDF2,W
+ bz txload5
+ bra txload
+txload5 bsf RXmode,2 ;flag R
+txload1 incf FSR2L ;miss N or R
+ incf FSR1L ;miss dlc
+ btfsc RXmode,3 ;is it ext
+ bra txload2
+ incf FSR1L ;miss out EIDH and EIDL if not extended
+ incf FSR1L
+
+txload2 movlw ";"
+ subwf INDF2,W
+ bz txdone
+
+
+
+txload4 movff POSTINC2,Abyte1
+ movff POSTINC2,Abyte2
+ call aschex
+ movwf POSTINC1 ;put in CAN TX buffer
+ incf RXnum,F
+ bra txload2
+txdone movf RXnum,W ;get number of data bytes
+ btfsc RXmode,2 ;is it a RTR
+ iorlw B'01000000' ;set RTR bit
+ movwf Tx0dlc
+ movlw B'00001000'
+ btfsc RXmode,3 ;extended?
+ iorwf Tx0sidl,F ;add extended bit
+ clrf RXmode ;ready for next
+ movlw .10
+ movwf Latcount ;ten tries at low priority
+ call sendTX0
+
+notin bcf PORTB,UREQ ;clear
+
+ goto main
+
+
+
+
+
+
+;***************************************************************************
+; main setup routine
+;*************************************************************************
+
+setup bcf WDTCON,SWDTEN ;WDT off during reset
+ movlb 0
+ clrf INTCON ;no interrupts yet
+
+ movlb .15
+
+ clrf ANCON0 ;disable A/D
+ clrf ANCON1
+ clrf CM1CON
+ clrf CM2CON
+ setf WPUB ;pullups set
+ movlb 0
+
+
+ ;port settings will be hardware dependent. RB2 and RB3 are for CAN.
+ ;set S_PORT and S_BIT to correspond to port used for setup.
+ ;rest are hardware options
+
+
+ movlw B'00100000' ;Port A outputs except reset pin
+ movwf TRISA ;
+ movlw B'00001011' ;RB0 is UDAV, RB1 is CREQ, RB2 = CANTX, RB3 = CANRX, RB4 = UREQ, RB5 = CDAV
+ ;RB6,7 for debug and ICSP and diagnostic LEDs
+ movwf TRISB
+ clrf PORTB
+ bsf PORTB,2 ;CAN recessive
+ bcf PORTB,4 ;USB write strobe
+ bcf PORTB,5 ;USB read strobe
+ movlw B'11111111' ;Port C USB interface
+ movwf TRISC
+
+; next segment is essential.
+
+ clrf BSR ;set to bank 0
+ clrf EECON1 ;no accesses to program memory
+ bsf CANCON,7 ;CAN to config mode
+ movlw B'10110000'
+ movwf ECANCON ;CAN mode 2
+ bsf ECANCON,5
+
+ movlb .15
+
+ clrf RXB0CON
+ clrf RXB1CON
+ bsf TXB0CON,TXABT ;abort any pending messages
+ bsf TXB1CON,TXABT
+
+
+ movlb .14
+
+ clrf BSEL0 ;8 frame FIFO
+ clrf B0CON
+ clrf B1CON
+ clrf B2CON
+ clrf B3CON
+ clrf B4CON
+ clrf B5CON
+ bcf TXBIE,TXB1IE ;no interrupt on busy
+
+
+
+ movlw B'00000011' ;set CAN bit rate at 125000 for now. 4 MHz
+ movwf BRGCON1
+ movlw B'10011110' ;set phase 1 etc
+ movwf BRGCON2
+ movlw B'00000011' ;set phase 2 etc
+ movwf BRGCON3
+ movlb 0
+
+ movlw B'00100000'
+ movwf CIOCON ;CAN to high when off
+
+
+mskload lfsr FSR0,RXM0SIDH ;Clear masks, point to start
+mskloop clrf POSTINC0
+ cpfseq FSR0L
+ bra mskloop
+
+ bcf COMSTAT,RXB0OVFL ;clear overflow flags if set
+ bcf COMSTAT,RXB1OVFL
+ clrf PIR5 ;clear all flags
+ clrf CANCON ;out of CAN setup mode
+ clrf CCP1CON
+
+ clrf IPR1 ;all peripheral interrupts are low priority
+ clrf IPR2
+ clrf PIE2
+ clrf PIR5 ;can FLAGS
+ clrf EEADRH ;clear EEPROM Hi byte
+
+
+
+ movlw B'10001000' ;Config TX1 buffer for busy frame
+ movwf CANCON
+ movlb .15 ;buffer in bank 15
+ movlw B'00000011'
+ movwf TXB0CON ;no send yet
+ movwf TXB1CON
+ clrf TXB1SIDH
+ clrf TXB1SIDL
+ clrf TXB1DLC
+ movlb 0 ;back to bank 0
+ clrf CANCON ;out of CAN setup mode
+
+ movlw 3
+ movwf Tx0con ;set transmit priority
+
+ movlw B'00100011'
+ movwf IPR3 ;high priority CAN RX and Tx error interrupts(for now)
+ clrf IPR1 ;all peripheral interrupts are low priority
+ clrf IPR2
+ clrf PIE2
+
+ clrf INTCON2 ;
+ clrf INTCON3 ;
+
+ clrf PIR1
+ clrf PIR2
+
+ clrf PIR5
+ movlw B'10110001'
+ movwf IPR5 ;FIFOHWM and TXB are high priority
+ movlw B'10110001'
+ movwf PIE5 ;FIFOHWM IRQ, error interrupts and TX complete only
+
+ bcf PORTB,6
+ bsf PORTB,7 ;put run LED on.
+ goto main
+
+
+
+;****************************************************************************
+; start of subroutines
+
+;*****************************************************************************
+; send a busy frame - already preloaded in TX0.
+
+sendTX1 movlb .15 ;set to bank 1
+ bsf TXB1CON,TXREQ ;send immediately
+ movlb 0 ;back to bank 0
+ return
+;******************************************************************
+
+; Send contents of Tx1 buffer via CAN TXB1
+
+sendTX0 movlb .15 ;check for buffer access
+tx_loop btfsc TXB0CON,TXREQ
+ bra tx_loop
+ movlb 0
+
+ lfsr FSR0,Tx0con
+ lfsr FSR1,TXB0CON
+ldTX0 movf POSTINC0,W
+ movwf POSTINC1 ;load TXB1
+ movlw Tx0d7+1
+ cpfseq FSR0L
+ bra ldTX0
+
+
+ movlb .15 ;bank 15
+tx0test btfsc TXB0CON,TXREQ ;test if clear to send
+ bra tx0test
+ bsf TXB0CON,TXREQ ;OK so send
+
+tx1done movlb 0 ;bank 0
+ return ;successful send
+
+
+
+;************************************************************************
+
+
+; converts one hex byte to two ascii bytes
+
+hexasc movwf Htemp ;save hex. comes in W
+ swapf Htemp,W
+ andlw B'00001111' ;mask
+ addlw 30h
+ movwf Hbyte1
+ movlw 39h
+ cpfsgt Hbyte1
+ bra nxtnib
+ movlw 7
+ addwf Hbyte1,F
+nxtnib movlw B'00001111'
+ andwf Htemp,W
+ addlw 30h
+ movwf Hbyte2
+ movlw 39h
+ cpfsgt Hbyte2
+ bra ascend
+ movlw 7
+ addwf Hbyte2,F
+ascend return ;Hbyte1 has high nibble, Hbyte2 has low nibble
+
+
+;****************************************************************************
+; converts two ascii bytes to one hex byte.
+; for consistency, ascii hi byte in Abyte1, ascii low byte in Abyte2
+; answer in Hexcon
+
+aschex movlw 30h
+ subwf Abyte1,F
+ movlw 9
+ cpfsgt Abyte1
+ bra hinib
+ movlw 7
+ subwf Abyte1,F
+hinib movf Abyte1,W
+ movwf Hexcon
+ swapf Hexcon,F
+ movlw 30h
+ subwf Abyte2,F
+ movlw 9
+ cpfsgt Abyte2
+ bra hexend
+ movlw 7
+ subwf Abyte2,F
+hexend movf Abyte2,W
+ iorwf Hexcon,W
+ return
+
+;
+
+
+;************************************************************************
+
+ end
diff --git a/Source/USB/HardwareProfile.h b/Source/USB/HardwareProfile.h
new file mode 100644
index 0000000..d8160f1
--- /dev/null
+++ b/Source/USB/HardwareProfile.h
@@ -0,0 +1,113 @@
+/*------------------------------------------------------------------------------
+; PICFT245
+;
+; FTDI FT245 replacement in a POC18F14K50 (C) SPROG DCC 2012
+; web: http://www.sprog-dcc.co.uk
+; e-mail: sprog@sprog-dcc.co.uk
+;-----------------------------------------------------------------------------*/
+
+#ifndef HARDWARE_PROFILE_H
+#define HARDWARE_PROFILE_H
+
+/*
+ 18F14K50 MERG CAN USB 4 pinout
+
+ |----------------------------|
+ Power |1 Vdd VSS 20| Power
+ Xtal |2 RA5/OSC1 D+/RA0 19| USB
+ Xtal |3 RA4/OSC2 D-/RA1 18| USB
+ MCLR |4 RA3/MCLR VUSB 17| USB
+ D5 |5 RC5/CCP1 AN4/RC0 16| D0
+ D4 |6 RC4/P1B AN5/RC1 15| D1
+ D3 |7 RC3/AN7 AN6/RC2 14| D2
+ D6 |8 RC6/AN8 AN10/RB4 13| UDAV
+ D7 |9 RC7/AN9 RX/AN11/RB5 12| CREQ
+ CDAV |10 RB7/TX RB6 11| UREQ
+ |----------------------------|
+*/
+
+//
+// Port C
+#define DATA_PORT PORTC
+#define DATA_PORTbits PORTCbits
+
+// Default to inputs
+#define PORTC_DDR 0b11111111
+#define PORTC_INIT 0b00000000
+
+//
+// Port B
+//
+#define UDAV RB4 //
+#define CREQ RB5 //
+#define UREQ RB6 //
+#define CDAV RB7 //
+
+//
+#define PORTB_DDR 0b11000000
+#define PORTB_INIT 0b00000000
+
+//
+// Port A
+//
+// USB D+ RA0 // reserved
+// USB D- RA1 // reserved
+// [VUSB] RA2 // reserved
+// MCLR RA3 // reserved
+// OSC2 RA4 // reserved
+// OSC1 RA5 // reserved
+
+#define PORTA_DDR 0xFF
+#define PORTA_INIT 0x00
+
+//
+// From low pin count hardware profile
+//
+ /*******************************************************************/
+ /******** USB stack hardware selection options *********************/
+ /*******************************************************************/
+ //This section is the set of definitions required by the MCHPFSUSB
+ // framework. These definitions tell the firmware what mode it is
+ // running in, and where it can find the results to some information
+ // that the stack needs.
+ //These definitions are required by every application developed with
+ // this revision of the MCHPFSUSB framework. Please review each
+ // option carefully and determine which options are desired/required
+ // for your application.
+
+ #define self_power 1
+
+ #define USB_BUS_SENSE 1
+
+ /*******************************************************************/
+ /******** Application specific definitions *************************/
+ /*******************************************************************/
+
+ /** Board definition ***********************************************/
+ //These defintions will tell the main() function which board is
+ // currently selected. This will allow the application to add
+ // the correct configuration bits as wells use the correct
+ // initialization functions for the board. These defitions are only
+ // required in the stack provided demos. They are not required in
+ // final application design.
+
+ #define CLOCK_FREQ 48000000
+ #define GetSystemClock() CLOCK_FREQ
+
+ /** LED ************************************************************/
+ #define mLED_1
+ #define mLED_2
+
+ #define mGetLED_1()
+ #define mGetLED_2()
+
+ #define mLED_1_On()
+ #define mLED_2_On()
+
+ #define mLED_1_Off()
+ #define mLED_2_Off()
+
+ #define mLED_1_Toggle()
+ #define mLED_2_Toggle()
+
+#endif //HARDWARE_PROFILE_H
diff --git a/Source/USB/USB2.9i_cdc/USB/CDC Device Driver/usb_function_cdc.c b/Source/USB/USB2.9i_cdc/USB/CDC Device Driver/usb_function_cdc.c
new file mode 100644
index 0000000..0cb3cac
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/USB/CDC Device Driver/usb_function_cdc.c
@@ -0,0 +1,1055 @@
+/********************************************************************************
+ File Information:
+ FileName: usb_function_cdc.c
+ Dependencies: See INCLUDES section
+ Processor: PIC18 or PIC24 USB Microcontrollers
+ Hardware: The code is natively intended to be used on the following
+ hardware platforms: PICDEM(TM) FS USB Demo Board,
+ PIC18F87J50 FS USB Plug-In Module, or
+ Explorer 16 + PIC24 USB PIM. The firmware may be
+ modified for use on other USB platforms by editing the
+ HardwareProfile.h file.
+ Complier: Microchip C18 (for PIC18) or C30 (for PIC24)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the "Company") for its PIC(R) Microcontroller is intended and
+ supplied to you, the Company's customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+ Summary:
+ This file contains all of functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the CDC function
+ driver. This file should be included in projects that use the CDC
+ \function driver.
+
+
+
+ This file is located in the "\\\Microchip\\USB\\CDC
+ Device Driver" directory.
+ Description:
+ USB CDC Function Driver File
+
+ This file contains all of functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the CDC function
+ driver. This file should be included in projects that use the CDC
+ \function driver.
+
+ This file is located in the "\\\Microchip\\USB\\CDC
+ Device Driver" directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ ..\\Include
+
+ .
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+ ********************************************************************************/
+
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.3 Decricated the mUSBUSARTIsTxTrfReady() macro. It is
+ replaced by the USBUSARTIsTxTrfReady() function.
+
+ 2.6 Minor definition changes
+
+ 2.6a No Changes
+
+ 2.7 Fixed error in the part support list of the variables section
+ where the address of the CDC variables are defined. The
+ PIC18F2553 was incorrectly named PIC18F2453 and the PIC18F4558
+ was incorrectly named PIC18F4458.
+
+ http://www.microchip.com/forums/fb.aspx?m=487397
+
+ 2.8 Minor change to CDCInitEP() to enhance ruggedness in
+ multithreaded usage scenarios.
+
+ 2.9b Updated to implement optional support for DTS reporting.
+
+********************************************************************/
+
+/** I N C L U D E S **********************************************************/
+#include "USB/usb.h"
+#include "USB/usb_function_cdc.h"
+#include "HardwareProfile.h"
+
+#ifdef USB_USE_CDC
+
+/** V A R I A B L E S ********************************************************/
+#if defined(__18CXX)
+ //The cdc_data_rx[] and cdc_data_tx[] arrays and associated variables are used
+ //as USB packet buffers in this firmware. Therefore, they must be located in
+ //a USB module accessible portion of microcontroller RAM.
+ #if defined(__18F14K50) || defined(__18F13K50) || defined(__18LF14K50) || defined(__18LF13K50)
+ #pragma udata usbram2
+ #elif defined(__18F2455) || defined(__18F2550) || defined(__18F4455) || defined(__18F4550)\
+ || defined(__18F2458) || defined(__18F2553) || defined(__18F4458) || defined(__18F4553)\
+ || defined(__18LF24K50) || defined(__18F24K50) || defined(__18LF25K50)\
+ || defined(__18F25K50) || defined(__18LF45K50) || defined(__18F45K50)
+ #pragma udata USB_VARIABLES=0x500
+ #elif defined(__18F4450) || defined(__18F2450)
+ #pragma udata USB_VARIABLES=0x480
+ #else
+ #pragma udata
+ #endif
+#endif
+
+#if defined(__XC8)
+ #if defined(_18F14K50) || defined(_18F13K50) || defined(_18LF14K50) || defined(_18LF13K50)
+ #define IN_DATA_BUFFER_ADDRESS 0x260
+ #define OUT_DATA_BUFFER_ADDRESS (IN_DATA_BUFFER_ADDRESS + CDC_DATA_IN_EP_SIZE)
+ #define LINE_CODING_ADDRESS (OUT_DATA_BUFFER_ADDRESS + CDC_DATA_OUT_EP_SIZE)
+ #define NOTICE_ADDRESS (LINE_CODING_ADDRESS + LINE_CODING_LENGTH)
+
+ #define IN_DATA_BUFFER_ADDRESS_TAG @IN_DATA_BUFFER_ADDRESS
+ #define OUT_DATA_BUFFER_ADDRESS_TAG @OUT_DATA_BUFFER_ADDRESS
+ #define LINE_CODING_ADDRESS_TAG @LINE_CODING_ADDRESS
+ #define NOTICE_ADDRESS_TAG @NOTICE_ADDRESS
+ #elif defined(_18F2455) || defined(_18F2550) || defined(_18F4455) || defined(_18F4550)\
+ || defined(_18F2458) || defined(_18F2453) || defined(_18F4558) || defined(_18F4553)\
+ || defined(_18LF24K50) || defined(_18F24K50) || defined(_18LF25K50)\
+ || defined(_18F25K50) || defined(_18LF45K50) || defined(_18F45K50)
+ #define IN_DATA_BUFFER_ADDRESS 0x500
+ #define OUT_DATA_BUFFER_ADDRESS (IN_DATA_BUFFER_ADDRESS + CDC_DATA_IN_EP_SIZE)
+ #define LINE_CODING_ADDRESS (OUT_DATA_BUFFER_ADDRESS + CDC_DATA_OUT_EP_SIZE)
+ #define NOTICE_ADDRESS (LINE_CODING_ADDRESS + LINE_CODING_LENGTH)
+
+ #define IN_DATA_BUFFER_ADDRESS_TAG @IN_DATA_BUFFER_ADDRESS
+ #define OUT_DATA_BUFFER_ADDRESS_TAG @OUT_DATA_BUFFER_ADDRESS
+ #define LINE_CODING_ADDRESS_TAG @LINE_CODING_ADDRESS
+ #define NOTICE_ADDRESS_TAG @NOTICE_ADDRESS
+ #elif defined(_18F4450) || defined(_18F2450)
+ #define IN_DATA_BUFFER_ADDRESS 0x480
+ #define OUT_DATA_BUFFER_ADDRESS (IN_DATA_BUFFER_ADDRESS + CDC_DATA_IN_EP_SIZE)
+ #define LINE_CODING_ADDRESS (OUT_DATA_BUFFER_ADDRESS + CDC_DATA_OUT_EP_SIZE)
+ #define NOTICE_ADDRESS (LINE_CODING_ADDRESS + LINE_CODING_LENGTH)
+
+ #define IN_DATA_BUFFER_ADDRESS_TAG @IN_DATA_BUFFER_ADDRESS
+ #define OUT_DATA_BUFFER_ADDRESS_TAG @OUT_DATA_BUFFER_ADDRESS
+ #define LINE_CODING_ADDRESS_TAG @LINE_CODING_ADDRESS
+ #define NOTICE_ADDRESS_TAG @NOTICE_ADDRESS
+ #elif defined(_16F1459) || defined(_16LF1459) || defined(_16F1454) || defined(_16LF1454) || defined(_16F1455) || defined(_16LF1455)
+ #define IN_DATA_BUFFER_ADDRESS 0x2140
+ #define OUT_DATA_BUFFER_ADDRESS 0x2190
+ #define LINE_CODING_ADDRESS 0x20A0
+ #define NOTICE_ADDRESS (LINE_CODING_ADDRESS + LINE_CODING_LENGTH)
+
+ #define IN_DATA_BUFFER_ADDRESS_TAG @IN_DATA_BUFFER_ADDRESS
+ #define OUT_DATA_BUFFER_ADDRESS_TAG @OUT_DATA_BUFFER_ADDRESS
+ #define LINE_CODING_ADDRESS_TAG @LINE_CODING_ADDRESS
+ #define NOTICE_ADDRESS_TAG @NOTICE_ADDRESS
+ #else
+ #define IN_DATA_BUFFER_ADDRESS_TAG
+ #define OUT_DATA_BUFFER_ADDRESS_TAG
+ #define LINE_CODING_ADDRESS_TAG
+ #define NOTICE_ADDRESS_TAG
+ #endif
+#else
+ #define IN_DATA_BUFFER_ADDRESS_TAG
+ #define OUT_DATA_BUFFER_ADDRESS_TAG
+ #define LINE_CODING_ADDRESS_TAG
+ #define NOTICE_ADDRESS_TAG
+#endif
+
+volatile FAR unsigned char cdc_data_tx[CDC_DATA_IN_EP_SIZE] IN_DATA_BUFFER_ADDRESS_TAG;
+volatile FAR unsigned char cdc_data_rx[CDC_DATA_OUT_EP_SIZE] OUT_DATA_BUFFER_ADDRESS_TAG;
+
+LINE_CODING line_coding LINE_CODING_ADDRESS_TAG; // Buffer to store line coding information
+volatile FAR CDC_NOTICE cdc_notice NOTICE_ADDRESS_TAG;
+
+#if defined(USB_CDC_SUPPORT_DSR_REPORTING)
+ SERIAL_STATE_NOTIFICATION SerialStatePacket;
+#endif
+
+#if defined(__18CXX)
+ #pragma udata
+#endif
+
+BYTE cdc_rx_len; // total rx length
+
+BYTE cdc_trf_state; // States are defined cdc.h
+POINTER pCDCSrc; // Dedicated source pointer
+POINTER pCDCDst; // Dedicated destination pointer
+BYTE cdc_tx_len; // total tx length
+BYTE cdc_mem_type; // _ROM, _RAM
+
+USB_HANDLE CDCDataOutHandle;
+USB_HANDLE CDCDataInHandle;
+
+
+CONTROL_SIGNAL_BITMAP control_signal_bitmap;
+DWORD BaudRateGen; // BRG value calculated from baudrate
+
+#if defined(USB_CDC_SUPPORT_DSR_REPORTING)
+ BM_SERIAL_STATE SerialStateBitmap;
+ BM_SERIAL_STATE OldSerialStateBitmap;
+ USB_HANDLE CDCNotificationInHandle;
+#endif
+
+/**************************************************************************
+ SEND_ENCAPSULATED_COMMAND and GET_ENCAPSULATED_RESPONSE are required
+ requests according to the CDC specification.
+ However, it is not really being used here, therefore a dummy buffer is
+ used for conformance.
+ **************************************************************************/
+#define dummy_length 0x08
+BYTE_VAL dummy_encapsulated_cmd_response[dummy_length];
+
+#if defined(USB_CDC_SET_LINE_CODING_HANDLER)
+CTRL_TRF_RETURN USB_CDC_SET_LINE_CODING_HANDLER(CTRL_TRF_PARAMS);
+#endif
+
+/** P R I V A T E P R O T O T Y P E S ***************************************/
+void USBCDCSetLineCoding(void);
+
+/** D E C L A R A T I O N S **************************************************/
+//#pragma code
+
+/** C L A S S S P E C I F I C R E Q ****************************************/
+/******************************************************************************
+ Function:
+ void USBCheckCDCRequest(void)
+
+ Description:
+ This routine checks the most recently received SETUP data packet to
+ see if the request is specific to the CDC class. If the request was
+ a CDC specific request, this function will take care of handling the
+ request and responding appropriately.
+
+ PreCondition:
+ This function should only be called after a control transfer SETUP
+ packet has arrived from the host.
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ This function does not change status or do anything if the SETUP packet
+ did not contain a CDC class specific request.
+ *****************************************************************************/
+void USBCheckCDCRequest(void)
+{
+ /*
+ * If request recipient is not an interface then return
+ */
+ if(SetupPkt.Recipient != USB_SETUP_RECIPIENT_INTERFACE_BITFIELD) return;
+
+ /*
+ * If request type is not class-specific then return
+ */
+ if(SetupPkt.RequestType != USB_SETUP_TYPE_CLASS_BITFIELD) return;
+
+ /*
+ * Interface ID must match interface numbers associated with
+ * CDC class, else return
+ */
+ if((SetupPkt.bIntfID != CDC_COMM_INTF_ID)&&
+ (SetupPkt.bIntfID != CDC_DATA_INTF_ID)) return;
+
+ switch(SetupPkt.bRequest)
+ {
+ //****** These commands are required ******//
+ case SEND_ENCAPSULATED_COMMAND:
+ //send the packet
+ inPipes[0].pSrc.bRam = (BYTE*)&dummy_encapsulated_cmd_response;
+ inPipes[0].wCount.Val = dummy_length;
+ inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM;
+ inPipes[0].info.bits.busy = 1;
+ break;
+ case GET_ENCAPSULATED_RESPONSE:
+ // Populate dummy_encapsulated_cmd_response first.
+ inPipes[0].pSrc.bRam = (BYTE*)&dummy_encapsulated_cmd_response;
+ inPipes[0].info.bits.busy = 1;
+ break;
+ //****** End of required commands ******//
+
+ #if defined(USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1)
+ case SET_LINE_CODING:
+ outPipes[0].wCount.Val = SetupPkt.wLength;
+ outPipes[0].pDst.bRam = (BYTE*)LINE_CODING_TARGET;
+ outPipes[0].pFunc = LINE_CODING_PFUNC;
+ outPipes[0].info.bits.busy = 1;
+ break;
+
+ case GET_LINE_CODING:
+ USBEP0SendRAMPtr(
+ (BYTE*)&line_coding,
+ LINE_CODING_LENGTH,
+ USB_EP0_INCLUDE_ZERO);
+ break;
+
+ case SET_CONTROL_LINE_STATE:
+ control_signal_bitmap._byte = (BYTE)SetupPkt.W_Value.v[0];
+ //------------------------------------------------------------------
+ //One way to control the RTS pin is to allow the USB host to decide the value
+ //that should be output on the RTS pin. Although RTS and CTS pin functions
+ //are technically intended for UART hardware based flow control, some legacy
+ //UART devices use the RTS pin like a "general purpose" output pin
+ //from the PC host. In this usage model, the RTS pin is not related
+ //to flow control for RX/TX.
+ //In this scenario, the USB host would want to be able to control the RTS
+ //pin, and the below line of code should be uncommented.
+ //However, if the intention is to implement true RTS/CTS flow control
+ //for the RX/TX pair, then this application firmware should override
+ //the USB host's setting for RTS, and instead generate a real RTS signal,
+ //based on the amount of remaining buffer space available for the
+ //actual hardware UART of this microcontroller. In this case, the
+ //below code should be left commented out, but instead RTS should be
+ //controlled in the application firmware reponsible for operating the
+ //hardware UART of this microcontroller.
+ //---------
+ //CONFIGURE_RTS(control_signal_bitmap.CARRIER_CONTROL);
+ //------------------------------------------------------------------
+
+ #if defined(USB_CDC_SUPPORT_DTR_SIGNALING)
+ if(control_signal_bitmap.DTE_PRESENT == 1)
+ {
+ UART_DTR = USB_CDC_DTR_ACTIVE_LEVEL;
+ }
+ else
+ {
+ UART_DTR = (USB_CDC_DTR_ACTIVE_LEVEL ^ 1);
+ }
+ #endif
+ inPipes[0].info.bits.busy = 1;
+ break;
+ #endif
+
+ #if defined(USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2)
+ case SEND_BREAK: // Optional
+ inPipes[0].info.bits.busy = 1;
+ if (SetupPkt.wValue == 0xFFFF) //0xFFFF means send break indefinitely until a new SEND_BREAK command is received
+ {
+ UART_Tx = 0; // Prepare to drive TX low (for break signalling)
+ UART_TRISTx = 0; // Make sure TX pin configured as an output
+ UART_ENABLE = 0; // Turn off USART (to relinquish TX pin control)
+ }
+ else if (SetupPkt.wValue == 0x0000) //0x0000 means stop sending indefinite break
+ {
+ UART_ENABLE = 1; // turn on USART
+ UART_TRISTx = 1; // Make TX pin an input
+ }
+ else
+ {
+ //Send break signalling on the pin for (SetupPkt.wValue) milliseconds
+ UART_SEND_BREAK();
+ }
+ break;
+ #endif
+ default:
+ break;
+ }//end switch(SetupPkt.bRequest)
+
+}//end USBCheckCDCRequest
+
+/** U S E R A P I ***********************************************************/
+
+/**************************************************************************
+ Function:
+ void CDCInitEP(void)
+
+ Summary:
+ This function initializes the CDC function driver. This function should
+ be called after the SET_CONFIGURATION command (ex: within the context of
+ the USBCBInitEP() function).
+ Description:
+ This function initializes the CDC function driver. This function sets
+ the default line coding (baud rate, bit parity, number of data bits,
+ and format). This function also enables the endpoints and prepares for
+ the first transfer from the host.
+
+ This function should be called after the SET_CONFIGURATION command.
+ This is most simply done by calling this function from the
+ USBCBInitEP() function.
+
+ Typical Usage:
+
+ void USBCBInitEP(void)
+ {
+ CDCInitEP();
+ }
+
+ Conditions:
+ None
+ Remarks:
+ None
+ **************************************************************************/
+void CDCInitEP(void)
+{
+ //Abstract line coding information
+ line_coding.dwDTERate.Val = 19200; // baud rate
+ line_coding.bCharFormat = 0x00; // 1 stop bit
+ line_coding.bParityType = 0x00; // None
+ line_coding.bDataBits = 0x08; // 5,6,7,8, or 16
+
+ cdc_rx_len = 0;
+
+ /*
+ * Do not have to init Cnt of IN pipes here.
+ * Reason: Number of BYTEs to send to the host
+ * varies from one transaction to
+ * another. Cnt should equal the exact
+ * number of BYTEs to transmit for
+ * a given IN transaction.
+ * This number of BYTEs will only
+ * be known right before the data is
+ * sent.
+ */
+ USBEnableEndpoint(CDC_COMM_EP,USB_IN_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP);
+ USBEnableEndpoint(CDC_DATA_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP);
+
+ CDCDataOutHandle = USBRxOnePacket(CDC_DATA_EP,(BYTE*)&cdc_data_rx,sizeof(cdc_data_rx));
+ CDCDataInHandle = NULL;
+
+ #if defined(USB_CDC_SUPPORT_DSR_REPORTING)
+ CDCNotificationInHandle = NULL;
+ mInitDTSPin(); //Configure DTS as a digital input
+ SerialStateBitmap.byte = 0x00;
+ OldSerialStateBitmap.byte = !SerialStateBitmap.byte; //To force firmware to send an initial serial state packet to the host.
+ //Prepare a SerialState notification element packet (contains info like DSR state)
+ SerialStatePacket.bmRequestType = 0xA1; //Always 0xA1 for this type of packet.
+ SerialStatePacket.bNotification = SERIAL_STATE;
+ SerialStatePacket.wValue = 0x0000; //Always 0x0000 for this type of packet
+ SerialStatePacket.wIndex = CDC_COMM_INTF_ID; //Interface number
+ SerialStatePacket.SerialState.byte = 0x00;
+ SerialStatePacket.Reserved = 0x00;
+ SerialStatePacket.wLength = 0x02; //Always 2 bytes for this type of packet
+ CDCNotificationHandler();
+ #endif
+
+ #if defined(USB_CDC_SUPPORT_DTR_SIGNALING)
+ mInitDTRPin();
+ #endif
+
+ #if defined(USB_CDC_SUPPORT_HARDWARE_FLOW_CONTROL)
+ mInitRTSPin();
+ mInitCTSPin();
+ #endif
+
+ cdc_trf_state = CDC_TX_READY;
+}//end CDCInitEP
+
+
+/**************************************************************************
+ Function: void CDCNotificationHandler(void)
+ Summary: Checks for changes in DSR status and reports them to the USB host.
+ Description: Checks for changes in DSR pin state and reports any changes
+ to the USB host.
+ Conditions: CDCInitEP() must have been called previously, prior to calling
+ CDCNotificationHandler() for the first time.
+ Remarks:
+ This function is only implemented and needed when the
+ USB_CDC_SUPPORT_DSR_REPORTING option has been enabled. If the function is
+ enabled, it should be called periodically to sample the DSR pin and feed
+ the information to the USB host. This can be done by calling
+ CDCNotificationHandler() by itself, or, by calling CDCTxService() which
+ also calls CDCNotificationHandler() internally, when appropriate.
+ **************************************************************************/
+#if defined(USB_CDC_SUPPORT_DSR_REPORTING)
+void CDCNotificationHandler(void)
+{
+ //Check the DTS I/O pin and if a state change is detected, notify the
+ //USB host by sending a serial state notification element packet.
+ if(UART_DTS == USB_CDC_DSR_ACTIVE_LEVEL) //UART_DTS must be defined to be an I/O pin in the hardware profile to use the DTS feature (ex: "PORTXbits.RXY")
+ {
+ SerialStateBitmap.bits.DSR = 1;
+ }
+ else
+ {
+ SerialStateBitmap.bits.DSR = 0;
+ }
+
+ //If the state has changed, and the endpoint is available, send a packet to
+ //notify the hUSB host of the change.
+ if((SerialStateBitmap.byte != OldSerialStateBitmap.byte) && (!USBHandleBusy(CDCNotificationInHandle)))
+ {
+ //Copy the updated value into the USB packet buffer to send.
+ SerialStatePacket.SerialState.byte = SerialStateBitmap.byte;
+ //We don't need to write to the other bytes in the SerialStatePacket USB
+ //buffer, since they don't change and will always be the same as our
+ //initialized value.
+
+ //Send the packet over USB to the host.
+ CDCNotificationInHandle = USBTransferOnePacket(CDC_COMM_EP, IN_TO_HOST, (BYTE*)&SerialStatePacket, sizeof(SERIAL_STATE_NOTIFICATION));
+
+ //Save the old value, so we can detect changes later.
+ OldSerialStateBitmap.byte = SerialStateBitmap.byte;
+ }
+}//void CDCNotificationHandler(void)
+#else
+ #define CDCNotificationHandler() {}
+#endif
+
+
+/**********************************************************************************
+ Function:
+ BOOL USBCDCEventHandler(USB_EVENT event, void *pdata, WORD size)
+
+ Summary:
+ Handles events from the USB stack, which may have an effect on the CDC
+ endpoint(s).
+
+ Description:
+ Handles events from the USB stack. This function should be called when
+ there is a USB event that needs to be processed by the CDC driver.
+
+ Conditions:
+ Value of input argument 'len' should be smaller than the maximum
+ endpoint size responsible for receiving bulk data from USB host for CDC
+ class. Input argument 'buffer' should point to a buffer area that is
+ bigger or equal to the size specified by 'len'.
+ Input:
+ event - the type of event that occured
+ pdata - pointer to the data that caused the event
+ size - the size of the data that is pointed to by pdata
+
+ **********************************************************************************/
+BOOL USBCDCEventHandler(USB_EVENT event, void *pdata, WORD size)
+{
+ switch( (INT)event )
+ {
+ case EVENT_TRANSFER_TERMINATED:
+ if(pdata == CDCDataOutHandle)
+ {
+ CDCDataOutHandle = USBRxOnePacket(CDC_DATA_EP,(BYTE*)&cdc_data_rx,sizeof(cdc_data_rx));
+ }
+ if(pdata == CDCDataInHandle)
+ {
+ //flush all of the data in the CDC buffer
+ cdc_trf_state = CDC_TX_READY;
+ cdc_tx_len = 0;
+ }
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**********************************************************************************
+ Function:
+ BYTE getsUSBUSART(char *buffer, BYTE len)
+
+ Summary:
+ getsUSBUSART copies a string of BYTEs received through USB CDC Bulk OUT
+ endpoint to a user's specified location. It is a non-blocking function.
+ It does not wait for data if there is no data available. Instead it
+ returns '0' to notify the caller that there is no data available.
+
+ Description:
+ getsUSBUSART copies a string of BYTEs received through USB CDC Bulk OUT
+ endpoint to a user's specified location. It is a non-blocking function.
+ It does not wait for data if there is no data available. Instead it
+ returns '0' to notify the caller that there is no data available.
+
+ Typical Usage:
+
+ BYTE numBytes;
+ BYTE buffer[64]
+
+ numBytes = getsUSBUSART(buffer,sizeof(buffer)); //until the buffer is free.
+ if(numBytes \> 0)
+ {
+ //we received numBytes bytes of data and they are copied into
+ // the "buffer" variable. We can do something with the data
+ // here.
+ }
+
+ Conditions:
+ Value of input argument 'len' should be smaller than the maximum
+ endpoint size responsible for receiving bulk data from USB host for CDC
+ class. Input argument 'buffer' should point to a buffer area that is
+ bigger or equal to the size specified by 'len'.
+ Input:
+ buffer - Pointer to where received BYTEs are to be stored
+ len - The number of BYTEs expected.
+
+ **********************************************************************************/
+BYTE getsUSBUSART(char *buffer, BYTE len)
+{
+ cdc_rx_len = 0;
+
+ if(!USBHandleBusy(CDCDataOutHandle))
+ {
+ /*
+ * Adjust the expected number of BYTEs to equal
+ * the actual number of BYTEs received.
+ */
+ if(len > USBHandleGetLength(CDCDataOutHandle))
+ len = USBHandleGetLength(CDCDataOutHandle);
+
+ /*
+ * Copy data from dual-ram buffer to user's buffer
+ */
+ for(cdc_rx_len = 0; cdc_rx_len < len; cdc_rx_len++)
+ buffer[cdc_rx_len] = cdc_data_rx[cdc_rx_len];
+
+ /*
+ * Prepare dual-ram buffer for next OUT transaction
+ */
+
+ CDCDataOutHandle = USBRxOnePacket(CDC_DATA_EP,(BYTE*)&cdc_data_rx,sizeof(cdc_data_rx));
+
+ }//end if
+
+ return cdc_rx_len;
+
+}//end getsUSBUSART
+
+/******************************************************************************
+ Function:
+ void putUSBUSART(char *data, BYTE length)
+
+ Summary:
+ putUSBUSART writes an array of data to the USB. Use this version, is
+ capable of transfering 0x00 (what is typically a NULL character in any of
+ the string transfer functions).
+
+ Description:
+ putUSBUSART writes an array of data to the USB. Use this version, is
+ capable of transfering 0x00 (what is typically a NULL character in any of
+ the string transfer functions).
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ char data[] = {0x00, 0x01, 0x02, 0x03, 0x04};
+ putUSBUSART(data,5);
+ }
+
+
+ The transfer mechanism for device-to-host(put) is more flexible than
+ host-to-device(get). It can handle a string of data larger than the
+ maximum size of bulk IN endpoint. A state machine is used to transfer a
+ \long string of data over multiple USB transactions. CDCTxService()
+ must be called periodically to keep sending blocks of data to the host.
+
+ Conditions:
+ USBUSARTIsTxTrfReady() must return TRUE. This indicates that the last
+ transfer is complete and is ready to receive a new block of data. The
+ string of characters pointed to by 'data' must equal to or smaller than
+ 255 BYTEs.
+
+ Input:
+ char *data - pointer to a RAM array of data to be transfered to the host
+ BYTE length - the number of bytes to be transfered (must be less than 255).
+
+ *****************************************************************************/
+void putUSBUSART(char *data, BYTE length)
+{
+ /*
+ * User should have checked that cdc_trf_state is in CDC_TX_READY state
+ * before calling this function.
+ * As a safety precaution, this fuction checks the state one more time
+ * to make sure it does not override any pending transactions.
+ *
+ * Currently it just quits the routine without reporting any errors back
+ * to the user.
+ *
+ * Bottomline: User MUST make sure that USBUSARTIsTxTrfReady()==1
+ * before calling this function!
+ * Example:
+ * if(USBUSARTIsTxTrfReady())
+ * putUSBUSART(pData, Length);
+ *
+ * IMPORTANT: Never use the following blocking while loop to wait:
+ * while(!USBUSARTIsTxTrfReady())
+ * putUSBUSART(pData, Length);
+ *
+ * The whole firmware framework is written based on cooperative
+ * multi-tasking and a blocking code is not acceptable.
+ * Use a state machine instead.
+ */
+ USBMaskInterrupts();
+ if(cdc_trf_state == CDC_TX_READY)
+ {
+ mUSBUSARTTxRam((BYTE*)data, length); // See cdc.h
+ }
+ USBUnmaskInterrupts();
+}//end putUSBUSART
+
+/******************************************************************************
+ Function:
+ void putsUSBUSART(char *data)
+
+ Summary:
+ putsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'puts', to transfer data from a RAM buffer.
+
+ Description:
+ putsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'puts', to transfer data from a RAM buffer.
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ char data[] = "Hello World";
+ putsUSBUSART(data);
+ }
+
+
+ The transfer mechanism for device-to-host(put) is more flexible than
+ host-to-device(get). It can handle a string of data larger than the
+ maximum size of bulk IN endpoint. A state machine is used to transfer a
+ \long string of data over multiple USB transactions. CDCTxService()
+ must be called periodically to keep sending blocks of data to the host.
+
+ Conditions:
+ USBUSARTIsTxTrfReady() must return TRUE. This indicates that the last
+ transfer is complete and is ready to receive a new block of data. The
+ string of characters pointed to by 'data' must equal to or smaller than
+ 255 BYTEs.
+
+ Input:
+ char *data - null\-terminated string of constant data. If a
+ null character is not found, 255 BYTEs of data
+ will be transferred to the host.
+
+ *****************************************************************************/
+
+void putsUSBUSART(char *data)
+{
+ BYTE len;
+ char *pData;
+
+ /*
+ * User should have checked that cdc_trf_state is in CDC_TX_READY state
+ * before calling this function.
+ * As a safety precaution, this fuction checks the state one more time
+ * to make sure it does not override any pending transactions.
+ *
+ * Currently it just quits the routine without reporting any errors back
+ * to the user.
+ *
+ * Bottomline: User MUST make sure that USBUSARTIsTxTrfReady()==1
+ * before calling this function!
+ * Example:
+ * if(USBUSARTIsTxTrfReady())
+ * putsUSBUSART(pData, Length);
+ *
+ * IMPORTANT: Never use the following blocking while loop to wait:
+ * while(!USBUSARTIsTxTrfReady())
+ * putsUSBUSART(pData);
+ *
+ * The whole firmware framework is written based on cooperative
+ * multi-tasking and a blocking code is not acceptable.
+ * Use a state machine instead.
+ */
+ USBMaskInterrupts();
+ if(cdc_trf_state != CDC_TX_READY)
+ {
+ USBUnmaskInterrupts();
+ return;
+ }
+
+ /*
+ * While loop counts the number of BYTEs to send including the
+ * null character.
+ */
+ len = 0;
+ pData = data;
+ do
+ {
+ len++;
+ if(len == 255) break; // Break loop once max len is reached.
+ }while(*pData++);
+
+ /*
+ * Second piece of information (length of data to send) is ready.
+ * Call mUSBUSARTTxRam to setup the transfer.
+ * The actual transfer process will be handled by CDCTxService(),
+ * which should be called once per Main Program loop.
+ */
+ mUSBUSARTTxRam((BYTE*)data, len); // See cdc.h
+ USBUnmaskInterrupts();
+}//end putsUSBUSART
+
+/**************************************************************************
+ Function:
+ void putrsUSBUSART(const ROM char *data)
+
+ Summary:
+ putrsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'putrs', to transfer data literals and
+ data located in program memory.
+
+ Description:
+ putrsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'putrs', to transfer data literals and
+ data located in program memory.
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ putrsUSBUSART("Hello World");
+ }
+
+
+ The transfer mechanism for device-to-host(put) is more flexible than
+ host-to-device(get). It can handle a string of data larger than the
+ maximum size of bulk IN endpoint. A state machine is used to transfer a
+ \long string of data over multiple USB transactions. CDCTxService()
+ must be called periodically to keep sending blocks of data to the host.
+
+ Conditions:
+ USBUSARTIsTxTrfReady() must return TRUE. This indicates that the last
+ transfer is complete and is ready to receive a new block of data. The
+ string of characters pointed to by 'data' must equal to or smaller than
+ 255 BYTEs.
+
+ Input:
+ const ROM char *data - null\-terminated string of constant data. If a
+ null character is not found, 255 BYTEs of data
+ will be transferred to the host.
+
+ **************************************************************************/
+void putrsUSBUSART(const ROM char *data)
+{
+ BYTE len;
+ const ROM char *pData;
+
+ /*
+ * User should have checked that cdc_trf_state is in CDC_TX_READY state
+ * before calling this function.
+ * As a safety precaution, this fuction checks the state one more time
+ * to make sure it does not override any pending transactions.
+ *
+ * Currently it just quits the routine without reporting any errors back
+ * to the user.
+ *
+ * Bottomline: User MUST make sure that USBUSARTIsTxTrfReady()
+ * before calling this function!
+ * Example:
+ * if(USBUSARTIsTxTrfReady())
+ * putsUSBUSART(pData);
+ *
+ * IMPORTANT: Never use the following blocking while loop to wait:
+ * while(cdc_trf_state != CDC_TX_READY)
+ * putsUSBUSART(pData);
+ *
+ * The whole firmware framework is written based on cooperative
+ * multi-tasking and a blocking code is not acceptable.
+ * Use a state machine instead.
+ */
+ USBMaskInterrupts();
+ if(cdc_trf_state != CDC_TX_READY)
+ {
+ USBUnmaskInterrupts();
+ return;
+ }
+
+ /*
+ * While loop counts the number of BYTEs to send including the
+ * null character.
+ */
+ len = 0;
+ pData = data;
+ do
+ {
+ len++;
+ if(len == 255) break; // Break loop once max len is reached.
+ }while(*pData++);
+
+ /*
+ * Second piece of information (length of data to send) is ready.
+ * Call mUSBUSARTTxRom to setup the transfer.
+ * The actual transfer process will be handled by CDCTxService(),
+ * which should be called once per Main Program loop.
+ */
+
+ mUSBUSARTTxRom((ROM BYTE*)data,len); // See cdc.h
+ USBUnmaskInterrupts();
+
+}//end putrsUSBUSART
+
+/************************************************************************
+ Function:
+ void CDCTxService(void)
+
+ Summary:
+ CDCTxService handles device-to-host transaction(s). This function
+ should be called once per Main Program loop after the device reaches
+ the configured state.
+ Description:
+ CDCTxService handles device-to-host transaction(s). This function
+ should be called once per Main Program loop after the device reaches
+ the configured state (after the CDCIniEP() function has already executed).
+ This function is needed, in order to advance the internal software state
+ machine that takes care of sending multiple transactions worth of IN USB
+ data to the host, associated with CDC serial data. Failure to call
+ CDCTxService() perioidcally will prevent data from being sent to the
+ USB host, over the CDC serial data interface.
+
+ Typical Usage:
+
+ void main(void)
+ {
+ USBDeviceInit();
+ while(1)
+ {
+ USBDeviceTasks();
+ if((USBGetDeviceState() \< CONFIGURED_STATE) ||
+ (USBIsDeviceSuspended() == TRUE))
+ {
+ //Either the device is not configured or we are suspended
+ // so we don't want to do execute any application code
+ continue; //go back to the top of the while loop
+ }
+ else
+ {
+ //Keep trying to send data to the PC as required
+ CDCTxService();
+
+ //Run application code.
+ UserApplication();
+ }
+ }
+ }
+
+ Conditions:
+ CDCIniEP() function should have already executed/the device should be
+ in the CONFIGURED_STATE.
+ Remarks:
+ None
+ ************************************************************************/
+
+void CDCTxService(void)
+{
+ BYTE byte_to_send;
+ BYTE i;
+
+ USBMaskInterrupts();
+
+ CDCNotificationHandler();
+
+ if(USBHandleBusy(CDCDataInHandle))
+ {
+ USBUnmaskInterrupts();
+ return;
+ }
+
+ /*
+ * Completing stage is necessary while [ mCDCUSartTxIsBusy()==1 ].
+ * By having this stage, user can always check cdc_trf_state,
+ * and not having to call mCDCUsartTxIsBusy() directly.
+ */
+ if(cdc_trf_state == CDC_TX_COMPLETING)
+ cdc_trf_state = CDC_TX_READY;
+
+ /*
+ * If CDC_TX_READY state, nothing to do, just return.
+ */
+ if(cdc_trf_state == CDC_TX_READY)
+ {
+ USBUnmaskInterrupts();
+ return;
+ }
+
+ /*
+ * If CDC_TX_BUSY_ZLP state, send zero length packet
+ */
+ if(cdc_trf_state == CDC_TX_BUSY_ZLP)
+ {
+ CDCDataInHandle = USBTxOnePacket(CDC_DATA_EP,NULL,0);
+ //CDC_DATA_BD_IN.CNT = 0;
+ cdc_trf_state = CDC_TX_COMPLETING;
+ }
+ else if(cdc_trf_state == CDC_TX_BUSY)
+ {
+ /*
+ * First, have to figure out how many byte of data to send.
+ */
+ if(cdc_tx_len > sizeof(cdc_data_tx))
+ byte_to_send = sizeof(cdc_data_tx);
+ else
+ byte_to_send = cdc_tx_len;
+
+ /*
+ * Subtract the number of bytes just about to be sent from the total.
+ */
+ cdc_tx_len = cdc_tx_len - byte_to_send;
+
+ pCDCDst.bRam = (BYTE*)&cdc_data_tx; // Set destination pointer
+
+ i = byte_to_send;
+ if(cdc_mem_type == USB_EP0_ROM) // Determine type of memory source
+ {
+ while(i)
+ {
+ *pCDCDst.bRam = *pCDCSrc.bRom;
+ pCDCDst.bRam++;
+ pCDCSrc.bRom++;
+ i--;
+ }//end while(byte_to_send)
+ }
+ else // _RAM
+ {
+ while(i)
+ {
+ *pCDCDst.bRam = *pCDCSrc.bRam;
+ pCDCDst.bRam++;
+ pCDCSrc.bRam++;
+ i--;
+ }//end while(byte_to_send._word)
+ }//end if(cdc_mem_type...)
+
+ /*
+ * Lastly, determine if a zero length packet state is necessary.
+ * See explanation in USB Specification 2.0: Section 5.8.3
+ */
+ if(cdc_tx_len == 0)
+ {
+ if(byte_to_send == CDC_DATA_IN_EP_SIZE)
+ cdc_trf_state = CDC_TX_BUSY_ZLP;
+ else
+ cdc_trf_state = CDC_TX_COMPLETING;
+ }//end if(cdc_tx_len...)
+ CDCDataInHandle = USBTxOnePacket(CDC_DATA_EP,(BYTE*)&cdc_data_tx,byte_to_send);
+
+ }//end if(cdc_tx_sate == CDC_TX_BUSY)
+
+ USBUnmaskInterrupts();
+}//end CDCTxService
+
+#endif //USB_USE_CDC
+
+/** EOF cdc.c ****************************************************************/
diff --git a/Source/USB/USB2.9i_cdc/USB/usb_device.c b/Source/USB/USB2.9i_cdc/USB/usb_device.c
new file mode 100644
index 0000000..39d8324
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/USB/usb_device.c
@@ -0,0 +1,3134 @@
+/********************************************************************
+ File Information:
+ FileName: usb_device.c
+ Dependencies: See INCLUDES section
+ Processor: PIC18,PIC24, PIC32 and dsPIC33E USB Microcontrollers
+ Hardware: This code is natively intended to be used on Mirochip USB
+ demo boards. See www.microchip.com/usb (Software & Tools
+ section) for list of available platforms. The firmware may
+ be modified for use on other USB platforms by editing the
+ HardwareProfile.h and HardwareProfile - [platform].h files.
+ Complier: Microchip C18 (for PIC18),C30 (for PIC24 and dsPIC33E)
+ and C32 (for PIC32)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the "Company") for its PIC(r) Microcontroller is intended and
+ supplied to you, the Company's customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+ Summary:
+ This file contains functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the MCHPFSUSB device
+ stack. This file should be included in projects that use the device stack.
+
+ This file is located in the "\\\Microchip\\USB"
+ directory.
+
+ Description:
+ USB Device Stack File
+
+ This file contains functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the MCHPFSUSB device
+ stack. This file should be included in projects that use the device stack.
+
+ This file is located in the "\\\Microchip\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+ ..\\..\\MicrochipInclude
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+
+********************************************************************
+ File Description:
+
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.6 Added USBCancelIO() function. Moved and some stack
+ defintions to be more consistant with the host stack.
+
+ 2.6a Fixed issue where a SET_CONFIGURATION received could cause
+ inability to transmit on an endpoint if using ping-pong
+ and an odd number of packets had been sent on that endpoint
+
+ 2.7 Fixed error where the USB error interrupt flag was not getting
+ cleared properly for PIC32 resulting in lots of extra error interrupts.
+ http://www.microchip.com/forums/tm.aspx?m=479085
+
+ Fixed issue with dual role mode when device run in polling
+ mode. Interrupts were remaining enabled after the host mode
+ operation was complete. This was incompatible with polling
+ mode operation.
+
+ Changed how the bus sensing works. In previous revisions it
+ was impossible to use the USBDeviceDetach to detach from the
+ bus if the bus voltage was still present. This is now
+ possible. It was also possible to move the device to the
+ ATTACHED state in interrupt mode even if the bus voltage
+ wasn't available. This is now prohibited unless VBUS is
+ present.
+
+ Improved error case handling when the host sends more OUT
+ bytes in a control transfer than the firmware was expecting
+ to receive (based on the size parameter when calling USBEP0Receive()).
+
+ In the USBStdSetCfgHandler(), modified the code so the USBDeviceState
+ variable only gets updated to the CONFIGURED_STATE at the end of the
+ function.
+
+ 2.7a Update to support the PIC18F47J53 A1 and later revision
+ devices.
+
+ Fixed an error on 16-bit and 32-bit processors where a word access
+ could be performed on a byte pointer resulting in possible address
+ errors with odd aligned pointers.
+
+ 2.8 Several changes to the way control transfers get processed,
+ so as to support the ability to allow application/class specific
+ handler code to defer the status stage.
+ Implemented USBCtrlEPAllowStatusStage() API function.
+ Implemented USBDeferStatusStage() API function (macro).
+ These changes also greatly relax the USBDeviceTasks() calling frequency
+ requirement, while allowing USB class handlers more flexibility.
+
+ Also implemented the following API functions and macros, for delaying
+ the data stage of a control transfer (with data stage):
+ USBDeferINDataStage()
+ USBDeferOUTDataStage()
+ USBOUTDataStageDeferred()
+ USBINDataStageDeferred()
+ USBCtrlEPAllowDataStage()
+
+ Fixed USB reset event handler issue, where the USB stack would
+ re-initialize global interrupt settings in the interrupt context, on
+ PIC18 devices with the stack operated in USB_INTERRUPT mode.
+
+ Fixed handling of SET/CLEAR FEATURE (endpoint halt) host requests.
+ Previous implementation would not always initialize endpoints correctly
+ to DATA0 DTS state after a clear feature endpoint halt request, for
+ all ping pong mode and usage scenarios.
+
+ 2.9 Fixed an issue with STALL handling behavior on non-EP0 endpoints, for
+ PIC24 and PIC32 devices.
+
+ Fixed an issue where the ep_data_in[]/ep_data_out[] flags weren't
+ getting re-initialized coincident with the hardware ping pong pointer
+ reset during set configuration events.
+
+ Implemented USBGetNextHandle() API function (actually a macro, defined
+ in usb_device.h).
+
+ 2.9d Added build option for disabling DTS checking
+
+ 2.9f Adding pragma for PIC18F97J94 Family BDT location.
+
+ 2.9h Updated to be able to support optional Microsoft OS Descriptors
+
+ 2.9i Updated to set UCON bit on PIC16F USB devices during
+ suspend, so as to save power.
+
+********************************************************************/
+
+/*----------------------------------------------------------------------------------
+The USBDeviceTasks() function is responsible for detecting and processing various
+USB bus events and host requests, such as those required for USB enumeration, when
+the USB cable is first attached to the host. This function is the main dispatcher
+routine for the USB stack.
+
+Additional API functions and macros are also provided by the USB stack, which can be
+used to send/receive USB data to/from the host, among other things. A full list
+of the available implemented functions/macros are provided in the
+"MCHPFSUSB Library Help". For normal installations of the MCHPFSUSB Framework,
+the USB API documentation can be found from:
+
+Start menu --> (All Programs) --> Microchip --> MCHPFSUSB vX.x --> Documents --> MCHPFSUSB Library Help
+
+Once the help file is opened, the API functions/macros are described in the following section:
+Library Interface (API) --> Device/Peripheral --> Device Stack --> Interface Routines
+Additional API functions may also be provided depending upon the specific USB device class
+implemented, and these functions are also documented in the MCHPFSUSB Library Help.
+
+
+If the USB stack is operated in "USB_POLLING" mode (user selectable option in
+usb_config.h), then the application firmware is reponsible for calling the
+USBDeviceTasks() function periodically. If the USB stack is operated in the
+"USB_INTERRUPT" mode, then the application firmware does not have to directly
+call USBDeviceTasks(), as it will execute only when necessary as an interrupt handler.
+
+In order to properly operate a USB connection, and to correctly process and respond
+to control transfers in the maximum time allowed by the USB specifications, the
+USBDeviceTasks() function/interrupt handler must be allowed to execute in a timely
+fashion.
+
+When the USB module is enabled, the USB cable is attached to the host, the USB bus
+is not in the suspend state, and the USB stack is operated in the USB_POLLING mode
+with ping pong buffering enabled (at least) on EP0 OUT, then the maximum allowed
+time between calls to the USBDeviceTasks() function needs to be:
+
+The faster of:
+1. Once per ~1.8ms, when USBDeviceState == ADR_PENDING_STATE
+2. Once per ~9.8ms, when USBDeviceState == (any other value other than ADR_PENDING_STATE)
+3. Fast enough to ensure the USTAT FIFO can never get full. See additional explanation below.
+
+Additional details of the above timing limits are provided:
+
+Timing item #1: This parameter originates from the 2ms set address "recovery interval"
+specification dictated by section "9.2.6.3 Set Address Processing" of the official
+USB 2.0 specifications.
+
+Timing item #2: This parameter originates from several "10 ms" criteria in the
+USB 2.0 specifications. For example, reset recovery intervals, resume recovery
+intervals, suspend to actual current reduction, etc. have timing maximums of 10ms.
+
+Timing item #3: This is not a fixed X.X ms parameter, but depends on the
+transaction rate implemented by the application. The USBDeviceTasks() function is
+responsible for popping entries off the USTAT FIFO. If the FIFO ever gets full,
+then no further USB transactions are allowed to occur, until the firmware pops entries
+off the FIFO. In practice, this means the firmware should call USBDeviceTasks() at
+a rate at least as fast as once every three times the USBTransferOnePacket() function
+is called. This ensures that the rate that USTAT FIFO entries are getting added to
+the FIFO is lower than the rate that the entries are getting popped off the FIFO (the
+USBDeviceTasks() function will pop up to 4 entries per call), which is a
+necessary criteria to ensure the USTAT FIFO entries don't "pile up." Calling
+USBDeviceTasks() even more often, ex: >=1 to 1 ratio of USBDeviceTasks() to
+USBTransferOnePacket(), adds further protection against the USTAT FIFO getting full,
+and is therefore recommended.
+
+When the USB stack is operated in USB_INTERRUPT mode, then the above timing
+parameters should be interpreted to be the longest allowed time that the USB
+interrupts may be masked/disabled for, before re-enabling the USB interrupts.
+
+Calling USBDeviceTasks() (or allowing USBDeviceTasks() to be called) more often
+will still have potential USB data rate speed and processing latency benefits.
+It is also beneficial to call USBDeviceTasks() more often than theoretically
+required, since it has been observed that not all host/drivers/bios/hubs are
+100% consistently compliant with all timing parameters of the USB 2.0 specifications.
+Therefore, in a USB_POLLING based application, it is still suggested to call
+USBDeviceTasks() as often as there are free CPU cycles. This ensures best
+performance, along with best possible compatibility with all existing USB
+hosts/hubs (both those that are compliant and [partially] non-compliant).
+
+If ping pong buffering is not enabled on (at least) EP0 OUT, then it is required
+to call (or allow to execute) USBDeviceTasks() much more frequently (ex: once
+per 100us, or preferrably faster). Therefore, in all applications, it is
+normally recommended to select either the USB_PING_PONG__FULL_PING_PONG or
+USB_PING_PONG__EP0_OUT_ONLY mode (user option in usb_config.h), as these modes
+allow for much more relaxed timing requirements, and therefore greater application
+firmware design flexibility.
+//----------------------------------------------------------------------------------*/
+
+/** INCLUDES *******************************************************/
+#include "./USB/usb.h"
+#include "HardwareProfile.h"
+
+#include "../USB/usb_device_local.h"
+
+
+#if defined(USB_USE_MSD)
+ #include "./USB/usb_function_msd.h"
+#endif
+
+#if !defined(USE_USB_BUS_SENSE_IO)
+ #undef USB_BUS_SENSE
+ #define USB_BUS_SENSE 1
+#endif
+
+#if defined(USB_DEVICE_DISABLE_DTS_CHECKING)
+ #define _DTS_CHECKING_ENABLED 0
+#else
+ #define _DTS_CHECKING_ENABLED _DTSEN
+#endif
+
+/** DEFINITIONS ****************************************************/
+
+/** VARIABLES ******************************************************/
+#if defined(__18CXX)
+ #pragma udata
+#endif
+
+USB_VOLATILE USB_DEVICE_STATE USBDeviceState;
+USB_VOLATILE BYTE USBActiveConfiguration;
+USB_VOLATILE BYTE USBAlternateInterface[USB_MAX_NUM_INT];
+volatile BDT_ENTRY *pBDTEntryEP0OutCurrent;
+volatile BDT_ENTRY *pBDTEntryEP0OutNext;
+volatile BDT_ENTRY *pBDTEntryOut[USB_MAX_EP_NUMBER+1];
+volatile BDT_ENTRY *pBDTEntryIn[USB_MAX_EP_NUMBER+1];
+USB_VOLATILE BYTE shortPacketStatus;
+USB_VOLATILE BYTE controlTransferState;
+USB_VOLATILE IN_PIPE inPipes[1];
+USB_VOLATILE OUT_PIPE outPipes[1];
+USB_VOLATILE BYTE *pDst;
+USB_VOLATILE BOOL RemoteWakeup;
+USB_VOLATILE BOOL USBBusIsSuspended;
+USB_VOLATILE USTAT_FIELDS USTATcopy;
+USB_VOLATILE BYTE endpoint_number;
+USB_VOLATILE BOOL BothEP0OutUOWNsSet;
+USB_VOLATILE EP_STATUS ep_data_in[USB_MAX_EP_NUMBER+1];
+USB_VOLATILE EP_STATUS ep_data_out[USB_MAX_EP_NUMBER+1];
+USB_VOLATILE BYTE USBStatusStageTimeoutCounter;
+volatile BOOL USBDeferStatusStagePacket;
+volatile BOOL USBStatusStageEnabledFlag1;
+volatile BOOL USBStatusStageEnabledFlag2;
+volatile BOOL USBDeferINDataStagePackets;
+volatile BOOL USBDeferOUTDataStagePackets;
+
+
+#if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
+ #define BDT_NUM_ENTRIES ((USB_MAX_EP_NUMBER + 1) * 2)
+#elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY)
+ #define BDT_NUM_ENTRIES (((USB_MAX_EP_NUMBER + 1) * 2)+1)
+#elif (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+ #define BDT_NUM_ENTRIES ((USB_MAX_EP_NUMBER + 1) * 4)
+#elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0)
+ #define BDT_NUM_ENTRIES (((USB_MAX_EP_NUMBER + 1) * 4)-2)
+#else
+ #error "No ping pong mode defined."
+#endif
+
+/** USB FIXED LOCATION VARIABLES ***********************************/
+#if defined(__18CXX)
+ #pragma udata USB_BDT=USB_BDT_ADDRESS
+#endif
+
+volatile BDT_ENTRY BDT[BDT_NUM_ENTRIES] BDT_BASE_ADDR_TAG;
+
+/********************************************************************
+ * Section B: EP0 Buffer Space
+ *******************************************************************/
+volatile CTRL_TRF_SETUP SetupPkt CTRL_TRF_SETUP_ADDR_TAG;
+volatile BYTE CtrlTrfData[USB_EP0_BUFF_SIZE] CTRL_TRF_DATA_ADDR_TAG;
+
+/********************************************************************
+ * Section C: non-EP0 Buffer Space
+ *******************************************************************/
+#if defined(USB_USE_MSD)
+ //volatile far USB_MSD_CBW_CSW msd_cbw_csw;
+ volatile USB_MSD_CBW msd_cbw;
+ volatile USB_MSD_CSW msd_csw;
+ //#pragma udata
+
+ #if defined(__18CXX)
+ #pragma udata myMSD=MSD_BUFFER_ADDRESS
+ #endif
+ volatile char msd_buffer[512];
+#endif
+
+
+
+////Depricated in v2.2 - will be removed in a future revision
+#if !defined(USB_USER_DEVICE_DESCRIPTOR)
+ //Device descriptor
+ extern ROM USB_DEVICE_DESCRIPTOR device_dsc;
+#else
+ USB_USER_DEVICE_DESCRIPTOR_INCLUDE;
+#endif
+
+#if !defined(USB_USER_CONFIG_DESCRIPTOR)
+ //Array of configuration descriptors
+ extern ROM BYTE *ROM USB_CD_Ptr[];
+#else
+ USB_USER_CONFIG_DESCRIPTOR_INCLUDE;
+#endif
+
+extern ROM BYTE *ROM USB_SD_Ptr[];
+
+/** DECLARATIONS ***************************************************/
+#if defined(__18CXX)
+ #pragma code
+#endif
+
+/** Macros *********************************************************/
+
+/** Function Prototypes ********************************************/
+//External
+//This is the prototype for the required user event handler
+BOOL USER_USB_CALLBACK_EVENT_HANDLER(int event, void *pdata, WORD size);
+
+//Internal Functions
+static void USBCtrlEPService(void);
+static void USBCtrlTrfSetupHandler(void);
+static void USBCtrlTrfInHandler(void);
+static void USBCheckStdRequest(void);
+static void USBStdGetDscHandler(void);
+static void USBCtrlEPServiceComplete(void);
+static void USBCtrlTrfTxService(void);
+static void USBCtrlTrfRxService(void);
+static void USBStdSetCfgHandler(void);
+static void USBStdGetStatusHandler(void);
+static void USBStdFeatureReqHandler(void);
+static void USBCtrlTrfOutHandler(void);
+static void USBConfigureEndpoint(BYTE EPNum, BYTE direction);
+static void USBWakeFromSuspend(void);
+static void USBSuspend(void);
+static void USBStallHandler(void);
+
+//static BOOL USBIsTxBusy(BYTE EPNumber);
+//static void USBPut(BYTE EPNum, BYTE Data);
+//static void USBEPService(void);
+//static void USBProtocolResetHandler(void);
+
+/******************************************************************************/
+/** Function Implementations *************************************************/
+/******************************************************************************/
+
+/******************************************************************************/
+/** Internal Macros *********************************************************/
+/******************************************************************************/
+
+/****************************************************************************
+ Function:
+ void USBAdvancePingPongBuffer(BDT_ENTRY** buffer)
+
+ Description:
+ This function will advance the passed pointer to the next buffer based on
+ the ping pong option setting. This function should be used for EP1-EP15
+ only. This function is not valid for EP0.
+
+ Precondition:
+ None
+
+ Parameters:
+ BDT_ENTRY** - pointer to the BDT_ENTRY pointer that you want to be advanced
+ to the next buffer state
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ ***************************************************************************/
+#define USBAdvancePingPongBuffer(buffer) ((BYTE_VAL*)buffer)->Val ^= USB_NEXT_PING_PONG;
+#define USBHALPingPongSetToOdd(buffer) {((BYTE_VAL*)buffer)->Val |= USB_NEXT_PING_PONG;}
+#define USBHALPingPongSetToEven(buffer) {((BYTE_VAL*)buffer)->Val &= ~USB_NEXT_PING_PONG;}
+
+
+/******************************************************************************/
+/** External API Functions ****************************************************/
+/******************************************************************************/
+
+/**************************************************************************
+ Function:
+ void USBDeviceInit(void)
+
+ Description:
+ This function initializes the device stack it in the default state. The
+ USB module will be completely reset including all of the internal
+ variables, registers, and interrupt flags.
+
+ Precondition:
+ This function must be called before any of the other USB Device
+ functions can be called, including USBDeviceTasks().
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ ***************************************************************************/
+void USBDeviceInit(void)
+{
+ BYTE i;
+
+ USBDisableInterrupts();
+
+ // Clear all USB error flags
+ USBClearInterruptRegister(U1EIR);
+
+ // Clears all USB interrupts
+ USBClearInterruptRegister(U1IR);
+
+ //Clear all of the endpoint control registers
+ U1EP0 = 0;
+
+ DisableNonZeroEndpoints(USB_MAX_EP_NUMBER);
+
+ SetConfigurationOptions();
+
+ //power up the module (if not already powered)
+ USBPowerModule();
+
+ //set the address of the BDT (if applicable)
+ USBSetBDTAddress(BDT);
+
+ //Clear all of the BDT entries
+ for(i=0;i<(sizeof(BDT)/sizeof(BDT_ENTRY));i++)
+ {
+ BDT[i].Val = 0x00;
+ }
+
+ // Assert reset request to all of the Ping Pong buffer pointers
+ USBPingPongBufferReset = 1;
+
+ // Reset to default address
+ U1ADDR = 0x00;
+
+ // Make sure packet processing is enabled
+ USBPacketDisable = 0;
+
+ //Stop trying to reset ping pong buffer pointers
+ USBPingPongBufferReset = 0;
+
+ // Flush any pending transactions
+ while(USBTransactionCompleteIF == 1)
+ {
+ USBClearInterruptFlag(USBTransactionCompleteIFReg,USBTransactionCompleteIFBitNum);
+ //Initialize USB stack software state variables
+ inPipes[0].info.Val = 0;
+ outPipes[0].info.Val = 0;
+ outPipes[0].wCount.Val = 0;
+ }
+
+ //Set flags to TRUE, so the USBCtrlEPAllowStatusStage() function knows not to
+ //try and arm a status stage, even before the first control transfer starts.
+ USBStatusStageEnabledFlag1 = TRUE;
+ USBStatusStageEnabledFlag2 = TRUE;
+ //Initialize other flags
+ USBDeferINDataStagePackets = FALSE;
+ USBDeferOUTDataStagePackets = FALSE;
+ USBBusIsSuspended = FALSE;
+
+ //Initialize all pBDTEntryIn[] and pBDTEntryOut[]
+ //pointers to NULL, so they don't get used inadvertently.
+ for(i = 0; i < (BYTE)(USB_MAX_EP_NUMBER+1u); i++)
+ {
+ pBDTEntryIn[i] = 0u;
+ pBDTEntryOut[i] = 0u;
+ ep_data_in[i].Val = 0u;
+ ep_data_out[i].Val = 0u;
+ }
+
+ //Get ready for the first packet
+ pBDTEntryIn[0] = (volatile BDT_ENTRY*)&BDT[EP0_IN_EVEN];
+ // Initialize EP0 as a Ctrl EP
+ U1EP0 = EP_CTRL|USB_HANDSHAKE_ENABLED;
+ //Prepare for the first SETUP on EP0 OUT
+ BDT[EP0_OUT_EVEN].ADR = ConvertToPhysicalAddress(&SetupPkt);
+ BDT[EP0_OUT_EVEN].CNT = USB_EP0_BUFF_SIZE;
+ BDT[EP0_OUT_EVEN].STAT.Val = _USIE|_DAT0|_BSTALL;
+
+ // Clear active configuration
+ USBActiveConfiguration = 0;
+
+ //Indicate that we are now in the detached state
+ USBDeviceState = DETACHED_STATE;
+}
+
+/**************************************************************************
+ Function:
+ void USBDeviceTasks(void)
+
+ Summary:
+ This function is the main state machine/transaction handler of the USB
+ device side stack. When the USB stack is operated in "USB_POLLING" mode
+ (usb_config.h user option) the USBDeviceTasks() function should be called
+ periodically to receive and transmit packets through the stack. This
+ function also takes care of control transfers associated with the USB
+ enumeration process, and detecting various USB events (such as suspend).
+ This function should be called at least once every 1.8ms during the USB
+ enumeration process. After the enumeration process is complete (which can
+ be determined when USBGetDeviceState() returns CONFIGURED_STATE), the
+ USBDeviceTasks() handler may be called the faster of: either once
+ every 9.8ms, or as often as needed to make sure that the hardware USTAT
+ FIFO never gets full. A good rule of thumb is to call USBDeviceTasks() at
+ a minimum rate of either the frequency that USBTransferOnePacket() gets
+ called, or, once/1.8ms, whichever is faster. See the inline code comments
+ near the top of usb_device.c for more details about minimum timing
+ requirements when calling USBDeviceTasks().
+
+ When the USB stack is operated in "USB_INTERRUPT" mode, it is not necessary
+ to call USBDeviceTasks() from the main loop context. In the USB_INTERRUPT
+ mode, the USBDeviceTasks() handler only needs to execute when a USB
+ interrupt occurs, and therefore only needs to be called from the interrupt
+ context.
+
+ Description:
+ This function is the main state machine/transaction handler of the USB
+ device side stack. When the USB stack is operated in "USB_POLLING" mode
+ (usb_config.h user option) the USBDeviceTasks() function should be called
+ periodically to receive and transmit packets through the stack. This
+ function also takes care of control transfers associated with the USB
+ enumeration process, and detecting various USB events (such as suspend).
+ This function should be called at least once every 1.8ms during the USB
+ enumeration process. After the enumeration process is complete (which can
+ be determined when USBGetDeviceState() returns CONFIGURED_STATE), the
+ USBDeviceTasks() handler may be called the faster of: either once
+ every 9.8ms, or as often as needed to make sure that the hardware USTAT
+ FIFO never gets full. A good rule of thumb is to call USBDeviceTasks() at
+ a minimum rate of either the frequency that USBTransferOnePacket() gets
+ called, or, once/1.8ms, whichever is faster. See the inline code comments
+ near the top of usb_device.c for more details about minimum timing
+ requirements when calling USBDeviceTasks().
+
+ When the USB stack is operated in "USB_INTERRUPT" mode, it is not necessary
+ to call USBDeviceTasks() from the main loop context. In the USB_INTERRUPT
+ mode, the USBDeviceTasks() handler only needs to execute when a USB
+ interrupt occurs, and therefore only needs to be called from the interrupt
+ context.
+
+ Typical usage:
+
+ void main(void)
+ {
+ USBDeviceInit();
+ while(1)
+ {
+ USBDeviceTasks(); //Takes care of enumeration and other USB events
+ if((USBGetDeviceState() \< CONFIGURED_STATE) ||
+ (USBIsDeviceSuspended() == TRUE))
+ {
+ //Either the device is not configured or we are suspended,
+ // so we don't want to execute any USB related application code
+ continue; //go back to the top of the while loop
+ }
+ else
+ {
+ //Otherwise we are free to run USB and non-USB related user
+ //application code.
+ UserApplication();
+ }
+ }
+ }
+
+
+ Precondition:
+ Make sure the USBDeviceInit() function has been called prior to calling
+ USBDeviceTasks() for the first time.
+ Remarks:
+ USBDeviceTasks() does not need to be called while in the USB suspend mode,
+ if the user application firmware in the USBCBSuspend() callback function
+ enables the ACTVIF USB interrupt source and put the microcontroller into
+ sleep mode. If the application firmware decides not to sleep the
+ microcontroller core during USB suspend (ex: continues running at full
+ frequency, or clock switches to a lower frequency), then the USBDeviceTasks()
+ function must still be called periodically, at a rate frequent enough to
+ ensure the 10ms resume recovery interval USB specification is met. Assuming
+ a worst case primary oscillator and PLL start up time of <5ms, then
+ USBDeviceTasks() should be called once every 5ms in this scenario.
+
+ When the USB cable is detached, or the USB host is not actively powering
+ the VBUS line to +5V nominal, the application firmware does not always have
+ to call USBDeviceTasks() frequently, as no USB activity will be taking
+ place. However, if USBDeviceTasks() is not called regularly, some
+ alternative means of promptly detecting when VBUS is powered (indicating
+ host attachment), or not powered (host powered down or USB cable unplugged)
+ is still needed. For self or dual self/bus powered USB applications, see
+ the USBDeviceAttach() and USBDeviceDetach() API documentation for additional
+ considerations.
+
+ **************************************************************************/
+
+#if defined(USB_INTERRUPT)
+#if defined(__18CXX) || defined (_PIC14E)
+ void USBDeviceTasks(void)
+ #elif defined(__C30__) || defined __XC16__
+ void __attribute__((interrupt,auto_psv)) _USB1Interrupt()
+ #elif defined(__PIC32MX__)
+ void __attribute__((interrupt(),vector(_USB_1_VECTOR))) _USB1Interrupt( void )
+ #endif
+#else
+void USBDeviceTasks(void)
+#endif
+{
+ BYTE i;
+
+#ifdef USB_SUPPORT_OTG
+ //SRP Time Out Check
+ if (USBOTGSRPIsReady())
+ {
+ if (USBT1MSECIF && USBT1MSECIE)
+ {
+ if (USBOTGGetSRPTimeOutFlag())
+ {
+ if (USBOTGIsSRPTimeOutExpired())
+ {
+ USB_OTGEventHandler(0,OTG_EVENT_SRP_FAILED,0,0);
+ }
+ }
+
+ //Clear Interrupt Flag
+ USBClearInterruptFlag(USBT1MSECIFReg,USBT1MSECIFBitNum);
+ }
+ }
+#endif
+
+ #if defined(USB_POLLING)
+ //If the interrupt option is selected then the customer is required
+ // to notify the stack when the device is attached or removed from the
+ // bus by calling the USBDeviceAttach() and USBDeviceDetach() functions.
+ if (USB_BUS_SENSE != 1)
+ {
+ // Disable module & detach from bus
+ U1CON = 0;
+
+ // Mask all USB interrupts
+ U1IE = 0;
+
+ //Move to the detached state
+ USBDeviceState = DETACHED_STATE;
+
+ #ifdef USB_SUPPORT_OTG
+ //Disable D+ Pullup
+ U1OTGCONbits.DPPULUP = 0;
+
+ //Disable HNP
+ USBOTGDisableHnp();
+
+ //Deactivate HNP
+ USBOTGDeactivateHnp();
+
+ //If ID Pin Changed State
+ if (USBIDIF && USBIDIE)
+ {
+ //Re-detect & Initialize
+ USBOTGInitialize();
+
+ //Clear ID Interrupt Flag
+ USBClearInterruptFlag(USBIDIFReg,USBIDIFBitNum);
+ }
+ #endif
+
+ #if defined __C30__ || defined __XC16__
+ //USBClearInterruptFlag(U1OTGIR, 3);
+ #endif
+ //return so that we don't go through the rest of
+ //the state machine
+ USBClearUSBInterrupt();
+ return;
+ }
+
+ #ifdef USB_SUPPORT_OTG
+ //If Session Is Started Then
+ else
+ {
+ //If SRP Is Ready
+ if (USBOTGSRPIsReady())
+ {
+ //Clear SRPReady
+ USBOTGClearSRPReady();
+
+ //Clear SRP Timeout Flag
+ USBOTGClearSRPTimeOutFlag();
+
+ //Indicate Session Started
+ UART2PrintString( "\r\n***** USB OTG B Event - Session Started *****\r\n" );
+ }
+ }
+ #endif //#ifdef USB_SUPPORT_OTG
+
+ //if we are in the detached state
+ if(USBDeviceState == DETACHED_STATE)
+ {
+ //Initialize register to known value
+ U1CON = 0;
+
+ // Mask all USB interrupts
+ U1IE = 0;
+
+ //Enable/set things like: pull ups, full/low-speed mode,
+ //set the ping pong mode, and set internal transceiver
+ SetConfigurationOptions();
+
+ // Enable module & attach to bus
+ while(!U1CONbits.USBEN){U1CONbits.USBEN = 1;}
+
+ //moved to the attached state
+ USBDeviceState = ATTACHED_STATE;
+
+ #ifdef USB_SUPPORT_OTG
+ U1OTGCON |= USB_OTG_DPLUS_ENABLE | USB_OTG_ENABLE;
+ #endif
+ }
+ #endif //#if defined(USB_POLLING)
+
+ if(USBDeviceState == ATTACHED_STATE)
+ {
+ /*
+ * After enabling the USB module, it takes some time for the
+ * voltage on the D+ or D- line to rise high enough to get out
+ * of the SE0 condition. The USB Reset interrupt should not be
+ * unmasked until the SE0 condition is cleared. This helps
+ * prevent the firmware from misinterpreting this unique event
+ * as a USB bus reset from the USB host.
+ */
+
+ if(!USBSE0Event)
+ {
+ USBClearInterruptRegister(U1IR);// Clear all USB interrupts
+ #if defined(USB_POLLING)
+ U1IE=0; // Mask all USB interrupts
+ #endif
+ USBResetIE = 1; // Unmask RESET interrupt
+ USBIdleIE = 1; // Unmask IDLE interrupt
+ USBDeviceState = POWERED_STATE;
+ }
+ }
+
+ #ifdef USB_SUPPORT_OTG
+ //If ID Pin Changed State
+ if (USBIDIF && USBIDIE)
+ {
+ //Re-detect & Initialize
+ USBOTGInitialize();
+
+ USBClearInterruptFlag(USBIDIFReg,USBIDIFBitNum);
+ }
+ #endif
+
+ /*
+ * Task A: Service USB Activity Interrupt
+ */
+ if(USBActivityIF && USBActivityIE)
+ {
+ USBClearInterruptFlag(USBActivityIFReg,USBActivityIFBitNum);
+ #if defined(USB_SUPPORT_OTG)
+ U1OTGIR = 0x10;
+ #else
+ USBWakeFromSuspend();
+ #endif
+ }
+
+ /*
+ * Pointless to continue servicing if the device is in suspend mode.
+ */
+ if(USBSuspendControl==1)
+ {
+ USBClearUSBInterrupt();
+ return;
+ }
+
+ /*
+ * Task B: Service USB Bus Reset Interrupt.
+ * When bus reset is received during suspend, ACTVIF will be set first,
+ * once the UCONbits.SUSPND is clear, then the URSTIF bit will be asserted.
+ * This is why URSTIF is checked after ACTVIF.
+ *
+ * The USB reset flag is masked when the USB state is in
+ * DETACHED_STATE or ATTACHED_STATE, and therefore cannot
+ * cause a USB reset event during these two states.
+ */
+ if(USBResetIF && USBResetIE)
+ {
+ USBDeviceInit();
+
+ //Re-enable the interrupts since the USBDeviceInit() function will
+ // disable them. This will do nothing in a polling setup
+ USBUnmaskInterrupts();
+
+ USBDeviceState = DEFAULT_STATE;
+
+ #ifdef USB_SUPPORT_OTG
+ //Disable HNP
+ USBOTGDisableHnp();
+
+ //Deactivate HNP
+ USBOTGDeactivateHnp();
+ #endif
+
+ USBClearInterruptFlag(USBResetIFReg,USBResetIFBitNum);
+ }
+
+ /*
+ * Task C: Service other USB interrupts
+ */
+ if(USBIdleIF && USBIdleIE)
+ {
+ #ifdef USB_SUPPORT_OTG
+ //If Suspended, Try to switch to Host
+ USBOTGSelectRole(ROLE_HOST);
+ #else
+ USBSuspend();
+ #endif
+
+ USBClearInterruptFlag(USBIdleIFReg,USBIdleIFBitNum);
+ }
+
+ if(USBSOFIF)
+ {
+ if(USBSOFIE)
+ {
+ USB_SOF_HANDLER(EVENT_SOF,0,1);
+ }
+ USBClearInterruptFlag(USBSOFIFReg,USBSOFIFBitNum);
+
+ #if defined(USB_ENABLE_STATUS_STAGE_TIMEOUTS)
+ //Supporting this feature requires a 1ms timebase for keeping track of the timeout interval.
+ #if(USB_SPEED_OPTION == USB_LOW_SPEED)
+ #warning "Double click this message. See inline code comments."
+ //The "USB_ENABLE_STATUS_STAGE_TIMEOUTS" feature is optional and is
+ //not strictly needed in all applications (ex: those that never call
+ //USBDeferStatusStage() and don't use host to device (OUT) control
+ //transfers with data stage).
+ //However, if this feature is enabled and used, it requires a timer
+ //(preferrably 1ms) to decrement the USBStatusStageTimeoutCounter.
+ //In USB Full Speed applications, the host sends Start-of-Frame (SOF)
+ //packets at a 1ms rate, which generates SOFIF interrupts.
+ //These interrupts can be used to decrement USBStatusStageTimeoutCounter as shown
+ //below. However, the host does not send SOF packets to Low Speed devices.
+ //Therefore, some other method (ex: using a general purpose microcontroller
+ //timer, such as Timer0) needs to be implemented to call and execute the below code
+ //at a once/1ms rate, in a low speed USB application.
+ //Note: Pre-condition to executing the below code: USBDeviceInit() should have
+ //been called at least once (since the last microcontroller reset/power up),
+ //prior to executing the below code.
+ #endif
+
+ //Decrement our status stage counter.
+ if(USBStatusStageTimeoutCounter != 0u)
+ {
+ USBStatusStageTimeoutCounter--;
+ }
+ //Check if too much time has elapsed since progress was made in
+ //processing the control transfer, without arming the status stage.
+ //If so, auto-arm the status stage to ensure that the control
+ //transfer can [eventually] complete, within the timing limits
+ //dictated by section 9.2.6 of the official USB 2.0 specifications.
+ if(USBStatusStageTimeoutCounter == 0)
+ {
+ USBCtrlEPAllowStatusStage(); //Does nothing if the status stage was already armed.
+ }
+ #endif
+ }
+
+ if(USBStallIF && USBStallIE)
+ {
+ USBStallHandler();
+ }
+
+ if(USBErrorIF && USBErrorIE)
+ {
+ USB_ERROR_HANDLER(EVENT_BUS_ERROR,0,1);
+ USBClearInterruptRegister(U1EIR); // This clears UERRIF
+
+ //On PIC18, clearing the source of the error will automatically clear
+ // the interrupt flag. On other devices the interrupt flag must be
+ // manually cleared.
+ #if defined(__C32__) || defined(__C30__) || defined __XC16__
+ USBClearInterruptFlag( USBErrorIFReg, USBErrorIFBitNum );
+ #endif
+ }
+
+ /*
+ * Pointless to continue servicing if the host has not sent a bus reset.
+ * Once bus reset is received, the device transitions into the DEFAULT
+ * state and is ready for communication.
+ */
+ if(USBDeviceState < DEFAULT_STATE)
+ {
+ USBClearUSBInterrupt();
+ return;
+ }
+
+ /*
+ * Task D: Servicing USB Transaction Complete Interrupt
+ */
+ if(USBTransactionCompleteIE)
+ {
+ for(i = 0; i < 4u; i++) //Drain or deplete the USAT FIFO entries. If the USB FIFO ever gets full, USB bandwidth
+ { //utilization can be compromised, and the device won't be able to receive SETUP packets.
+ if(USBTransactionCompleteIF)
+ {
+ //Save and extract USTAT register info. Will use this info later.
+ USTATcopy.Val = U1STAT;
+ endpoint_number = USBHALGetLastEndpoint(USTATcopy);
+
+ USBClearInterruptFlag(USBTransactionCompleteIFReg,USBTransactionCompleteIFBitNum);
+
+ //Keep track of the hardware ping pong state for endpoints other
+ //than EP0, if ping pong buffering is enabled.
+ #if (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) || (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+ if(USBHALGetLastDirection(USTATcopy) == OUT_FROM_HOST)
+ {
+ ep_data_out[endpoint_number].bits.ping_pong_state ^= 1;
+ }
+ else
+ {
+ ep_data_in[endpoint_number].bits.ping_pong_state ^= 1;
+ }
+ #endif
+
+ //USBCtrlEPService only services transactions over EP0.
+ //It ignores all other EP transactions.
+ if(endpoint_number == 0)
+ {
+ USBCtrlEPService();
+ }
+ else
+ {
+ USB_TRANSFER_COMPLETE_HANDLER(EVENT_TRANSFER, (BYTE*)&USTATcopy.Val, 0);
+ }
+ }//end if(USBTransactionCompleteIF)
+ else
+ break; //USTAT FIFO must be empty.
+ }//end for()
+ }//end if(USBTransactionCompleteIE)
+
+ USBClearUSBInterrupt();
+}//end of USBDeviceTasks()
+
+/*******************************************************************************
+ Function:
+ void USBEnableEndpoint(BYTE ep, BYTE options)
+
+ Summary:
+ This function will enable the specified endpoint with the specified
+ options
+ Description:
+ This function will enable the specified endpoint with the specified
+ options.
+
+ Typical Usage:
+
+ void USBCBInitEP(void)
+ {
+ USBEnableEndpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP);
+ USBMSDInit();
+ }
+
+
+ In the above example endpoint number MSD_DATA_IN_EP is being configured
+ for both IN and OUT traffic with handshaking enabled. Also since
+ MSD_DATA_IN_EP is not endpoint 0 (MSD does not allow this), then we can
+ explicitly disable SETUP packets on this endpoint.
+ Conditions:
+ None
+ Input:
+ BYTE ep - the endpoint to be configured
+ BYTE options - optional settings for the endpoint. The options should
+ be ORed together to form a single options string. The
+ available optional settings for the endpoint. The
+ options should be ORed together to form a single options
+ string. The available options are the following\:
+ * USB_HANDSHAKE_ENABLED enables USB handshaking (ACK,
+ NAK)
+ * USB_HANDSHAKE_DISABLED disables USB handshaking (ACK,
+ NAK)
+ * USB_OUT_ENABLED enables the out direction
+ * USB_OUT_DISABLED disables the out direction
+ * USB_IN_ENABLED enables the in direction
+ * USB_IN_DISABLED disables the in direction
+ * USB_ALLOW_SETUP enables control transfers
+ * USB_DISALLOW_SETUP disables control transfers
+ * USB_STALL_ENDPOINT STALLs this endpoint
+ Return:
+ None
+ Remarks:
+ None
+ *****************************************************************************/
+void USBEnableEndpoint(BYTE ep, BYTE options)
+{
+ unsigned char* p;
+
+ //Use USBConfigureEndpoint() to set up the pBDTEntryIn/Out[ep] pointer and
+ //starting DTS state in the BDT entry.
+ if(options & USB_OUT_ENABLED)
+ {
+ USBConfigureEndpoint(ep, OUT_FROM_HOST);
+ }
+ if(options & USB_IN_ENABLED)
+ {
+ USBConfigureEndpoint(ep, IN_TO_HOST);
+ }
+
+ //Update the relevant UEPx register to actually enable the endpoint with
+ //the specified options (ex: handshaking enabled, control transfers allowed,
+ //etc.)
+ #if defined(__C32__)
+ p = (unsigned char*)(&U1EP0+(4*ep));
+ #else
+ p = (unsigned char*)(&U1EP0+ep);
+ #endif
+ *p = options;
+}
+
+
+/*************************************************************************
+ Function:
+ USB_HANDLE USBTransferOnePacket(BYTE ep, BYTE dir, BYTE* data, BYTE len)
+
+ Summary:
+ Transfers a single packet (one transaction) of data on the USB bus.
+
+ Description:
+ The USBTransferOnePacket() function prepares a USB endpoint
+ so that it may send data to the host (an IN transaction), or
+ receive data from the host (an OUT transaction). The
+ USBTransferOnePacket() function can be used both to receive and
+ send data to the host. This function is the primary API function
+ provided by the USB stack firmware for sending or receiving application
+ data over the USB port.
+
+ The USBTransferOnePacket() is intended for use with all application
+ endpoints. It is not used for sending or receiving applicaiton data
+ through endpoint 0 by using control transfers. Separate API
+ functions, such as USBEP0Receive(), USBEP0SendRAMPtr(), and
+ USBEP0SendROMPtr() are provided for this purpose.
+
+ The USBTransferOnePacket() writes to the Buffer Descriptor Table (BDT)
+ entry associated with an endpoint buffer, and sets the UOWN bit, which
+ prepares the USB hardware to allow the transaction to complete. The
+ application firmware can use the USBHandleBusy() macro to check the
+ status of the transaction, to see if the data has been successfully
+ transmitted yet.
+
+
+ Typical Usage
+
+ //make sure that the we are in the configured state
+ if(USBGetDeviceState() == CONFIGURED_STATE)
+ {
+ //make sure that the last transaction isn't busy by checking the handle
+ if(!USBHandleBusy(USBInHandle))
+ {
+ //Write the new data that we wish to send to the host to the INPacket[] array
+ INPacket[0] = USEFUL_APPLICATION_VALUE1;
+ INPacket[1] = USEFUL_APPLICATION_VALUE2;
+ //INPacket[2] = ... (fill in the rest of the packet data)
+
+ //Send the data contained in the INPacket[] array through endpoint "EP_NUM"
+ USBInHandle = USBTransferOnePacket(EP_NUM,IN_TO_HOST,(BYTE*)&INPacket[0],sizeof(INPacket));
+ }
+ }
+
+
+ Conditions:
+ Before calling USBTransferOnePacket(), the following should be true.
+ 1. The USB stack has already been initialized (USBDeviceInit() was called).
+ 2. A transaction is not already pending on the specified endpoint. This
+ is done by checking the previous request using the USBHandleBusy()
+ macro (see the typical usage example).
+ 3. The host has already sent a set configuration request and the
+ enumeration process is complete.
+ This can be checked by verifying that the USBGetDeviceState()
+ macro returns "CONFIGURED_STATE", prior to calling
+ USBTransferOnePacket().
+
+ Input:
+ BYTE ep - The endpoint number that the data will be transmitted or
+ received on
+ BYTE dir - The direction of the transfer
+ This value is either OUT_FROM_HOST or IN_TO_HOST
+ BYTE* data - For IN transactions: pointer to the RAM buffer containing
+ the data to be sent to the host. For OUT transactions: pointer
+ to the RAM buffer that the received data should get written to.
+ BYTE len - Length of the data needing to be sent (for IN transactions).
+ For OUT transactions, the len parameter should normally be set
+ to the endpoint size specified in the endpoint descriptor.
+
+ Return Values:
+ USB_HANDLE - handle to the transfer. The handle is a pointer to
+ the BDT entry associated with this transaction. The
+ status of the transaction (ex: if it is complete or still
+ pending) can be checked using the USBHandleBusy() macro
+ and supplying the USB_HANDLE provided by
+ USBTransferOnePacket().
+
+ Remarks:
+ If calling the USBTransferOnePacket() function from within the USBCBInitEP()
+ callback function, the set configuration is still being processed and the
+ USBDeviceState may not be == CONFIGURED_STATE yet. In this special case,
+ the USBTransferOnePacket() may still be called, but make sure that the
+ endpoint has been enabled and initialized by the USBEnableEndpoint()
+ function first.
+
+ *************************************************************************/
+USB_HANDLE USBTransferOnePacket(BYTE ep,BYTE dir,BYTE* data,BYTE len)
+{
+ volatile BDT_ENTRY* handle;
+
+ //If the direction is IN
+ if(dir != 0)
+ {
+ //point to the IN BDT of the specified endpoint
+ handle = pBDTEntryIn[ep];
+ }
+ else
+ {
+ //else point to the OUT BDT of the specified endpoint
+ handle = pBDTEntryOut[ep];
+ }
+
+ //Error checking code. Make sure the handle (pBDTEntryIn[ep] or
+ //pBDTEntryOut[ep]) is initialized before using it.
+ if(handle == 0)
+ {
+ return 0;
+ }
+
+ //Toggle the DTS bit if required
+ #if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
+ handle->STAT.Val ^= _DTSMASK;
+ #elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY)
+ if(ep != 0)
+ {
+ handle->STAT.Val ^= _DTSMASK;
+ }
+ #endif
+
+ //Set the data pointer, data length, and enable the endpoint
+ handle->ADR = ConvertToPhysicalAddress(data);
+ handle->CNT = len;
+ handle->STAT.Val &= _DTSMASK;
+ handle->STAT.Val |= _USIE | (_DTSEN & _DTS_CHECKING_ENABLED);
+
+ //Point to the next buffer for ping pong purposes.
+ if(dir != OUT_FROM_HOST)
+ {
+ //toggle over the to the next buffer for an IN endpoint
+ USBAdvancePingPongBuffer(&pBDTEntryIn[ep]);
+ }
+ else
+ {
+ //toggle over the to the next buffer for an OUT endpoint
+ USBAdvancePingPongBuffer(&pBDTEntryOut[ep]);
+ }
+ return (USB_HANDLE)handle;
+}
+
+
+/********************************************************************
+ Function:
+ void USBStallEndpoint(BYTE ep, BYTE dir)
+
+ Summary:
+ Configures the specified endpoint to send STALL to the host, the next
+ time the host tries to access the endpoint.
+
+ PreCondition:
+ None
+
+ Parameters:
+ BYTE ep - The endpoint number that should be configured to send STALL.
+ BYTE dir - The direction of the endpoint to STALL, either
+ IN_TO_HOST or OUT_FROM_HOST.
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *******************************************************************/
+void USBStallEndpoint(BYTE ep, BYTE dir)
+{
+ BDT_ENTRY *p;
+
+ if(ep == 0)
+ {
+ //For control endpoints (ex: EP0), we need to STALL both IN and OUT
+ //endpoints. EP0 OUT must also be prepared to receive the next SETUP
+ //packet that will arrrive.
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|(_DTSEN & _DTS_CHECKING_ENABLED)|_BSTALL;
+ pBDTEntryIn[0]->STAT.Val = _USIE|_BSTALL;
+
+ }
+ else
+ {
+ p = (BDT_ENTRY*)(&BDT[EP(ep,dir,0)]);
+ p->STAT.Val |= _BSTALL | _USIE;
+
+ //If the device is in FULL or ALL_BUT_EP0 ping pong modes
+ //then stall that entry as well
+ #if (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) || (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0)
+
+ p = (BDT_ENTRY*)(&BDT[EP(ep,dir,1)]);
+ p->STAT.Val |= _BSTALL | _USIE;
+ #endif
+ }
+}
+
+/**************************************************************************
+ Function:
+ void USBCancelIO(BYTE endpoint)
+
+ Description:
+ This function cancels the transfers pending on the specified endpoint.
+ This function can only be used after a SETUP packet is received and
+ before that setup packet is handled. This is the time period in which
+ the EVENT_EP0_REQUEST is thrown, before the event handler function
+ returns to the stack.
+
+ Precondition:
+
+ Parameters:
+ BYTE endpoint - the endpoint number you wish to cancel the transfers for
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ **************************************************************************/
+void USBCancelIO(BYTE endpoint)
+{
+ if(USBPacketDisable == 1)
+ {
+ //The PKTDIS bit is currently set right now. It is therefore "safe"
+ //to mess with the BDT right now.
+ pBDTEntryIn[endpoint]->Val &= _DTSMASK; //Makes UOWN = 0 (_UCPU mode). Deactivates endpoint. Only sends NAKs.
+ pBDTEntryIn[endpoint]->Val ^= _DTSMASK; //Toggle the DTS bit. This packet didn't get sent yet, and the next call to USBTransferOnePacket() will re-toggle the DTS bit back to the original (correct) value.
+
+ //Need to do additional handling if ping-pong buffering is being used
+ #if ((USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG) || (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0))
+ //Point to the next buffer for ping pong purposes. UOWN getting cleared
+ //(either due to SIE clearing it after a transaction, or the firmware
+ //clearing it) makes hardware ping pong pointer advance.
+ USBAdvancePingPongBuffer(&pBDTEntryIn[endpoint]);
+
+ pBDTEntryIn[endpoint]->STAT.Val &= _DTSMASK;
+ pBDTEntryIn[endpoint]->STAT.Val ^= _DTSMASK;
+ #endif
+ }
+}
+
+/**************************************************************************
+ Function:
+ void USBDeviceDetach(void)
+
+ Summary:
+ This function configures the USB module to "soft detach" itself from
+ the USB host.
+
+ Description:
+ This function configures the USB module to perform a "soft detach"
+ operation, by disabling the D+ (or D-) ~1.5k pull up resistor, which
+ lets the host know the device is present and attached. This will make
+ the host think that the device has been unplugged. This is potentially
+ useful, as it allows the USB device to force the host to re-enumerate
+ the device (on the firmware has re-enabled the USB module/pull up, by
+ calling USBDeviceAttach(), to "soft re-attach" to the host).
+
+ Precondition:
+ Should only be called when USB_INTERRUPT is defined. See remarks
+ section if USB_POLLING mode option is being used (usb_config.h option).
+
+ Additionally, this function should only be called from the main() loop
+ context. Do not call this function from within an interrupt handler, as
+ this function may modify global interrupt enable bits and settings.
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ If the application firmware calls USBDeviceDetach(), it is strongly
+ recommended that the firmware wait at least >= 80ms before calling
+ USBDeviceAttach(). If the firmeware performs a soft detach, and then
+ re-attaches too soon (ex: after a few micro seconds for instance), some
+ hosts may interpret this as an unexpected "glitch" rather than as a
+ physical removal/re-attachment of the USB device. In this case the host
+ may simply ignore the event without re-enumerating the device. To
+ ensure that the host properly detects and processes the device soft
+ detach/re-attach, it is recommended to make sure the device remains
+ detached long enough to mimic a real human controlled USB
+ unplug/re-attach event (ex: after calling USBDeviceDetach(), do not
+ call USBDeviceAttach() for at least 80+ms, preferrably longer.
+
+ Neither the USBDeviceDetach() or USBDeviceAttach() functions are blocking
+ or take long to execute. It is the application firmware's
+ responsibility for adding the 80+ms delay, when using these API
+ functions.
+
+ Note: The Windows plug and play event handler processing is fairly
+ slow, especially in certain versions of Windows, and for certain USB
+ device classes. It has been observed that some device classes need to
+ provide even more USB detach dwell interval (before calling
+ USBDeviceAttach()), in order to work correctly after re-enumeration.
+ If the USB device is a CDC class device, it is recommended to wait
+ at least 1.5 seconds or longer, before soft re-attaching to the host,
+ to provide the plug and play event handler enough time to finish
+ processing the removal event, before the re-attach occurs.
+
+ If the application is using the USB_POLLING mode option, then the
+ USBDeviceDetach() and USBDeviceAttach() functions are not available.
+ In this mode, the USB stack relies on the "#define USE_USB_BUS_SENSE_IO"
+ and "#define USB_BUS_SENSE" options in the
+ HardwareProfile – [platform name].h file.
+
+ When using the USB_POLLING mode option, and the
+ "#define USE_USB_BUS_SENSE_IO" definition has been commented out, then
+ the USB stack assumes that it should always enable the USB module at
+ pretty much all times. Basically, anytime the application firmware
+ calls USBDeviceTasks(), the firmware will automatically enable the USB
+ module. This mode would typically be selected if the application was
+ designed to be a purely bus powered device. In this case, the
+ application is powered from the +5V VBUS supply from the USB port, so
+ it is correct and sensible in this type of application to power up and
+ turn on the USB module, at anytime that the microcontroller is
+ powered (which implies the USB cable is attached and the host is also
+ powered).
+
+ In a self powered application, the USB stack is designed with the
+ intention that the user will enable the "#define USE_USB_BUS_SENSE_IO"
+ option in the HardwareProfile – [platform name].h file. When this
+ option is defined, then the USBDeviceTasks() function will automatically
+ check the I/O pin port value of the designated pin (based on the
+ #define USB_BUS_SENSE option in the HardwareProfile – [platform name].h
+ file), every time the application calls USBDeviceTasks(). If the
+ USBDeviceTasks() function is executed and finds that the pin defined by
+ the #define USB_BUS_SENSE is in a logic low state, then it will
+ automatically disable the USB module and tri-state the D+ and D- pins.
+ If however the USBDeviceTasks() function is executed and finds the pin
+ defined by the #define USB_BUS_SENSE is in a logic high state, then it
+ will automatically enable the USB module, if it has not already been
+ enabled.
+
+ **************************************************************************/
+#if defined(USB_INTERRUPT)
+void USBDeviceDetach(void)
+{
+ //If the interrupt option is selected then the customer is required
+ // to notify the stack when the device is attached or removed from the
+ // bus by calling the USBDeviceAttach() and USBDeviceDetach() functions.
+#ifdef USB_SUPPORT_OTG
+ if (USB_BUS_SENSE != 1)
+#endif
+ {
+ // Disable module & detach from bus
+ U1CON = 0;
+
+ // Mask all USB interrupts
+ U1IE = 0;
+
+ //Move to the detached state
+ USBDeviceState = DETACHED_STATE;
+
+ #ifdef USB_SUPPORT_OTG
+ //Disable D+ Pullup
+ U1OTGCONbits.DPPULUP = 0;
+
+ //Disable HNP
+ USBOTGDisableHnp();
+
+ //Deactivate HNP
+ USBOTGDeactivateHnp();
+
+ //If ID Pin Changed State
+ if (USBIDIF && USBIDIE)
+ {
+ //Re-detect & Initialize
+ USBOTGInitialize();
+
+ //Clear ID Interrupt Flag
+ USBClearInterruptFlag(USBIDIFReg,USBIDIFBitNum);
+ }
+ #endif
+
+ #if defined __C30__ || defined __XC16__
+ //USBClearInterruptFlag(U1OTGIR, 3);
+ #endif
+ //return so that we don't go through the rest of
+ //the state machine
+ return;
+ }
+
+#ifdef USB_SUPPORT_OTG
+ //If Session Is Started Then
+ else
+ {
+ //If SRP Is Ready
+ if (USBOTGSRPIsReady())
+ {
+ //Clear SRPReady
+ USBOTGClearSRPReady();
+
+ //Clear SRP Timeout Flag
+ USBOTGClearSRPTimeOutFlag();
+
+ //Indicate Session Started
+ UART2PrintString( "\r\n***** USB OTG B Event - Session Started *****\r\n" );
+ }
+ }
+#endif
+}
+#endif //#if defined(USB_INTERRUPT)
+/**************************************************************************
+ Function:
+ void USBDeviceAttach(void)
+
+ Summary:
+ Checks if VBUS is present, and that the USB module is not already
+ initalized, and if so, enables the USB module so as to signal device
+ attachment to the USB host.
+
+ Description:
+ This function indicates to the USB host that the USB device has been
+ attached to the bus. This function needs to be called in order for the
+ device to start to enumerate on the bus.
+
+ Precondition:
+ Should only be called when USB_INTERRUPT is defined. Also, should only
+ be called from the main() loop context. Do not call USBDeviceAttach()
+ from within an interrupt handler, as the USBDeviceAttach() function
+ may modify global interrupt enable bits and settings.
+
+ For normal USB devices:
+ Make sure that if the module was previously on, that it has been turned off
+ for a long time (ex: 100ms+) before calling this function to re-enable the module.
+ If the device turns off the D+ (for full speed) or D- (for low speed) ~1.5k ohm
+ pull up resistor, and then turns it back on very quickly, common hosts will sometimes
+ reject this event, since no human could ever unplug and reattach a USB device in a
+ microseconds (or nanoseconds) timescale. The host could simply treat this as some kind
+ of glitch and ignore the event altogether.
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ See also the USBDeviceDetach() API function documentation.
+****************************************************************************/
+#if defined(USB_INTERRUPT)
+void USBDeviceAttach(void)
+{
+ //if we are in the detached state
+ if(USBDeviceState == DETACHED_STATE)
+ {
+ if(USB_BUS_SENSE == 1)
+ {
+ //Initialize registers to known states.
+ U1CON = 0;
+
+ // Mask all USB interrupts
+ U1IE = 0;
+
+ //Configure things like: pull ups, full/low-speed mode,
+ //set the ping pong mode, and set internal transceiver
+ SetConfigurationOptions();
+
+ USBEnableInterrupts(); //Modifies global interrupt settings
+
+ // Enable module & attach to bus
+ while(!U1CONbits.USBEN){U1CONbits.USBEN = 1;}
+
+ //moved to the attached state
+ USBDeviceState = ATTACHED_STATE;
+
+ #ifdef USB_SUPPORT_OTG
+ U1OTGCON = USB_OTG_DPLUS_ENABLE | USB_OTG_ENABLE;
+ #endif
+ }
+ }
+}
+#endif //#if defined(USB_INTERRUPT)
+
+
+/*******************************************************************************
+ Function: void USBCtrlEPAllowStatusStage(void);
+
+ Summary: This function prepares the proper endpoint 0 IN or endpoint 0 OUT
+ (based on the controlTransferState) to allow the status stage packet
+ of a control transfer to complete. This function gets used
+ internally by the USB stack itself, but it may also be called from
+ the application firmware, IF the application firmware called
+ the USBDeferStatusStage() function during the initial processing
+ of the control transfer request. In this case, the application
+ must call the USBCtrlEPAllowStatusStage() once, after it has fully
+ completed processing and handling the data stage portion of the
+ request.
+
+ If the application firmware has no need for delaying control
+ transfers, and therefore never calls USBDeferStatusStage(), then the
+ application firmware should not call USBCtrlEPAllowStatusStage().
+
+ Description:
+
+ Conditions:
+ None
+
+ Input:
+
+ Return:
+
+ Remarks:
+ None
+ *****************************************************************************/
+void USBCtrlEPAllowStatusStage(void)
+{
+ //Check and set two flags, prior to actually modifying any BDT entries.
+ //This double checking is necessary to make certain that
+ //USBCtrlEPAllowStatusStage() can be called twice simultaneously (ex: once
+ //in main loop context, while simultaneously getting an interrupt which
+ //tries to call USBCtrlEPAllowStatusStage() again, at the same time).
+ if(USBStatusStageEnabledFlag1 == FALSE)
+ {
+ USBStatusStageEnabledFlag1 = TRUE;
+ if(USBStatusStageEnabledFlag2 == FALSE)
+ {
+ USBStatusStageEnabledFlag2 = TRUE;
+
+ //Determine which endpoints (EP0 IN or OUT needs arming for the status
+ //stage), based on the type of control transfer currently pending.
+ if(controlTransferState == CTRL_TRF_RX)
+ {
+ pBDTEntryIn[0]->CNT = 0;
+ pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+ else if(controlTransferState == CTRL_TRF_TX)
+ {
+ BothEP0OutUOWNsSet = FALSE; //Indicator flag used in USBCtrlTrfOutHandler()
+
+ //This buffer (when ping pong buffering is enabled on EP0 OUT) receives the
+ //next SETUP packet.
+ #if((USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY) || (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG))
+ pBDTEntryEP0OutCurrent->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutCurrent->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ pBDTEntryEP0OutCurrent->STAT.Val = _USIE|_BSTALL; //Prepare endpoint to accept a SETUP transaction
+ BothEP0OutUOWNsSet = TRUE; //Indicator flag used in USBCtrlTrfOutHandler()
+ #endif
+
+ //This EP0 OUT buffer receives the 0-byte OUT status stage packet.
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ pBDTEntryEP0OutNext->STAT.Val = _USIE; // Note: DTSEN is 0
+ }
+ }
+ }
+}
+
+
+/*******************************************************************************
+ Function: void USBCtrlEPAllowDataStage(void);
+
+ Summary: This function allows the data stage of either a host-to-device or
+ device-to-host control transfer (with data stage) to complete.
+ This function is meant to be used in conjunction with either the
+ USBDeferOUTDataStage() or USBDeferINDataStage(). If the firmware
+ does not call either USBDeferOUTDataStage() or USBDeferINDataStage(),
+ then the firmware does not need to manually call
+ USBCtrlEPAllowDataStage(), as the USB stack will call this function
+ instead.
+
+ Description:
+
+ Conditions: A control transfer (with data stage) should already be pending,
+ if the firmware calls this function. Additionally, the firmware
+ should have called either USBDeferOUTDataStage() or
+ USBDeferINDataStage() at the start of the control transfer, if
+ the firmware will be calling this function manually.
+
+ Input:
+
+ Return:
+
+ Remarks:
+ *****************************************************************************/
+void USBCtrlEPAllowDataStage(void)
+{
+ USBDeferINDataStagePackets = FALSE;
+ USBDeferOUTDataStagePackets = FALSE;
+
+ if(controlTransferState == CTRL_TRF_RX) //(...)
+ {
+ //Prepare EP0 OUT to receive the first OUT data packet in the data stage sequence.
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&CtrlTrfData);
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT1|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+ else //else must be controlTransferState == CTRL_TRF_TX (...)
+ {
+ //Error check the data stage byte count. Make sure the user specified
+ //value was no greater than the number of bytes the host requested.
+ if(SetupPkt.wLength < inPipes[0].wCount.Val)
+ {
+ inPipes[0].wCount.Val = SetupPkt.wLength;
+ }
+ USBCtrlTrfTxService(); //Copies one IN data packet worth of data from application buffer
+ //to CtrlTrfData buffer. Also keeps track of how many bytes remaining.
+
+ //Cnt should have been initialized by responsible request owner (ex: by
+ //using the USBEP0SendRAMPtr() or USBEP0SendROMPtr() API function).
+ pBDTEntryIn[0]->ADR = ConvertToPhysicalAddress(&CtrlTrfData);
+ pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+}
+
+
+/******************************************************************************/
+/** Internal Functions *********************************************************/
+/******************************************************************************/
+
+/********************************************************************
+ * Function: void USBConfigureEndpoint(BYTE EPNum, BYTE direction)
+ *
+ * PreCondition: None
+ *
+ * Input: BYTE EPNum - the endpoint to be configured
+ * BYTE direction - the direction to be configured
+ * (either OUT_FROM_HOST or IN_TO_HOST)
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This function will configure the specified
+ * endpoint
+ *
+ * Note: None
+ *******************************************************************/
+static void USBConfigureEndpoint(BYTE EPNum, BYTE direction)
+{
+ volatile BDT_ENTRY* handle;
+
+ //Compute a pointer to the even BDT entry corresponding to the
+ //EPNum and direction values passed to this function.
+ handle = (volatile BDT_ENTRY*)&BDT[EP0_OUT_EVEN]; //Get address of start of BDT
+ handle += EP(EPNum,direction,0u); //Add in offset to the BDT of interest
+
+ handle->STAT.UOWN = 0; //mostly redundant, since USBStdSetCfgHandler()
+ //already cleared the entire BDT table
+
+ //Make sure our pBDTEntryIn/Out[] pointer is initialized. Needed later
+ //for USBTransferOnePacket() API calls.
+ if(direction == OUT_FROM_HOST)
+ {
+ pBDTEntryOut[EPNum] = handle;
+ }
+ else
+ {
+ pBDTEntryIn[EPNum] = handle;
+ }
+
+ #if (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+ handle->STAT.DTS = 0;
+ (handle+1)->STAT.DTS = 1;
+ #elif (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
+ //Set DTS to one because the first thing we will do
+ //when transmitting is toggle the bit
+ handle->STAT.DTS = 1;
+ #elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY)
+ if(EPNum != 0)
+ {
+ handle->STAT.DTS = 1;
+ }
+ #elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0)
+ if(EPNum != 0)
+ {
+ handle->STAT.DTS = 0;
+ (handle+1)->STAT.DTS = 1;
+ }
+ #endif
+}
+
+
+/******************************************************************************
+ * Function: void USBCtrlEPServiceComplete(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine wrap up the remaining tasks in servicing
+ * a Setup Request. Its main task is to set the endpoint
+ * controls appropriately for a given situation. See code
+ * below.
+ * There are three main scenarios:
+ * a) There was no handler for the Request, in this case
+ * a STALL should be sent out.
+ * b) The host has requested a read control transfer,
+ * endpoints are required to be setup in a specific way.
+ * c) The host has requested a write control transfer, or
+ * a control data stage is not required, endpoints are
+ * required to be setup in a specific way.
+ *
+ * Packet processing is resumed by clearing PKTDIS bit.
+ *
+ * Note: None
+ *****************************************************************************/
+static void USBCtrlEPServiceComplete(void)
+{
+ /*
+ * PKTDIS bit is set when a Setup Transaction is received.
+ * Clear to resume packet processing.
+ */
+ USBPacketDisable = 0;
+
+ //Check the busy bits and the SetupPtk.DataDir variables to determine what type of
+ //control transfer is currently in progress. We need to know the type of control
+ //transfer that is currently pending, in order to know how to properly arm the
+ //EP0 IN and EP0 OUT endpoints.
+ if(inPipes[0].info.bits.busy == 0)
+ {
+ if(outPipes[0].info.bits.busy == 1)
+ {
+ controlTransferState = CTRL_TRF_RX;
+ /*
+ * Control Write:
+ * ... |
+ */
+
+ //1. Prepare OUT EP to receive data, unless a USB class request handler
+ // function decided to defer the data stage (ex: because the intended
+ // RAM buffer wasn't available yet) by calling USBDeferDataStage().
+ // If it did so, it is then responsible for calling USBCtrlEPAllowDataStage(),
+ // once it is ready to begin receiving the data.
+ if(USBDeferOUTDataStagePackets == FALSE)
+ {
+ USBCtrlEPAllowDataStage();
+ }
+
+ //2. IN endpoint 0 status stage will be armed by USBCtrlEPAllowStatusStage()
+ //after all of the OUT data has been received and consumed, or if a timeout occurs.
+ USBStatusStageEnabledFlag2 = FALSE;
+ USBStatusStageEnabledFlag1 = FALSE;
+ }
+ else
+ {
+ /*
+ * If no one knows how to service this request then stall.
+ * Must also prepare EP0 to receive the next SETUP transaction.
+ */
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|(_DTSEN & _DTS_CHECKING_ENABLED)|_BSTALL;
+ pBDTEntryIn[0]->STAT.Val = _USIE|_BSTALL;
+ }
+ }
+ else // A module has claimed ownership of the control transfer session.
+ {
+ if(SetupPkt.DataDir == USB_SETUP_DEVICE_TO_HOST_BITFIELD)
+ {
+ controlTransferState = CTRL_TRF_TX;
+ /*
+ * Control Read:
+ * ... |
+ *
+ * 1. Prepare IN EP to transfer data to the host. If however the data
+ * wasn't ready yet (ex: because the firmware needs to go and read it from
+ * some slow/currently unavailable resource, such as an external I2C EEPROM),
+ * Then the class request handler reponsible should call the USBDeferDataStage()
+ * macro. In this case, the firmware may wait up to 500ms, before it is required
+ * to transmit the first IN data packet. Once the data is ready, and the firmware
+ * is ready to begin sending the data, it should then call the
+ * USBCtrlEPAllowDataStage() function to start the data stage.
+ */
+ if(USBDeferINDataStagePackets == FALSE)
+ {
+ USBCtrlEPAllowDataStage();
+ }
+
+ // 2. (Optionally) allow the status stage now, to prepare for early termination.
+ // Note: If a class request handler decided to set USBDeferStatusStagePacket == TRUE,
+ // then it is responsible for eventually calling USBCtrlEPAllowStatusStage() once it
+ // is ready. If the class request handler does this, it needs to be careful to
+ // be written so that it can handle the early termination scenario.
+ // Ex: It should call USBCtrlEPAllowStatusStage() when any of the following occurs:
+ // 1. The desired total number of bytes were sent to the host.
+ // 2. The number of bytes that the host originally requested (in the SETUP packet that
+ // started the control transfer) has been reached.
+ // 3. Or, if a timeout occurs (ex: <50ms since the last successful EP0 IN transaction), regardless
+ // of how many bytes have actually been sent. This is necessary to prevent a deadlock situation
+ // (where the control transfer can't complete, due to continuous NAK on status stage) if the
+ // host performs early termination. If enabled, the USB_ENABLE_STATUS_STAGE_TIMEOUTS usb_config.h
+ // option can take care of this for you.
+ // Note: For this type of control transfer, there is normally no harm in simply arming the
+ // status stage packet right now, even if the IN data is not ready yet. This allows for
+ // immediate early termination, without adding unecessary delay. Therefore, it is generally not
+ // recommended for the USB class handler firmware to call USBDeferStatusStage(), for this
+ // type of control transfer. If the USB class handler firmware needs more time to fetch the IN
+ // data that needs to be sent to the host, it should instead use the USBDeferDataStage() function.
+ USBStatusStageEnabledFlag2 = FALSE;
+ USBStatusStageEnabledFlag1 = FALSE;
+ if(USBDeferStatusStagePacket == FALSE)
+ {
+ USBCtrlEPAllowStatusStage();
+ }
+ }
+ else // (SetupPkt.DataDir == USB_SETUP_DIRECTION_HOST_TO_DEVICE)
+ {
+ //This situation occurs for special types of control transfers,
+ //such as that which occurs when the host sends a SET_ADDRESS
+ //control transfer. Ex:
+ //
+ // |
+
+ //Although the data direction is HOST_TO_DEVICE, there is no data stage
+ //(hence: outPipes[0].info.bits.busy == 0). There is however still
+ //an IN status stage.
+
+ controlTransferState = CTRL_TRF_RX; //Since this is a HOST_TO_DEVICE control transfer
+
+ //1. Prepare OUT EP to receive the next SETUP packet.
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_BSTALL;
+
+ //2. Prepare for IN status stage of the control transfer
+ USBStatusStageEnabledFlag2 = FALSE;
+ USBStatusStageEnabledFlag1 = FALSE;
+ if(USBDeferStatusStagePacket == FALSE)
+ {
+ USBCtrlEPAllowStatusStage();
+ }
+ }
+
+ }//end if(ctrl_trf_session_owner == MUID_NULL)
+
+}//end USBCtrlEPServiceComplete
+
+
+/******************************************************************************
+ * Function: void USBCtrlTrfTxService(void)
+ *
+ * PreCondition: pSrc, wCount, and usb_stat.ctrl_trf_mem are setup properly.
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine is used for device to host control transfers
+ * (IN transactions). This function takes care of managing a
+ * transfer over multiple USB transactions.
+ * This routine should be called from only two places.
+ * One from USBCtrlEPServiceComplete() and one from
+ * USBCtrlTrfInHandler().
+ *
+ * Note:
+ *****************************************************************************/
+static void USBCtrlTrfTxService(void)
+{
+ BYTE byteToSend;
+
+ //Figure out how many bytes of data to send in the next IN transaction.
+ //Assume a full size packet, unless otherwise determined below.
+ byteToSend = USB_EP0_BUFF_SIZE;
+ if(inPipes[0].wCount.Val < (BYTE)USB_EP0_BUFF_SIZE)
+ {
+ byteToSend = inPipes[0].wCount.Val;
+
+ //Keep track of whether or not we have sent a "short packet" yet.
+ //This is useful so that later on, we can configure EP0 IN to STALL,
+ //after we have sent all of the intended data. This makes sure the
+ //hardware STALLs if the host erroneously tries to send more IN token
+ //packets, requesting more data than intended in the control transfer.
+ if(shortPacketStatus == SHORT_PKT_NOT_USED)
+ {
+ shortPacketStatus = SHORT_PKT_PENDING;
+ }
+ else if(shortPacketStatus == SHORT_PKT_PENDING)
+ {
+ shortPacketStatus = SHORT_PKT_SENT;
+ }
+ }
+
+ //Keep track of how many bytes remain to be sent in the transfer, by
+ //subtracting the number of bytes about to be sent from the total.
+ inPipes[0].wCount.Val = inPipes[0].wCount.Val - byteToSend;
+
+ //Next, load the number of bytes to send to BC7..0 in buffer descriptor.
+ //Note: Control endpoints may never have a max packet size of > 64 bytes.
+ //Therefore, the BC8 and BC9 bits should always be maintained clear.
+ pBDTEntryIn[0]->CNT = byteToSend;
+
+ //Now copy the data from the source location, to the CtrlTrfData[] buffer,
+ //which we will send to the host.
+ pDst = (USB_VOLATILE BYTE*)CtrlTrfData; // Set destination pointer
+ if(inPipes[0].info.bits.ctrl_trf_mem == USB_EP0_ROM) // Determine type of memory source
+ {
+ while(byteToSend)
+ {
+ *pDst++ = *inPipes[0].pSrc.bRom++;
+ byteToSend--;
+ }//end while(byte_to_send.Val)
+ }
+ else // RAM
+ {
+ while(byteToSend)
+ {
+ *pDst++ = *inPipes[0].pSrc.bRam++;
+ byteToSend--;
+ }//end while(byte_to_send.Val)
+ }//end if(usb_stat.ctrl_trf_mem == _ROM)
+}//end USBCtrlTrfTxService
+
+/******************************************************************************
+ * Function: void USBCtrlTrfRxService(void)
+ *
+ * PreCondition: pDst and wCount are setup properly.
+ * pSrc is always &CtrlTrfData
+ * usb_stat.ctrl_trf_mem is always USB_EP0_RAM.
+ * wCount should be set to 0 at the start of each control
+ * transfer.
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine is used for host to device control transfers
+ * (uses OUT transactions). This function receives the data that arrives
+ * on EP0 OUT, and copies it into the appropriate outPipes[0].pDst.bRam
+ * buffer. Once the host has sent all the data it was intending
+ * to send, this function will call the appropriate outPipes[0].pFunc()
+ * handler (unless it is NULL), so that it can be used by the
+ * intended target firmware.
+ *
+ * Note: None
+ *****************************************************************************/
+static void USBCtrlTrfRxService(void)
+{
+ BYTE byteToRead;
+ BYTE i;
+
+ //Load byteToRead with the number of bytes the host just sent us in the
+ //last OUT transaction.
+ byteToRead = pBDTEntryEP0OutCurrent->CNT;
+
+ //Update the "outPipes[0].wCount.Val", which keeps track of the total number
+ //of remaining bytes expected to be received from the host, in the control
+ //transfer. First check to see if the host sent us more bytes than the
+ //application firmware was expecting to receive.
+ if(byteToRead > outPipes[0].wCount.Val)
+ {
+ byteToRead = outPipes[0].wCount.Val;
+ }
+ //Reduce the number of remaining bytes by the number we just received.
+ outPipes[0].wCount.Val = outPipes[0].wCount.Val - byteToRead;
+
+ //Copy the OUT DATAx packet bytes that we just received from the host,
+ //into the user application buffer space.
+ for(i=0;i 0)
+ {
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&CtrlTrfData);
+ if(pBDTEntryEP0OutCurrent->STAT.DTS == 0)
+ {
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT1|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+ else
+ {
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+ }
+ else
+ {
+ //We have received all OUT packets that we were expecting to
+ //receive for the control transfer. Prepare EP0 OUT to receive
+ //the next SETUP transaction that may arrive.
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ //Configure EP0 OUT to receive the next SETUP transaction for any future
+ //control transfers. However, set BSTALL in case the host tries to send
+ //more data than it claims it was going to send.
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_BSTALL;
+
+ //All data bytes for the host to device control write (OUT) have now been
+ //received successfully.
+ //Go ahead and call the user specified callback function, to use/consume
+ //the control transfer data (ex: if the "void (*function)" parameter
+ //was non-NULL when USBEP0Receive() was called).
+ if(outPipes[0].pFunc != NULL)
+ {
+ #if defined(__XC8)
+ //Special pragmas to suppress an expected/harmless warning
+ //message when building with the XC8 compiler
+ #pragma warning push
+ #pragma warning disable 1088
+ outPipes[0].pFunc(); //Call the user's callback function
+ #pragma warning pop
+ #else
+ outPipes[0].pFunc(); //Call the user's callback function
+ #endif
+ }
+ outPipes[0].info.bits.busy = 0;
+
+ //Ready to arm status stage IN transaction now, if the application
+ //firmware has completed processing the request. If it is still busy
+ //and needs more time to finish handling the request, then the user
+ //callback (the one called by the outPipes[0].pFunc();) should set the
+ //USBDeferStatusStagePacket to TRUE (by calling USBDeferStatusStage()). In
+ //this case, it is the application's firmware responsibility to call
+ //the USBCtrlEPAllowStatusStage() function, once it is fully done handling the request.
+ //Note: The application firmware must process the request and call
+ //USBCtrlEPAllowStatusStage() in a semi-timely fashion. "Semi-timely"
+ //means either 50ms, 500ms, or 5 seconds, depending on the type of
+ //control transfer. See the USB 2.0 specification section 9.2.6 for
+ //more details.
+ if(USBDeferStatusStagePacket == FALSE)
+ {
+ USBCtrlEPAllowStatusStage();
+ }
+ }
+
+}//end USBCtrlTrfRxService
+
+
+/********************************************************************
+ * Function: void USBStdSetCfgHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine first disables all endpoints by
+ * clearing UEP registers. It then configures
+ * (initializes) endpoints by calling the callback
+ * function USBCBInitEP().
+ *
+ * Note: None
+ *******************************************************************/
+static void USBStdSetCfgHandler(void)
+{
+ BYTE i;
+
+ // This will generate a zero length packet
+ inPipes[0].info.bits.busy = 1;
+
+ //Clear all of the endpoint control registers
+ DisableNonZeroEndpoints(USB_MAX_EP_NUMBER);
+
+ //Clear all of the BDT entries
+ memset((void*)&BDT[0], 0x00, sizeof(BDT));
+
+ // Assert reset request to all of the Ping Pong buffer pointers
+ USBPingPongBufferReset = 1;
+
+ //Re-Initialize all ping pong software state bits to 0 (which corresponds to
+ //the EVEN buffer being the next one that will be used), since we are also
+ //doing a hardware ping pong pointer reset above.
+ for(i = 0; i < (BYTE)(USB_MAX_EP_NUMBER+1u); i++)
+ {
+ ep_data_in[i].Val = 0u;
+ ep_data_out[i].Val = 0u;
+ }
+
+ //clear the alternate interface settings
+ memset((void*)&USBAlternateInterface,0x00,USB_MAX_NUM_INT);
+
+ //Stop trying to reset ping pong buffer pointers
+ USBPingPongBufferReset = 0;
+
+ pBDTEntryIn[0] = (volatile BDT_ENTRY*)&BDT[EP0_IN_EVEN];
+
+ //Set the next out to the current out packet
+ pBDTEntryEP0OutCurrent = (volatile BDT_ENTRY*)&BDT[EP0_OUT_EVEN];
+ pBDTEntryEP0OutNext = pBDTEntryEP0OutCurrent;
+
+ //set the current configuration
+ USBActiveConfiguration = SetupPkt.bConfigurationValue;
+
+ //if the configuration value == 0
+ if(USBActiveConfiguration == 0)
+ {
+ //Go back to the addressed state
+ USBDeviceState = ADDRESS_STATE;
+ }
+ else
+ {
+ //initialize the required endpoints
+ USB_SET_CONFIGURATION_HANDLER(EVENT_CONFIGURED,(void*)&USBActiveConfiguration,1);
+
+ //Otherwise go to the configured state. Update the state variable last,
+ //after performing all of the set configuration related initialization
+ //tasks.
+ USBDeviceState = CONFIGURED_STATE;
+ }//end if(SetupPkt.bConfigurationValue == 0)
+}//end USBStdSetCfgHandler
+
+
+/********************************************************************
+ * Function: void USBStdGetDscHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine handles the standard GET_DESCRIPTOR
+ * request.
+ *
+ * Note: None
+ *******************************************************************/
+static void USBStdGetDscHandler(void)
+{
+ if(SetupPkt.bmRequestType == 0x80)
+ {
+ inPipes[0].info.Val = USB_EP0_ROM | USB_EP0_BUSY | USB_EP0_INCLUDE_ZERO;
+
+ switch(SetupPkt.bDescriptorType)
+ {
+ case USB_DESCRIPTOR_DEVICE:
+ #if !defined(USB_USER_DEVICE_DESCRIPTOR)
+ inPipes[0].pSrc.bRom = (ROM BYTE*)&device_dsc;
+ #else
+ inPipes[0].pSrc.bRom = (ROM BYTE*)USB_USER_DEVICE_DESCRIPTOR;
+ #endif
+ inPipes[0].wCount.Val = sizeof(device_dsc);
+ break;
+ case USB_DESCRIPTOR_CONFIGURATION:
+ #if !defined(USB_USER_CONFIG_DESCRIPTOR)
+ inPipes[0].pSrc.bRom = *(USB_CD_Ptr+SetupPkt.bDscIndex);
+ #else
+ inPipes[0].pSrc.bRom = *(USB_USER_CONFIG_DESCRIPTOR+SetupPkt.bDscIndex);
+ #endif
+
+ //This must be loaded using byte addressing. The source pointer
+ // may not be word aligned for the 16 or 32 bit machines resulting
+ // in an address error on the dereference.
+ inPipes[0].wCount.byte.LB = *(inPipes[0].pSrc.bRom+2);
+ inPipes[0].wCount.byte.HB = *(inPipes[0].pSrc.bRom+3);
+ break;
+ case USB_DESCRIPTOR_STRING:
+ //USB_NUM_STRING_DESCRIPTORS was introduced as optional in release v2.3. In v2.4 and
+ // later it is now manditory. This should be defined in usb_config.h and should
+ // indicate the number of string descriptors.
+ if(SetupPkt.bDscIndexSTAT.UOWN == 1) && (p->STAT.BSTALL == 1))
+ CtrlTrfData[0]=0x01; // Set bit0
+ break;
+ }
+ }//end switch
+
+ if(inPipes[0].info.bits.busy == 1)
+ {
+ inPipes[0].pSrc.bRam = (BYTE*)&CtrlTrfData; // Set Source
+ inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
+ inPipes[0].wCount.v[0] = 2; // Set data count
+ }//end if(...)
+}//end USBStdGetStatusHandler
+
+/********************************************************************
+ * Function: void USBStallHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects:
+ *
+ * Overview: This function handles the event of a STALL
+ * occuring on the bus
+ *
+ * Note: None
+ *******************************************************************/
+static void USBStallHandler(void)
+{
+ /*
+ * Does not really have to do anything here,
+ * even for the control endpoint.
+ * All BDs of Endpoint 0 are owned by SIE right now,
+ * but once a Setup Transaction is received, the ownership
+ * for EP0_OUT will be returned to CPU.
+ * When the Setup Transaction is serviced, the ownership
+ * for EP0_IN will then be forced back to CPU by firmware.
+ */
+
+ /* v2b fix */
+ if(U1EP0bits.EPSTALL == 1)
+ {
+ // UOWN - if 0, owned by CPU, if 1, owned by SIE
+ if((pBDTEntryEP0OutCurrent->STAT.Val == _USIE) && (pBDTEntryIn[0]->STAT.Val == (_USIE|_BSTALL)))
+ {
+ // Set ep0Bo to stall also
+ pBDTEntryEP0OutCurrent->STAT.Val = _USIE|_DAT0|(_DTSEN & _DTS_CHECKING_ENABLED)|_BSTALL;
+ }//end if
+ U1EP0bits.EPSTALL = 0; // Clear stall status
+ }//end if
+
+ USBClearInterruptFlag(USBStallIFReg,USBStallIFBitNum);
+}
+
+/********************************************************************
+ * Function: void USBSuspend(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects:
+ *
+ * Overview: This function handles if the host tries to
+ * suspend the device
+ *
+ * Note: None
+ *******************************************************************/
+static void USBSuspend(void)
+{
+ /*
+ * NOTE: Do not clear UIRbits.ACTVIF here!
+ * Reason:
+ * ACTVIF is only generated once an IDLEIF has been generated.
+ * This is a 1:1 ratio interrupt generation.
+ * For every IDLEIF, there will be only one ACTVIF regardless of
+ * the number of subsequent bus transitions.
+ *
+ * If the ACTIF is cleared here, a problem could occur when:
+ * [ IDLE ][bus activity ->
+ * <--- 3 ms -----> ^
+ * ^ ACTVIF=1
+ * IDLEIF=1
+ * # # # # (#=Program polling flags)
+ * ^
+ * This polling loop will see both
+ * IDLEIF=1 and ACTVIF=1.
+ * However, the program services IDLEIF first
+ * because ACTIVIE=0.
+ * If this routine clears the only ACTIVIF,
+ * then it can never get out of the suspend
+ * mode.
+ */
+ USBActivityIE = 1; // Enable bus activity interrupt
+ USBClearInterruptFlag(USBIdleIFReg,USBIdleIFBitNum);
+
+ #if defined(__18CXX) || defined(_PIC14E)
+ U1CONbits.SUSPND = 1; // Put USB module in power conserve
+ // mode, SIE clock inactive
+ #endif
+ USBBusIsSuspended = TRUE;
+
+ /*
+ * At this point the PIC can go into sleep,idle, or
+ * switch to a slower clock, etc. This should be done in the
+ * USBCBSuspend() if necessary.
+ */
+ USB_SUSPEND_HANDLER(EVENT_SUSPEND,0,0);
+}
+
+/********************************************************************
+ * Function: void USBWakeFromSuspend(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview:
+ *
+ * Note: None
+ *******************************************************************/
+static void USBWakeFromSuspend(void)
+{
+ USBBusIsSuspended = FALSE;
+
+ /*
+ * If using clock switching, the place to restore the original
+ * microcontroller core clock frequency is in the USBCBWakeFromSuspend() callback
+ */
+ USB_WAKEUP_FROM_SUSPEND_HANDLER(EVENT_RESUME,0,0);
+
+ #if defined(__18CXX) || defined(_PIC14E)
+ //To avoid improperly clocking the USB module, make sure the oscillator
+ //settings are consistant with USB operation before clearing the SUSPND bit.
+ //Make sure the correct oscillator settings are selected in the
+ //"USB_WAKEUP_FROM_SUSPEND_HANDLER(EVENT_RESUME,0,0)" handler.
+ U1CONbits.SUSPND = 0; // Bring USB module out of power conserve
+ // mode.
+ #endif
+
+
+ USBActivityIE = 0;
+
+ /********************************************************************
+ Bug Fix: Feb 26, 2007 v2.1
+ *********************************************************************
+ The ACTVIF bit cannot be cleared immediately after the USB module wakes
+ up from Suspend or while the USB module is suspended. A few clock cycles
+ are required to synchronize the internal hardware state machine before
+ the ACTIVIF bit can be cleared by firmware. Clearing the ACTVIF bit
+ before the internal hardware is synchronized may not have an effect on
+ the value of ACTVIF. Additonally, if the USB module uses the clock from
+ the 96 MHz PLL source, then after clearing the SUSPND bit, the USB
+ module may not be immediately operational while waiting for the 96 MHz
+ PLL to lock.
+ ********************************************************************/
+
+ // UIRbits.ACTVIF = 0; // Removed
+ #if defined(__18CXX)
+ while(USBActivityIF)
+ #endif
+ {
+ USBClearInterruptFlag(USBActivityIFReg,USBActivityIFBitNum);
+ } // Added
+
+}//end USBWakeFromSuspend
+
+/********************************************************************
+ * Function: void USBCtrlEPService(void)
+ *
+ * PreCondition: USTAT is loaded with a valid endpoint address.
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: USBCtrlEPService checks for three transaction
+ * types that it knows how to service and services
+ * them:
+ * 1. EP0 SETUP
+ * 2. EP0 OUT
+ * 3. EP0 IN
+ * It ignores all other types (i.e. EP1, EP2, etc.)
+ *
+ * Note: None
+ *******************************************************************/
+static void USBCtrlEPService(void)
+{
+ //If we get to here, that means a successful transaction has just occurred
+ //on EP0. This means "progress" has occurred in the currently pending
+ //control transfer, so we should re-initialize our timeout counter.
+ #if defined(USB_ENABLE_STATUS_STAGE_TIMEOUTS)
+ USBStatusStageTimeoutCounter = USB_STATUS_STAGE_TIMEOUT;
+ #endif
+
+ //Check if the last transaction was on EP0 OUT endpoint (of any kind, to either the even or odd buffer if ping pong buffers used)
+ if((USTATcopy.Val & USTAT_EP0_PP_MASK) == USTAT_EP0_OUT_EVEN)
+ {
+ //Point to the EP0 OUT buffer of the buffer that arrived
+ #if defined (_PIC14E) || defined(__18CXX)
+ pBDTEntryEP0OutCurrent = (volatile BDT_ENTRY*)&BDT[(USTATcopy.Val & USTAT_EP_MASK)>>1];
+ #elif defined(__C30__) || defined(__C32__) || defined __XC16__
+ pBDTEntryEP0OutCurrent = (volatile BDT_ENTRY*)&BDT[(USTATcopy.Val & USTAT_EP_MASK)>>2];
+ #else
+ #error "unimplemented"
+ #endif
+
+ //Set the next out to the current out packet
+ pBDTEntryEP0OutNext = pBDTEntryEP0OutCurrent;
+ //Toggle it to the next ping pong buffer (if applicable)
+ ((BYTE_VAL*)&pBDTEntryEP0OutNext)->Val ^= USB_NEXT_EP0_OUT_PING_PONG;
+
+ //If the current EP0 OUT buffer has a SETUP packet
+ if(pBDTEntryEP0OutCurrent->STAT.PID == PID_SETUP)
+ {
+ unsigned char setup_cnt;
+
+ //The SETUP transaction data may have gone into the the CtrlTrfData
+ //buffer, or elsewhere, depending upon how the BDT was prepared
+ //before the transaction. Therefore, we should copy the data to the
+ //SetupPkt buffer so it can be processed correctly by USBCtrlTrfSetupHandler().
+ for(setup_cnt = 0; setup_cnt < 8u; setup_cnt++) //SETUP data packets always contain exactly 8 bytes.
+ {
+ *(BYTE*)((BYTE*)&SetupPkt + setup_cnt) = *(BYTE*)ConvertToVirtualAddress(pBDTEntryEP0OutCurrent->ADR);
+ pBDTEntryEP0OutCurrent->ADR++;
+ }
+ pBDTEntryEP0OutCurrent->ADR = ConvertToPhysicalAddress(&SetupPkt);
+
+ //Handle the control transfer (parse the 8-byte SETUP command and figure out what to do)
+ USBCtrlTrfSetupHandler();
+ }
+ else
+ {
+ //Handle the DATA transfer
+ USBCtrlTrfOutHandler();
+ }
+ }
+ else if((USTATcopy.Val & USTAT_EP0_PP_MASK) == USTAT_EP0_IN)
+ {
+ //Otherwise the transmission was and EP0 IN
+ // so take care of the IN transfer
+ USBCtrlTrfInHandler();
+ }
+
+}//end USBCtrlEPService
+
+/********************************************************************
+ * Function: void USBCtrlTrfSetupHandler(void)
+ *
+ * PreCondition: SetupPkt buffer is loaded with valid USB Setup Data
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine is a task dispatcher and has 3 stages.
+ * 1. It initializes the control transfer state machine.
+ * 2. It calls on each of the module that may know how to
+ * service the Setup Request from the host.
+ * Module Example: USBD, HID, CDC, MSD, ...
+ * A callback function, USBCBCheckOtherReq(),
+ * is required to call other module handlers.
+ * 3. Once each of the modules has had a chance to check if
+ * it is responsible for servicing the request, stage 3
+ * then checks direction of the transfer to determine how
+ * to prepare EP0 for the control transfer.
+ * Refer to USBCtrlEPServiceComplete() for more details.
+ *
+ * Note: Microchip USB Firmware has three different states for
+ * the control transfer state machine:
+ * 1. WAIT_SETUP
+ * 2. CTRL_TRF_TX (device sends data to host through IN transactions)
+ * 3. CTRL_TRF_RX (device receives data from host through OUT transactions)
+ * Refer to firmware manual to find out how one state
+ * is transitioned to another.
+ *
+ * A Control Transfer is composed of many USB transactions.
+ * When transferring data over multiple transactions,
+ * it is important to keep track of data source, data
+ * destination, and data count. These three parameters are
+ * stored in pSrc,pDst, and wCount. A flag is used to
+ * note if the data source is from ROM or RAM.
+ *
+ *******************************************************************/
+static void USBCtrlTrfSetupHandler(void)
+{
+ //--------------------------------------------------------------------------
+ //1. Re-initialize state tracking variables related to control transfers.
+ //--------------------------------------------------------------------------
+ shortPacketStatus = SHORT_PKT_NOT_USED;
+ USBDeferStatusStagePacket = FALSE;
+ USBDeferINDataStagePackets = FALSE;
+ USBDeferOUTDataStagePackets = FALSE;
+ BothEP0OutUOWNsSet = FALSE;
+ controlTransferState = WAIT_SETUP;
+
+ //Abandon any previous control transfers that might have been using EP0.
+ //Ordinarily, nothing actually needs abandoning, since the previous control
+ //transfer would have completed successfully prior to the host sending the next
+ //SETUP packet. However, in a timeout error case, or after an EP0 STALL event,
+ //one or more UOWN bits might still be set. If so, we should clear the UOWN bits,
+ //so the EP0 IN/OUT endpoints are in a known inactive state, ready for re-arming
+ //by the class request handler that will be called next.
+ pBDTEntryIn[0]->STAT.Val &= ~(_USIE);
+ ((BYTE_VAL*)&pBDTEntryIn[0])->Val ^= USB_NEXT_EP0_IN_PING_PONG;
+ pBDTEntryIn[0]->STAT.Val &= ~(_USIE);
+ ((BYTE_VAL*)&pBDTEntryIn[0])->Val ^= USB_NEXT_EP0_IN_PING_PONG;
+ pBDTEntryEP0OutNext->STAT.Val &= ~(_USIE);
+
+ inPipes[0].info.Val = 0;
+ inPipes[0].wCount.Val = 0;
+ outPipes[0].info.Val = 0;
+ outPipes[0].wCount.Val = 0;
+
+
+ //--------------------------------------------------------------------------
+ //2. Now find out what was in the SETUP packet, and begin handling the request.
+ //--------------------------------------------------------------------------
+ USBCheckStdRequest(); //Check for standard USB "Chapter 9" requests.
+ USB_NONSTANDARD_EP0_REQUEST_HANDLER(EVENT_EP0_REQUEST,0,0); //Check for USB device class specific requests
+
+
+ //--------------------------------------------------------------------------
+ //3. Re-arm EP0 IN and EP0 OUT endpoints, based on the control transfer in
+ // progress. If one of the above handlers (in step 2) knew how to process
+ // the request, it will have set one of the inPipes[0].info.bits.busy or
+ // outPipes[0].info.bits.busy flags = 1. This lets the
+ // USBCtrlEPServiceComplete() function know how and which endpoints to
+ // arm. If both info.bits.busy flags are = 0, then no one knew how to
+ // process the request. In this case, the default behavior will be to
+ // perform protocol STALL on EP0.
+ //--------------------------------------------------------------------------
+ USBCtrlEPServiceComplete();
+}//end USBCtrlTrfSetupHandler
+
+
+/******************************************************************************
+ * Function: void USBCtrlTrfOutHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine handles an OUT transaction according to
+ * which control transfer state is currently active.
+ *
+ * Note: Note that if the the control transfer was from
+ * host to device, the session owner should be notified
+ * at the end of each OUT transaction to service the
+ * received data.
+ *
+ *****************************************************************************/
+static void USBCtrlTrfOutHandler(void)
+{
+ if(controlTransferState == CTRL_TRF_RX)
+ {
+ USBCtrlTrfRxService(); //Copies the newly received data into the appropriate buffer and configures EP0 OUT for next transaction.
+ }
+ else //In this case the last OUT transaction must have been a status stage of a CTRL_TRF_TX (... <-- this last OUT just occurred as the status stage)
+ {
+ //If the status stage is complete, this means we are done with the
+ //control transfer. Go back to the idle "WAIT_SETUP" state.
+ controlTransferState = WAIT_SETUP;
+
+ //Prepare EP0 OUT for the next SETUP transaction, however, it may have
+ //already been prepared if ping-pong buffering was enabled on EP0 OUT,
+ //and the last control transfer was of direction: device to host, see
+ //USBCtrlEPServiceComplete(). If it was already prepared, do not want
+ //to do anything to the BDT.
+ if(BothEP0OutUOWNsSet == FALSE)
+ {
+ pBDTEntryEP0OutNext->CNT = USB_EP0_BUFF_SIZE;
+ pBDTEntryEP0OutNext->ADR = ConvertToPhysicalAddress(&SetupPkt);
+ pBDTEntryEP0OutNext->STAT.Val = _USIE|_DAT0|(_DTSEN & _DTS_CHECKING_ENABLED)|_BSTALL;
+ }
+ else
+ {
+ BothEP0OutUOWNsSet = FALSE;
+ }
+ }
+}
+
+/******************************************************************************
+ * Function: void USBCtrlTrfInHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine handles an IN transaction according to
+ * which control transfer state is currently active.
+ *
+ * Note: A Set Address Request must not change the acutal address
+ * of the device until the completion of the control
+ * transfer. The end of the control transfer for Set Address
+ * Request is an IN transaction. Therefore it is necessary
+ * to service this unique situation when the condition is
+ * right. Macro mUSBCheckAdrPendingState is defined in
+ * usb9.h and its function is to specifically service this
+ * event.
+ *****************************************************************************/
+static void USBCtrlTrfInHandler(void)
+{
+ BYTE lastDTS;
+
+ lastDTS = pBDTEntryIn[0]->STAT.DTS;
+
+ //switch to the next ping pong buffer
+ ((BYTE_VAL*)&pBDTEntryIn[0])->Val ^= USB_NEXT_EP0_IN_PING_PONG;
+
+ //Must check if in ADR_PENDING_STATE. If so, we need to update the address
+ //now, since the IN status stage of the (set address) control transfer has
+ //evidently completed successfully.
+ if(USBDeviceState == ADR_PENDING_STATE)
+ {
+ U1ADDR = SetupPkt.bDevADR.Val;
+ if(U1ADDR != 0u)
+ {
+ USBDeviceState=ADDRESS_STATE;
+ }
+ else
+ {
+ USBDeviceState=DEFAULT_STATE;
+ }
+ }//end if
+
+
+ if(controlTransferState == CTRL_TRF_TX)
+ {
+ pBDTEntryIn[0]->ADR = ConvertToPhysicalAddress(CtrlTrfData);
+ USBCtrlTrfTxService();
+
+ //Check if we have already sent a short packet. If so, configure
+ //the endpoint to STALL in response to any further IN tokens (in the
+ //case that the host erroneously tries to receive more data than it
+ //should).
+ if(shortPacketStatus == SHORT_PKT_SENT)
+ {
+ // If a short packet has been sent, don't want to send any more,
+ // stall next time if host is still trying to read.
+ pBDTEntryIn[0]->STAT.Val = _USIE|_BSTALL;
+ }
+ else
+ {
+ if(lastDTS == 0)
+ {
+ pBDTEntryIn[0]->STAT.Val = _USIE|_DAT1|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+ else
+ {
+ pBDTEntryIn[0]->STAT.Val = _USIE|_DAT0|(_DTSEN & _DTS_CHECKING_ENABLED);
+ }
+ }//end if(...)else
+ }
+ else // must have been a CTRL_TRF_RX status stage IN packet (... <-- this last IN just occurred as the status stage)
+ {
+ //if someone is still expecting data from the control transfer
+ // then make sure to terminate that request and let them know that
+ // they are done
+ if(outPipes[0].info.bits.busy == 1)
+ {
+ if(outPipes[0].pFunc != NULL)
+ {
+ outPipes[0].pFunc();
+ }
+ outPipes[0].info.bits.busy = 0;
+ }
+
+ controlTransferState = WAIT_SETUP;
+ //Don't need to arm EP0 OUT here. It was already armed by the last that
+ //got processed by the USBCtrlTrfRxService() handler.
+ }
+
+}
+
+
+/********************************************************************
+ * Function: void USBCheckStdRequest(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine checks the setup data packet to see
+ * if it knows how to handle it
+ *
+ * Note: None
+ *******************************************************************/
+static void USBCheckStdRequest(void)
+{
+ if(SetupPkt.RequestType != USB_SETUP_TYPE_STANDARD_BITFIELD) return;
+
+ switch(SetupPkt.bRequest)
+ {
+ case USB_REQUEST_SET_ADDRESS:
+ inPipes[0].info.bits.busy = 1; // This will generate a zero length packet
+ USBDeviceState = ADR_PENDING_STATE; // Update state only
+ /* See USBCtrlTrfInHandler() for the next step */
+ break;
+ case USB_REQUEST_GET_DESCRIPTOR:
+ USBStdGetDscHandler();
+ break;
+ case USB_REQUEST_SET_CONFIGURATION:
+ USBStdSetCfgHandler();
+ break;
+ case USB_REQUEST_GET_CONFIGURATION:
+ inPipes[0].pSrc.bRam = (BYTE*)&USBActiveConfiguration; // Set Source
+ inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
+ inPipes[0].wCount.v[0] = 1; // Set data count
+ inPipes[0].info.bits.busy = 1;
+ break;
+ case USB_REQUEST_GET_STATUS:
+ USBStdGetStatusHandler();
+ break;
+ case USB_REQUEST_CLEAR_FEATURE:
+ case USB_REQUEST_SET_FEATURE:
+ USBStdFeatureReqHandler();
+ break;
+ case USB_REQUEST_GET_INTERFACE:
+ inPipes[0].pSrc.bRam = (BYTE*)&USBAlternateInterface[SetupPkt.bIntfID]; // Set source
+ inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
+ inPipes[0].wCount.v[0] = 1; // Set data count
+ inPipes[0].info.bits.busy = 1;
+ break;
+ case USB_REQUEST_SET_INTERFACE:
+ inPipes[0].info.bits.busy = 1;
+ USBAlternateInterface[SetupPkt.bIntfID] = SetupPkt.bAltID;
+ break;
+ case USB_REQUEST_SET_DESCRIPTOR:
+ USB_SET_DESCRIPTOR_HANDLER(EVENT_SET_DESCRIPTOR,0,0);
+ break;
+ case USB_REQUEST_SYNCH_FRAME:
+ default:
+ break;
+ }//end switch
+}//end USBCheckStdRequest
+
+/********************************************************************
+ * Function: void USBStdFeatureReqHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: Can alter BDT entries. Can also modify USB stack
+ * Maintained variables.
+ *
+ * Side Effects: None
+ *
+ * Overview: This routine handles the standard SET & CLEAR
+ * FEATURES requests
+ *
+ * Note: This is a private function, intended for internal
+ * use by the USB stack, when processing SET/CLEAR
+ * feature requests.
+ *******************************************************************/
+static void USBStdFeatureReqHandler(void)
+{
+ BDT_ENTRY *p;
+ EP_STATUS current_ep_data;
+ #if defined(__C32__)
+ DWORD* pUEP;
+ #else
+ unsigned char* pUEP;
+ #endif
+
+
+ #ifdef USB_SUPPORT_OTG
+ //Check for USB On-The-Go (OTG) specific requests
+ if ((SetupPkt.bFeature == OTG_FEATURE_B_HNP_ENABLE)&&
+ (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD))
+ {
+ inPipes[0].info.bits.busy = 1;
+ if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ USBOTGEnableHnp();
+ else
+ USBOTGDisableHnp();
+ }
+
+ if ((SetupPkt.bFeature == OTG_FEATURE_A_HNP_SUPPORT)&&
+ (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD))
+ {
+ inPipes[0].info.bits.busy = 1;
+ if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ USBOTGEnableSupportHnp();
+ else
+ USBOTGDisableSupportHnp();
+ }
+
+ if ((SetupPkt.bFeature == OTG_FEATURE_A_ALT_HNP_SUPPORT)&&
+ (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD))
+ {
+ inPipes[0].info.bits.busy = 1;
+ if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ USBOTGEnableAltHnp();
+ else
+ USBOTGDisableAltHnp();
+ }
+ #endif //#ifdef USB_SUPPORT_OTG
+
+ //Check if the host sent a valid SET or CLEAR feature (remote wakeup) request.
+ if((SetupPkt.bFeature == USB_FEATURE_DEVICE_REMOTE_WAKEUP)&&
+ (SetupPkt.Recipient == USB_SETUP_RECIPIENT_DEVICE_BITFIELD))
+ {
+ inPipes[0].info.bits.busy = 1;
+ if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ RemoteWakeup = TRUE;
+ else
+ RemoteWakeup = FALSE;
+ }//end if
+
+ //Check if the host sent a valid SET or CLEAR endpoint halt request.
+ if((SetupPkt.bFeature == USB_FEATURE_ENDPOINT_HALT)&&
+ (SetupPkt.Recipient == USB_SETUP_RECIPIENT_ENDPOINT_BITFIELD)&&
+ (SetupPkt.EPNum != 0) && (SetupPkt.EPNum <= USB_MAX_EP_NUMBER)&&
+ (USBDeviceState == CONFIGURED_STATE))
+ {
+ //The request was valid. Take control of the control transfer and
+ //perform the host requested action.
+ inPipes[0].info.bits.busy = 1;
+
+ //Fetch a pointer to the BDT that the host wants to SET/CLEAR halt on.
+ if(SetupPkt.EPDir == OUT_FROM_HOST)
+ {
+ p = (BDT_ENTRY*)pBDTEntryOut[SetupPkt.EPNum];
+ current_ep_data.Val = ep_data_out[SetupPkt.EPNum].Val;
+ }
+ else
+ {
+ p = (BDT_ENTRY*)pBDTEntryIn[SetupPkt.EPNum];
+ current_ep_data.Val = ep_data_in[SetupPkt.EPNum].Val;
+ }
+
+ //If ping pong buffering is enabled on the requested endpoint, need
+ //to point to the one that is the active BDT entry which the SIE will
+ //use for the next attempted transaction on that EP number.
+ #if (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) || (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+ if(current_ep_data.bits.ping_pong_state == 0) //Check if even
+ {
+ USBHALPingPongSetToEven(&p);
+ }
+ else //else must have been odd
+ {
+ USBHALPingPongSetToOdd(&p);
+ }
+ #endif
+
+ //Update the BDT pointers with the new, next entry based on the feature
+ // request
+ if(SetupPkt.EPDir == OUT_FROM_HOST)
+ {
+ pBDTEntryOut[SetupPkt.EPNum] = (volatile BDT_ENTRY *)p;
+ }
+ else
+ {
+ pBDTEntryIn[SetupPkt.EPNum] = (volatile BDT_ENTRY *)p;
+ }
+
+ //Check if it was a SET_FEATURE endpoint halt request
+ if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ {
+ if(p->STAT.UOWN == 1)
+ {
+ //Mark that we are terminating this transfer and that the user
+ // needs to be notified later
+ if(SetupPkt.EPDir == OUT_FROM_HOST)
+ {
+ ep_data_out[SetupPkt.EPNum].bits.transfer_terminated = 1;
+ }
+ else
+ {
+ ep_data_in[SetupPkt.EPNum].bits.transfer_terminated = 1;
+ }
+ }
+
+ //Then STALL the endpoint
+ p->STAT.Val |= _USIE|_BSTALL;
+ }//if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ else
+ {
+ //Else the request must have been a CLEAR_FEATURE endpoint halt.
+ #if (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) || (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+ //toggle over the to the non-active BDT
+ USBAdvancePingPongBuffer(&p);
+
+ if(p->STAT.UOWN == 1)
+ {
+ //Clear UOWN and set DTS state so it will be correct the next time
+ //the application firmware uses USBTransferOnePacket() on the EP.
+ p->STAT.Val &= (~_USIE); //Clear UOWN bit
+ p->STAT.Val |= _DAT1; //Set DTS to DATA1
+ USB_TRANSFER_TERMINATED_HANDLER(EVENT_TRANSFER_TERMINATED,p,sizeof(p));
+ }
+ else
+ {
+ //UOWN already clear, but still need to set DTS to DATA1
+ p->STAT.Val |= _DAT1;
+ }
+
+ //toggle back to the active BDT (the one the SIE is currently looking at
+ //and will use for the next successful transaction to take place on the EP
+ USBAdvancePingPongBuffer(&p);
+
+ //Check if we are currently terminating, or have previously terminated
+ //a transaction on the given endpoint. If so, need to clear UOWN,
+ //set DTS to the proper state, and call the application callback
+ //function.
+ if((current_ep_data.bits.transfer_terminated != 0) || (p->STAT.UOWN == 1))
+ {
+ if(SetupPkt.EPDir == OUT_FROM_HOST)
+ {
+ ep_data_out[SetupPkt.EPNum].bits.transfer_terminated = 0;
+ }
+ else
+ {
+ ep_data_in[SetupPkt.EPNum].bits.transfer_terminated = 0;
+ }
+ //clear UOWN, clear DTS to DATA0, and finally remove the STALL condition
+ p->STAT.Val &= ~(_USIE | _DAT1 | _BSTALL);
+ //Call the application event handler callback function, so it can
+ //decide if the endpoint should get re-armed again or not.
+ USB_TRANSFER_TERMINATED_HANDLER(EVENT_TRANSFER_TERMINATED,p,sizeof(p));
+ }
+ else
+ {
+ //clear UOWN, clear DTS to DATA0, and finally remove the STALL condition
+ p->STAT.Val &= ~(_USIE | _DAT1 | _BSTALL);
+ }
+ #else //else we must not be using ping-pong buffering on the requested endpoint
+ //Check if we need to call the user transfer terminated event callback function.
+ //We should call the callback, if the endpoint was previously terminated,
+ //or the endpoint is currently armed, and the host is performing clear
+ //endpoint halt, even though the endpoint wasn't stalled.
+ if((current_ep_data.bits.transfer_terminated != 0) || (p->STAT.UOWN == 1))
+ {
+ //We are going to call the user transfer terminated callback.
+ //Clear the flag so we know we took care of it and don't need
+ //to call it again later.
+ if(SetupPkt.EPDir == OUT_FROM_HOST)
+ {
+ ep_data_out[SetupPkt.EPNum].bits.transfer_terminated = 0;
+ }
+ else
+ {
+ ep_data_in[SetupPkt.EPNum].bits.transfer_terminated = 0;
+ }
+
+ //Clear UOWN and remove the STALL condition.
+ // In this case we also need to set the DTS bit to 1 so that
+ // it toggles to DATA0 the next time the application firmware
+ // calls USBTransferOnePacket() (or equivalent macro).
+ p->STAT.Val &= ~(_USIE | _BSTALL);
+ p->STAT.Val |= _DAT1;
+ //Let the application firmware know a transaction just
+ //got terminated by the host, and that it is now free to
+ //re-arm the endpoint or do other tasks if desired.
+ USB_TRANSFER_TERMINATED_HANDLER(EVENT_TRANSFER_TERMINATED,p,sizeof(p));
+ }
+ else
+ {
+ //Clear UOWN and remove the STALL condition.
+ // In this case we also need to set the DTS bit to 1 so that
+ // it toggles to DATA0 the next time the application firmware
+ // calls USBTransferOnePacket() (or equivalent macro).
+ p->STAT.Val &= ~(_USIE | _BSTALL);
+ p->STAT.Val |= _DAT1;
+ }
+ #endif //end of #if (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0) || (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+
+ //Get a pointer to the appropriate UEPn register
+ #if defined(__C32__)
+ pUEP = (DWORD*)(&U1EP0);
+ pUEP += (SetupPkt.EPNum*4);
+ #else
+ pUEP = (unsigned char*)(&U1EP0+SetupPkt.EPNum);
+ #endif
+
+ //Clear the STALL bit in the UEP register
+ *pUEP &= ~UEP_STALL;
+ }//end if(SetupPkt.bRequest == USB_REQUEST_SET_FEATURE)
+ }//end if (lots of checks for set/clear endpoint halt)
+}//end USBStdFeatureReqHandler
+
+
+/** EOF USBDevice.c *****************************************************/
diff --git a/Source/USB/USB2.9i_cdc/USB/usb_device_local.h b/Source/USB/USB2.9i_cdc/USB/usb_device_local.h
new file mode 100644
index 0000000..27123b5
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/USB/usb_device_local.h
@@ -0,0 +1,490 @@
+/********************************************************************
+ File Information:
+ FileName: usb_device_local.h
+ Dependencies: See INCLUDES section
+ Processor: PIC18,PIC24, PIC32 and dsPIC33E USB Microcontrollers
+ Hardware: The code is natively intended to be used on the following
+ hardware platforms: PICDEM™ FS USB Demo Board,
+ PIC18F87J50 FS USB Plug-In Module, or
+ Explorer 16 + compatible USB PIM. The firmware may be
+ modified for use on other USB platforms by editing the
+ HardwareProfile.h file.
+ Complier: Microchip C18 (for PIC18),C30 (for PIC24 and dsPIC33E)
+ and C32 (for PIC32)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+ Summary:
+ This file contains functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the MCHPFSUSB device
+ stack. This file should be included in projects that use the device stack.
+
+ This file is located in the "\\\Microchip\\USB"
+ directory.
+
+ Description:
+ USB Device Stack File
+
+ This file contains functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the MCHPFSUSB device
+ stack. This file should be included in projects that use the device stack.
+
+ This file is located in the "\\\Microchip\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+ ..\\..\\MicrochipInclude
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+
+********************************************************************
+ File Description:
+
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.8 Initial revision. Contents extracted from the previous usb_device.c
+ file, so as to make the usb_device.c file less cluttered.
+ Fixed BD() and EP() macro computation error, when running in
+ USB_PING_PONG__EP0_OUT_ONLY mode.
+ 2.9 No functional change. Fixed spelling typo in the name of
+ "USB_TRANSFER_COMPLETE_HANDLER()"
+********************************************************************/
+#include "usb_config.h"
+
+/* Short Packet States - Used by Control Transfer Read - CTRL_TRF_TX */
+#define SHORT_PKT_NOT_USED 0
+#define SHORT_PKT_PENDING 1
+#define SHORT_PKT_SENT 2
+
+/* Control Transfer States */
+#define WAIT_SETUP 0
+#define CTRL_TRF_TX 1
+#define CTRL_TRF_RX 2
+
+
+typedef union
+{
+ struct
+ {
+ unsigned char ping_pong_state :1;
+ unsigned char transfer_terminated :1;
+ } bits;
+ BYTE Val;
+} EP_STATUS;
+
+#if (USB_PING_PONG_MODE == USB_PING_PONG__NO_PING_PONG)
+ #define USB_NEXT_EP0_OUT_PING_PONG 0x0000 // Used in USB Device Mode only
+ #define USB_NEXT_EP0_IN_PING_PONG 0x0000 // Used in USB Device Mode only
+ #define USB_NEXT_PING_PONG 0x0000 // Used in USB Device Mode only
+ #define EP0_OUT_EVEN 0 // Used in USB Device Mode only
+ #define EP0_OUT_ODD 0 // Used in USB Device Mode only
+ #define EP0_IN_EVEN 1 // Used in USB Device Mode only
+ #define EP0_IN_ODD 1 // Used in USB Device Mode only
+ #define EP1_OUT_EVEN 2 // Used in USB Device Mode only
+ #define EP1_OUT_ODD 2 // Used in USB Device Mode only
+ #define EP1_IN_EVEN 3 // Used in USB Device Mode only
+ #define EP1_IN_ODD 3 // Used in USB Device Mode only
+ #define EP2_OUT_EVEN 4 // Used in USB Device Mode only
+ #define EP2_OUT_ODD 4 // Used in USB Device Mode only
+ #define EP2_IN_EVEN 5 // Used in USB Device Mode only
+ #define EP2_IN_ODD 5 // Used in USB Device Mode only
+ #define EP3_OUT_EVEN 6 // Used in USB Device Mode only
+ #define EP3_OUT_ODD 6 // Used in USB Device Mode only
+ #define EP3_IN_EVEN 7 // Used in USB Device Mode only
+ #define EP3_IN_ODD 7 // Used in USB Device Mode only
+ #define EP4_OUT_EVEN 8 // Used in USB Device Mode only
+ #define EP4_OUT_ODD 8 // Used in USB Device Mode only
+ #define EP4_IN_EVEN 9 // Used in USB Device Mode only
+ #define EP4_IN_ODD 9 // Used in USB Device Mode only
+ #define EP5_OUT_EVEN 10 // Used in USB Device Mode only
+ #define EP5_OUT_ODD 10 // Used in USB Device Mode only
+ #define EP5_IN_EVEN 11 // Used in USB Device Mode only
+ #define EP5_IN_ODD 11 // Used in USB Device Mode only
+ #define EP6_OUT_EVEN 12 // Used in USB Device Mode only
+ #define EP6_OUT_ODD 12 // Used in USB Device Mode only
+ #define EP6_IN_EVEN 13 // Used in USB Device Mode only
+ #define EP6_IN_ODD 13 // Used in USB Device Mode only
+ #define EP7_OUT_EVEN 14 // Used in USB Device Mode only
+ #define EP7_OUT_ODD 14 // Used in USB Device Mode only
+ #define EP7_IN_EVEN 15 // Used in USB Device Mode only
+ #define EP7_IN_ODD 15 // Used in USB Device Mode only
+ #define EP8_OUT_EVEN 16 // Used in USB Device Mode only
+ #define EP8_OUT_ODD 16 // Used in USB Device Mode only
+ #define EP8_IN_EVEN 17 // Used in USB Device Mode only
+ #define EP8_IN_ODD 17 // Used in USB Device Mode only
+ #define EP9_OUT_EVEN 18 // Used in USB Device Mode only
+ #define EP9_OUT_ODD 18 // Used in USB Device Mode only
+ #define EP9_IN_EVEN 19 // Used in USB Device Mode only
+ #define EP9_IN_ODD 19 // Used in USB Device Mode only
+ #define EP10_OUT_EVEN 20 // Used in USB Device Mode only
+ #define EP10_OUT_ODD 20 // Used in USB Device Mode only
+ #define EP10_IN_EVEN 21 // Used in USB Device Mode only
+ #define EP10_IN_ODD 21 // Used in USB Device Mode only
+ #define EP11_OUT_EVEN 22 // Used in USB Device Mode only
+ #define EP11_OUT_ODD 22 // Used in USB Device Mode only
+ #define EP11_IN_EVEN 23 // Used in USB Device Mode only
+ #define EP11_IN_ODD 23 // Used in USB Device Mode only
+ #define EP12_OUT_EVEN 24 // Used in USB Device Mode only
+ #define EP12_OUT_ODD 24 // Used in USB Device Mode only
+ #define EP12_IN_EVEN 25 // Used in USB Device Mode only
+ #define EP12_IN_ODD 25 // Used in USB Device Mode only
+ #define EP13_OUT_EVEN 26 // Used in USB Device Mode only
+ #define EP13_OUT_ODD 26 // Used in USB Device Mode only
+ #define EP13_IN_EVEN 27 // Used in USB Device Mode only
+ #define EP13_IN_ODD 27 // Used in USB Device Mode only
+ #define EP14_OUT_EVEN 28 // Used in USB Device Mode only
+ #define EP14_OUT_ODD 28 // Used in USB Device Mode only
+ #define EP14_IN_EVEN 29 // Used in USB Device Mode only
+ #define EP14_IN_ODD 29 // Used in USB Device Mode only
+ #define EP15_OUT_EVEN 30 // Used in USB Device Mode only
+ #define EP15_OUT_ODD 30 // Used in USB Device Mode only
+ #define EP15_IN_EVEN 31 // Used in USB Device Mode only
+ #define EP15_IN_ODD 31 // Used in USB Device Mode only
+
+ #define EP(ep,dir,pp) (2*ep+dir) // Used in USB Device Mode only
+ #define BD(ep,dir,pp) ((8 * ep) + (4 * dir)) // Used in USB Device Mode only
+
+#elif (USB_PING_PONG_MODE == USB_PING_PONG__EP0_OUT_ONLY)
+ #define USB_NEXT_EP0_OUT_PING_PONG 0x0004
+ #define USB_NEXT_EP0_IN_PING_PONG 0x0000
+ #define USB_NEXT_PING_PONG 0x0000
+ #define EP0_OUT_EVEN 0
+ #define EP0_OUT_ODD 1
+ #define EP0_IN_EVEN 2
+ #define EP0_IN_ODD 2
+ #define EP1_OUT_EVEN 3
+ #define EP1_OUT_ODD 3
+ #define EP1_IN_EVEN 4
+ #define EP1_IN_ODD 4
+ #define EP2_OUT_EVEN 5
+ #define EP2_OUT_ODD 5
+ #define EP2_IN_EVEN 6
+ #define EP2_IN_ODD 6
+ #define EP3_OUT_EVEN 7
+ #define EP3_OUT_ODD 7
+ #define EP3_IN_EVEN 8
+ #define EP3_IN_ODD 8
+ #define EP4_OUT_EVEN 9
+ #define EP4_OUT_ODD 9
+ #define EP4_IN_EVEN 10
+ #define EP4_IN_ODD 10
+ #define EP5_OUT_EVEN 11
+ #define EP5_OUT_ODD 11
+ #define EP5_IN_EVEN 12
+ #define EP5_IN_ODD 12
+ #define EP6_OUT_EVEN 13
+ #define EP6_OUT_ODD 13
+ #define EP6_IN_EVEN 14
+ #define EP6_IN_ODD 14
+ #define EP7_OUT_EVEN 15
+ #define EP7_OUT_ODD 15
+ #define EP7_IN_EVEN 16
+ #define EP7_IN_ODD 16
+ #define EP8_OUT_EVEN 17
+ #define EP8_OUT_ODD 17
+ #define EP8_IN_EVEN 18
+ #define EP8_IN_ODD 18
+ #define EP9_OUT_EVEN 19
+ #define EP9_OUT_ODD 19
+ #define EP9_IN_EVEN 20
+ #define EP9_IN_ODD 20
+ #define EP10_OUT_EVEN 21
+ #define EP10_OUT_ODD 21
+ #define EP10_IN_EVEN 22
+ #define EP10_IN_ODD 22
+ #define EP11_OUT_EVEN 23
+ #define EP11_OUT_ODD 23
+ #define EP11_IN_EVEN 24
+ #define EP11_IN_ODD 24
+ #define EP12_OUT_EVEN 25
+ #define EP12_OUT_ODD 25
+ #define EP12_IN_EVEN 26
+ #define EP12_IN_ODD 26
+ #define EP13_OUT_EVEN 27
+ #define EP13_OUT_ODD 27
+ #define EP13_IN_EVEN 28
+ #define EP13_IN_ODD 28
+ #define EP14_OUT_EVEN 29
+ #define EP14_OUT_ODD 29
+ #define EP14_IN_EVEN 30
+ #define EP14_IN_ODD 30
+ #define EP15_OUT_EVEN 31
+ #define EP15_OUT_ODD 31
+ #define EP15_IN_EVEN 32
+ #define EP15_IN_ODD 32
+
+ #define EP(ep,dir,pp) (2u*ep+dir+(((ep==0)&&(dir==0))?pp:1))
+ #define BD(ep,dir,pp) (4u*((2u*ep)+dir+(((ep==0)&&(dir==0))?pp:1)))
+
+#elif (USB_PING_PONG_MODE == USB_PING_PONG__FULL_PING_PONG)
+#if defined (__18CXX) || defined(__C30__) || defined __XC16__ || defined(__XC8)
+ #if (defined (__dsPIC33E__) || defined (__PIC24E__))
+ #define USB_NEXT_EP0_OUT_PING_PONG 0x0008
+ #define USB_NEXT_EP0_IN_PING_PONG 0x0008
+ #define USB_NEXT_PING_PONG 0x0008
+ #else
+ #define USB_NEXT_EP0_OUT_PING_PONG 0x0004
+ #define USB_NEXT_EP0_IN_PING_PONG 0x0004
+ #define USB_NEXT_PING_PONG 0x0004
+ #endif
+ #elif defined(__C32__)
+ #define USB_NEXT_EP0_OUT_PING_PONG 0x0008
+ #define USB_NEXT_EP0_IN_PING_PONG 0x0008
+ #define USB_NEXT_PING_PONG 0x0008
+ #else
+ #error "Not defined for this compiler"
+ #endif
+ #define EP0_OUT_EVEN 0
+ #define EP0_OUT_ODD 1
+ #define EP0_IN_EVEN 2
+ #define EP0_IN_ODD 3
+ #define EP1_OUT_EVEN 4
+ #define EP1_OUT_ODD 5
+ #define EP1_IN_EVEN 6
+ #define EP1_IN_ODD 7
+ #define EP2_OUT_EVEN 8
+ #define EP2_OUT_ODD 9
+ #define EP2_IN_EVEN 10
+ #define EP2_IN_ODD 11
+ #define EP3_OUT_EVEN 12
+ #define EP3_OUT_ODD 13
+ #define EP3_IN_EVEN 14
+ #define EP3_IN_ODD 15
+ #define EP4_OUT_EVEN 16
+ #define EP4_OUT_ODD 17
+ #define EP4_IN_EVEN 18
+ #define EP4_IN_ODD 19
+ #define EP5_OUT_EVEN 20
+ #define EP5_OUT_ODD 21
+ #define EP5_IN_EVEN 22
+ #define EP5_IN_ODD 23
+ #define EP6_OUT_EVEN 24
+ #define EP6_OUT_ODD 25
+ #define EP6_IN_EVEN 26
+ #define EP6_IN_ODD 27
+ #define EP7_OUT_EVEN 28
+ #define EP7_OUT_ODD 29
+ #define EP7_IN_EVEN 30
+ #define EP7_IN_ODD 31
+ #define EP8_OUT_EVEN 32
+ #define EP8_OUT_ODD 33
+ #define EP8_IN_EVEN 34
+ #define EP8_IN_ODD 35
+ #define EP9_OUT_EVEN 36
+ #define EP9_OUT_ODD 37
+ #define EP9_IN_EVEN 38
+ #define EP9_IN_ODD 39
+ #define EP10_OUT_EVEN 40
+ #define EP10_OUT_ODD 41
+ #define EP10_IN_EVEN 42
+ #define EP10_IN_ODD 43
+ #define EP11_OUT_EVEN 44
+ #define EP11_OUT_ODD 45
+ #define EP11_IN_EVEN 46
+ #define EP11_IN_ODD 47
+ #define EP12_OUT_EVEN 48
+ #define EP12_OUT_ODD 49
+ #define EP12_IN_EVEN 50
+ #define EP12_IN_ODD 51
+ #define EP13_OUT_EVEN 52
+ #define EP13_OUT_ODD 53
+ #define EP13_IN_EVEN 54
+ #define EP13_IN_ODD 55
+ #define EP14_OUT_EVEN 56
+ #define EP14_OUT_ODD 57
+ #define EP14_IN_EVEN 58
+ #define EP14_IN_ODD 59
+ #define EP15_OUT_EVEN 60
+ #define EP15_OUT_ODD 61
+ #define EP15_IN_EVEN 62
+ #define EP15_IN_ODD 63
+
+ #define EP(ep,dir,pp) (4*ep+2*dir+pp)
+
+ #if defined (__18CXX) || defined(__C30__) || defined __XC16__ || (__XC8)
+ #if (defined(__dsPIC33E__) || defined (__PIC24E__))
+ #define BD(ep,dir,pp) (8*(4*ep+2*dir+pp))
+ #else
+ #define BD(ep,dir,pp) (4*(4*ep+2*dir+pp))
+ #endif
+ #elif defined(__C32__)
+ #define BD(ep,dir,pp) (8*(4*ep+2*dir+pp))
+ #else
+ #error "Not defined for this compiler"
+ #endif
+
+#elif (USB_PING_PONG_MODE == USB_PING_PONG__ALL_BUT_EP0)
+ #define USB_NEXT_EP0_OUT_PING_PONG 0x0000
+ #define USB_NEXT_EP0_IN_PING_PONG 0x0000
+ #define USB_NEXT_PING_PONG 0x0004
+ #define EP0_OUT_EVEN 0
+ #define EP0_OUT_ODD 0
+ #define EP0_IN_EVEN 1
+ #define EP0_IN_ODD 1
+ #define EP1_OUT_EVEN 2
+ #define EP1_OUT_ODD 3
+ #define EP1_IN_EVEN 4
+ #define EP1_IN_ODD 5
+ #define EP2_OUT_EVEN 6
+ #define EP2_OUT_ODD 7
+ #define EP2_IN_EVEN 8
+ #define EP2_IN_ODD 9
+ #define EP3_OUT_EVEN 10
+ #define EP3_OUT_ODD 11
+ #define EP3_IN_EVEN 12
+ #define EP3_IN_ODD 13
+ #define EP4_OUT_EVEN 14
+ #define EP4_OUT_ODD 15
+ #define EP4_IN_EVEN 16
+ #define EP4_IN_ODD 17
+ #define EP5_OUT_EVEN 18
+ #define EP5_OUT_ODD 19
+ #define EP5_IN_EVEN 20
+ #define EP5_IN_ODD 21
+ #define EP6_OUT_EVEN 22
+ #define EP6_OUT_ODD 23
+ #define EP6_IN_EVEN 24
+ #define EP6_IN_ODD 25
+ #define EP7_OUT_EVEN 26
+ #define EP7_OUT_ODD 27
+ #define EP7_IN_EVEN 28
+ #define EP7_IN_ODD 29
+ #define EP8_OUT_EVEN 30
+ #define EP8_OUT_ODD 31
+ #define EP8_IN_EVEN 32
+ #define EP8_IN_ODD 33
+ #define EP9_OUT_EVEN 34
+ #define EP9_OUT_ODD 35
+ #define EP9_IN_EVEN 36
+ #define EP9_IN_ODD 37
+ #define EP10_OUT_EVEN 38
+ #define EP10_OUT_ODD 39
+ #define EP10_IN_EVEN 40
+ #define EP10_IN_ODD 41
+ #define EP11_OUT_EVEN 42
+ #define EP11_OUT_ODD 43
+ #define EP11_IN_EVEN 44
+ #define EP11_IN_ODD 45
+ #define EP12_OUT_EVEN 46
+ #define EP12_OUT_ODD 47
+ #define EP12_IN_EVEN 48
+ #define EP12_IN_ODD 49
+ #define EP13_OUT_EVEN 50
+ #define EP13_OUT_ODD 51
+ #define EP13_IN_EVEN 52
+ #define EP13_IN_ODD 53
+ #define EP14_OUT_EVEN 54
+ #define EP14_OUT_ODD 55
+ #define EP14_IN_EVEN 56
+ #define EP14_IN_ODD 57
+ #define EP15_OUT_EVEN 58
+ #define EP15_OUT_ODD 59
+ #define EP15_IN_EVEN 60
+ #define EP15_IN_ODD 61
+
+ #define EP(ep,dir,pp) (4*ep+2*dir+((ep==0)?0:(pp-2)))
+ #define BD(ep,dir,pp) (4*(4*ep+2*dir+((ep==0)?0:(pp-2))))
+
+#else
+ #error "No ping pong mode defined."
+#endif
+
+/****** Event callback enabling/disabling macros ********************
+ This section of code is used to disable specific USB events that may not be
+ desired by the user. This can save code size and increase throughput and
+ decrease CPU utiliazation.
+********************************************************************/
+#if defined USB_DISABLE_SUSPEND_HANDLER
+ #define USB_SUSPEND_HANDLER(event,pointer,size)
+
+ #warning "Disabling the suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device."
+#else
+ #define USB_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_WAKEUP_FROM_SUSPEND_HANDLER
+ #define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size)
+
+ #warning "Disabling the wake from suspend handler is not recommended. Proper suspend handling is required to create a compliant USB device."
+#else
+ #define USB_WAKEUP_FROM_SUSPEND_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_SOF_HANDLER
+ #define USB_SOF_HANDLER(event,pointer,size)
+#else
+ #define USB_SOF_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_TRANSFER_TERMINATED_HANDLER
+ #define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size)
+#else
+ #define USB_TRANSFER_TERMINATED_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_ERROR_HANDLER
+ #define USB_ERROR_HANDLER(event,pointer,size)
+#else
+ #define USB_ERROR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_NONSTANDARD_EP0_REQUEST_HANDLER
+ #define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size)
+#else
+ #define USB_NONSTANDARD_EP0_REQUEST_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_SET_DESCRIPTOR_HANDLER
+ #define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size)
+#else
+ #define USB_SET_DESCRIPTOR_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_SET_CONFIGURATION_HANDLER
+ #define USB_SET_CONFIGURATION_HANDLER(event,pointer,size)
+#else
+ #define USB_SET_CONFIGURATION_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
+#if defined USB_DISABLE_TRANSFER_COMPLETE_HANDLER
+ #define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size)
+#else
+ #define USB_TRANSFER_COMPLETE_HANDLER(event,pointer,size) USER_USB_CALLBACK_EVENT_HANDLER(event,pointer,size)
+#endif
+
diff --git a/Source/USB/USB2.9i_cdc/include/Compiler.h b/Source/USB/USB2.9i_cdc/include/Compiler.h
new file mode 100644
index 0000000..3a3840f
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/Compiler.h
@@ -0,0 +1,218 @@
+/*********************************************************************
+ *
+ * Compiler and hardware specific definitions
+ *
+ *********************************************************************
+ * FileName: Compiler.h
+ * Dependencies: None
+ * Processor: PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, PIC32
+ * Compiler: Microchip C32 v2.02 or higher
+ * Microchip C30 v3.31 or higher
+ * Microchip C18 v3.40 or higher
+ * HI-TECH PICC-18 PRO 9.66 or higher
+ * HI-TECH PICC PRO V9.81 or higher
+ * Company: Microchip Technology, Inc.
+ *
+ * Software License Agreement
+ *
+ * Copyright (C) 2012 Microchip Technology Inc. All rights
+ * reserved.
+ *
+ * Microchip licenses to you the right to use, modify, copy, and
+ * distribute:
+ * (i) the Software when embedded on a Microchip microcontroller or
+ * digital signal controller product ("Device") which is
+ * integrated into Licensee's product; or
+ * (ii) ONLY the Software driver source files ENC28J60.c and
+ * ENC28J60.h ported to a non-Microchip device used in
+ * conjunction with a Microchip ethernet controller for the
+ * sole purpose of interfacing with the ethernet controller.
+ *
+ * You should refer to the license agreement accompanying this
+ * Software for additional information regarding your rights and
+ * obligations.
+ *
+ * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
+ * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
+ * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
+ * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
+ * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
+ * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
+ * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
+ * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
+ *
+ *
+ * Date Comment
+ *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ * 10/03/2006 Original, copied from old Compiler.h
+ * 11/07/2007 Reorganized and simplified
+ * 03/31/2010 Removed dependency on WORD and DWORD typedefs
+ * 04/14/2010 Added defines to uniquely identify each compiler
+ * 10/13/2010 Added support for PIC10, PIC12, and PIC16 with PICC compiler
+ * 02/15/2012 Added re-define check for Nop, ClrWdt, Reset, Sleep
+ ********************************************************************/
+#ifndef __COMPILER_H
+#define __COMPILER_H
+
+// Include proper device header file
+#if defined(__18CXX) && !defined(HI_TECH_C)
+ // PIC18 processor with Microchip C18 compiler
+ #define COMPILER_MPLAB_C18
+ #include
+#elif defined(__PICC18__) && defined(HI_TECH_C)
+ // PIC18 processor with (Microchip) HI-TECH PICC-18 compiler
+ #if !defined(__18CXX)
+ #define __18CXX
+ #endif
+ #define COMPILER_HITECH_PICC18
+ #include
+#elif (defined(_PIC12) || defined(_PIC14) || defined(_PIC14E)) && defined(HI_TECH_C)
+ // PIC10/12/16 processor with (Microchip) HI-TECH PICC compiler
+ #define COMPILER_HITECH_PICC
+ #include
+#elif (defined(__PIC24F__) || defined(__PIC24FK__)) && defined(__C30__) // Microchip C30 compiler
+ // PIC24F processor
+ #define COMPILER_MPLAB_C30
+ #include
+#elif defined(__PIC24H__) && defined(__C30__) // Microchip C30 compiler
+ // PIC24H processor
+ #define COMPILER_MPLAB_C30
+ #include
+#elif defined(__PIC24E__) && defined(__C30__) // Microchip C30 compiler
+ // PIC24E processor
+ #define COMPILER_MPLAB_C30
+ #include
+#elif defined(__dsPIC33F__) && defined(__C30__) // Microchip C30 compiler
+ // dsPIC33F processor
+ #define COMPILER_MPLAB_C30
+ #include
+#elif defined(__dsPIC33E__) && defined(__C30__) // Microchip C30 compiler
+ // dsPIC33E processor
+ #define COMPILER_MPLAB_C30
+ #include
+#elif defined(__dsPIC30F__) && defined(__C30__) // Microchip C30 compiler
+ // dsPIC30F processor
+ #define COMPILER_MPLAB_C30
+ #include
+#elif defined(__C30__) // Microchip C30 compiler, but targeting "generic-16bit" processor.
+ #define COMPILER_MPLAB_C30
+ #include
+ // Define some useful inline assembly functions which are normally in the
+ // processor header files, but absent from the generic p30sim.h file.
+ #if !defined(Nop)
+ #define Nop() __builtin_nop()
+ #define ClrWdt() {__asm__ volatile ("clrwdt");}
+ #define Sleep() {__asm__ volatile ("pwrsav #0");}
+ #define Idle() {__asm__ volatile ("pwrsav #1");}
+ #endif
+#elif defined(__PIC32MX__) // Microchip C32 compiler
+ #if !defined(__C32__)
+ #define __C32__
+ #endif
+ #define COMPILER_MPLAB_C32
+ #include
+ #include
+#else
+ #error Unknown processor or compiler. See Compiler.h
+#endif
+
+#include
+#include
+#include
+
+
+// Base RAM and ROM pointer types for given architecture
+#if defined(__PIC32MX__)
+ #define PTR_BASE unsigned long
+ #define ROM_PTR_BASE unsigned long
+#elif defined(__C30__)
+ #define PTR_BASE unsigned short
+ #define ROM_PTR_BASE unsigned short
+#elif defined(COMPILER_MPLAB_C18)
+ #define PTR_BASE unsigned short
+ #define ROM_PTR_BASE unsigned short long
+#elif defined(COMPILER_HITECH_PICC18)
+ #define PTR_BASE unsigned short
+ #define ROM_PTR_BASE unsigned long
+#endif
+
+
+// Definitions that apply to all except Microchip MPLAB C Compiler for PIC18 MCUs (C18)
+#if !defined(COMPILER_MPLAB_C18)
+ #define memcmppgm2ram(a,b,c) memcmp(a,b,c)
+ #define strcmppgm2ram(a,b) strcmp(a,b)
+ #define memcpypgm2ram(a,b,c) memcpy(a,b,c)
+ #define strcpypgm2ram(a,b) strcpy(a,b)
+ #define strncpypgm2ram(a,b,c) strncpy(a,b,c)
+ #define strstrrampgm(a,b) strstr(a,b)
+ #define strlenpgm(a) strlen(a)
+ #define strchrpgm(a,b) strchr(a,b)
+ #define strcatpgm2ram(a,b) strcat(a,b)
+#endif
+
+
+// Definitions that apply to all 8-bit products
+// (PIC10, PIC12, PIC16, PIC18)
+#if defined(__18CXX) || defined(COMPILER_HITECH_PICC)
+ #define __attribute__(a)
+
+ #define FAR far
+
+ // Microchip C18 specific defines
+ #if defined(COMPILER_MPLAB_C18)
+ #define ROM rom
+ #endif
+
+ // HI TECH specific defines
+ #if defined(COMPILER_HITECH_PICC18) || defined(COMPILER_HITECH_PICC)
+ #define ROM const
+ #define rom
+ #ifndef Nop()
+ #define Nop() asm("NOP");
+ #endif
+ #ifndef ClrWdt()
+ #define ClrWdt() asm("CLRWDT");
+ #endif
+ #ifndef Reset()
+ #define Reset() asm("RESET");
+ #endif
+ #ifndef Sleep()
+ #define Sleep() asm("SLEEP");
+ #endif
+ #endif
+
+// Definitions that apply to all 16-bit and 32-bit products
+// (PIC24F, PIC24H, dsPIC30F, dsPIC33F, and PIC32)
+#else
+ #define ROM const
+
+ // 16-bit specific defines (PIC24F, PIC24H, dsPIC30F, dsPIC33F)
+ #if defined(__C30__)
+ #define Reset() asm("reset")
+ #define FAR __attribute__((far))
+ #endif
+
+ // 32-bit specific defines (PIC32)
+ #if defined(__PIC32MX__)
+ #if (__C32_VERSION__ < 200)
+ #define persistent
+ #endif
+ #define far
+ #define FAR
+ #define Reset() SoftReset()
+ #define ClrWdt() (WDTCONSET = _WDTCON_WDTCLR_MASK)
+
+ // MPLAB C Compiler for PIC32 MCUs version 1.04 and below don't have a
+ // Nop() function. However, version 1.05 has Nop() declared as _nop().
+ #if !defined(Nop) && (__C32_VERSION__ <= 104)
+ #define Nop() asm("nop")
+ #endif
+ #endif
+#endif
+
+
+
+#endif
diff --git a/Source/USB/USB2.9i_cdc/include/GenericTypeDefs.h b/Source/USB/USB2.9i_cdc/include/GenericTypeDefs.h
new file mode 100644
index 0000000..3cc8654
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/GenericTypeDefs.h
@@ -0,0 +1,549 @@
+/*******************************************************************
+
+ Generic Type Definitions
+
+********************************************************************
+ FileName: GenericTypeDefs.h
+ Dependencies: None
+ Processor: PIC10, PIC12, PIC16, PIC18, PIC24, dsPIC, PIC32
+ Compiler: MPLAB C Compilers for PIC18, PIC24, dsPIC, & PIC32
+ Hi-Tech PICC PRO, Hi-Tech PICC18 PRO
+ Company: Microchip Technology Inc.
+
+ Software License Agreement
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the "Company") is intended and supplied to you, the Company's
+ customer, for use solely and exclusively with products manufactured
+ by the Company.
+
+ The software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+********************************************************************
+ File Description:
+
+ Change History:
+ Rev Date Description
+ 1.1 09/11/06 Add base signed types
+ 1.2 02/28/07 Add QWORD, LONGLONG, QWORD_VAL
+ 1.3 02/06/08 Add def's for PIC32
+ 1.4 08/08/08 Remove LSB/MSB Macros, adopted by Peripheral lib
+ 1.5 08/14/08 Simplify file header
+ 2.0 07/13/09 Updated for new release of coding standards
+ 3.1 05/28/10 MiWi DE 3.1
+*******************************************************************/
+
+#ifndef __GENERIC_TYPE_DEFS_H_
+#define __GENERIC_TYPE_DEFS_H_
+
+/* Specify an extension for GCC based compilers */
+#if defined(__GNUC__)
+#define __EXTENSION __extension__
+#else
+#define __EXTENSION
+#endif
+
+#if !defined(__PACKED)
+ #define __PACKED
+#endif
+
+/* get compiler defined type definitions (NULL, size_t, etc) */
+#include
+
+typedef enum _BOOL { FALSE = 0, TRUE } BOOL; /* Undefined size */
+typedef enum _BIT { CLEAR = 0, SET } BIT;
+
+#define PUBLIC /* Function attributes */
+#define PROTECTED
+#define PRIVATE static
+
+/* INT is processor specific in length may vary in size */
+typedef signed int INT;
+typedef signed char INT8;
+typedef signed short int INT16;
+typedef signed long int INT32;
+
+/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
+#if !defined(__18CXX)
+__EXTENSION typedef signed long long INT64;
+#endif
+
+/* UINT is processor specific in length may vary in size */
+typedef unsigned int UINT;
+typedef unsigned char UINT8;
+typedef unsigned short int UINT16;
+/* 24-bit type only available on C18 */
+#if defined(__18CXX)
+typedef unsigned short long UINT24;
+#endif
+typedef unsigned long int UINT32; /* other name for 32-bit integer */
+/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
+#if !defined(__18CXX)
+__EXTENSION typedef unsigned long long UINT64;
+#endif
+
+typedef union
+{
+ UINT8 Val;
+ struct
+ {
+ __EXTENSION UINT8 b0:1;
+ __EXTENSION UINT8 b1:1;
+ __EXTENSION UINT8 b2:1;
+ __EXTENSION UINT8 b3:1;
+ __EXTENSION UINT8 b4:1;
+ __EXTENSION UINT8 b5:1;
+ __EXTENSION UINT8 b6:1;
+ __EXTENSION UINT8 b7:1;
+ } bits;
+} UINT8_VAL, UINT8_BITS;
+
+typedef union
+{
+ UINT16 Val;
+ UINT8 v[2] __PACKED;
+ struct __PACKED
+ {
+ UINT8 LB;
+ UINT8 HB;
+ } byte;
+ struct __PACKED
+ {
+ __EXTENSION UINT8 b0:1;
+ __EXTENSION UINT8 b1:1;
+ __EXTENSION UINT8 b2:1;
+ __EXTENSION UINT8 b3:1;
+ __EXTENSION UINT8 b4:1;
+ __EXTENSION UINT8 b5:1;
+ __EXTENSION UINT8 b6:1;
+ __EXTENSION UINT8 b7:1;
+ __EXTENSION UINT8 b8:1;
+ __EXTENSION UINT8 b9:1;
+ __EXTENSION UINT8 b10:1;
+ __EXTENSION UINT8 b11:1;
+ __EXTENSION UINT8 b12:1;
+ __EXTENSION UINT8 b13:1;
+ __EXTENSION UINT8 b14:1;
+ __EXTENSION UINT8 b15:1;
+ } bits;
+} UINT16_VAL, UINT16_BITS;
+
+/* 24-bit type only available on C18 */
+#if defined(__18CXX)
+typedef union
+{
+ UINT24 Val;
+ UINT8 v[3] __PACKED;
+ struct __PACKED
+ {
+ UINT8 LB;
+ UINT8 HB;
+ UINT8 UB;
+ } byte;
+ struct __PACKED
+ {
+ __EXTENSION UINT8 b0:1;
+ __EXTENSION UINT8 b1:1;
+ __EXTENSION UINT8 b2:1;
+ __EXTENSION UINT8 b3:1;
+ __EXTENSION UINT8 b4:1;
+ __EXTENSION UINT8 b5:1;
+ __EXTENSION UINT8 b6:1;
+ __EXTENSION UINT8 b7:1;
+ __EXTENSION UINT8 b8:1;
+ __EXTENSION UINT8 b9:1;
+ __EXTENSION UINT8 b10:1;
+ __EXTENSION UINT8 b11:1;
+ __EXTENSION UINT8 b12:1;
+ __EXTENSION UINT8 b13:1;
+ __EXTENSION UINT8 b14:1;
+ __EXTENSION UINT8 b15:1;
+ __EXTENSION UINT8 b16:1;
+ __EXTENSION UINT8 b17:1;
+ __EXTENSION UINT8 b18:1;
+ __EXTENSION UINT8 b19:1;
+ __EXTENSION UINT8 b20:1;
+ __EXTENSION UINT8 b21:1;
+ __EXTENSION UINT8 b22:1;
+ __EXTENSION UINT8 b23:1;
+ } bits;
+} UINT24_VAL, UINT24_BITS;
+#endif
+
+typedef union
+{
+ UINT32 Val;
+ UINT16 w[2] __PACKED;
+ UINT8 v[4] __PACKED;
+ struct __PACKED
+ {
+ UINT16 LW;
+ UINT16 HW;
+ } word;
+ struct __PACKED
+ {
+ UINT8 LB;
+ UINT8 HB;
+ UINT8 UB;
+ UINT8 MB;
+ } byte;
+ struct __PACKED
+ {
+ UINT16_VAL low;
+ UINT16_VAL high;
+ }wordUnion;
+ struct __PACKED
+ {
+ __EXTENSION UINT8 b0:1;
+ __EXTENSION UINT8 b1:1;
+ __EXTENSION UINT8 b2:1;
+ __EXTENSION UINT8 b3:1;
+ __EXTENSION UINT8 b4:1;
+ __EXTENSION UINT8 b5:1;
+ __EXTENSION UINT8 b6:1;
+ __EXTENSION UINT8 b7:1;
+ __EXTENSION UINT8 b8:1;
+ __EXTENSION UINT8 b9:1;
+ __EXTENSION UINT8 b10:1;
+ __EXTENSION UINT8 b11:1;
+ __EXTENSION UINT8 b12:1;
+ __EXTENSION UINT8 b13:1;
+ __EXTENSION UINT8 b14:1;
+ __EXTENSION UINT8 b15:1;
+ __EXTENSION UINT8 b16:1;
+ __EXTENSION UINT8 b17:1;
+ __EXTENSION UINT8 b18:1;
+ __EXTENSION UINT8 b19:1;
+ __EXTENSION UINT8 b20:1;
+ __EXTENSION UINT8 b21:1;
+ __EXTENSION UINT8 b22:1;
+ __EXTENSION UINT8 b23:1;
+ __EXTENSION UINT8 b24:1;
+ __EXTENSION UINT8 b25:1;
+ __EXTENSION UINT8 b26:1;
+ __EXTENSION UINT8 b27:1;
+ __EXTENSION UINT8 b28:1;
+ __EXTENSION UINT8 b29:1;
+ __EXTENSION UINT8 b30:1;
+ __EXTENSION UINT8 b31:1;
+ } bits;
+} UINT32_VAL;
+
+/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
+#if !defined(__18CXX)
+typedef union
+{
+ UINT64 Val;
+ UINT32 d[2] __PACKED;
+ UINT16 w[4] __PACKED;
+ UINT8 v[8] __PACKED;
+ struct __PACKED
+ {
+ UINT32 LD;
+ UINT32 HD;
+ } dword;
+ struct __PACKED
+ {
+ UINT16 LW;
+ UINT16 HW;
+ UINT16 UW;
+ UINT16 MW;
+ } word;
+ struct __PACKED
+ {
+ __EXTENSION UINT8 b0:1;
+ __EXTENSION UINT8 b1:1;
+ __EXTENSION UINT8 b2:1;
+ __EXTENSION UINT8 b3:1;
+ __EXTENSION UINT8 b4:1;
+ __EXTENSION UINT8 b5:1;
+ __EXTENSION UINT8 b6:1;
+ __EXTENSION UINT8 b7:1;
+ __EXTENSION UINT8 b8:1;
+ __EXTENSION UINT8 b9:1;
+ __EXTENSION UINT8 b10:1;
+ __EXTENSION UINT8 b11:1;
+ __EXTENSION UINT8 b12:1;
+ __EXTENSION UINT8 b13:1;
+ __EXTENSION UINT8 b14:1;
+ __EXTENSION UINT8 b15:1;
+ __EXTENSION UINT8 b16:1;
+ __EXTENSION UINT8 b17:1;
+ __EXTENSION UINT8 b18:1;
+ __EXTENSION UINT8 b19:1;
+ __EXTENSION UINT8 b20:1;
+ __EXTENSION UINT8 b21:1;
+ __EXTENSION UINT8 b22:1;
+ __EXTENSION UINT8 b23:1;
+ __EXTENSION UINT8 b24:1;
+ __EXTENSION UINT8 b25:1;
+ __EXTENSION UINT8 b26:1;
+ __EXTENSION UINT8 b27:1;
+ __EXTENSION UINT8 b28:1;
+ __EXTENSION UINT8 b29:1;
+ __EXTENSION UINT8 b30:1;
+ __EXTENSION UINT8 b31:1;
+ __EXTENSION UINT8 b32:1;
+ __EXTENSION UINT8 b33:1;
+ __EXTENSION UINT8 b34:1;
+ __EXTENSION UINT8 b35:1;
+ __EXTENSION UINT8 b36:1;
+ __EXTENSION UINT8 b37:1;
+ __EXTENSION UINT8 b38:1;
+ __EXTENSION UINT8 b39:1;
+ __EXTENSION UINT8 b40:1;
+ __EXTENSION UINT8 b41:1;
+ __EXTENSION UINT8 b42:1;
+ __EXTENSION UINT8 b43:1;
+ __EXTENSION UINT8 b44:1;
+ __EXTENSION UINT8 b45:1;
+ __EXTENSION UINT8 b46:1;
+ __EXTENSION UINT8 b47:1;
+ __EXTENSION UINT8 b48:1;
+ __EXTENSION UINT8 b49:1;
+ __EXTENSION UINT8 b50:1;
+ __EXTENSION UINT8 b51:1;
+ __EXTENSION UINT8 b52:1;
+ __EXTENSION UINT8 b53:1;
+ __EXTENSION UINT8 b54:1;
+ __EXTENSION UINT8 b55:1;
+ __EXTENSION UINT8 b56:1;
+ __EXTENSION UINT8 b57:1;
+ __EXTENSION UINT8 b58:1;
+ __EXTENSION UINT8 b59:1;
+ __EXTENSION UINT8 b60:1;
+ __EXTENSION UINT8 b61:1;
+ __EXTENSION UINT8 b62:1;
+ __EXTENSION UINT8 b63:1;
+ } bits;
+} UINT64_VAL;
+#endif /* __18CXX */
+
+/***********************************************************************************/
+
+/* Alternate definitions */
+typedef void VOID;
+
+typedef char CHAR8;
+typedef unsigned char UCHAR8;
+
+typedef unsigned char BYTE; /* 8-bit unsigned */
+typedef unsigned short int WORD; /* 16-bit unsigned */
+typedef unsigned long DWORD; /* 32-bit unsigned */
+/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
+__EXTENSION
+typedef unsigned long long QWORD; /* 64-bit unsigned */
+typedef signed char CHAR; /* 8-bit signed */
+typedef signed short int SHORT; /* 16-bit signed */
+typedef signed long LONG; /* 32-bit signed */
+/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
+__EXTENSION
+typedef signed long long LONGLONG; /* 64-bit signed */
+typedef union
+{
+ BYTE Val;
+ struct __PACKED
+ {
+ __EXTENSION BYTE b0:1;
+ __EXTENSION BYTE b1:1;
+ __EXTENSION BYTE b2:1;
+ __EXTENSION BYTE b3:1;
+ __EXTENSION BYTE b4:1;
+ __EXTENSION BYTE b5:1;
+ __EXTENSION BYTE b6:1;
+ __EXTENSION BYTE b7:1;
+ } bits;
+} BYTE_VAL, BYTE_BITS;
+
+typedef union
+{
+ WORD Val;
+ BYTE v[2] __PACKED;
+ struct __PACKED
+ {
+ BYTE LB;
+ BYTE HB;
+ } byte;
+ struct __PACKED
+ {
+ __EXTENSION BYTE b0:1;
+ __EXTENSION BYTE b1:1;
+ __EXTENSION BYTE b2:1;
+ __EXTENSION BYTE b3:1;
+ __EXTENSION BYTE b4:1;
+ __EXTENSION BYTE b5:1;
+ __EXTENSION BYTE b6:1;
+ __EXTENSION BYTE b7:1;
+ __EXTENSION BYTE b8:1;
+ __EXTENSION BYTE b9:1;
+ __EXTENSION BYTE b10:1;
+ __EXTENSION BYTE b11:1;
+ __EXTENSION BYTE b12:1;
+ __EXTENSION BYTE b13:1;
+ __EXTENSION BYTE b14:1;
+ __EXTENSION BYTE b15:1;
+ } bits;
+} WORD_VAL, WORD_BITS;
+
+typedef union
+{
+ DWORD Val;
+ WORD w[2] __PACKED;
+ BYTE v[4] __PACKED;
+ struct __PACKED
+ {
+ WORD LW;
+ WORD HW;
+ } word;
+ struct __PACKED
+ {
+ BYTE LB;
+ BYTE HB;
+ BYTE UB;
+ BYTE MB;
+ } byte;
+ struct __PACKED
+ {
+ WORD_VAL low;
+ WORD_VAL high;
+ }wordUnion;
+ struct __PACKED
+ {
+ __EXTENSION BYTE b0:1;
+ __EXTENSION BYTE b1:1;
+ __EXTENSION BYTE b2:1;
+ __EXTENSION BYTE b3:1;
+ __EXTENSION BYTE b4:1;
+ __EXTENSION BYTE b5:1;
+ __EXTENSION BYTE b6:1;
+ __EXTENSION BYTE b7:1;
+ __EXTENSION BYTE b8:1;
+ __EXTENSION BYTE b9:1;
+ __EXTENSION BYTE b10:1;
+ __EXTENSION BYTE b11:1;
+ __EXTENSION BYTE b12:1;
+ __EXTENSION BYTE b13:1;
+ __EXTENSION BYTE b14:1;
+ __EXTENSION BYTE b15:1;
+ __EXTENSION BYTE b16:1;
+ __EXTENSION BYTE b17:1;
+ __EXTENSION BYTE b18:1;
+ __EXTENSION BYTE b19:1;
+ __EXTENSION BYTE b20:1;
+ __EXTENSION BYTE b21:1;
+ __EXTENSION BYTE b22:1;
+ __EXTENSION BYTE b23:1;
+ __EXTENSION BYTE b24:1;
+ __EXTENSION BYTE b25:1;
+ __EXTENSION BYTE b26:1;
+ __EXTENSION BYTE b27:1;
+ __EXTENSION BYTE b28:1;
+ __EXTENSION BYTE b29:1;
+ __EXTENSION BYTE b30:1;
+ __EXTENSION BYTE b31:1;
+ } bits;
+} DWORD_VAL;
+
+/* MPLAB C Compiler for PIC18 does not support 64-bit integers */
+typedef union
+{
+ QWORD Val;
+ DWORD d[2] __PACKED;
+ WORD w[4] __PACKED;
+ BYTE v[8] __PACKED;
+ struct __PACKED
+ {
+ DWORD LD;
+ DWORD HD;
+ } dword;
+ struct __PACKED
+ {
+ WORD LW;
+ WORD HW;
+ WORD UW;
+ WORD MW;
+ } word;
+ struct __PACKED
+ {
+ __EXTENSION BYTE b0:1;
+ __EXTENSION BYTE b1:1;
+ __EXTENSION BYTE b2:1;
+ __EXTENSION BYTE b3:1;
+ __EXTENSION BYTE b4:1;
+ __EXTENSION BYTE b5:1;
+ __EXTENSION BYTE b6:1;
+ __EXTENSION BYTE b7:1;
+ __EXTENSION BYTE b8:1;
+ __EXTENSION BYTE b9:1;
+ __EXTENSION BYTE b10:1;
+ __EXTENSION BYTE b11:1;
+ __EXTENSION BYTE b12:1;
+ __EXTENSION BYTE b13:1;
+ __EXTENSION BYTE b14:1;
+ __EXTENSION BYTE b15:1;
+ __EXTENSION BYTE b16:1;
+ __EXTENSION BYTE b17:1;
+ __EXTENSION BYTE b18:1;
+ __EXTENSION BYTE b19:1;
+ __EXTENSION BYTE b20:1;
+ __EXTENSION BYTE b21:1;
+ __EXTENSION BYTE b22:1;
+ __EXTENSION BYTE b23:1;
+ __EXTENSION BYTE b24:1;
+ __EXTENSION BYTE b25:1;
+ __EXTENSION BYTE b26:1;
+ __EXTENSION BYTE b27:1;
+ __EXTENSION BYTE b28:1;
+ __EXTENSION BYTE b29:1;
+ __EXTENSION BYTE b30:1;
+ __EXTENSION BYTE b31:1;
+ __EXTENSION BYTE b32:1;
+ __EXTENSION BYTE b33:1;
+ __EXTENSION BYTE b34:1;
+ __EXTENSION BYTE b35:1;
+ __EXTENSION BYTE b36:1;
+ __EXTENSION BYTE b37:1;
+ __EXTENSION BYTE b38:1;
+ __EXTENSION BYTE b39:1;
+ __EXTENSION BYTE b40:1;
+ __EXTENSION BYTE b41:1;
+ __EXTENSION BYTE b42:1;
+ __EXTENSION BYTE b43:1;
+ __EXTENSION BYTE b44:1;
+ __EXTENSION BYTE b45:1;
+ __EXTENSION BYTE b46:1;
+ __EXTENSION BYTE b47:1;
+ __EXTENSION BYTE b48:1;
+ __EXTENSION BYTE b49:1;
+ __EXTENSION BYTE b50:1;
+ __EXTENSION BYTE b51:1;
+ __EXTENSION BYTE b52:1;
+ __EXTENSION BYTE b53:1;
+ __EXTENSION BYTE b54:1;
+ __EXTENSION BYTE b55:1;
+ __EXTENSION BYTE b56:1;
+ __EXTENSION BYTE b57:1;
+ __EXTENSION BYTE b58:1;
+ __EXTENSION BYTE b59:1;
+ __EXTENSION BYTE b60:1;
+ __EXTENSION BYTE b61:1;
+ __EXTENSION BYTE b62:1;
+ __EXTENSION BYTE b63:1;
+ } bits;
+} QWORD_VAL;
+
+#undef __EXTENSION
+
+#endif /* __GENERIC_TYPE_DEFS_H_ */
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb.h b/Source/USB/USB2.9i_cdc/include/USB/usb.h
new file mode 100644
index 0000000..ad5962c
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb.h
@@ -0,0 +1,146 @@
+//DOM-IGNORE-BEGIN
+/*********************************************************************
+ * The following lines are used by VDI.
+ * GUID=E537A0C0-6FEE-4afd-89B9-0C35BF72A80B
+ * GUIInterfaceVersion=1.00
+ * LibraryVersion=2.4
+ *********************************************************************/
+//DOM-IGNORE-END
+/*******************************************************************************
+
+ USB Header File
+
+Summary:
+ This file aggregates all necessary header files for the Microchip USB Host,
+ Device, and OTG libraries. It provides a single-file can be included in
+ application code. The USB libraries simplify the implementation of USB
+ applications by providing an abstraction of the USB module and its registers
+ and bits such that the source code for the can be the same across various
+ hardware platforms.
+
+Description:
+ This file aggregates all necessary header files for the Microchip USB Host,
+ Device, and OTG libraries. It provides a single-file can be included in
+ application code. The USB libraries simplify the implementation of USB
+ applications by providing an abstraction of the USB module and its registers
+ and bits such that the source code for the can be the same across various
+ hardware platforms.
+
+ Note that this file does not include the header files for any client or
+ function drivers.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+
+ ..\\..\\Microchip\\Include
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+
+******************************************************************************/
+/******************************************************************************
+ FileName: usb.h
+ Dependencies: See INCLUDES section
+ Processor: PIC18, PIC24, & PIC32 USB Microcontrollers
+ Hardware:
+ Complier: Microchip C18 (for PIC18), C30 (for PIC24), or C32 (for PIC32)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the "Company") for its PICmicro(r) Microcontroller is intended and
+ supplied to you, the Company's customer, for use solely and
+ exclusively on Microchip PICmicro Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+********************************************************************/
+//DOM-IGNORE-END
+
+//DOM-IGNORE-BEGIN
+/********************************************************************
+ File Description:
+
+ Change History:
+ Rev Description
+ ---------- -----------
+ 2.6 - 2.9 No change except stack revision number
+********************************************************************/
+//DOM-IGNORE-END
+
+#ifndef _USB_H_
+#define _USB_H_
+//DOM-IGNORE-END
+
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: All necessary USB Library headers
+// *****************************************************************************
+// *****************************************************************************
+
+#include "GenericTypeDefs.h"
+#include "Compiler.h"
+
+#include "usb_config.h" // Must be defined by the application
+
+#include "USB/usb_common.h" // Common USB library definitions
+#include "USB/usb_ch9.h" // USB device framework definitions
+
+#if defined( USB_SUPPORT_DEVICE )
+ #include "USB/usb_device.h" // USB Device abstraction layer interface
+#endif
+
+#if defined( USB_SUPPORT_HOST )
+ #include "USB/usb_host.h" // USB Host abstraction layer interface
+#endif
+
+#if defined ( USB_SUPPORT_OTG )
+ #include "USB/usb_otg.h"
+#endif
+
+#include "USB/usb_hal.h" // Hardware Abstraction Layer interface
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: MCHPFSUSB Firmware Version
+// *****************************************************************************
+// *****************************************************************************
+
+#define USB_MAJOR_VER 2 // Firmware version, major release number.
+#define USB_MINOR_VER 9 // Firmware version, minor release number.
+#define USB_DOT_VER 0 // Firmware version, dot release number.
+
+#endif // _USB_H_
+/*************************************************************************
+ * EOF
+ */
+
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb_ch9.h b/Source/USB/USB2.9i_cdc/include/USB/usb_ch9.h
new file mode 100644
index 0000000..62e4588
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb_ch9.h
@@ -0,0 +1,618 @@
+/*******************************************************************************
+
+ USB Chapter 9 Protocol (Header File)
+
+Summary:
+ This file defines data structures, constants, and macros that are used to
+ to support the USB Device Framework protocol described in Chapter 9 of the
+ USB 2.0 specification.
+
+Description:
+ This file defines data structures, constants, and macros that are used to
+ to support the USB Device Framework protocol described in Chapter 9 of the
+ USB 2.0 specification.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+
+ ..\\..\\Microchip\\Include
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+*******************************************************************************/
+//DOM-IGNORE-BEGIN
+/*******************************************************************************
+
+* FileName: usb_ch9.h
+* Dependencies: None
+* Processor: PIC18/PIC24/PIC32MX microcontrollers with USB module
+* Compiler: C18 v3.13+/C30 v2.01+/C32 v0.00.18+
+* Company: Microchip Technology, Inc.
+* File Description:
+* This file contains the definitions and prototypes used for
+* specification chapter 9 compliance.
+
+Software License Agreement
+
+The software supplied herewith by Microchip Technology Incorporated
+(the “Company”) for its PICmicro® Microcontroller is intended and
+supplied to you, the Company’s customer, for use solely and
+exclusively on Microchip PICmicro Microcontroller products. The
+software is owned by the Company and/or its supplier, and is
+protected under applicable copyright laws. All rights are reserved.
+Any use in violation of the foregoing restrictions may subject the
+user to criminal sanctions under applicable laws, as well as to
+civil liability for the breach of the terms and conditions of this
+license.
+
+THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+*******************************************************************************/
+//DOM-IGNORE-END
+
+//DOM-IGNORE-BEGIN
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.6 Moved many of the CH9 defintions from the device stack files
+ into this file.
+********************************************************************/
+//DOM-IGNORE-END
+
+//DOM-IGNORE-BEGIN
+#ifndef _USB_CH9_H_
+#define _USB_CH9_H_
+//DOM-IGNORE-END
+
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: USB Descriptors
+// *****************************************************************************
+// *****************************************************************************
+
+#define USB_DESCRIPTOR_DEVICE 0x01 // bDescriptorType for a Device Descriptor.
+#define USB_DESCRIPTOR_CONFIGURATION 0x02 // bDescriptorType for a Configuration Descriptor.
+#define USB_DESCRIPTOR_STRING 0x03 // bDescriptorType for a String Descriptor.
+#define USB_DESCRIPTOR_INTERFACE 0x04 // bDescriptorType for an Interface Descriptor.
+#define USB_DESCRIPTOR_ENDPOINT 0x05 // bDescriptorType for an Endpoint Descriptor.
+#define USB_DESCRIPTOR_DEVICE_QUALIFIER 0x06 // bDescriptorType for a Device Qualifier.
+#define USB_DESCRIPTOR_OTHER_SPEED 0x07 // bDescriptorType for a Other Speed Configuration.
+#define USB_DESCRIPTOR_INTERFACE_POWER 0x08 // bDescriptorType for Interface Power.
+#define USB_DESCRIPTOR_OTG 0x09 // bDescriptorType for an OTG Descriptor.
+
+// *****************************************************************************
+/* USB Device Descriptor Structure
+
+This struct defines the structure of a USB Device Descriptor. Note that this
+structure may need to be packed, or even accessed as bytes, to properly access
+the correct fields when used on some device architectures.
+*/
+typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR
+{
+ BYTE bLength; // Length of this descriptor.
+ BYTE bDescriptorType; // DEVICE descriptor type (USB_DESCRIPTOR_DEVICE).
+ WORD bcdUSB; // USB Spec Release Number (BCD).
+ BYTE bDeviceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
+ BYTE bDeviceSubClass; // Subclass code (assigned by the USB-IF).
+ BYTE bDeviceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
+ BYTE bMaxPacketSize0; // Maximum packet size for endpoint 0.
+ WORD idVendor; // Vendor ID (assigned by the USB-IF).
+ WORD idProduct; // Product ID (assigned by the manufacturer).
+ WORD bcdDevice; // Device release number (BCD).
+ BYTE iManufacturer; // Index of String Descriptor describing the manufacturer.
+ BYTE iProduct; // Index of String Descriptor describing the product.
+ BYTE iSerialNumber; // Index of String Descriptor with the device's serial number.
+ BYTE bNumConfigurations; // Number of possible configurations.
+} USB_DEVICE_DESCRIPTOR;
+
+
+// *****************************************************************************
+/* USB Configuration Descriptor Structure
+
+This struct defines the structure of a USB Configuration Descriptor. Note that this
+structure may need to be packed, or even accessed as bytes, to properly access
+the correct fields when used on some device architectures.
+*/
+typedef struct __attribute__ ((packed)) _USB_CONFIGURATION_DESCRIPTOR
+{
+ BYTE bLength; // Length of this descriptor.
+ BYTE bDescriptorType; // CONFIGURATION descriptor type (USB_DESCRIPTOR_CONFIGURATION).
+ WORD wTotalLength; // Total length of all descriptors for this configuration.
+ BYTE bNumInterfaces; // Number of interfaces in this configuration.
+ BYTE bConfigurationValue; // Value of this configuration (1 based).
+ BYTE iConfiguration; // Index of String Descriptor describing the configuration.
+ BYTE bmAttributes; // Configuration characteristics.
+ BYTE bMaxPower; // Maximum power consumed by this configuration.
+} USB_CONFIGURATION_DESCRIPTOR;
+
+// Attributes bits
+#define USB_CFG_DSC_REQUIRED 0x80 // Required attribute
+#define USB_CFG_DSC_SELF_PWR (0x40|USB_CFG_DSC_REQUIRED) // Device is self powered.
+#define USB_CFG_DSC_REM_WAKE (0x20|USB_CFG_DSC_REQUIRED) // Device can request remote wakup
+
+
+// *****************************************************************************
+/* USB Interface Descriptor Structure
+
+This struct defines the structure of a USB Interface Descriptor. Note that this
+structure may need to be packed, or even accessed as bytes, to properly access
+the correct fields when used on some device architectures.
+*/
+typedef struct __attribute__ ((packed)) _USB_INTERFACE_DESCRIPTOR
+{
+ BYTE bLength; // Length of this descriptor.
+ BYTE bDescriptorType; // INTERFACE descriptor type (USB_DESCRIPTOR_INTERFACE).
+ BYTE bInterfaceNumber; // Number of this interface (0 based).
+ BYTE bAlternateSetting; // Value of this alternate interface setting.
+ BYTE bNumEndpoints; // Number of endpoints in this interface.
+ BYTE bInterfaceClass; // Class code (assigned by the USB-IF). 0xFF-Vendor specific.
+ BYTE bInterfaceSubClass; // Subclass code (assigned by the USB-IF).
+ BYTE bInterfaceProtocol; // Protocol code (assigned by the USB-IF). 0xFF-Vendor specific.
+ BYTE iInterface; // Index of String Descriptor describing the interface.
+} USB_INTERFACE_DESCRIPTOR;
+
+
+// *****************************************************************************
+/* USB Endpoint Descriptor Structure
+
+This struct defines the structure of a USB Endpoint Descriptor. Note that this
+structure may need to be packed, or even accessed as bytes, to properly access
+the correct fields when used on some device architectures.
+*/
+typedef struct __attribute__ ((packed)) _USB_ENDPOINT_DESCRIPTOR
+{
+ BYTE bLength; // Length of this descriptor.
+ BYTE bDescriptorType; // ENDPOINT descriptor type (USB_DESCRIPTOR_ENDPOINT).
+ BYTE bEndpointAddress; // Endpoint address. Bit 7 indicates direction (0=OUT, 1=IN).
+ BYTE bmAttributes; // Endpoint transfer type.
+ WORD wMaxPacketSize; // Maximum packet size.
+ BYTE bInterval; // Polling interval in frames.
+} USB_ENDPOINT_DESCRIPTOR;
+
+
+// Endpoint Direction
+#define EP_DIR_IN 0x80 // Data flows from device to host
+#define EP_DIR_OUT 0x00 // Data flows from host to device
+
+
+// ******************************************************************
+// USB Endpoint Attributes
+// ******************************************************************
+
+// Section: Transfer Types
+#define EP_ATTR_CONTROL (0<<0) // Endoint used for control transfers
+#define EP_ATTR_ISOCH (1<<0) // Endpoint used for isochronous transfers
+#define EP_ATTR_BULK (2<<0) // Endpoint used for bulk transfers
+#define EP_ATTR_INTR (3<<0) // Endpoint used for interrupt transfers
+
+// Section: Synchronization Types (for isochronous enpoints)
+#define EP_ATTR_NO_SYNC (0<<2) // No Synchronization
+#define EP_ATTR_ASYNC (1<<2) // Asynchronous
+#define EP_ATTR_ADAPT (2<<2) // Adaptive synchronization
+#define EP_ATTR_SYNC (3<<2) // Synchronous
+
+// Section: Usage Types (for isochronous endpoints)
+#define EP_ATTR_DATA (0<<4) // Data Endpoint
+#define EP_ATTR_FEEDBACK (1<<4) // Feedback endpoint
+#define EP_ATTR_IMP_FB (2<<4) // Implicit Feedback data EP
+
+// Section: Max Packet Sizes
+#define EP_MAX_PKT_INTR_LS 8 // Max low-speed interrupt packet
+#define EP_MAX_PKT_INTR_FS 64 // Max full-speed interrupt packet
+#define EP_MAX_PKT_ISOCH_FS 1023 // Max full-speed isochronous packet
+#define EP_MAX_PKT_BULK_FS 64 // Max full-speed bulk packet
+#define EP_LG_PKT_BULK_FS 32 // Large full-speed bulk packet
+#define EP_MED_PKT_BULK_FS 16 // Medium full-speed bulk packet
+#define EP_SM_PKT_BULK_FS 8 // Small full-speed bulk packet
+
+/* Descriptor IDs
+The descriptor ID type defines the information required by the HOST during a
+GET_DESCRIPTOR request
+*/
+typedef struct
+{
+ BYTE index;
+ BYTE type;
+ UINT16 language_id;
+
+} DESCRIPTOR_ID;
+
+// *****************************************************************************
+/* USB OTG Descriptor Structure
+
+This struct defines the structure of a USB OTG Descriptor. Note that this
+structure may need to be packed, or even accessed as bytes, to properly access
+the correct fields when used on some device architectures.
+*/
+typedef struct __attribute__ ((packed)) _USB_OTG_DESCRIPTOR
+{
+ BYTE bLength; // Length of this descriptor.
+ BYTE bDescriptorType; // OTG descriptor type (USB_DESCRIPTOR_OTG).
+ BYTE bmAttributes; // OTG attributes.
+} USB_OTG_DESCRIPTOR;
+
+
+// ******************************************************************
+// Section: USB String Descriptor Structure
+// ******************************************************************
+// This structure describes the USB string descriptor. The string
+// descriptor provides user-readable information about various aspects of
+// the device. The first string desriptor (string descriptor zero (0)),
+// provides a list of the number of languages supported by the set of
+// string descriptors for this device instead of an actual string.
+//
+// Note: The strings are in 2-byte-per-character unicode, not ASCII.
+//
+// Note: This structure only describes the "header" of the string
+// descriptor. The actual data (either the language ID array or the
+// array of unicode characters making up the string, must be allocated
+// immediately following this header with no padding between them.
+
+typedef struct __attribute__ ((packed)) _USB_STRING_DSC
+{
+ BYTE bLength; // Size of this descriptor
+ BYTE bDescriptorType; // Type, USB_DSC_STRING
+
+} USB_STRING_DESCRIPTOR;
+
+
+// ******************************************************************
+// Section: USB Device Qualifier Descriptor Structure
+// ******************************************************************
+// This structure describes the device qualifier descriptor. The device
+// qualifier descriptor provides overall device information if the device
+// supports "other" speeds.
+//
+// Note: A high-speed device may support "other" speeds (ie. full or low).
+// If so, it may need to implement the the device qualifier and other
+// speed descriptors.
+
+typedef struct __attribute__ ((packed)) _USB_DEVICE_QUALIFIER_DESCRIPTOR
+{
+ BYTE bLength; // Size of this descriptor
+ BYTE bType; // Type, always USB_DESCRIPTOR_DEVICE_QUALIFIER
+ WORD bcdUSB; // USB spec version, in BCD
+ BYTE bDeviceClass; // Device class code
+ BYTE bDeviceSubClass; // Device sub-class code
+ BYTE bDeviceProtocol; // Device protocol
+ BYTE bMaxPacketSize0; // EP0, max packet size
+ BYTE bNumConfigurations; // Number of "other-speed" configurations
+ BYTE bReserved; // Always zero (0)
+
+} USB_DEVICE_QUALIFIER_DESCRIPTOR;
+
+// ******************************************************************
+// Section: USB Setup Packet Structure
+// ******************************************************************
+// This structure describes the data contained in a USB standard device
+// request's setup packet. It is the data packet sent from the host to
+// the device to control and configure the device.
+//
+// Note: Refer to the USB 2.0 specification for additional details on the
+// usage of the setup packet and standard device requests.
+typedef union __attribute__ ((packed))
+{
+ /** Standard Device Requests ***********************************/
+ struct __attribute__ ((packed))
+ {
+ BYTE bmRequestType; //from table 9-2 of USB2.0 spec
+ BYTE bRequest; //from table 9-2 of USB2.0 spec
+ WORD wValue; //from table 9-2 of USB2.0 spec
+ WORD wIndex; //from table 9-2 of USB2.0 spec
+ WORD wLength; //from table 9-2 of USB2.0 spec
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ WORD_VAL W_Value; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
+ WORD_VAL W_Index; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
+ WORD_VAL W_Length; //from table 9-2 of USB2.0 spec, allows byte/bitwise access
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned Recipient:5; //Device,Interface,Endpoint,Other
+ unsigned RequestType:2; //Standard,Class,Vendor,Reserved
+ unsigned DataDir:1; //Host-to-device,Device-to-host
+ unsigned :8;
+ BYTE bFeature; //DEVICE_REMOTE_WAKEUP,ENDPOINT_HALT
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ };
+ struct __attribute__ ((packed))
+ {
+ union // offset description
+ { // ------ ------------------------
+ BYTE bmRequestType; // 0 Bit-map of request type
+ struct
+ {
+ BYTE recipient: 5; // Recipient of the request
+ BYTE type: 2; // Type of request
+ BYTE direction: 1; // Direction of data X-fer
+ };
+ }requestInfo;
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ BYTE bDscIndex; //For Configuration and String DSC Only
+ BYTE bDescriptorType; //Device,Configuration,String
+ WORD wLangID; //Language ID
+ unsigned :8;
+ unsigned :8;
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ BYTE_VAL bDevADR; //Device Address 0-127
+ BYTE bDevADRH; //Must equal zero
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ BYTE bConfigurationValue; //Configuration Value 0-255
+ BYTE bCfgRSD; //Must equal zero (Reserved)
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ BYTE bAltID; //Alternate Setting Value 0-255
+ BYTE bAltID_H; //Must equal zero
+ BYTE bIntfID; //Interface Number Value 0-255
+ BYTE bIntfID_H; //Must equal zero
+ unsigned :8;
+ unsigned :8;
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ BYTE bEPID; //Endpoint ID (Number & Direction)
+ BYTE bEPID_H; //Must equal zero
+ unsigned :8;
+ unsigned :8;
+ };
+ struct __attribute__ ((packed))
+ {
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ unsigned EPNum:4; //Endpoint Number 0-15
+ unsigned :3;
+ unsigned EPDir:1; //Endpoint Direction: 0-OUT, 1-IN
+ unsigned :8;
+ unsigned :8;
+ unsigned :8;
+ };
+
+ /** End: Standard Device Requests ******************************/
+
+} CTRL_TRF_SETUP, SETUP_PKT, *PSETUP_PKT;
+
+
+// ******************************************************************
+// ******************************************************************
+// Section: USB Specification Constants
+// ******************************************************************
+// ******************************************************************
+
+// Section: Valid PID Values
+//DOM-IGNORE-BEGIN
+#define PID_OUT 0x1 // PID for an OUT token
+#define PID_ACK 0x2 // PID for an ACK handshake
+#define PID_DATA0 0x3 // PID for DATA0 data
+#define PID_PING 0x4 // Special PID PING
+#define PID_SOF 0x5 // PID for a SOF token
+#define PID_NYET 0x6 // PID for a NYET handshake
+#define PID_DATA2 0x7 // PID for DATA2 data
+#define PID_SPLIT 0x8 // Special PID SPLIT
+#define PID_IN 0x9 // PID for a IN token
+#define PID_NAK 0xA // PID for a NAK handshake
+#define PID_DATA1 0xB // PID for DATA1 data
+#define PID_PRE 0xC // Special PID PRE (Same as PID_ERR)
+#define PID_ERR 0xC // Special PID ERR (Same as PID_PRE)
+#define PID_SETUP 0xD // PID for a SETUP token
+#define PID_STALL 0xE // PID for a STALL handshake
+#define PID_MDATA 0xF // PID for MDATA data
+
+#define PID_MASK_DATA 0x03 // Data PID mask
+#define PID_MASK_DATA_SHIFTED (PID_MASK_DATA << 2) // Data PID shift to proper position
+//DOM-IGNORE-END
+
+// Section: USB Token Types
+//DOM-IGNORE-BEGIN
+#define USB_TOKEN_OUT 0x01 // U1TOK - OUT token
+#define USB_TOKEN_IN 0x09 // U1TOK - IN token
+#define USB_TOKEN_SETUP 0x0D // U1TOK - SETUP token
+//DOM-IGNORE-END
+
+// Section: OTG Descriptor Constants
+
+#define OTG_HNP_SUPPORT 0x02 // OTG Descriptor bmAttributes - HNP support flag
+#define OTG_SRP_SUPPORT 0x01 // OTG Descriptor bmAttributes - SRP support flag
+
+// Section: Endpoint Directions
+
+#define USB_IN_EP 0x80 // IN endpoint mask
+#define USB_OUT_EP 0x00 // OUT endpoint mask
+
+// Section: Standard Device Requests
+
+#define USB_REQUEST_GET_STATUS 0 // Standard Device Request - GET STATUS
+#define USB_REQUEST_CLEAR_FEATURE 1 // Standard Device Request - CLEAR FEATURE
+#define USB_REQUEST_SET_FEATURE 3 // Standard Device Request - SET FEATURE
+#define USB_REQUEST_SET_ADDRESS 5 // Standard Device Request - SET ADDRESS
+#define USB_REQUEST_GET_DESCRIPTOR 6 // Standard Device Request - GET DESCRIPTOR
+#define USB_REQUEST_SET_DESCRIPTOR 7 // Standard Device Request - SET DESCRIPTOR
+#define USB_REQUEST_GET_CONFIGURATION 8 // Standard Device Request - GET CONFIGURATION
+#define USB_REQUEST_SET_CONFIGURATION 9 // Standard Device Request - SET CONFIGURATION
+#define USB_REQUEST_GET_INTERFACE 10 // Standard Device Request - GET INTERFACE
+#define USB_REQUEST_SET_INTERFACE 11 // Standard Device Request - SET INTERFACE
+#define USB_REQUEST_SYNCH_FRAME 12 // Standard Device Request - SYNCH FRAME
+
+#define USB_FEATURE_ENDPOINT_HALT 0 // CLEAR/SET FEATURE - Endpoint Halt
+#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // CLEAR/SET FEATURE - Device remote wake-up
+#define USB_FEATURE_TEST_MODE 2 // CLEAR/SET FEATURE - Test mode
+
+// Section: Setup Data Constants
+
+#define USB_SETUP_HOST_TO_DEVICE 0x00 // Device Request bmRequestType transfer direction - host to device transfer
+#define USB_SETUP_DEVICE_TO_HOST 0x80 // Device Request bmRequestType transfer direction - device to host transfer
+#define USB_SETUP_TYPE_STANDARD 0x00 // Device Request bmRequestType type - standard
+#define USB_SETUP_TYPE_CLASS 0x20 // Device Request bmRequestType type - class
+#define USB_SETUP_TYPE_VENDOR 0x40 // Device Request bmRequestType type - vendor
+#define USB_SETUP_RECIPIENT_DEVICE 0x00 // Device Request bmRequestType recipient - device
+#define USB_SETUP_RECIPIENT_INTERFACE 0x01 // Device Request bmRequestType recipient - interface
+#define USB_SETUP_RECIPIENT_ENDPOINT 0x02 // Device Request bmRequestType recipient - endpoint
+#define USB_SETUP_RECIPIENT_OTHER 0x03 // Device Request bmRequestType recipient - other
+
+#define USB_SETUP_HOST_TO_DEVICE_BITFIELD (USB_SETUP_HOST_TO_DEVICE>>7) // Device Request bmRequestType transfer direction - host to device transfer - bit definition
+#define USB_SETUP_DEVICE_TO_HOST_BITFIELD (USB_SETUP_DEVICE_TO_HOST>>7) // Device Request bmRequestType transfer direction - device to host transfer - bit definition
+#define USB_SETUP_TYPE_STANDARD_BITFIELD (USB_SETUP_TYPE_STANDARD>>5) // Device Request bmRequestType type - standard
+#define USB_SETUP_TYPE_CLASS_BITFIELD (USB_SETUP_TYPE_CLASS>>5) // Device Request bmRequestType type - class
+#define USB_SETUP_TYPE_VENDOR_BITFIELD (USB_SETUP_TYPE_VENDOR>>5) // Device Request bmRequestType type - vendor
+#define USB_SETUP_RECIPIENT_DEVICE_BITFIELD (USB_SETUP_RECIPIENT_DEVICE) // Device Request bmRequestType recipient - device
+#define USB_SETUP_RECIPIENT_INTERFACE_BITFIELD (USB_SETUP_RECIPIENT_INTERFACE) // Device Request bmRequestType recipient - interface
+#define USB_SETUP_RECIPIENT_ENDPOINT_BITFIELD (USB_SETUP_RECIPIENT_ENDPOINT) // Device Request bmRequestType recipient - endpoint
+#define USB_SETUP_RECIPIENT_OTHER_BITFIELD (USB_SETUP_RECIPIENT_OTHER) // Device Request bmRequestType recipient - other
+
+// Section: OTG SET FEATURE Constants
+
+#define OTG_FEATURE_B_HNP_ENABLE 3 // SET FEATURE OTG - Enable B device to perform HNP
+#define OTG_FEATURE_A_HNP_SUPPORT 4 // SET FEATURE OTG - A device supports HNP
+#define OTG_FEATURE_A_ALT_HNP_SUPPORT 5 // SET FEATURE OTG - Another port on the A device supports HNP
+
+// Section: USB Endpoint Transfer Types
+
+#define USB_TRANSFER_TYPE_CONTROL 0x00 // Endpoint is a control endpoint.
+#define USB_TRANSFER_TYPE_ISOCHRONOUS 0x01 // Endpoint is an isochronous endpoint.
+#define USB_TRANSFER_TYPE_BULK 0x02 // Endpoint is a bulk endpoint.
+#define USB_TRANSFER_TYPE_INTERRUPT 0x03 // Endpoint is an interrupt endpoint.
+
+// Section: Standard Feature Selectors for CLEAR_FEATURE Requests
+#define USB_FEATURE_ENDPOINT_STALL 0 // Endpoint recipient
+#define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1 // Device recipient
+#define USB_FEATURE_TEST_MODE 2 // Device recipient
+
+
+// Section: USB Class Code Definitions
+#define USB_HUB_CLASSCODE 0x09 // Class code for a hub.
+
+/********************************************************************
+USB Endpoint Definitions
+USB Standard EP Address Format: DIR:X:X:X:EP3:EP2:EP1:EP0
+This is used in the descriptors.
+********************************************************************/
+#define _EP_IN 0x80
+#define _EP_OUT 0x00
+#define _EP01_OUT 0x01
+#define _EP01_IN 0x81
+#define _EP02_OUT 0x02
+#define _EP02_IN 0x82
+#define _EP03_OUT 0x03
+#define _EP03_IN 0x83
+#define _EP04_OUT 0x04
+#define _EP04_IN 0x84
+#define _EP05_OUT 0x05
+#define _EP05_IN 0x85
+#define _EP06_OUT 0x06
+#define _EP06_IN 0x86
+#define _EP07_OUT 0x07
+#define _EP07_IN 0x87
+#define _EP08_OUT 0x08
+#define _EP08_IN 0x88
+#define _EP09_OUT 0x09
+#define _EP09_IN 0x89
+#define _EP10_OUT 0x0A
+#define _EP10_IN 0x8A
+#define _EP11_OUT 0x0B
+#define _EP11_IN 0x8B
+#define _EP12_OUT 0x0C
+#define _EP12_IN 0x8C
+#define _EP13_OUT 0x0D
+#define _EP13_IN 0x8D
+#define _EP14_OUT 0x0E
+#define _EP14_IN 0x8E
+#define _EP15_OUT 0x0F
+#define _EP15_IN 0x8F
+
+/* Configuration Attributes */
+#define _DEFAULT (0x01<<7) //Default Value (Bit 7 is set)
+#define _SELF (0x01<<6) //Self-powered (Supports if set)
+#define _RWU (0x01<<5) //Remote Wakeup (Supports if set)
+#define _HNP (0x01 << 1) //HNP (Supports if set)
+#define _SRP (0x01) //SRP (Supports if set)
+
+/* Endpoint Transfer Type */
+#define _CTRL 0x00 //Control Transfer
+#define _ISO 0x01 //Isochronous Transfer
+#define _BULK 0x02 //Bulk Transfer
+
+#define _INTERRUPT 0x03 //Interrupt Transfer
+#if defined(__18CXX) || defined(__C30__) || defined __XC16__
+ #define _INT 0x03 //Interrupt Transfer
+#endif
+
+/* Isochronous Endpoint Synchronization Type */
+#define _NS (0x00<<2) //No Synchronization
+#define _AS (0x01<<2) //Asynchronous
+#define _AD (0x02<<2) //Adaptive
+#define _SY (0x03<<2) //Synchronous
+
+/* Isochronous Endpoint Usage Type */
+#define _DE (0x00<<4) //Data endpoint
+#define _FE (0x01<<4) //Feedback endpoint
+#define _IE (0x02<<4) //Implicit feedback Data endpoint
+
+//These are the directional indicators used for the USBTransferOnePacket()
+// function.
+#define OUT_FROM_HOST 0
+#define IN_TO_HOST 1
+
+#endif // _USB_CH9_H_
+/*************************************************************************
+ * EOF
+ */
+
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb_common.h b/Source/USB/USB2.9i_cdc/include/USB/usb_common.h
new file mode 100644
index 0000000..106e8f7
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb_common.h
@@ -0,0 +1,601 @@
+/******************************************************************************
+
+ Common USB Library Definitions (Header File)
+
+Summary:
+ This file defines data types, constants, and macros that are common to
+ multiple layers of the Microchip USB Firmware Stack.
+
+Description:
+ This file defines data types, constants, and macros that are common to
+ multiple layers of the Microchip USB Firmware Stack.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+ ..\\..\\MicrochipInclude
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+*******************************************************************************/
+//DOM-IGNORE-BEGIN
+/*******************************************************************************
+
+ FileName: usb_common.h
+ Dependencies: See included files, below.
+ Processor: PIC18/PIC24/PIC32MX microcontrollers with USB module
+ Compiler: C18 v3.13+/C30 v2.01+/C32 v0.00.18+
+ Company: Microchip Technology, Inc.
+
+Software License Agreement
+
+The software supplied herewith by Microchip Technology Incorporated
+(the “Company”) for its PICmicro® Microcontroller is intended and
+supplied to you, the Company’s customer, for use solely and
+exclusively on Microchip PICmicro Microcontroller products. The
+software is owned by the Company and/or its supplier, and is
+protected under applicable copyright laws. All rights are reserved.
+Any use in violation of the foregoing restrictions may subject the
+user to criminal sanctions under applicable laws, as well as to
+civil liability for the breach of the terms and conditions of this
+license.
+
+THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+*******************************************************************************/
+//DOM-IGNORE-END
+
+//DOM-IGNORE-BEGIN
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.6 Moved many of the USB events
+ 2.6a Changed the limit of USB_EVENT from UINT_MAX to INT_MAX
+ 2.7 No change
+********************************************************************/
+//DOM-IGNORE-END
+
+
+//DOM-IGNORE-BEGIN
+#ifndef _USB_COMMON_H_
+#define _USB_COMMON_H_
+//DOM-IGNORE-END
+
+#include
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: USB Constants
+// *****************************************************************************
+// *****************************************************************************
+
+// Section: Error Code Values
+
+#define USB_SUCCESS 0x00 // USB operation successful.
+#define USB_INVALID_STATE 0x01 // Operation cannot be performed in current state.
+#define USB_BUSY 0x02 // A transaction is already in progress.
+#define USB_ILLEGAL_REQUEST 0x03 // Cannot perform requested operation.
+#define USB_INVALID_CONFIGURATION 0x04 // Configuration descriptor not found.
+#define USB_MEMORY_ALLOCATION_ERROR 0x05 // Out of dynamic memory.
+#define USB_UNKNOWN_DEVICE 0x06 // Device with specified address is not attached.
+#define USB_CANNOT_ENUMERATE 0x07 // Cannot enumerate the attached device.
+#define USB_EVENT_QUEUE_FULL 0x08 // Event queue was full when an event occured.
+#define USB_ENDPOINT_BUSY 0x10 // Endpoint is currently processing a transaction.
+#define USB_ENDPOINT_STALLED 0x11 // Endpoint is currently stalled. User must clear the condition.
+#define USB_ENDPOINT_ERROR 0x12 // Will need more than this eventually
+#define USB_ENDPOINT_ERROR_ILLEGAL_PID 0x13 // Illegal PID received.
+#define USB_ENDPOINT_NOT_FOUND 0x14 // Requested endpoint does not exist on device.
+#define USB_ENDPOINT_ILLEGAL_DIRECTION 0x15 // Reads must be performe on IN endpoints, writes on OUT endpoints.
+//#define USB_ENDPOINT_TRANSACTION_IN_PROGRESS 0x16
+#define USB_ENDPOINT_NAK_TIMEOUT 0x17 // Too many NAK's occurred while waiting for the current transaction.
+#define USB_ENDPOINT_ILLEGAL_TYPE 0x18 // Transfer type must match endpoint description.
+#define USB_ENDPOINT_UNRESOLVED_STATE 0x19 // Endpoint is in an unknown state after completing a transaction.
+#define USB_ENDPOINT_ERROR_BIT_STUFF 0x20 // USB Module - Bit stuff error.
+#define USB_ENDPOINT_ERROR_DMA 0x21 // USB Module - DMA error.
+#define USB_ENDPOINT_ERROR_TIMEOUT 0x22 // USB Module - Bus timeout.
+#define USB_ENDPOINT_ERROR_DATA_FIELD 0x23 // USB Module - Data field size error.
+#define USB_ENDPOINT_ERROR_CRC16 0x24 // USB Module - CRC16 failure.
+#define USB_ENDPOINT_ERROR_END_OF_FRAME 0x25 // USB Module - End of Frame error.
+#define USB_ENDPOINT_ERROR_PID_CHECK 0x26 // USB Module - Illegal PID received.
+#define USB_ENDPOINT_ERROR_BMX 0x27 // USB Module - Bus Matrix error.
+#define USB_ERROR_INSUFFICIENT_POWER 0x28 // Too much power was requested
+
+// Section: Return values for USBHostDeviceStatus()
+
+#define USB_DEVICE_STATUS 0x30 // Offset for USBHostDeviceStatus() return codes
+#define USB_DEVICE_ATTACHED (USB_DEVICE_STATUS | 0x30) // Device is attached and running
+#define USB_DEVICE_DETACHED (USB_DEVICE_STATUS | 0x01) // No device is attached
+#define USB_DEVICE_ENUMERATING (USB_DEVICE_STATUS | 0x02) // Device is enumerating
+#define USB_HOLDING_OUT_OF_MEMORY (USB_DEVICE_STATUS | 0x03) // Not enough heap space available
+#define USB_HOLDING_UNSUPPORTED_DEVICE (USB_DEVICE_STATUS | 0x04) // Invalid configuration or unsupported class
+#define USB_HOLDING_UNSUPPORTED_HUB (USB_DEVICE_STATUS | 0x05) // Hubs are not supported
+#define USB_HOLDING_INVALID_CONFIGURATION (USB_DEVICE_STATUS | 0x06) // Invalid configuration requested
+#define USB_HOLDING_PROCESSING_CAPACITY (USB_DEVICE_STATUS | 0x07) // Processing requirement excessive
+#define USB_HOLDING_POWER_REQUIREMENT (USB_DEVICE_STATUS | 0x08) // Power requirement excessive
+#define USB_HOLDING_CLIENT_INIT_ERROR (USB_DEVICE_STATUS | 0x09) // Client driver failed to initialize
+#define USB_DEVICE_SUSPENDED (USB_DEVICE_STATUS | 0x0A) // Device is suspended
+
+#define USB_ERROR_CLASS_DEFINED 0x50 // Offset for application defined errors
+
+#define USB_SINGLE_DEVICE_ADDRESS 0x01 // Default USB device address (single device support)
+
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: USB Data Types
+// *****************************************************************************
+// *****************************************************************************
+
+// *****************************************************************************
+/* Data Transfer Flags
+
+The following flags are used in the flags parameter of the "USBDEVTransferData"
+and "USBHALTransferData" routines. They can be accessed by the bitfield
+definitions or the macros can be OR'd together to identify the endpoint number
+and properties of the data transfer.
+
+
+ 7 6 5 4 3 2 1 0 - Field name
+ | | | | \_____/
+ | | | | +----- ep_num - Endpoint number
+ | | | +---------- zero_pkt - End transfer with short or zero-sized packet
+ | | +------------ dts - 0=DATA0 packet, 1=DATA1 packet
+ | +-------------- force_dts - Force data toggle sync to match dts field
+ +---------------- direction - Transfer direction: 0=Receive, 1=Transmit
+
+*/
+
+typedef union
+{
+ BYTE bitmap;
+ struct
+ {
+ BYTE ep_num: 4;
+ BYTE zero_pkt: 1;
+ BYTE dts: 1;
+ BYTE force_dts: 1;
+ BYTE direction: 1;
+ }field;
+
+} TRANSFER_FLAGS;
+
+// *****************************************************************************
+/* Data Transfer Flags, Endpoint Number Constants
+
+These macros can be used as values for the "ep_num" field of the TRANSFER_FLAGS
+data type.
+*/
+#define USB_EP0 0 //
+#define USB_EP1 1 //
+#define USB_EP2 2 //
+#define USB_EP3 3 //
+#define USB_EP4 4 //
+#define USB_EP5 5 //
+#define USB_EP6 6 //
+#define USB_EP7 7 //
+#define USB_EP8 8 //
+#define USB_EP9 9 //
+#define USB_EP10 10 //
+#define USB_EP11 11 //
+#define USB_EP12 12 //
+#define USB_EP13 13 //
+#define USB_EP14 14 //
+#define USB_EP15 15 //
+
+// *****************************************************************************
+/* Data Transfer Flags, Bitmap Constants
+
+These macros can be used as values for the "bitmap" field of the TRANSFER_FLAGS
+data type.
+*/
+#define USB_TRANSMIT 0x80 // Data will be transmitted to the USB
+#define USB_RECEIVE 0x00 // Data will be received from the USB
+#define USB_FORCE_DTS 0x40 // Forces data toggle sync as below:
+#define USB_DTS_MASK 0x20 // Mask for DTS bit (below)
+#define USB_ZERO_PKT 0x10 // End transfer w/a short or zero-length packet
+#define USB_DATA0 0x00|USB_FORCE_DTS // Force DATA0
+#define USB_DATA1 0x20|USB_FORCE_DTS // Force DATA1
+#define USB_SETUP_PKT USB_RECEIVE|USB_DATA0|USB_EP0 // Setup Packet
+#define USB_SETUP_DATA USB_DATA1|USB_ZERO_PKT|USB_EP0 // Setup-transfer Data Packet
+#define USB_SETUP_STATUS USB_DATA1|USB_EP0 // Setup-transfer Status Packet
+#define USB_EP_NUM_MASK 0x0F // Endpoint number (ep_num) mask
+
+// *****************************************************************************
+/* Data Transfer Flags, Initialization Macro
+
+This macro can be used with the above bitmap constants to initialize a
+TRANSFER_FLAGS value. It provides the correct data type to avoid compiler
+warnings.
+*/
+#define XFLAGS(f) ((TRANSFER_FLAGS)((BYTE)(f))) // Initialization Macro
+
+
+// *****************************************************************************
+/* USB Events
+
+This enumeration identifies USB events that occur. It is used to
+inform USB drivers and applications of events on the bus. It is passed
+as a parameter to the event-handling routine, which must match the
+prototype of the USB_CLIENT_EVENT_HANDLER data type, when an event occurs.
+*/
+
+typedef enum
+{
+ // No event occured (NULL event)
+ EVENT_NONE = 0,
+
+ EVENT_DEVICE_STACK_BASE = 1,
+
+ EVENT_HOST_STACK_BASE = 100,
+
+ // A USB hub has been attached. Hub support is not currently available.
+ EVENT_HUB_ATTACH,
+
+ // A stall has occured. This event is not used by the Host stack.
+ EVENT_STALL,
+
+ // VBus SRP Pulse, (VBus > 2.0v), Data: BYTE Port Number (For future support)
+ EVENT_VBUS_SES_REQUEST,
+
+ // The voltage on Vbus has dropped below 4.4V/4.7V. The application is
+ // responsible for monitoring Vbus and calling USBHostVbusEvent() with this
+ // event. This event is not generated by the stack.
+ EVENT_VBUS_OVERCURRENT,
+
+ // An enumerating device is requesting power. The data associated with this
+ // event is of the data type USB_VBUS_POWER_EVENT_DATA. Note that
+ // the requested current is specified in 2mA units, identical to the power
+ // specification in a device's Configuration Descriptor.
+ EVENT_VBUS_REQUEST_POWER,
+
+ // Release power from a detaching device. The data associated with this
+ // event is of the data type USB_VBUS_POWER_EVENT_DATA. The current value
+ // specified in the data can be ignored.
+ EVENT_VBUS_RELEASE_POWER,
+
+ // The voltage on Vbus is good, and the USB OTG module can be powered on.
+ // The application is responsible for monitoring Vbus and calling
+ // USBHostVbusEvent() with this event. This event is not generated by the
+ // stack. If the application issues an EVENT_VBUS_OVERCURRENT, then no
+ // power will be applied to that port, and no device can attach to that
+ // port, until the application issues the EVENT_VBUS_POWER_AVAILABLE for
+ // the port.
+ EVENT_VBUS_POWER_AVAILABLE,
+
+ // The attached device is not supported by the application. The attached
+ // device is not allowed to enumerate.
+ EVENT_UNSUPPORTED_DEVICE,
+
+ // Cannot enumerate the attached device. This is generated if communication
+ // errors prevent the device from enumerating.
+ EVENT_CANNOT_ENUMERATE,
+
+ // The client driver cannot initialize the the attached device. The
+ // attached is not allowed to enumerate.
+ EVENT_CLIENT_INIT_ERROR,
+
+ // The Host stack does not have enough heap space to enumerate the device.
+ // Check the amount of heap space allocated to the application. In MPLAB,
+ // select Project> Build Options...> Project. Select the appropriate
+ // linker tab, and inspect the "Heap size" entry.
+ EVENT_OUT_OF_MEMORY,
+
+ // Unspecified host error. (This error should not occur).
+ EVENT_UNSPECIFIED_ERROR,
+
+ // USB cable has been detached. The data associated with this event is the
+ // address of detached device, a single BYTE.
+ EVENT_DETACH,
+
+ // A USB transfer has completed. The data associated with this event is of
+ // the data type HOST_TRANSFER_DATA if the event is generated from the host
+ // stack.
+ EVENT_TRANSFER,
+
+ // A USB Start of Frame token has been received. This event is not
+ // used by the Host stack.
+ EVENT_SOF,
+
+ // Device-mode resume received. This event is not used by the Host stack.
+ EVENT_RESUME,
+
+ // Device-mode suspend/idle event received. This event is not used by the
+ // Host stack.
+ EVENT_SUSPEND,
+
+ // Device-mode bus reset received. This event is not used by the Host
+ // stack.
+ EVENT_RESET,
+
+ // In Host mode, an isochronous data read has completed. This event will only
+ // be passed to the DataEventHandler, which is only utilized if it is defined.
+ // Note that the DataEventHandler is called from within the USB interrupt, so
+ // it is critical that it return in time for the next isochronous data packet.
+ EVENT_DATA_ISOC_READ,
+
+ // In Host mode, an isochronous data write has completed. This event will only
+ // be passed to the DataEventHandler, which is only utilized if it is defined.
+ // Note that the DataEventHandler is called from within the USB interrupt, so
+ // it is critical that it return in time for the next isochronous data packet.
+ EVENT_DATA_ISOC_WRITE,
+
+ // In Host mode, this event gives the application layer the option to reject
+ // a client driver that was selected by the stack. This is needed when multiple
+ // devices are supported by class level support, but one configuration and client
+ // driver is preferred over another. Since configuration number is not guaranteed,
+ // the stack cannot do this automatically. This event is issued only when
+ // looking through configuration descriptors; the driver selected at the device
+ // level cannot be overridden, since there shouldn't be any other options to
+ // choose from.
+ EVENT_OVERRIDE_CLIENT_DRIVER_SELECTION,
+
+ // In host mode, this event is thrown for every millisecond that passes. Like all
+ // events, this is thrown from the USBHostTasks() or USBTasks() routine so its
+ // timeliness will be determined by the rate that these functions are called. If
+ // they are not called very often, then the 1ms events will build up and be
+ // dispatched as the USBTasks() or USBHostTasks() functions are called (one event
+ // per call to these functions.
+ EVENT_1MS,
+
+ // Class-defined event offsets start here:
+ EVENT_GENERIC_BASE = 400, // Offset for Generic class events
+
+ EVENT_MSD_BASE = 500, // Offset for Mass Storage Device class events
+
+ EVENT_HID_BASE = 600, // Offset for Human Interface Device class events
+
+ EVENT_PRINTER_BASE = 700, // Offset for Printer class events
+
+ EVENT_CDC_BASE = 800, // Offset for CDC class events
+
+ EVENT_CHARGER_BASE = 900, // Offset for Charger client driver events.
+
+ EVENT_AUDIO_BASE = 1000, // Offset for Audio client driver events.
+
+ EVENT_USER_BASE = 10000, // Add integral values to this event number
+ // to create user-defined events.
+
+ // There was a transfer error on the USB. The data associated with this
+ // event is of data type HOST_TRANSFER_DATA.
+ EVENT_BUS_ERROR = INT_MAX
+
+} USB_EVENT;
+
+
+// *****************************************************************************
+/* EVENT_TRANSFER Data
+
+This data structure is passed to the appropriate layer's
+USB_EVENT_HANDLER when an EVT_XFER event has occured, indicating
+that a transfer has completed on the USB. It provides the endpoint,
+direction, and actual size of the transfer.
+ */
+
+typedef struct _transfer_event_data
+{
+ TRANSFER_FLAGS flags; // Transfer flags (see above)
+ UINT32 size; // Actual number of bytes transferred
+ BYTE pid; // Packet ID
+
+} USB_TRANSFER_EVENT_DATA;
+
+
+// *****************************************************************************
+/* EVENT_VBUS_REQUEST_POWER and EVENT_VBUS_RELEASE_POWER Data
+
+This data structure is passed to the appropriate layer's
+USB_EVENT_HANDLER when an EVENT_VBUS_REQUEST_POWER or EVENT_VBUS_RELEASE_POWER
+event has occured, indicating that a change in Vbus power is being requested.
+*/
+
+typedef struct _vbus_power_data
+{
+ BYTE port; // Physical port number
+ BYTE current; // Current in 2mA units
+} USB_VBUS_POWER_EVENT_DATA;
+
+
+// *****************************************************************************
+/* USB_OVERRIDE_CLIENT_DRIVER_EVENT_DATA Data
+
+This data structure is passed to the application layer when a client driver is
+select, in case multiple client drivers can support a particular device.
+*/
+typedef struct _override_client_driver_data
+{
+ WORD idVendor;
+ WORD idProduct;
+ BYTE bDeviceClass;
+ BYTE bDeviceSubClass;
+ BYTE bDeviceProtocol;
+} USB_OVERRIDE_CLIENT_DRIVER_EVENT_DATA;
+
+
+// *****************************************************************************
+/* EVT_STALL Data
+
+The EVT_STALL event has a 16-bit data value associated with it where
+a bit is set in the position for each endpoint that is currently
+stalled (ie. bit 0 = EP0, bit 1 = EP1, etc.)
+*/
+
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: Event Handling Routines
+// *****************************************************************************
+// *****************************************************************************
+
+/*******************************************************************************
+ Function:
+ BOOL ( USB_EVENT event,
+ void *data, unsigned int size )
+
+ Description:
+ This routine is a "call out" routine that must be implemented by
+ any layer of the USB SW Stack (except the HAL which is at the
+ root of the event-call tree that needs to receive events. When
+ an event occurs, the HAL calls the next higher layer in the
+ stack to handle the event. Each layer either handles the event
+ or calls the layer above it to handle the event. Events are
+ identified by the "event" parameter and may have associated
+ data. If the higher layer was able to handle the event, it
+ should return TRUE. If not, it should return FALSE.
+
+ Preconditions:
+ USBInitialize must have been called to initialize the USB SW
+ Stack.
+
+ Paramters:
+ USB_EVENT event - Identifies the bus event that occured
+ void *data - Pointer to event-specific data
+ unsigned int size - Size of the event-specific data
+
+ Return Values:
+ None
+
+ Remarks:
+ The function is name is defined by the layer that implements
+ it. A pointer to the function will be placed by into a table
+ that the lower-layer will use to call it. This requires the
+ function to use a specific call "signature" (return data type
+ and values and data parameter types and values).
+
+*******************************************************************************/
+
+typedef BOOL (*USB_EVENT_HANDLER) ( USB_EVENT event, void *data, unsigned int size );
+
+
+// *****************************************************************************
+// *****************************************************************************
+// Section: USB Application Program Interface (API) Routines
+// *****************************************************************************
+// *****************************************************************************
+
+/****************************************************************************
+ Function:
+ BOOL USBInitialize ( unsigned long flags )
+
+ Summary:
+ This interface initializes the variables of the USB host stack.
+
+ Description:
+ This interface initializes the USB stack.
+
+ Precondition:
+ None
+
+ Parameters:
+ flags - reserved
+
+ Return Values:
+ TRUE - Initialization successful
+ FALSE - Initialization failure
+
+ Remarks:
+ This interface is implemented as a macro that can be defined by the
+ application or by default is defined correctly for the stack mode.
+
+ ***************************************************************************/
+
+#ifndef USBInitialize
+ #if defined( USB_SUPPORT_DEVICE )
+ #if defined( USB_SUPPORT_HOST )
+ #if defined( USB_SUPPORT_OTG )
+ #error "USB OTG is not yet supported."
+ #else
+ #define USBInitialize(f) \
+ (USBDEVInitialize(f) && USBHostInit(f)) ? \
+ TRUE : FALSE
+ #endif
+ #else
+ #define USBInitialize(f) USBDeviceInit()
+ #endif
+ #else
+ #if defined( USB_SUPPORT_HOST )
+ #define USBInitialize(f) USBHostInit(f)
+ #else
+ #error "Application must define support mode in usb_config.h"
+ #endif
+ #endif
+#endif
+
+
+/****************************************************************************
+ Function:
+ void USBTasks( void )
+
+ Summary:
+ This function executes the tasks for USB operation.
+
+ Description:
+ This function executes the tasks for USB host operation. It must be
+ executed on a regular basis to keep everything functioning.
+
+ Precondition:
+ USBInitialize() has been called.
+
+ Parameters:
+ None
+
+ Returns:
+ None
+
+ Remarks:
+ This interface is implemented as a macro that can be defined by the
+ application or by default is defined correctly for the stack mode.
+
+ ***************************************************************************/
+
+#ifndef USBTasks // Implemented as a macro that can be overridden.
+ #if defined( USB_SUPPORT_DEVICE )
+ #if defined( USB_SUPPORT_HOST )
+ #if defined( USB_SUPPORT_OTG )
+ #error "USB OTG is not yet supported."
+ #else
+ #define USBTasks() {USBHostTasks(); USBHALHandleBusEvent();}
+ #endif
+ #else
+ #define USBTasks() USBDeviceTasks()
+ #endif
+ #else
+ #if defined( USB_SUPPORT_HOST )
+ #define USBTasks() USBHostTasks()
+ #else
+ #error "Application must define support mode in usb_config.h"
+ #endif
+ #endif
+#endif
+
+#define USB_PING_PONG__NO_PING_PONG 0x00 //0b00
+#define USB_PING_PONG__EP0_OUT_ONLY 0x01 //0b01
+#define USB_PING_PONG__FULL_PING_PONG 0x02 //0b10
+#define USB_PING_PONG__ALL_BUT_EP0 0x03 //0b11
+
+#endif // _USB_COMMON_H_
+/*************************************************************************
+ * EOF
+ */
+
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb_device.h b/Source/USB/USB2.9i_cdc/include/USB/usb_device.h
new file mode 100644
index 0000000..547339f
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb_device.h
@@ -0,0 +1,1988 @@
+/*******************************************************************************
+
+ USB Device header file
+
+Summary:
+ This file, with its associated C source file, provides the main substance of
+ the USB device side stack. These files will receive, transmit, and process
+ various USB commands as well as take action when required for various events
+ that occur on the bus.
+
+Description:
+ This file, with its associated C source file, provides the main substance of
+ the USB device side stack. These files will receive, transmit, and process
+ various USB commands as well as take action when required for various events
+ that occur on the bus.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ ..\\..\\Microchip\\Include
+
+ .
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+
+******************************************************************************/
+//DOM-IGNORE-BEGIN
+/******************************************************************************
+ FileName: usb_device.h
+ Dependencies: See INCLUDES section
+ Processor: All Microchip parts with a USB module
+ Hardware: Please see documentation in "/Microchip/Help"
+ folder for details.
+ Complier: Microchip C18
+ XC16
+ XC32
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the "Company") for its PIC(R) Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+*******************************************************************/
+
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.1 Added "(" & ")" to EP definitions
+ updated for simplicity and to use common
+ coding style
+
+ 2.6 Removed many of the device specific information to the
+ HAL layer files. Moved many of the CH9 defintions to the
+ CH9 file.
+
+ 2.6a No Change
+
+ 2.7 Fixed error where USBHandleGetAddr() didn't convert the
+ return address from a physical address to a virtual address
+ for PIC32.
+
+ Added macro versions of USBDeviceAttach() and USBDeviceDetach()
+ so they will compile without error when using polling mode.
+
+ 2.7a No Change
+
+ 2.8 Added EVENT_TRANSFER_TERMINATED event enum item.
+
+********************************************************************/
+
+#ifndef USBDEVICE_H
+#define USBDEVICE_H
+//DOM-IGNORE-END
+
+/** DEFINITIONS ****************************************************/
+
+//USB_HANDLE is a pointer to an entry in the BDT. This pointer can be used
+// to read the length of the last transfer, the status of the last transfer,
+// and various other information. Insure to initialize USB_HANDLE objects
+// to NULL so that they are in a known state during their first usage.
+#define USB_HANDLE void*
+
+#define USB_EP0_ROM 0x00 //Data comes from RAM
+#define USB_EP0_RAM 0x01 //Data comes from ROM
+#define USB_EP0_BUSY 0x80 //The PIPE is busy
+#define USB_EP0_INCLUDE_ZERO 0x40 //include a trailing zero packet
+#define USB_EP0_NO_DATA 0x00 //no data to send
+#define USB_EP0_NO_OPTIONS 0x00 //no options set
+
+/********************************************************************
+ * Standard Request Codes
+ * USB 2.0 Spec Ref Table 9-4
+ *******************************************************************/
+
+/* USB Device States as returned by USBGetDeviceState(). Only the defintions
+ for these states should be used. The actual value for each state should
+ not be relied upon as constant and may change based on the implementation. */
+typedef enum
+{
+ /* Detached is the state in which the device is not attached to the bus. When
+ in the detached state a device should not have any pull-ups attached to either
+ the D+ or D- line. */
+ DETACHED_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x00 /*DOM-IGNORE-END*/,
+ /* Attached is the state in which the device is attached ot the bus but the
+ hub/port that it is attached to is not yet configured. */
+ ATTACHED_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x01 /*DOM-IGNORE-END*/,
+ /* Powered is the state in which the device is attached to the bus and the
+ hub/port that it is attached to is configured. */
+ POWERED_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x02 /*DOM-IGNORE-END*/,
+ /* Default state is the state after the device receives a RESET command from
+ the host. */
+ DEFAULT_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x04 /*DOM-IGNORE-END*/,
+ /* Address pending state is not an official state of the USB defined states.
+ This state is internally used to indicate that the device has received a
+ SET_ADDRESS command but has not received the STATUS stage of the transfer yet.
+ The device is should not switch addresses until after the STATUS stage is
+ complete. */
+ ADR_PENDING_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x08 /*DOM-IGNORE-END*/,
+ /* Address is the state in which the device has its own specific address on the
+ bus. */
+ ADDRESS_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x10 /*DOM-IGNORE-END*/,
+ /* Configured is the state where the device has been fully enumerated and is
+ operating on the bus. The device is now allowed to excute its application
+ specific tasks. It is also allowed to increase its current consumption to the
+ value specified in the configuration descriptor of the current configuration.
+ */
+ CONFIGURED_STATE
+ /*DOM-IGNORE-BEGIN*/ = 0x20 /*DOM-IGNORE-END*/
+} USB_DEVICE_STATE;
+
+
+/* USB device stack events description here - DWF */
+typedef enum
+{
+ // Notification that a SET_CONFIGURATION() command was received (device)
+ EVENT_CONFIGURED
+ /*DOM-IGNORE-BEGIN*/ = EVENT_DEVICE_STACK_BASE /*DOM-IGNORE-END*/,
+
+ // A SET_DESCRIPTOR request was received (device)
+ EVENT_SET_DESCRIPTOR,
+
+ // An endpoint 0 request was received that the stack did not know how to
+ // handle. This is most often a request for one of the class drivers.
+ // Please refer to the class driver documenation for information related
+ // to what to do if this request is received. (device)
+ EVENT_EP0_REQUEST,
+
+// // A USB transfer has completed. The data associated with this event is of
+// // the data type HOST_TRANSFER_DATA if the event is generated from the host
+// // stack.
+// EVENT_TRANSFER,
+//
+// // A USB Start of Frame token has been received. This event is not
+// // used by the Host stack.
+// EVENT_SOF,
+//
+// // Device-mode resume received. This event is not used by the Host stack.
+// EVENT_RESUME,
+//
+// // Device-mode suspend/idle event received. This event is not used by the
+// // Host stack.
+// EVENT_SUSPEND,
+//
+// // Device-mode bus reset received. This event is not used by the Host
+// // stack.
+// EVENT_RESET,
+
+// // Device Mode: A setup packet received (data: SETUP_PKT). This event is
+// // not used by the Host stack.
+// EVENT_SETUP,
+
+ // Device-mode USB cable has been attached. This event is not used by the
+ // Host stack. The client driver may provide an application event when a
+ // device attaches.
+ EVENT_ATTACH,
+
+ // A user transfer was terminated by the stack. This event will pass back
+ // the value of the handle that was terminated. Compare this value against
+ // the current valid handles to determine which transfer was terminated.
+ EVENT_TRANSFER_TERMINATED
+
+} USB_DEVICE_STACK_EVENTS;
+
+/** Function Prototypes **********************************************/
+
+
+/******************************************************************************/
+/** External API Functions ****************************************************/
+/******************************************************************************/
+
+/**************************************************************************
+ Function:
+ void USBDeviceInit(void)
+
+ Description:
+ This function initializes the device stack it in the default state. The
+ USB module will be completely reset including all of the internal
+ variables, registers, and interrupt flags.
+
+ Precondition:
+ This function must be called before any of the other USB Device
+ functions can be called, including USBDeviceTasks().
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ **************************************************************************/
+void USBDeviceInit(void);
+
+/**************************************************************************
+ Function:
+ void USBDeviceTasks(void)
+
+ Summary:
+ This function is the main state machine/transaction handler of the USB
+ device side stack. When the USB stack is operated in "USB_POLLING" mode
+ (usb_config.h user option) the USBDeviceTasks() function should be called
+ periodically to receive and transmit packets through the stack. This
+ function also takes care of control transfers associated with the USB
+ enumeration process, and detecting various USB events (such as suspend).
+ This function should be called at least once every 1.8ms during the USB
+ enumeration process. After the enumeration process is complete (which can
+ be determined when USBGetDeviceState() returns CONFIGURED_STATE), the
+ USBDeviceTasks() handler may be called the faster of: either once
+ every 9.8ms, or as often as needed to make sure that the hardware USTAT
+ FIFO never gets full. A good rule of thumb is to call USBDeviceTasks() at
+ a minimum rate of either the frequency that USBTransferOnePacket() gets
+ called, or, once/1.8ms, whichever is faster. See the inline code comments
+ near the top of usb_device.c for more details about minimum timing
+ requirements when calling USBDeviceTasks().
+
+ When the USB stack is operated in "USB_INTERRUPT" mode, it is not necessary
+ to call USBDeviceTasks() from the main loop context. In the USB_INTERRUPT
+ mode, the USBDeviceTasks() handler only needs to execute when a USB
+ interrupt occurs, and therefore only needs to be called from the interrupt
+ context.
+
+ Description:
+ This function is the main state machine/transaction handler of the USB
+ device side stack. When the USB stack is operated in "USB_POLLING" mode
+ (usb_config.h user option) the USBDeviceTasks() function should be called
+ periodically to receive and transmit packets through the stack. This
+ function also takes care of control transfers associated with the USB
+ enumeration process, and detecting various USB events (such as suspend).
+ This function should be called at least once every 1.8ms during the USB
+ enumeration process. After the enumeration process is complete (which can
+ be determined when USBGetDeviceState() returns CONFIGURED_STATE), the
+ USBDeviceTasks() handler may be called the faster of: either once
+ every 9.8ms, or as often as needed to make sure that the hardware USTAT
+ FIFO never gets full. A good rule of thumb is to call USBDeviceTasks() at
+ a minimum rate of either the frequency that USBTransferOnePacket() gets
+ called, or, once/1.8ms, whichever is faster. See the inline code comments
+ near the top of usb_device.c for more details about minimum timing
+ requirements when calling USBDeviceTasks().
+
+ When the USB stack is operated in "USB_INTERRUPT" mode, it is not necessary
+ to call USBDeviceTasks() from the main loop context. In the USB_INTERRUPT
+ mode, the USBDeviceTasks() handler only needs to execute when a USB
+ interrupt occurs, and therefore only needs to be called from the interrupt
+ context.
+
+ Typical usage:
+
+ void main(void)
+ {
+ USBDeviceInit();
+ while(1)
+ {
+ USBDeviceTasks(); //Takes care of enumeration and other USB events
+ if((USBGetDeviceState() \< CONFIGURED_STATE) ||
+ (USBIsDeviceSuspended() == TRUE))
+ {
+ //Either the device is not configured or we are suspended,
+ // so we don't want to execute any USB related application code
+ continue; //go back to the top of the while loop
+ }
+ else
+ {
+ //Otherwise we are free to run USB and non-USB related user
+ //application code.
+ UserApplication();
+ }
+ }
+ }
+
+
+ Precondition:
+ Make sure the USBDeviceInit() function has been called prior to calling
+ USBDeviceTasks() for the first time.
+ Remarks:
+ USBDeviceTasks() does not need to be called while in the USB suspend mode,
+ if the user application firmware in the USBCBSuspend() callback function
+ enables the ACTVIF USB interrupt source and put the microcontroller into
+ sleep mode. If the application firmware decides not to sleep the
+ microcontroller core during USB suspend (ex: continues running at full
+ frequency, or clock switches to a lower frequency), then the USBDeviceTasks()
+ function must still be called periodically, at a rate frequent enough to
+ ensure the 10ms resume recovery interval USB specification is met. Assuming
+ a worst case primary oscillator and PLL start up time of <5ms, then
+ USBDeviceTasks() should be called once every 5ms in this scenario.
+
+ When the USB cable is detached, or the USB host is not actively powering
+ the VBUS line to +5V nominal, the application firmware does not always have
+ to call USBDeviceTasks() frequently, as no USB activity will be taking
+ place. However, if USBDeviceTasks() is not called regularly, some
+ alternative means of promptly detecting when VBUS is powered (indicating
+ host attachment), or not powered (host powered down or USB cable unplugged)
+ is still needed. For self or dual self/bus powered USB applications, see
+ the USBDeviceAttach() and USBDeviceDetach() API documentation for additional
+ considerations.
+
+ **************************************************************************/
+void USBDeviceTasks(void);
+
+
+/*******************************************************************************
+ Function:
+ void USBEnableEndpoint(BYTE ep, BYTE options)
+
+ Summary:
+ This function will enable the specified endpoint with the specified
+ options
+ Description:
+ This function will enable the specified endpoint with the specified
+ options.
+
+ Typical Usage:
+
+ void USBCBInitEP(void)
+ {
+ USBEnableEndpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|USB_DISALLOW_SETUP);
+ USBMSDInit();
+ }
+
+
+ In the above example endpoint number MSD_DATA_IN_EP is being configured
+ for both IN and OUT traffic with handshaking enabled. Also since
+ MSD_DATA_IN_EP is not endpoint 0 (MSD does not allow this), then we can
+ explicitly disable SETUP packets on this endpoint.
+ Conditions:
+ None
+ Input:
+ BYTE ep - the endpoint to be configured
+ BYTE options - optional settings for the endpoint. The options should
+ be ORed together to form a single options string. The
+ available optional settings for the endpoint. The
+ options should be ORed together to form a single options
+ string. The available options are the following\:
+ * USB_HANDSHAKE_ENABLED enables USB handshaking (ACK,
+ NAK)
+ * USB_HANDSHAKE_DISABLED disables USB handshaking (ACK,
+ NAK)
+ * USB_OUT_ENABLED enables the out direction
+ * USB_OUT_DISABLED disables the out direction
+ * USB_IN_ENABLED enables the in direction
+ * USB_IN_DISABLED disables the in direction
+ * USB_ALLOW_SETUP enables control transfers
+ * USB_DISALLOW_SETUP disables control transfers
+ * USB_STALL_ENDPOINT STALLs this endpoint
+ Return:
+ None
+ Remarks:
+ None
+ *****************************************************************************/
+void USBEnableEndpoint(BYTE ep, BYTE options);
+
+
+/*************************************************************************
+ Function:
+ USB_HANDLE USBTransferOnePacket(BYTE ep, BYTE dir, BYTE* data, BYTE len)
+
+ Summary:
+ Transfers a single packet (one transaction) of data on the USB bus.
+
+ Description:
+ The USBTransferOnePacket() function prepares a USB endpoint
+ so that it may send data to the host (an IN transaction), or
+ receive data from the host (an OUT transaction). The
+ USBTransferOnePacket() function can be used both to receive and
+ send data to the host. This function is the primary API function
+ provided by the USB stack firmware for sending or receiving application
+ data over the USB port.
+
+ The USBTransferOnePacket() is intended for use with all application
+ endpoints. It is not used for sending or receiving applicaiton data
+ through endpoint 0 by using control transfers. Separate API
+ functions, such as USBEP0Receive(), USBEP0SendRAMPtr(), and
+ USBEP0SendROMPtr() are provided for this purpose.
+
+ The USBTransferOnePacket() writes to the Buffer Descriptor Table (BDT)
+ entry associated with an endpoint buffer, and sets the UOWN bit, which
+ prepares the USB hardware to allow the transaction to complete. The
+ application firmware can use the USBHandleBusy() macro to check the
+ status of the transaction, to see if the data has been successfully
+ transmitted yet.
+
+
+ Typical Usage
+
+ //make sure that the we are in the configured state
+ if(USBGetDeviceState() == CONFIGURED_STATE)
+ {
+ //make sure that the last transaction isn't busy by checking the handle
+ if(!USBHandleBusy(USBInHandle))
+ {
+ //Write the new data that we wish to send to the host to the INPacket[] array
+ INPacket[0] = USEFUL_APPLICATION_VALUE1;
+ INPacket[1] = USEFUL_APPLICATION_VALUE2;
+ //INPacket[2] = ... (fill in the rest of the packet data)
+
+ //Send the data contained in the INPacket[] array through endpoint "EP_NUM"
+ USBInHandle = USBTransferOnePacket(EP_NUM,IN_TO_HOST,(BYTE*)&INPacket[0],sizeof(INPacket));
+ }
+ }
+
+
+ Conditions:
+ Before calling USBTransferOnePacket(), the following should be true.
+ 1. The USB stack has already been initialized (USBDeviceInit() was called).
+ 2. A transaction is not already pending on the specified endpoint. This
+ is done by checking the previous request using the USBHandleBusy()
+ macro (see the typical usage example).
+ 3. The host has already sent a set configuration request and the
+ enumeration process is complete.
+ This can be checked by verifying that the USBGetDeviceState()
+ macro returns "CONFIGURED_STATE", prior to calling
+ USBTransferOnePacket().
+
+ Input:
+ BYTE ep - The endpoint number that the data will be transmitted or
+ received on
+ BYTE dir - The direction of the transfer
+ This value is either OUT_FROM_HOST or IN_TO_HOST
+ BYTE* data - For IN transactions: pointer to the RAM buffer containing
+ the data to be sent to the host. For OUT transactions: pointer
+ to the RAM buffer that the received data should get written to.
+ BYTE len - Length of the data needing to be sent (for IN transactions).
+ For OUT transactions, the len parameter should normally be set
+ to the endpoint size specified in the endpoint descriptor.
+
+ Return Values:
+ USB_HANDLE - handle to the transfer. The handle is a pointer to
+ the BDT entry associated with this transaction. The
+ status of the transaction (ex: if it is complete or still
+ pending) can be checked using the USBHandleBusy() macro
+ and supplying the USB_HANDLE provided by
+ USBTransferOnePacket().
+
+ Remarks:
+ If calling the USBTransferOnePacket() function from within the USBCBInitEP()
+ callback function, the set configuration is still being processed and the
+ USBDeviceState may not be == CONFIGURED_STATE yet. In this special case,
+ the USBTransferOnePacket() may still be called, but make sure that the
+ endpoint has been enabled and initialized by the USBEnableEndpoint()
+ function first.
+
+ *************************************************************************/
+USB_HANDLE USBTransferOnePacket(BYTE ep,BYTE dir,BYTE* data,BYTE len);
+
+/********************************************************************
+ Function:
+ void USBStallEndpoint(BYTE ep, BYTE dir)
+
+ Summary:
+ Configures the specified endpoint to send STALL to the host, the next
+ time the host tries to access the endpoint.
+
+ PreCondition:
+ None
+
+ Parameters:
+ BYTE ep - The endpoint number that should be configured to send STALL.
+ BYTE dir - The direction of the endpoint to STALL, either
+ IN_TO_HOST or OUT_FROM_HOST.
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *******************************************************************/
+void USBStallEndpoint(BYTE ep, BYTE dir);
+/**************************************************************************
+ Function:
+ void USBCancelIO(BYTE endpoint)
+
+ Description:
+ This function cancels the transfers pending on the specified endpoint.
+ This function can only be used after a SETUP packet is received and
+ before that setup packet is handled. This is the time period in which
+ the EVENT_EP0_REQUEST is thrown, before the event handler function
+ returns to the stack.
+
+ Precondition:
+
+ Parameters:
+ BYTE endpoint - the endpoint number you wish to cancel the transfers for
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ **************************************************************************/
+void USBCancelIO(BYTE endpoint);
+
+/**************************************************************************
+ Function:
+ void USBDeviceDetach(void)
+
+ Summary:
+ This function configures the USB module to "soft detach" itself from
+ the USB host.
+
+ Description:
+ This function configures the USB module to perform a "soft detach"
+ operation, by disabling the D+ (or D-) ~1.5k pull up resistor, which
+ lets the host know the device is present and attached. This will make
+ the host think that the device has been unplugged. This is potentially
+ useful, as it allows the USB device to force the host to re-enumerate
+ the device (on the firmware has re-enabled the USB module/pull up, by
+ calling USBDeviceAttach(), to "soft re-attach" to the host).
+
+ Precondition:
+ Should only be called when USB_INTERRUPT is defined. See remarks
+ section if USB_POLLING mode option is being used (usb_config.h option).
+
+ Additionally, this function should only be called from the main() loop
+ context. Do not call this function from within an interrupt handler, as
+ this function may modify global interrupt enable bits and settings.
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ If the application firmware calls USBDeviceDetach(), it is strongly
+ recommended that the firmware wait at least >= 80ms before calling
+ USBDeviceAttach(). If the firmeware performs a soft detach, and then
+ re-attaches too soon (ex: after a few micro seconds for instance), some
+ hosts may interpret this as an unexpected "glitch" rather than as a
+ physical removal/re-attachment of the USB device. In this case the host
+ may simply ignore the event without re-enumerating the device. To
+ ensure that the host properly detects and processes the device soft
+ detach/re-attach, it is recommended to make sure the device remains
+ detached long enough to mimic a real human controlled USB
+ unplug/re-attach event (ex: after calling USBDeviceDetach(), do not
+ call USBDeviceAttach() for at least 80+ms, preferrably longer.
+
+ Neither the USBDeviceDetach() or USBDeviceAttach() functions are blocking
+ or take long to execute. It is the application firmware's
+ responsibility for adding the 80+ms delay, when using these API
+ functions.
+
+ Note: The Windows plug and play event handler processing is fairly
+ slow, especially in certain versions of Windows, and for certain USB
+ device classes. It has been observed that some device classes need to
+ provide even more USB detach dwell interval (before calling
+ USBDeviceAttach()), in order to work correctly after re-enumeration.
+ If the USB device is a CDC class device, it is recommended to wait
+ at least 1.5 seconds or longer, before soft re-attaching to the host,
+ to provide the plug and play event handler enough time to finish
+ processing the removal event, before the re-attach occurs.
+
+ If the application is using the USB_POLLING mode option, then the
+ USBDeviceDetach() and USBDeviceAttach() functions are not available.
+ In this mode, the USB stack relies on the "#define USE_USB_BUS_SENSE_IO"
+ and "#define USB_BUS_SENSE" options in the
+ HardwareProfile – [platform name].h file.
+
+ When using the USB_POLLING mode option, and the
+ "#define USE_USB_BUS_SENSE_IO" definition has been commented out, then
+ the USB stack assumes that it should always enable the USB module at
+ pretty much all times. Basically, anytime the application firmware
+ calls USBDeviceTasks(), the firmware will automatically enable the USB
+ module. This mode would typically be selected if the application was
+ designed to be a purely bus powered device. In this case, the
+ application is powered from the +5V VBUS supply from the USB port, so
+ it is correct and sensible in this type of application to power up and
+ turn on the USB module, at anytime that the microcontroller is
+ powered (which implies the USB cable is attached and the host is also
+ powered).
+
+ In a self powered application, the USB stack is designed with the
+ intention that the user will enable the "#define USE_USB_BUS_SENSE_IO"
+ option in the HardwareProfile – [platform name].h file. When this
+ option is defined, then the USBDeviceTasks() function will automatically
+ check the I/O pin port value of the designated pin (based on the
+ #define USB_BUS_SENSE option in the HardwareProfile – [platform name].h
+ file), every time the application calls USBDeviceTasks(). If the
+ USBDeviceTasks() function is executed and finds that the pin defined by
+ the #define USB_BUS_SENSE is in a logic low state, then it will
+ automatically disable the USB module and tri-state the D+ and D- pins.
+ If however the USBDeviceTasks() function is executed and finds the pin
+ defined by the #define USB_BUS_SENSE is in a logic high state, then it
+ will automatically enable the USB module, if it has not already been
+ enabled.
+
+ **************************************************************************/
+void USBDeviceDetach(void);
+
+/*DOM-IGNORE-BEGIN*/
+#if !defined(USB_INTERRUPT)
+ #define USBDeviceDetach()
+#endif
+/*DOM-IGNORE-END*/
+
+/**************************************************************************
+ Function:
+ void USBDeviceAttach(void)
+
+ Summary:
+ Checks if VBUS is present, and that the USB module is not already
+ initalized, and if so, enables the USB module so as to signal device
+ attachment to the USB host.
+
+ Description:
+ This function indicates to the USB host that the USB device has been
+ attached to the bus. This function needs to be called in order for the
+ device to start to enumerate on the bus.
+
+ Precondition:
+ Should only be called when USB_INTERRUPT is defined. Also, should only
+ be called from the main() loop context. Do not call USBDeviceAttach()
+ from within an interrupt handler, as the USBDeviceAttach() function
+ may modify global interrupt enable bits and settings.
+
+ For normal USB devices:
+ Make sure that if the module was previously on, that it has been turned off
+ for a long time (ex: 100ms+) before calling this function to re-enable the module.
+ If the device turns off the D+ (for full speed) or D- (for low speed) ~1.5k ohm
+ pull up resistor, and then turns it back on very quickly, common hosts will sometimes
+ reject this event, since no human could ever unplug and reattach a USB device in a
+ microseconds (or nanoseconds) timescale. The host could simply treat this as some kind
+ of glitch and ignore the event altogether.
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ See also the USBDeviceDetach() API function documentation.
+****************************************************************************/
+void USBDeviceAttach(void);
+
+/*DOM-IGNORE-BEGIN*/
+#if !defined(USB_INTERRUPT)
+ #define USBDeviceAttach()
+#endif
+/*DOM-IGNORE-END*/
+
+
+/*******************************************************************************
+ Function: void USBCtrlEPAllowStatusStage(void);
+
+ Summary: This function prepares the proper endpoint 0 IN or endpoint 0 OUT
+ (based on the controlTransferState) to allow the status stage packet
+ of a control transfer to complete. This function gets used
+ internally by the USB stack itself, but it may also be called from
+ the application firmware, IF the application firmware called
+ the USBDeferStatusStage() function during the initial processing
+ of the control transfer request. In this case, the application
+ must call the USBCtrlEPAllowStatusStage() once, after it has fully
+ completed processing and handling the data stage portion of the
+ request.
+
+ If the application firmware has no need for delaying control
+ transfers, and therefore never calls USBDeferStatusStage(), then the
+ application firmware should not call USBCtrlEPAllowStatusStage().
+
+ Description:
+
+ Conditions:
+ None
+
+ Input:
+
+ Return:
+
+ Remarks:
+ None
+ *****************************************************************************/
+void USBCtrlEPAllowStatusStage(void);
+
+
+
+/*******************************************************************************
+ Function: void USBCtrlEPAllowDataStage(void);
+
+ Summary: This function allows the data stage of either a host-to-device or
+ device-to-host control transfer (with data stage) to complete.
+ This function is meant to be used in conjunction with either the
+ USBDeferOUTDataStage() or USBDeferINDataStage(). If the firmware
+ does not call either USBDeferOUTDataStage() or USBDeferINDataStage(),
+ then the firmware does not need to manually call
+ USBCtrlEPAllowDataStage(), as the USB stack will call this function
+ instead.
+
+ Description:
+
+ Conditions: A control transfer (with data stage) should already be pending,
+ if the firmware calls this function. Additionally, the firmware
+ should have called either USBDeferOUTDataStage() or
+ USBDeferINDataStage() at the start of the control transfer, if
+ the firmware will be calling this function manually.
+
+ Input:
+
+ Return:
+
+ Remarks:
+ *****************************************************************************/
+void USBCtrlEPAllowDataStage(void);
+
+
+/*******************************************************************************
+ Function: void USBDeferOUTDataStage(void);
+
+ Summary: This function will cause the USB hardware to continuously NAK the
+ OUT data packets sent from the host, during the data stage of a
+ device to host control transfer. This allows the firmware more time
+ to prepare the RAM buffer that will eventually be used to receive the
+ data from the host. This is also useful, if the firmware wishes to
+ receive the OUT data in a different context than what the
+ USBDeviceTasks() function executes at.
+
+ Calling this function (macro) will assert ownership of the currently
+ pending control transfer. Therefore, the USB stack will not STALL
+ when it reaches the data stage of the control transfer, even if the
+ firmware has not (yet) called the USBEP0Receive() API function.
+ However, the application firware must still (eventually, once it is
+ ready) call one of the aforementioned API function.
+
+ Example Usage:
+
+ 1. Host sends a SETUP packet to the device, requesting a host to
+ device control transfer, with data stage (OUT data packets).
+ 2. USBDeviceTasks() executes, and then calls the USBCBCheckOtherReq()
+ callback event handler. The USBCBCheckOtherReq() calls the
+ application specific/device class specific handler that detects
+ the type of control transfer.
+ 3. If the firmware needs more time before it wishes to receive the
+ first OUT data packet, or, if the firmware wishes to process the
+ command in a different context, then it may call
+ USBDeferOUTDataStage(), in the context of the
+ USBCBCheckOtherReq() handler function.
+ 4. If the firmware called USBDeferOUTDataStage() in step #3 above,
+ then the hardware will NAK the OUT data packets sent by the
+ host, for the OUT data stage.
+ 5. Once the firmware is ready, it should then call USBEP0Receive(),
+ to prepare the USB stack to receive the OUT data from the host,
+ and to write it to the user specified buffer.
+ 6. The firmware should now call USBCtrlEPAllowDataStage(). This
+ will allow the data stage to complete. Once all OUT data has
+ been received, the user callback function (provided by the
+ function pointer provided when calling USBEP0Receive()) will
+ get called.
+ 7. Once all data has been received from the host, the status stage
+ (a 0-byte IN packet) will complete automatically (assuming the
+ firmware did not call USBDeferStatusStage() during step #3).
+
+
+ Description:
+
+ Conditions: Before calling USBDeferOUTDataStage(), the firmware should first
+ verify that the control transfer has a data stage, and that
+ it is of type host-to-device (OUT).
+
+ Input:
+
+ Return:
+
+ Remarks: Section 9.2.6 of the official USB 2.0 specifications indicates that
+ the USB device must be able to receive all bytes and complete the
+ control transfer within a maximum of 5 seconds.
+
+ If the firmware calls USBDeferOUTDataStage(), it must eventually call
+ USBEP0Receive(), and then call USBCtrlEPAllowDataStage(). If it does
+ not do this, the control transfer will never be able to complete.
+ This will break the USB connection, as the host needs to be able to
+ communicate over EP0, in order to perform basic tasks including
+ enumeration.
+
+ The firmware should never call both USBDeferINDataStage() and
+ USBDeferOUTDataStage() during the same control transfer. These
+ functions are mutually exclusive (a control transfer with data stage
+ can never contain both IN and OUT data packets during the data stage).
+ *****************************************************************************/
+void USBDeferOUTDataStage(void);
+extern volatile BOOL USBDeferOUTDataStagePackets;
+/*DOM-IGNORE-BEGIN*/
+#define USBDeferOUTDataStage() {USBDeferOUTDataStagePackets = TRUE; outPipes[0].info.bits.busy = 1;}
+/*DOM-IGNORE-END*/
+
+/*******************************************************************************
+ Function: void USBDeferStatusStage(void);
+
+ Summary: Calling this function will prevent the USB stack from automatically
+ enabling the status stage for the currently pending control transfer
+ from completing immediately after all data bytes have been sent or
+ received. This is useful if a class handler or USB application
+ firmware project uses control transfers for sending/receiving data
+ over EP0, but requires time in order to finish processing and/or to
+ consume the data.
+
+ For example: Consider an application which receives OUT data from the
+ USB host, through EP0 using control transfers. Now assume that this
+ application wishes to do something time consuming with this data (ex:
+ transmit it to and save it to an external EEPROM device, connected
+ via SPI/I2C/etc.). In this case, it would typically be desireable to
+ defer allowing the USB status stage of the control transfer to complete,
+ until after the data has been fully sent to the EEPROM device and saved.
+
+ If the USB class handler firmware that processes the control transfer
+ SETUP packet determines that it will need extra time to complete the
+ control transfer, it may optionally call USBDeferStatusStage(). If it
+ does so, it is then the responsibility of the application firmware to
+ eventually call USBCtrlEPAllowStatusStage(), once the firmware has
+ finished processing the data associated with the control transfer.
+
+ If the firmware call USBDeferStatusStage(), but never calls
+ USBCtrlEPAllowStatusStage(), then one of two possibilities will occur.
+
+ 1. If the "USB_ENABLE_STATUS_STAGE_TIMEOUTS" option is commented in
+ usb_config.h, then the status stage of the control transfer will
+ never be able to complete. This is an error case and should be
+ avoided.
+ 2. If the "USB_ENABLE_STATUS_STAGE_TIMEOUTS" option is enabled in
+ usb_config.h, then the USBDeviceTasks() function will
+ automatically call USBCtrlEPAllowStatusStage(), after the
+ "USB_STATUS_STAGE_TIMEOUT" has elapsed, since the last quanta of
+ "progress" has occurred in the control transfer. Progress is
+ defined as the last successful transaction completing on EP0 IN or
+ EP0 OUT.
+ Although the timeouts feature allows the status stage to
+ [eventually] complete, it is still preferable to manually call
+ USBCtrlEPAllowStatusStage() after the application firmware has
+ finished processing/consuming the control transfer data, as this
+ will allow for much faster processing of control transfers, and
+ therefore much higher data rates and better user responsiveness.
+ Description:
+
+ Conditions:
+ None
+
+ Input:
+
+ Return:
+
+ Remarks: If this function is called, is should get called after the SETUP
+ packet has arrived (the control transfer has started), but before
+ the USBCtrlEPServiceComplete() function has been called by the USB
+ stack. Therefore, the normal place to call USBDeferStatusStage()
+ would be from within the USBCBCheckOtherReq() handler context. For
+ example, in a HID application using control transfers, the
+ USBDeferStatusStage() function would be called from within the
+ USER_GET_REPORT_HANDLER or USER_SET_REPORT_HANDLER functions.
+ *****************************************************************************/
+void USBDeferStatusStage(void);
+extern volatile BOOL USBDeferStatusStagePacket;
+/*DOM-IGNORE-BEGIN*/
+#define USBDeferStatusStage() {USBDeferStatusStagePacket = TRUE;}
+/*DOM-IGNORE-END*/
+
+
+/*******************************************************************************
+ Function: BOOL USBOUTDataStageDeferred(void);
+
+ Summary: Returns TRUE if a control transfer with OUT data stage is pending,
+ and the firmware has called USBDeferOUTDataStage(), but has not
+ yet called USBCtrlEPAllowDataStage().
+ Returns FALSE if a control transfer with OUT data stage is either
+ not pending, or the firmware did not call USBDeferOUTDataStage()
+ at the start of the control transfer.
+
+ This function (macro) would typically be used in the case where the
+ USBDeviceTasks() function executes in the interrupt context (ex:
+ USB_INTERRUPT option selected in usb_config.h), but the firmware
+ wishes to take care of handling the data stage of the control transfer
+ in the main loop context.
+
+ In this scenario, typical usage would be:
+ 1. Host starts a control transfer with OUT data stage.
+ 2. USBDeviceTasks() (in this scenario, interrupt context) executes.
+ 3. USBDeviceTasks() calls USBCBCheckOtherReq(), which in turn
+ determines that the control transfer is class specific, with
+ OUT data stage.
+ 4. The user code in USBCBCheckOtherReq() (also in interrupt context,
+ since it is called from USBDeviceTasks(), and therefore executes
+ at the same priority/context) calls USBDeferOUTDataStage().
+
+ 5. Meanwhile, in the main loop context, a polling handler may be
+ periodically checking if(USBOUTDataStageDeferred() == TRUE).
+ Ordinarily, it would evaluate false, but when a control transfer
+ becomes pending, and after the USBDeferOUTDataStage() macro has
+ been called (ex: in the interrupt context), the if() statement
+ will evaluate true. In this case, the main loop context can then
+ take care of receiving the data, by calling USBEP0Receive() and
+ USBCtrlEPAllowDataStage().
+
+ Description:
+
+ Conditions:
+
+ Input:
+
+ Return:
+
+ Remarks:
+ *****************************************************************************/
+BOOL USBOUTDataStageDeferred(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBOUTDataStageDeferred() USBDeferOUTDataStagePackets
+/*DOM-IGNORE-END*/
+
+/*******************************************************************************
+ Function: void USBDeferINDataStage(void);
+
+ Summary: This function will cause the USB hardware to continuously NAK the
+ IN token packets sent from the host, during the data stage of a
+ device to host control transfer. This allows the firmware more time
+ to process and prepare the IN data packets that will eventually be
+ sent to the host. This is also useful, if the firmware needs to
+ process/prepare the IN data in a different context than what the
+ USBDeviceTasks() function executes at.
+
+ Calling this function (macro) will assert ownership of the currently
+ pending control transfer. Therefore, the USB stack will not STALL
+ when it reaches the data stage of the control transfer, even if the
+ firmware has not (yet) called the USBEP0SendRAMPtr() or
+ USBEP0SendROMPtr() API function. However, the application firware
+ must still (eventually, once it is ready) call one of the
+ aforementioned API functions.
+
+ Example Usage:
+
+ 1. Host sends a SETUP packet to the device, requesting a device to
+ host control transfer, with data stage.
+ 2. USBDeviceTasks() executes, and then calls the USBCBCheckOtherReq()
+ callback event handler. The USBCBCheckOtherReq() calls the
+ application specific/device class specific handler that detects
+ the type of control transfer.
+ 3. If the firmware needs more time to prepare the first IN data packet,
+ or, if the firmware wishes to process the command in a different
+ context (ex: if USBDeviceTasks() executes as an interrupt handler,
+ but the IN data stage data needs to be prepared in the main loop
+ context), then it may call USBDeferINDataStage(), in the context
+ of the USBCBCheckOtherReq() handler function.
+ 4. If the firmware called USBDeferINDataStage() in step #3 above,
+ then the hardware will NAK the IN token packets sent by the
+ host, for the IN data stage.
+ 5. Once the firmware is ready, and has successfully prepared the
+ data to be sent to the host in fulfillment of the control
+ transfer, it should then call USBEP0SendRAMPtr() or
+ USBEP0SendROMPtr(), to prepare the USB stack to know how many
+ bytes to send to the host, and from what source location.
+ 6. The firmware should now call USBCtrlEPAllowDataStage(). This
+ will allow the data stage to complete. The USB stack will send
+ the data buffer specified by the USBEP0SendRAMPtr() or
+ USBEP0SendROMPtr() function, when it was called.
+ 7. Once all data has been sent to the host, or if the host performs
+ early termination, the status stage (a 0-byte OUT packet) will
+ complete automatically (assuming the firmware did not call
+ USBDeferStatusStage() during step #3).
+
+
+ Description:
+
+ Conditions: Before calling USBDeferINDataStage(), the firmware should first
+ verify that the control transfer has a data stage, and that
+ it is of type device-to-host (IN).
+
+ Input:
+
+ Return:
+
+ Remarks: Section 9.2.6 of the official USB 2.0 specifications indicates that
+ the USB device must return the first IN data packet within 500ms
+ of the start of the control transfer. In order to meet this
+ specification, the firmware must call USBEP0SendRAMPtr() or
+ USBEP0SendROMPtr(), and then call USBCtrlEPAllowDataStage(), in
+ less than 500ms from the start of the control transfer.
+
+ If the firmware calls USBDeferINDataStage(), it must eventually call
+ USBEP0SendRAMPtr() or USBEP0SendROMPtr(), and then call
+ USBCtrlEPAllowDataStage(). If it does not do this, the control
+ transfer will never be able to complete.
+
+ The firmware should never call both USBDeferINDataStage() and
+ USBDeferOUTDataStage() during the same control transfer. These
+ functions are mutually exclusive (a control transfer with data stage
+ can never contain both IN and OUT data packets during the data stage).
+ *****************************************************************************/
+void USBDeferINDataStage(void);
+extern volatile BOOL USBDeferINDataStagePackets;
+/*DOM-IGNORE-BEGIN*/
+#define USBDeferINDataStage() {USBDeferINDataStagePackets = TRUE; inPipes[0].info.bits.busy = 1;}
+/*DOM-IGNORE-END*/
+
+
+
+/*******************************************************************************
+ Function: BOOL USBINDataStageDeferred(void);
+
+ Summary: Returns TRUE if a control transfer with IN data stage is pending,
+ and the firmware has called USBDeferINDataStage(), but has not
+ yet called USBCtrlEPAllowDataStage().
+ Returns FALSE if a control transfer with IN data stage is either
+ not pending, or the firmware did not call USBDeferINDataStage()
+ at the start of the control transfer.
+
+ This function (macro) would typically be used in the case where the
+ USBDeviceTasks() function executes in the interrupt context (ex:
+ USB_INTERRUPT option selected in usb_config.h), but the firmware
+ wishes to take care of handling the data stage of the control transfer
+ in the main loop context.
+
+ In this scenario, typical usage would be:
+ 1. Host starts a control transfer with IN data stage.
+ 2. USBDeviceTasks() (in this scenario, interrupt context) executes.
+ 3. USBDeviceTasks() calls USBCBCheckOtherReq(), which in turn
+ determines that the control transfer is class specific, with
+ IN data stage.
+ 4. The user code in USBCBCheckOtherReq() (also in interrupt context,
+ since it is called from USBDeviceTasks(), and therefore executes
+ at the same priority/context) calls USBDeferINDataStage().
+
+ 5. Meanwhile, in the main loop context, a polling handler may be
+ periodically checking if(USBINDataStageDeferred() == TRUE).
+ Ordinarily, it would evaluate false, but when a control transfer
+ becomes pending, and after the USBDeferINDataStage() macro has
+ been called (ex: in the interrupt context), the if() statement
+ will evaluate true. In this case, the main loop context can then
+ take care of sending the data (when ready), by calling
+ USBEP0SendRAMPtr() or USBEP0SendROMPtr() and
+ USBCtrlEPAllowDataStage().
+
+ Description:
+
+ Conditions:
+
+ Input:
+
+ Return:
+
+ Remarks:
+ *****************************************************************************/
+BOOL USBINDataStageDeferred(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBINDataStageDeferred() USBDeferINDataStagePackets
+/*DOM-IGNORE-END*/
+
+
+
+/********************************************************************
+ Function:
+ BOOL USBGetRemoteWakeupStatus(void)
+
+ Summary:
+ This function indicates if remote wakeup has been enabled by the host.
+ Devices that support remote wakeup should use this function to
+ determine if it should send a remote wakeup.
+
+ Description:
+ This function indicates if remote wakeup has been enabled by the host.
+ Devices that support remote wakeup should use this function to
+ determine if it should send a remote wakeup.
+
+ If a device does not support remote wakeup (the Remote wakeup bit, bit
+ 5, of the bmAttributes field of the Configuration descriptor is set to
+ 1), then it should not send a remote wakeup command to the PC and this
+ function is not of any use to the device. If a device does support
+ remote wakeup then it should use this function as described below.
+
+ If this function returns FALSE and the device is suspended, it should
+ not issue a remote wakeup (resume).
+
+ If this function returns TRUE and the device is suspended, it should
+ issue a remote wakeup (resume).
+
+ A device can add remote wakeup support by having the _RWU symbol added
+ in the configuration descriptor (located in the usb_descriptors.c file
+ in the project). This done in the 8th byte of the configuration
+ descriptor. For example:
+
+
+ ROM BYTE configDescriptor1[]={
+ 0x09, // Size
+ USB_DESCRIPTOR_CONFIGURATION, // descriptor type
+ DESC_CONFIG_WORD(0x0022), // Total length
+ 1, // Number of interfaces
+ 1, // Index value of this cfg
+ 0, // Configuration string index
+ _DEFAULT | _SELF | _RWU, // Attributes, see usb_device.h
+ 50, // Max power consumption in 2X mA(100mA)
+
+ //The rest of the configuration descriptor should follow
+
+
+ For more information about remote wakeup, see the following section of
+ the USB v2.0 specification available at www.usb.org:
+ * Section 9.2.5.2
+ * Table 9-10
+ * Section 7.1.7.7
+ * Section 9.4.5
+
+ Conditions:
+ None
+
+ Return Values:
+ TRUE - Remote Wakeup has been enabled by the host
+ FALSE - Remote Wakeup is not currently enabled
+
+ Remarks:
+ None
+
+ *******************************************************************/
+BOOL USBGetRemoteWakeupStatus(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBGetRemoteWakeupStatus() RemoteWakeup
+/*DOM-IGNORE-END*/
+
+/***************************************************************************
+ Function:
+ USB_DEVICE_STATE USBGetDeviceState(void)
+
+ Summary:
+ This function will return the current state of the device on the USB.
+ This function should return CONFIGURED_STATE before an application
+ tries to send information on the bus.
+ Description:
+ This function returns the current state of the device on the USB. This
+ \function is used to determine when the device is ready to communicate
+ on the bus. Applications should not try to send or receive data until
+ this function returns CONFIGURED_STATE.
+
+ It is also important that applications yield as much time as possible
+ to the USBDeviceTasks() function as possible while the this function
+ \returns any value between ATTACHED_STATE through CONFIGURED_STATE.
+
+ For more information about the various device states, please refer to
+ the USB specification section 9.1 available from www.usb.org.
+
+ Typical usage:
+
+ void main(void)
+ {
+ USBDeviceInit()
+ while(1)
+ {
+ USBDeviceTasks();
+ if((USBGetDeviceState() \< CONFIGURED_STATE) ||
+ (USBIsDeviceSuspended() == TRUE))
+ {
+ //Either the device is not configured or we are suspended
+ // so we don't want to do execute any application code
+ continue; //go back to the top of the while loop
+ }
+ else
+ {
+ //Otherwise we are free to run user application code.
+ UserApplication();
+ }
+ }
+ }
+
+ Conditions:
+ None
+ Return Values:
+ USB_DEVICE_STATE - the current state of the device on the bus
+
+ Remarks:
+ None
+ ***************************************************************************/
+USB_DEVICE_STATE USBGetDeviceState(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBGetDeviceState() USBDeviceState
+/*DOM-IGNORE-END*/
+
+
+
+/***************************************************************************
+ Function:
+ BOOL USBGetSuspendState(void)
+
+ Summary:
+ This function indicates if the USB port that this device is attached to is
+ currently suspended. When suspended, it will not be able to transfer data
+ over the bus.
+ Description:
+ This function indicates if the USB port that this device is attached to is
+ currently suspended. When suspended, it will not be able to transfer data
+ over the bus.
+ This function can be used by the application to skip over section of
+ code that do not need to exectute if the device is unable to send data
+ over the bus. This function can also be used to help determine when it is
+ legal to perform USB remote wakeup signalling, for devices supporting this
+ feature.
+
+ Typical usage:
+
+ void main(void)
+ {
+ USBDeviceInit()
+ while(1)
+ {
+ USBDeviceTasks();
+ if((USBGetDeviceState() \< CONFIGURED_STATE) ||
+ (USBGetSuspendState() == TRUE))
+ {
+ //Either the device is not configured or we are suspended
+ // so we don't want to do execute any application code
+ continue; //go back to the top of the while loop
+ }
+ else
+ {
+ //Otherwise we are free to run user application code.
+ UserApplication();
+ }
+ }
+ }
+
+ Conditions:
+ None
+ Return Values:
+ TRUE - the USB port this device is attached to is suspended.
+ FALSE - the USB port this device is attached to is not suspended.
+ Remarks:
+ This function is the same as USBIsBusSuspended().
+ ***************************************************************************/
+BOOL USBGetSuspendState(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBGetSuspendState() USBBusIsSuspended
+/*DOM-IGNORE-END*/
+
+/*******************************************************************************
+ Function:
+ BOOL USBIsDeviceSuspended(void)
+
+ Summary:
+ This function indicates if the USB module is in suspend mode.
+
+ Description:
+ This function indicates if the USB module is in suspend mode. This function
+ does NOT indicate that a suspend request has been received. It only
+ reflects the state of the USB module.
+
+ Typical Usage:
+
+ if(USBIsDeviceSuspended() == TRUE)
+ {
+ return;
+ }
+ // otherwise do some application specific tasks
+
+
+ Conditions:
+ None
+ Input:
+ None
+ Return:
+ None
+ Remarks:
+ None
+ *****************************************************************************/
+BOOL USBIsDeviceSuspended(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBIsDeviceSuspended() USBSuspendControl
+/*DOM-IGNORE-END*/
+
+
+/*******************************************************************************
+ Function:
+ BOOL USBIsBusSuspended(void);
+
+ Summary:
+ This function indicates if the USB bus is in suspend mode.
+
+ Description:
+ This function indicates if the USB bus is in suspend mode. This function
+ is typically used for checking if the conditions are consistent with
+ performing a USB remote wakeup sequence.
+
+ Typical Usage:
+
+ if((USBIsBusSuspended() == TRUE) && (USBGetRemoteWakeupStatus() == TRUE))
+ {
+ //Check if some stimulus occured, which will be used as the wakeup source
+ if(sw3 == 0)
+ {
+ USBCBSendResume(); //Send the remote wakeup signalling to the host
+ }
+ }
+ // otherwise do some other application specific tasks
+
+
+ Conditions:
+ None
+ Input:
+ None
+ Return:
+ None
+ Remarks:
+ The USBIsBusSuspended() function relies on the USBBusIsSuspended boolean
+ variable, which gets updated by the USBDeviceTasks() function. Therefore,
+ in order to be sure the return value is not "stale", it is suggested to make
+ sure USBDeviceTasks() has executed recently (if using USB polling mode).
+ *****************************************************************************/
+BOOL USBIsBusSuspended(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBIsBusSuspended() USBBusIsSuspended
+/*DOM-IGNORE-END*/
+
+/*******************************************************************************
+ Function:
+ void USBSoftDetach(void);
+
+ Summary:
+ This function performs a detach from the USB bus via software.
+
+ Description:
+ This function performs a detach from the USB bus via software.
+
+ Conditions:
+ None
+ Input:
+ None
+ Return:
+ None
+ Remarks:
+ Caution should be used when detaching from the bus. Some PC drivers and
+ programs may require additional time after a detach before a device can be
+ reattached to the bus.
+ *****************************************************************************/
+void USBSoftDetach(void);
+/*DOM-IGNORE-BEGIN*/
+#define USBSoftDetach() U1CON = 0; U1IE = 0; USBDeviceState = DETACHED_STATE;
+/*DOM-IGNORE-END*/
+
+
+/*************************************************************************
+ Function:
+ BOOL USBHandleBusy(USB_HANDLE handle)
+
+ Summary:
+ Checks to see if the input handle is busy
+
+ Description:
+ Checks to see if the input handle is busy
+
+ Typical Usage
+
+ //make sure that the last transfer isn't busy by checking the handle
+ if(!USBHandleBusy(USBGenericInHandle))
+ {
+ //Send the data contained in the INPacket[] array out on
+ // endpoint USBGEN_EP_NUM
+ USBGenericInHandle = USBGenWrite(USBGEN_EP_NUM,(BYTE*)&INPacket[0],sizeof(INPacket));
+ }
+
+
+ Conditions:
+ None
+ Input:
+ USB_HANDLE handle - handle of the transfer that you want to check the
+ status of
+ Return Values:
+ TRUE - The specified handle is busy
+ FALSE - The specified handle is free and available for a transfer
+ Remarks:
+ None
+ *************************************************************************/
+BOOL USBHandleBusy(USB_HANDLE handle);
+/*DOM-IGNORE-BEGIN*/
+#define USBHandleBusy(handle) (handle==0?0:((volatile BDT_ENTRY*)handle)->STAT.UOWN)
+/*DOM-IGNORE-END*/
+
+/********************************************************************
+ Function:
+ WORD USBHandleGetLength(USB_HANDLE handle)
+
+ Summary:
+ Retrieves the length of the destination buffer of the input
+ handle
+
+ Description:
+ Retrieves the length of the destination buffer of the input
+ handle
+
+ PreCondition:
+ None
+
+ Parameters:
+ USB_HANDLE handle - the handle to the transfer you want the
+ address for.
+
+ Return Values:
+ WORD - length of the current buffer that the input handle
+ points to. If the transfer is complete then this is the
+ length of the data transmitted or the length of data
+ actually received.
+
+ Remarks:
+ None
+
+ *******************************************************************/
+WORD USBHandleGetLength(USB_HANDLE handle);
+/*DOM-IGNORE-BEGIN*/
+#define USBHandleGetLength(handle) (((volatile BDT_ENTRY*)handle)->CNT)
+/*DOM-IGNORE-END*/
+
+/********************************************************************
+ Function:
+ WORD USBHandleGetAddr(USB_HANDLE)
+
+ Summary:
+ Retrieves the address of the destination buffer of the input
+ handle
+
+ Description:
+ Retrieves the address of the destination buffer of the input
+ handle
+
+ PreCondition:
+ None
+
+ Parameters:
+ USB_HANDLE handle - the handle to the transfer you want the
+ address for.
+
+ Return Values:
+ WORD - address of the current buffer that the input handle
+ points to.
+
+ Remarks:
+ None
+
+ *******************************************************************/
+WORD USBHandleGetAddr(USB_HANDLE);
+/*DOM-IGNORE-BEGIN*/
+#define USBHandleGetAddr(handle) ConvertToVirtualAddress((((volatile BDT_ENTRY*)handle)->ADR))
+/*DOM-IGNORE-END*/
+
+
+/********************************************************************
+ Function:
+ USB_HANDLE USBGetNextHandle(BYTE ep_num, BYTE ep_dir)
+ Summary:
+ Retrieves the handle to the next endpoint BDT entry that the
+ USBTransferOnePacket() will use.
+ Description:
+ Retrieves the handle to the next endpoint BDT that the
+ USBTransferOnePacket() will use. Useful for initialization and when
+ ping pong buffering will be used on application endpoints.
+ PreCondition:
+ Will return NULL if the USB device has not yet been configured/the
+ endpoint specified has not yet been initalized by USBEnableEndpoint().
+ Parameters:
+ BYTE ep_num - The endpoint number to get the handle for (valid
+ values are 1-15, 0 is not a valid input value for this API)
+ BYTE ep_dir - The endpoint direction associated with the endpoint number
+ to get the handle for (valid values are OUT_FROM_HOST and IN_TO_HOST).
+ Return Values:
+ USB_HANDLE - Returns the USB_HANDLE (a pointer) to the BDT that will be
+ used next time the USBTransferOnePacket() function is called, for the
+ given ep_num and ep_dir
+ Remarks:
+ This API is useful for initializing USB_HANDLEs during initialization of
+ the application firmware. It is also useful when ping-pong bufferring is
+ enabled, and the application firmware wishes to arm both the even and odd
+ BDTs for an endpoint simultaneously. In this case, the application
+ firmware for sending data to the host would typically be something like
+ follows:
+
+
+ USB_HANDLE Handle1;
+ USB_HANDLE Handle2;
+ USB_HANDLE* pHandle = &Handle1;
+ BYTE UserDataBuffer1[64];
+ BYTE UserDataBuffer2[64];
+ BYTE* pDataBuffer = &UserDataBuffer1[0];
+
+ //Add some code that loads UserDataBuffer1[] with useful data to send,
+ //using the pDataBuffer pointer, for example:
+ //for(i = 0; i < 64; i++)
+ //{
+ // *pDataBuffer++ = [useful data value];
+ //}
+
+ //Check if the next USB endpoint BDT is available
+ if(!USBHandleBusy(USBGetNextHandle(ep_num, IN_TO_HOST))
+ {
+ //The endpoint is available. Send the data.
+ *pHandle = USBTransferOnePacket(ep_num, ep_dir, pDataBuffer, bytecount);
+ //Toggle the handle and buffer pointer for the next transaction
+ if(pHandle == &Handle1)
+ {
+ pHandle = &Handle2;
+ pDataBuffer = &UserDataBuffer2[0];
+ }
+ else
+ {
+ pHandle = &Handle1;
+ pDataBuffer = &UserDataBuffer1[0];
+ }
+ }
+
+ //The firmware can then load the next data buffer (in this case
+ //UserDataBuffer2)with useful data, and send it using the same
+ //process. For example:
+
+ //Add some code that loads UserDataBuffer2[] with useful data to send,
+ //using the pDataBuffer pointer, for example:
+ //for(i = 0; i < 64; i++)
+ //{
+ // *pDataBuffer++ = [useful data value];
+ //}
+
+ //Check if the next USB endpoint BDT is available
+ if(!USBHandleBusy(USBGetNextHandle(ep_num, IN_TO_HOST))
+ {
+ //The endpoint is available. Send the data.
+ *pHandle = USBTransferOnePacket(ep_num, ep_dir, pDataBuffer, bytecount);
+ //Toggle the handle and buffer pointer for the next transaction
+ if(pHandle == &Handle1)
+ {
+ pHandle = &Handle2;
+ pDataBuffer = &UserDataBuffer2[0];
+ }
+ else
+ {
+ pHandle = &Handle1;
+ pDataBuffer = &UserDataBuffer1[0];
+ }
+ }
+
+
+ *******************************************************************/
+USB_HANDLE USBGetNextHandle(BYTE ep_num, BYTE ep_dir);
+/*DOM-IGNORE-BEGIN*/
+#define USBGetNextHandle(ep_num, ep_dir) ((ep_dir == OUT_FROM_HOST)?((USB_HANDLE)pBDTEntryOut[ep_num]):((USB_HANDLE)pBDTEntryIn[ep_num]))
+/*DOM-IGNORE-END*/
+
+/********************************************************************
+ Function:
+ void USBEP0Transmit(BYTE options)
+
+ Summary:
+ Sets the address of the data to send over the
+ control endpoint
+
+ PreCondition:
+ None
+
+ Paramters:
+ options - the various options that you want
+ when sending the control data. Options are:
+ USB_EP0_ROM
+ USB_EP0_RAM
+ USB_EP0_BUSY
+ USB_EP0_INCLUDE_ZERO
+ USB_EP0_NO_DATA
+ USB_EP0_NO_OPTIONS
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *******************************************************************/
+void USBEP0Transmit(BYTE options);
+/*DOM-IGNORE-BEGIN*/
+#define USBEP0Transmit(options) inPipes[0].info.Val = options | USB_EP0_BUSY
+/*DOM-IGNORE-END*/
+
+/*************************************************************************
+ Function:
+ void USBEP0SendRAMPtr(BYTE* src, WORD size, BYTE Options)
+
+ Summary:
+ Sets the source, size, and options of the data you wish to send from a
+ RAM source
+ Conditions:
+ None
+ Input:
+ src - address of the data to send
+ size - the size of the data needing to be transmitted
+ options - the various options that you want when sending the control
+ data. Options are\:
+ * USB_EP0_ROM
+ * USB_EP0_RAM
+ * USB_EP0_BUSY
+ * USB_EP0_INCLUDE_ZERO
+ * USB_EP0_NO_DATA
+ * USB_EP0_NO_OPTIONS
+ Remarks:
+ None
+ *************************************************************************/
+void USBEP0SendRAMPtr(BYTE* src, WORD size, BYTE Options);
+/*DOM-IGNORE-BEGIN*/
+#define USBEP0SendRAMPtr(src,size,options) {\
+ inPipes[0].pSrc.bRam = src;\
+ inPipes[0].wCount.Val = size;\
+ inPipes[0].info.Val = options | USB_EP0_BUSY | USB_EP0_RAM;\
+ }
+/*DOM-IGNORE-END*/
+
+/**************************************************************************
+ Function:
+ void USBEP0SendROMPtr(BYTE* src, WORD size, BYTE Options)
+
+ Summary:
+ Sets the source, size, and options of the data you wish to send from a
+ ROM source
+ Conditions:
+ None
+ Input:
+ src - address of the data to send
+ size - the size of the data needing to be transmitted
+ options - the various options that you want when sending the control
+ data. Options are\:
+ * USB_EP0_ROM
+ * USB_EP0_RAM
+ * USB_EP0_BUSY
+ * USB_EP0_INCLUDE_ZERO
+ * USB_EP0_NO_DATA
+ * USB_EP0_NO_OPTIONS
+ Remarks:
+ None
+ **************************************************************************/
+void USBEP0SendROMPtr(BYTE* src, WORD size, BYTE Options);
+/*DOM-IGNORE-BEGIN*/
+#define USBEP0SendROMPtr(src,size,options) {\
+ inPipes[0].pSrc.bRom = src;\
+ inPipes[0].wCount.Val = size;\
+ inPipes[0].info.Val = options | USB_EP0_BUSY | USB_EP0_ROM;\
+ }
+/*DOM-IGNORE-END*/
+
+/***************************************************************************
+ Function:
+ void USBEP0Receive(BYTE* dest, WORD size, void (*function))
+ Summary:
+ Sets the destination, size, and a function to call on the completion of
+ the next control write.
+ Conditions:
+ None
+ Input:
+ dest - address of where the incoming data will go (make sure that this
+ address is directly accessable by the USB module for parts with
+ dedicated USB RAM this address must be in that space)
+ size - the size of the data being received (is almost always going tobe
+ presented by the preceeding setup packet SetupPkt.wLength)
+ (*function) - a function that you want called once the data is received. If
+ this is specificed as NULL then no function is called.
+ Remarks:
+ None
+ ***************************************************************************/
+void USBEP0Receive(BYTE* dest, WORD size, void (*function));
+/*DOM-IGNORE-BEGIN*/
+#define USBEP0Receive(dest,size,function) {outPipes[0].pDst.bRam = dest;outPipes[0].wCount.Val = size;outPipes[0].pFunc = function;outPipes[0].info.bits.busy = 1; }
+/*DOM-IGNORE-END*/
+
+/********************************************************************
+ Function:
+ USB_HANDLE USBTxOnePacket(BYTE ep, BYTE* data, WORD len)
+
+ Summary:
+ Sends the specified data out the specified endpoint
+
+ PreCondition:
+ None
+
+ Parameters:
+ ep - the endpoint number you want to send the data out of
+ data - pointer to a user buffer that contains the data that you wish to
+ send to the host. Note: This RAM buffer must be accessible by
+ the USB module.
+ len - the number of bytes of data that you wish to send to the host,
+ in the next transaction on this endpoint. Note: this value
+ should always be less than or equal to the endpoint size, as
+ specified in the USB endpoint descriptor.
+
+ Return Values:
+ USB_HANDLE - Returns a pointer to the BDT entry associated with the
+ transaction. The firmware can check for completion
+ of the transaction by using the USBHandleBusy() function,
+ using the returned USB_HANDLE value.
+
+ Remarks:
+ None
+
+ *******************************************************************/
+USB_HANDLE USBTxOnePacket(BYTE ep, BYTE* data, WORD len);
+/*DOM-IGNORE-BEGIN*/
+#define USBTxOnePacket(ep,data,len) USBTransferOnePacket(ep,IN_TO_HOST,data,len)
+/*DOM-IGNORE-END*/
+
+/********************************************************************
+ Function:
+ USB_HANDLE USBRxOnePacket(BYTE ep, BYTE* data, WORD len)
+
+ Summary:
+ Receives the specified data out the specified endpoint
+
+ PreCondition:
+ None
+
+ Parameters:
+ ep - The endpoint number you want to receive the data on.
+ data - Pointer to a user buffer where the data will go when
+ it arrives from the host. Note: This RAM must be USB module
+ accessible.
+ len - The len parameter should always be set to the maximum endpoint packet
+ size, specified in the USB descriptor for this endpoint. The host
+ may send <= the number of bytes as the endpoint size in the endpoint
+ descriptor. After the transaction is complete, the application
+ firmware can call USBHandleGetLength() to determine how many bytes
+ the host actually sent in the last transaction on this endpoint.
+
+ Return Values:
+ USB_HANDLE - Returns a pointer to the BDT entry associated with the
+ transaction. The firmware can check for completion
+ of the transaction by using the USBHandleBusy() function,
+ using the returned USB_HANDLE value.
+
+ Remarks:
+ None
+
+ *******************************************************************/
+USB_HANDLE USBRxOnePacket(BYTE ep, BYTE* data, WORD len);
+/*DOM-IGNORE-BEGIN*/
+#define USBRxOnePacket(ep,data,len) USBTransferOnePacket(ep,OUT_FROM_HOST,data,len)
+/*DOM-IGNORE-END*/
+
+/*******************************************************************************
+ Function:
+ BOOL USB_APPLICATION_EVENT_HANDLER(BYTE address, USB_EVENT event, void *pdata, WORD size);
+
+ Summary:
+ This function is called whenever the USB stack wants to notify the user of
+ an event.
+
+ Description:
+ This function is called whenever the USB stack wants to notify the user of
+ an event. This function should be implemented by the user.
+
+ Example Usage:
+ Conditions:
+ None
+
+ Input:
+ BYTE address - the address of the device when the event happened
+ BYTE event - The event input specifies which event happened. The
+ possible options are listed in the USB_DEVICE_STACK_EVENTS
+ enumeration.
+
+ Return:
+ None
+ Remarks:
+ None
+ *****************************************************************************/
+BOOL USB_APPLICATION_EVENT_HANDLER(BYTE address, USB_EVENT event, void *pdata, WORD size);
+
+/*******************************************************************************
+ Function:
+ ROM void *USBDeviceCBGetDescriptor (UINT16 *length, DESCRIPTOR_ID *id);
+
+ Summary:
+ This function is called whenever the USB stack gets a USB GET_DESCRIPTOR
+ request.
+
+ Description:
+ This function is called whenever the USB stack gets a USB GET_DESCRIPTOR
+ request. This function is responsible for returning a pointer to the
+ requested descriptor and setting that the length for the that descriptor.
+
+ This function should be implemented by the user. This function might be
+ generated automatically by the USB configuration tool.
+
+ Conditions:
+ None
+
+ Input:
+ BYTE *length - pointer to a variable that should be set to the length of
+ the requested descriptor.
+ BYTE *id - This structure contains information about the requested
+ descriptor
+
+ Return:
+ ROM void* - pointer to the requested descriptor.
+ Remarks:
+ None
+ *****************************************************************************/
+void *USBDeviceCBGetDescriptor ( UINT16 *length,
+ UINT8 *ptr_type,
+ DESCRIPTOR_ID *id);
+
+
+
+/** Section: MACROS ******************************************************/
+
+/* The DESC_CONFIG_WORD() macro is implemented for convinence. Since the
+ configuration descriptor array is a BYTE array, each entry needs to be a
+ BYTE in LSB format. The DESC_CONFIG_WORD() macro breaks up a WORD into
+ the appropriate BYTE entries in LSB.
+ Typical Usage:
+
+ ROM BYTE configDescriptor1[]={
+ 0x09, // Size of this descriptor in bytes
+ USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type
+ DESC_CONFIG_WORD(0x0022), // Total length of data for this cfg
+
+*/
+#define DESC_CONFIG_WORD(a) (a&0xFF),((a>>8)&0xFF)
+
+/* The DESC_CONFIG_DWORD() macro is implemented for convinence. Since the
+ configuration descriptor array is a BYTE array, each entry needs to be a
+ BYTE in LSB format. The DESC_CONFIG_DWORD() macro breaks up a DWORD into
+ the appropriate BYTE entries in LSB.
+*/
+#define DESC_CONFIG_DWORD(a) (a&0xFF),((a>>8)&0xFF),((a>>16)&0xFF),((a>>24)&0xFF)
+
+/* The DESC_CONFIG_BYTE() macro is implemented for convinence. The
+ DESC_CONFIG_BYTE() macro provides a consistant macro for use with a byte
+ when generating a configuratin descriptor when using either the
+ DESC_CONFIG_WORD() or DESC_CONFIG_DWORD() macros.
+*/
+#define DESC_CONFIG_BYTE(a) (a)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* DOM-IGNORE-BEGIN */
+/*******************************************************************************
+********************************************************************************
+********************************************************************************
+ This section contains implementation specific information that may vary
+ between releases as the implementation needs to change. This section is
+ included for compilation reasons only.
+********************************************************************************
+********************************************************************************
+*******************************************************************************/
+
+#if defined(USB_POLLING)
+ #define USB_VOLATILE
+#else
+ #define USB_VOLATILE volatile
+#endif
+
+#define CTRL_TRF_RETURN void
+#define CTRL_TRF_PARAMS void
+
+// Defintion of the PIPE structure
+// This structure is used to keep track of data that is sent out
+// of the stack automatically.
+typedef struct __attribute__ ((packed))
+{
+ union __attribute__ ((packed))
+ {
+ //Various options of pointers that are available to
+ // get the data from
+ BYTE *bRam;
+ ROM BYTE *bRom;
+ WORD *wRam;
+ ROM WORD *wRom;
+ }pSrc;
+ union __attribute__ ((packed))
+ {
+ struct __attribute__ ((packed))
+ {
+ //is this transfer from RAM or ROM?
+ BYTE ctrl_trf_mem :1;
+ BYTE reserved :5;
+ //include a zero length packet after
+ //data is done if data_size%ep_size = 0?
+ BYTE includeZero :1;
+ //is this PIPE currently in use
+ BYTE busy :1;
+ }bits;
+ BYTE Val;
+ }info;
+ WORD_VAL __attribute__((aligned)) wCount;
+}IN_PIPE;
+
+extern USB_VOLATILE IN_PIPE inPipes[];
+
+typedef struct __attribute__ ((packed))
+{
+ union __attribute__ ((packed))
+ {
+ //Various options of pointers that are available to
+ // get the data from
+ BYTE *bRam;
+ WORD *wRam;
+ }pDst;
+ union __attribute__ ((packed))
+ {
+ struct __attribute__ ((packed))
+ {
+ BYTE reserved :7;
+ //is this PIPE currently in use
+ BYTE busy :1;
+ }bits;
+ BYTE Val;
+ }info;
+ WORD_VAL wCount;
+ CTRL_TRF_RETURN (*pFunc)(CTRL_TRF_PARAMS);
+}OUT_PIPE;
+
+/************* DWF - SHOULD BE REIMPLEMENTED AS AN EVENT *******************/
+//#if defined(ENABLE_EP0_DATA_RECEIVED_CALLBACK)
+// void USBCBEP0DataReceived(void);
+// #define USBCB_EP0_DATA_RECEIVED() USBCBEP0DataReceived()
+//#else
+// #define USBCB_EP0_DATA_RECEIVED()
+//#endif
+
+extern USB_VOLATILE BOOL RemoteWakeup;
+extern USB_VOLATILE BOOL USBBusIsSuspended;
+extern USB_VOLATILE USB_DEVICE_STATE USBDeviceState;
+extern USB_VOLATILE BYTE USBActiveConfiguration;
+/******************************************************************************/
+/* DOM-IGNORE-END */
+
+#endif //USBD_H
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb_function_cdc.h b/Source/USB/USB2.9i_cdc/include/USB/usb_function_cdc.h
new file mode 100644
index 0000000..13b7bb9
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb_function_cdc.h
@@ -0,0 +1,1057 @@
+/************************************************************************
+ File Information:
+ FileName: usb_function_cdc.h
+ Dependencies: See INCLUDES section
+ Processor: PIC18,PIC24, PIC32 and dsPIC33 USB Microcontrollers
+ Hardware: This code is natively intended to be used on Mirochip USB
+ demo boards. See www.microchip.com/usb (Software & Tools
+ section) for list of available platforms. The firmware may
+ be modified for use on other USB platforms by editing the
+ HardwareProfile.h and HardwareProfile - [platform].h files.
+ Complier: Microchip C18 (for PIC18),C30 (for PIC24 and dsPIC33)
+ and C32 (for PIC32)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the "Company") for its PIC® Microcontroller is intended and
+ supplied to you, the Company's customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+ Summary:
+ This file contains all of functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the CDC function
+ driver. This file should be included in projects that use the CDC
+ \function driver. This file should also be included into the
+ usb_descriptors.c file and any other user file that requires access to the
+ CDC interface.
+
+
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ Description:
+ USB CDC Function Driver File
+
+ This file contains all of functions, macros, definitions, variables,
+ datatypes, etc. that are required for usage with the CDC function
+ driver. This file should be included in projects that use the CDC
+ \function driver. This file should also be included into the
+ usb_descriptors.c file and any other user file that requires access to the
+ CDC interface.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+
+ ..\\..\\Microchip\\Include
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+
+********************************************************************/
+
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.3 Decricated the mUSBUSARTIsTxTrfReady() macro. It is
+ replaced by the USBUSARTIsTxTrfReady() function.
+
+ 2.6 Minor definition changes
+
+ 2.6a No Changes
+
+ 2.9b Added new CDCNotificationHandler() prototype and related
+ structure definitions useful when sending serial state
+ notifications over the CDC interrupt endpoint.
+
+********************************************************************/
+
+#ifndef CDC_H
+#define CDC_H
+
+/** I N C L U D E S **********************************************************/
+#include "GenericTypeDefs.h"
+#include "USB/usb.h"
+#include "usb_config.h"
+
+/** D E F I N I T I O N S ****************************************************/
+
+/* Class-Specific Requests */
+#define SEND_ENCAPSULATED_COMMAND 0x00
+#define GET_ENCAPSULATED_RESPONSE 0x01
+#define SET_COMM_FEATURE 0x02
+#define GET_COMM_FEATURE 0x03
+#define CLEAR_COMM_FEATURE 0x04
+#define SET_LINE_CODING 0x20
+#define GET_LINE_CODING 0x21
+#define SET_CONTROL_LINE_STATE 0x22
+#define SEND_BREAK 0x23
+
+/* Notifications *
+ * Note: Notifications are polled over
+ * Communication Interface (Interrupt Endpoint)
+ */
+#define NETWORK_CONNECTION 0x00
+#define RESPONSE_AVAILABLE 0x01
+#define SERIAL_STATE 0x20
+
+
+/* Device Class Code */
+#define CDC_DEVICE 0x02
+
+/* Communication Interface Class Code */
+#define COMM_INTF 0x02
+
+/* Communication Interface Class SubClass Codes */
+#define ABSTRACT_CONTROL_MODEL 0x02
+
+/* Communication Interface Class Control Protocol Codes */
+#define V25TER 0x01 // Common AT commands ("Hayes(TM)")
+
+
+/* Data Interface Class Codes */
+#define DATA_INTF 0x0A
+
+/* Data Interface Class Protocol Codes */
+#define NO_PROTOCOL 0x00 // No class specific protocol required
+
+
+/* Communication Feature Selector Codes */
+#define ABSTRACT_STATE 0x01
+#define COUNTRY_SETTING 0x02
+
+/* Functional Descriptors */
+/* Type Values for the bDscType Field */
+#define CS_INTERFACE 0x24
+#define CS_ENDPOINT 0x25
+
+/* bDscSubType in Functional Descriptors */
+#define DSC_FN_HEADER 0x00
+#define DSC_FN_CALL_MGT 0x01
+#define DSC_FN_ACM 0x02 // ACM - Abstract Control Management
+#define DSC_FN_DLM 0x03 // DLM - Direct Line Managment
+#define DSC_FN_TELEPHONE_RINGER 0x04
+#define DSC_FN_RPT_CAPABILITIES 0x05
+#define DSC_FN_UNION 0x06
+#define DSC_FN_COUNTRY_SELECTION 0x07
+#define DSC_FN_TEL_OP_MODES 0x08
+#define DSC_FN_USB_TERMINAL 0x09
+/* more.... see Table 25 in USB CDC Specification 1.1 */
+
+/* CDC Bulk IN transfer states */
+#define CDC_TX_READY 0
+#define CDC_TX_BUSY 1
+#define CDC_TX_BUSY_ZLP 2 // ZLP: Zero Length Packet
+#define CDC_TX_COMPLETING 3
+
+#if defined(USB_CDC_SET_LINE_CODING_HANDLER)
+ #define LINE_CODING_TARGET &cdc_notice.SetLineCoding._byte[0]
+ #define LINE_CODING_PFUNC &USB_CDC_SET_LINE_CODING_HANDLER
+#else
+ #define LINE_CODING_TARGET &line_coding._byte[0]
+ #define LINE_CODING_PFUNC NULL
+#endif
+
+#if defined(USB_CDC_SUPPORT_HARDWARE_FLOW_CONTROL)
+ #define CONFIGURE_RTS(a) UART_RTS = a;
+#else
+ #define CONFIGURE_RTS(a)
+#endif
+
+#if defined(USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D3)
+ #error This option is not currently supported.
+#else
+ #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D3_VAL 0x00
+#endif
+
+#if defined(USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2)
+ #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2_VAL 0x04
+#else
+ #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2_VAL 0x00
+#endif
+
+#if defined(USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1)
+ #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1_VAL 0x02
+#else
+ #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1_VAL 0x00
+#endif
+
+#if defined(USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D0)
+ #error This option is not currently supported.
+#else
+ #define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D0_VAL 0x00
+#endif
+
+#define USB_CDC_ACM_FN_DSC_VAL \
+ USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D3_VAL |\
+ USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2_VAL |\
+ USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1_VAL |\
+ USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D0_VAL
+
+/******************************************************************************
+ Function:
+ void CDCSetBaudRate(DWORD baudRate)
+
+ Summary:
+ This macro is used set the baud rate reported back to the host during
+ a get line coding request. (optional)
+
+ Description:
+ This macro is used set the baud rate reported back to the host during
+ a get line coding request.
+
+ Typical Usage:
+
+ CDCSetBaudRate(19200);
+
+
+ This function is optional for CDC devices that do not actually convert
+ the USB traffic to a hardware UART.
+
+ PreCondition:
+ None
+
+ Parameters:
+ DWORD baudRate - The desired baudrate
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *****************************************************************************/
+#define CDCSetBaudRate(baudRate) {line_coding.dwDTERate.Val=baudRate;}
+
+/******************************************************************************
+ Function:
+ void CDCSetCharacterFormat(BYTE charFormat)
+
+ Summary:
+ This macro is used manually set the character format reported back to
+ the host during a get line coding request. (optional)
+
+ Description:
+ This macro is used manually set the character format reported back to
+ the host during a get line coding request.
+
+ Typical Usage:
+
+ CDCSetCharacterFormat(NUM_STOP_BITS_1);
+
+
+ This function is optional for CDC devices that do not actually convert
+ the USB traffic to a hardware UART.
+
+ PreCondition:
+ None
+
+ Parameters:
+ BYTE charFormat - number of stop bits. Available options are:
+ * NUM_STOP_BITS_1 - 1 Stop bit
+ * NUM_STOP_BITS_1_5 - 1.5 Stop bits
+ * NUM_STOP_BITS_2 - 2 Stop bits
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *****************************************************************************/
+#define CDCSetCharacterFormat(charFormat) {line_coding.bCharFormat=charFormat;}
+#define NUM_STOP_BITS_1 0 //1 stop bit - used by CDCSetLineCoding() and CDCSetCharacterFormat()
+#define NUM_STOP_BITS_1_5 1 //1.5 stop bit - used by CDCSetLineCoding() and CDCSetCharacterFormat()
+#define NUM_STOP_BITS_2 2 //2 stop bit - used by CDCSetLineCoding() and CDCSetCharacterFormat()
+
+/******************************************************************************
+ Function:
+ void CDCSetParity(BYTE parityType)
+
+ Summary:
+ This function is used manually set the parity format reported back to
+ the host during a get line coding request. (optional)
+
+ Description:
+ This macro is used manually set the parity format reported back to
+ the host during a get line coding request.
+
+ Typical Usage:
+
+ CDCSetParity(PARITY_NONE);
+
+
+ This function is optional for CDC devices that do not actually convert
+ the USB traffic to a hardware UART.
+
+ PreCondition:
+ None
+
+ Parameters:
+ BYTE parityType - Type of parity. The options are the following:
+ * PARITY_NONE
+ * PARITY_ODD
+ * PARITY_EVEN
+ * PARITY_MARK
+ * PARITY_SPACE
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *****************************************************************************/
+#define CDCSetParity(parityType) {line_coding.bParityType=parityType;}
+#define PARITY_NONE 0 //no parity - used by CDCSetLineCoding() and CDCSetParity()
+#define PARITY_ODD 1 //odd parity - used by CDCSetLineCoding() and CDCSetParity()
+#define PARITY_EVEN 2 //even parity - used by CDCSetLineCoding() and CDCSetParity()
+#define PARITY_MARK 3 //mark parity - used by CDCSetLineCoding() and CDCSetParity()
+#define PARITY_SPACE 4 //space parity - used by CDCSetLineCoding() and CDCSetParity()
+
+/******************************************************************************
+ Function:
+ void CDCSetDataSize(BYTE dataBits)
+
+ Summary:
+ This function is used manually set the number of data bits reported back
+ to the host during a get line coding request. (optional)
+
+ Description:
+ This function is used manually set the number of data bits reported back
+ to the host during a get line coding request.
+
+ Typical Usage:
+
+ CDCSetDataSize(8);
+
+
+ This function is optional for CDC devices that do not actually convert
+ the USB traffic to a hardware UART.
+
+ PreCondition:
+ None
+
+ Parameters:
+ BYTE dataBits - number of data bits. The options are 5, 6, 7, 8, or 16.
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *****************************************************************************/
+#define CDCSetDataSize(dataBits) {line_coding.bDataBits=dataBits;}
+
+/******************************************************************************
+ Function:
+ void CDCSetLineCoding(DWORD baud, BYTE format, BYTE parity, BYTE dataSize)
+
+ Summary:
+ This function is used to manually set the data reported back
+ to the host during a get line coding request. (optional)
+
+ Description:
+ This function is used to manually set the data reported back
+ to the host during a get line coding request.
+
+ Typical Usage:
+
+ CDCSetLineCoding(19200, NUM_STOP_BITS_1, PARITY_NONE, 8);
+
+
+ This function is optional for CDC devices that do not actually convert
+ the USB traffic to a hardware UART.
+
+ PreCondition:
+ None
+
+ Parameters:
+ DWORD baud - The desired baudrate
+ BYTE format - number of stop bits. Available options are:
+ * NUM_STOP_BITS_1 - 1 Stop bit
+ * NUM_STOP_BITS_1_5 - 1.5 Stop bits
+ * NUM_STOP_BITS_2 - 2 Stop bits
+ BYTE parity - Type of parity. The options are the following:
+ * PARITY_NONE
+ * PARITY_ODD
+ * PARITY_EVEN
+ * PARITY_MARK
+ * PARITY_SPACE
+ BYTE dataSize - number of data bits. The options are 5, 6, 7, 8, or 16.
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *****************************************************************************/
+#define CDCSetLineCoding(baud,format,parity,dataSize) {\
+ CDCSetBaudRate(baud);\
+ CDCSetCharacterFormat(format);\
+ CDCSetParity(parity);\
+ CDCSetDataSize(dataSize);\
+ }
+
+/******************************************************************************
+ Function:
+ BOOL USBUSARTIsTxTrfReady(void)
+
+ Summary:
+ This macro is used to check if the CDC class is ready
+ to send more data.
+
+ Description:
+ This macro is used to check if the CDC class handler firmware is
+ ready to send more data to the host over the CDC bulk IN endpoint.
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ putrsUSBUSART("Hello World");
+ }
+
+
+ PreCondition:
+ The return value of this function is only valid if the device is in a
+ configured state (i.e. - USBDeviceGetState() returns CONFIGURED_STATE)
+
+ Parameters:
+ None
+
+ Return Values:
+ Returns a boolean value indicating if the CDC class handler firmware
+ is ready to receive new data to send to the host over the bulk data IN
+ endpoint. A return value of true indicates that the CDC handler
+ firmware is ready to receive new data, and it is therefore safe to
+ call other APIs like putrsUSBUSART() and putsUSBUSART(). A return
+ value of false implies that the firmware is still busy sending the
+ last data, or is otherwise not ready to process any new data at
+ this time.
+
+ Remarks:
+ Make sure the application periodically calls the CDCTxService()
+ handler, or pending USB IN transfers will not be able to advance
+ and complete.
+
+ *****************************************************************************/
+#define USBUSARTIsTxTrfReady() (cdc_trf_state == CDC_TX_READY)
+
+/******************************************************************************
+ Function:
+ void mUSBUSARTTxRam(BYTE *pData, BYTE len)
+
+ Description:
+ Depricated in MCHPFSUSB v2.3. This macro has been replaced by
+ USBUSARTIsTxTrfReady().
+ *****************************************************************************/
+#define mUSBUSARTIsTxTrfReady() USBUSARTIsTxTrfReady()
+
+/******************************************************************************
+ Function:
+ void mUSBUSARTTxRam(BYTE *pData, BYTE len)
+
+ Description:
+ Use this macro to transfer data located in data memory.
+ Use this macro when:
+ 1. Data stream is not null-terminated
+ 2. Transfer length is known
+ Remember: cdc_trf_state must == CDC_TX_READY
+ Unlike putsUSBUSART, there is not code double checking
+ the transfer state. Unexpected behavior will occur if
+ this function is called when cdc_trf_state != CDC_TX_READY
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ mUSBUSARTTxRam(&UserDataBuffer[0], 200);
+ }
+
+
+ PreCondition:
+ cdc_trf_state must be in the CDC_TX_READY state.
+ Value of 'len' must be equal to or smaller than 255 bytes.
+ The USB stack should have reached the CONFIGURED_STATE prior
+ to calling this API function for the first time.
+
+ Paramters:
+ pDdata : Pointer to the starting location of data bytes
+ len : Number of bytes to be transferred
+
+ Return Values:
+ None
+
+ Remarks:
+ This macro only handles the setup of the transfer. The
+ actual transfer is handled by CDCTxService(). This macro
+ does not "double buffer" the data. The application firmware
+ should not modify the contents of the pData buffer until all
+ of the data has been sent, as indicated by the
+ USBUSARTIsTxTrfReady() function returning true, subsequent to
+ calling mUSBUSARTTxRam().
+
+
+ *****************************************************************************/
+#define mUSBUSARTTxRam(pData,len) \
+{ \
+ pCDCSrc.bRam = pData; \
+ cdc_tx_len = len; \
+ cdc_mem_type = USB_EP0_RAM; \
+ cdc_trf_state = CDC_TX_BUSY; \
+}
+
+/******************************************************************************
+ Function:
+ void mUSBUSARTTxRom(rom BYTE *pData, BYTE len)
+
+ Description:
+ Use this macro to transfer data located in program memory.
+ Use this macro when:
+ 1. Data stream is not null-terminated
+ 2. Transfer length is known
+
+ Remember: cdc_trf_state must == CDC_TX_READY
+ Unlike putrsUSBUSART, there is not code double checking
+ the transfer state. Unexpected behavior will occur if
+ this function is called when cdc_trf_state != CDC_TX_READY
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ mUSBUSARTTxRom(&SomeRomString[0], 200);
+ }
+
+
+ PreCondition:
+ cdc_trf_state must be in the CDC_TX_READY state.
+ Value of 'len' must be equal to or smaller than 255 bytes.
+
+ Parameters:
+ pDdata : Pointer to the starting location of data bytes
+ len : Number of bytes to be transferred
+
+ Return Values:
+ None
+
+ Remarks:
+ This macro only handles the setup of the transfer. The
+ actual transfer is handled by CDCTxService().
+
+ *****************************************************************************/
+#define mUSBUSARTTxRom(pData,len) \
+{ \
+ pCDCSrc.bRom = pData; \
+ cdc_tx_len = len; \
+ cdc_mem_type = USB_EP0_ROM; \
+ cdc_trf_state = CDC_TX_BUSY; \
+}
+
+/**************************************************************************
+ Function:
+ void CDCInitEP(void)
+
+ Summary:
+ This function initializes the CDC function driver. This function should
+ be called after the SET_CONFIGURATION command (ex: within the context of
+ the USBCBInitEP() function).
+ Description:
+ This function initializes the CDC function driver. This function sets
+ the default line coding (baud rate, bit parity, number of data bits,
+ and format). This function also enables the endpoints and prepares for
+ the first transfer from the host.
+
+ This function should be called after the SET_CONFIGURATION command.
+ This is most simply done by calling this function from the
+ USBCBInitEP() function.
+
+ Typical Usage:
+
+ void USBCBInitEP(void)
+ {
+ CDCInitEP();
+ }
+
+ Conditions:
+ None
+ Remarks:
+ None
+ **************************************************************************/
+void CDCInitEP(void);
+
+/******************************************************************************
+ Function:
+ void USBCheckCDCRequest(void)
+
+ Description:
+ This routine checks the most recently received SETUP data packet to
+ see if the request is specific to the CDC class. If the request was
+ a CDC specific request, this function will take care of handling the
+ request and responding appropriately.
+
+ PreCondition:
+ This function should only be called after a control transfer SETUP
+ packet has arrived from the host.
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ This function does not change status or do anything if the SETUP packet
+ did not contain a CDC class specific request.
+ *****************************************************************************/
+void USBCheckCDCRequest(void);
+
+
+/**************************************************************************
+ Function: void CDCNotificationHandler(void)
+ Summary: Checks for changes in DSR status and reports them to the USB host.
+ Description: Checks for changes in DSR pin state and reports any changes
+ to the USB host.
+ Conditions: CDCInitEP() must have been called previously, prior to calling
+ CDCNotificationHandler() for the first time.
+ Remarks:
+ This function is only implemented and needed when the
+ USB_CDC_SUPPORT_DSR_REPORTING option has been enabled. If the function is
+ enabled, it should be called periodically to sample the DSR pin and feed
+ the information to the USB host. This can be done by calling
+ CDCNotificationHandler() by itself, or, by calling CDCTxService() which
+ also calls CDCNotificationHandler() internally, when appropriate.
+ **************************************************************************/
+void CDCNotificationHandler(void);
+
+
+/**********************************************************************************
+ Function:
+ BOOL USBCDCEventHandler(USB_EVENT event, void *pdata, WORD size)
+
+ Summary:
+ Handles events from the USB stack, which may have an effect on the CDC
+ endpoint(s).
+
+ Description:
+ Handles events from the USB stack. This function should be called when
+ there is a USB event that needs to be processed by the CDC driver.
+
+ Conditions:
+ Value of input argument 'len' should be smaller than the maximum
+ endpoint size responsible for receiving bulk data from USB host for CDC
+ class. Input argument 'buffer' should point to a buffer area that is
+ bigger or equal to the size specified by 'len'.
+ Input:
+ event - the type of event that occured
+ pdata - pointer to the data that caused the event
+ size - the size of the data that is pointed to by pdata
+
+ **********************************************************************************/
+BOOL USBCDCEventHandler(USB_EVENT event, void *pdata, WORD size);
+
+
+/**********************************************************************************
+ Function:
+ BYTE getsUSBUSART(char *buffer, BYTE len)
+
+ Summary:
+ getsUSBUSART copies a string of BYTEs received through USB CDC Bulk OUT
+ endpoint to a user's specified location. It is a non-blocking function.
+ It does not wait for data if there is no data available. Instead it
+ returns '0' to notify the caller that there is no data available.
+
+ Description:
+ getsUSBUSART copies a string of BYTEs received through USB CDC Bulk OUT
+ endpoint to a user's specified location. It is a non-blocking function.
+ It does not wait for data if there is no data available. Instead it
+ returns '0' to notify the caller that there is no data available.
+
+ Typical Usage:
+
+ BYTE numBytes;
+ BYTE buffer[64]
+
+ numBytes = getsUSBUSART(buffer,sizeof(buffer)); //until the buffer is free.
+ if(numBytes \> 0)
+ {
+ //we received numBytes bytes of data and they are copied into
+ // the "buffer" variable. We can do something with the data
+ // here.
+ }
+
+ Conditions:
+ Value of input argument 'len' should be smaller than the maximum
+ endpoint size responsible for receiving bulk data from USB host for CDC
+ class. Input argument 'buffer' should point to a buffer area that is
+ bigger or equal to the size specified by 'len'.
+ Input:
+ buffer - Pointer to where received BYTEs are to be stored
+ len - The number of BYTEs expected.
+ Output:
+ BYTE - Returns a byte indicating the total number of bytes that were actually
+ received and copied into the specified buffer. The returned value
+ can be anything from 0 up to the len input value. A return value of 0
+ indicates that no new CDC bulk OUT endpoint data was available.
+
+ **********************************************************************************/
+BYTE getsUSBUSART(char *buffer, BYTE len);
+
+/******************************************************************************
+ Function:
+ void putUSBUSART(char *data, BYTE length)
+
+ Summary:
+ putUSBUSART writes an array of data to the USB. Use this version, is
+ capable of transfering 0x00 (what is typically a NULL character in any of
+ the string transfer functions).
+
+ Description:
+ putUSBUSART writes an array of data to the USB. Use this version, is
+ capable of transfering 0x00 (what is typically a NULL character in any of
+ the string transfer functions).
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ char data[] = {0x00, 0x01, 0x02, 0x03, 0x04};
+ putUSBUSART(data,5);
+ }
+
+
+ The transfer mechanism for device-to-host(put) is more flexible than
+ host-to-device(get). It can handle a string of data larger than the
+ maximum size of bulk IN endpoint. A state machine is used to transfer a
+ \long string of data over multiple USB transactions. CDCTxService()
+ must be called periodically to keep sending blocks of data to the host.
+
+ Conditions:
+ USBUSARTIsTxTrfReady() must return TRUE. This indicates that the last
+ transfer is complete and is ready to receive a new block of data. The
+ string of characters pointed to by 'data' must equal to or smaller than
+ 255 BYTEs.
+
+ Input:
+ char *data - pointer to a RAM array of data to be transfered to the host
+ BYTE length - the number of bytes to be transfered (must be less than 255).
+
+ *****************************************************************************/
+void putUSBUSART(char *data, BYTE Length);
+
+/******************************************************************************
+ Function:
+ void putsUSBUSART(char *data)
+
+ Summary:
+ putsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'puts', to transfer data from a RAM buffer.
+
+ Description:
+ putsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'puts', to transfer data from a RAM buffer.
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ char data[] = "Hello World";
+ putsUSBUSART(data);
+ }
+
+
+ The transfer mechanism for device-to-host(put) is more flexible than
+ host-to-device(get). It can handle a string of data larger than the
+ maximum size of bulk IN endpoint. A state machine is used to transfer a
+ \long string of data over multiple USB transactions. CDCTxService()
+ must be called periodically to keep sending blocks of data to the host.
+
+ Conditions:
+ USBUSARTIsTxTrfReady() must return TRUE. This indicates that the last
+ transfer is complete and is ready to receive a new block of data. The
+ string of characters pointed to by 'data' must equal to or smaller than
+ 255 BYTEs.
+
+ Input:
+ char *data - null\-terminated string of constant data. If a
+ null character is not found, 255 BYTEs of data
+ will be transferred to the host.
+
+ *****************************************************************************/
+void putsUSBUSART(char *data);
+
+
+/**************************************************************************
+ Function:
+ void putrsUSBUSART(const ROM char *data)
+
+ Summary:
+ putrsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'putrs', to transfer data literals and
+ data located in program memory.
+
+ Description:
+ putrsUSBUSART writes a string of data to the USB including the null
+ character. Use this version, 'putrs', to transfer data literals and
+ data located in program memory.
+
+ Typical Usage:
+
+ if(USBUSARTIsTxTrfReady())
+ {
+ putrsUSBUSART("Hello World");
+ }
+
+
+ The transfer mechanism for device-to-host(put) is more flexible than
+ host-to-device(get). It can handle a string of data larger than the
+ maximum size of bulk IN endpoint. A state machine is used to transfer a
+ \long string of data over multiple USB transactions. CDCTxService()
+ must be called periodically to keep sending blocks of data to the host.
+
+ Conditions:
+ USBUSARTIsTxTrfReady() must return TRUE. This indicates that the last
+ transfer is complete and is ready to receive a new block of data. The
+ string of characters pointed to by 'data' must equal to or smaller than
+ 255 BYTEs.
+
+ Input:
+ const ROM char *data - null\-terminated string of constant data. If a
+ null character is not found, 255 BYTEs of data
+ will be transferred to the host.
+
+ **************************************************************************/
+void putrsUSBUSART(const ROM char *data);
+
+/************************************************************************
+ Function:
+ void CDCTxService(void)
+
+ Summary:
+ CDCTxService handles device-to-host transaction(s). This function
+ should be called once per Main Program loop after the device reaches
+ the configured state.
+ Description:
+ CDCTxService handles device-to-host transaction(s). This function
+ should be called once per Main Program loop after the device reaches
+ the configured state (after the CDCIniEP() function has already executed).
+ This function is needed, in order to advance the internal software state
+ machine that takes care of sending multiple transactions worth of IN USB
+ data to the host, associated with CDC serial data. Failure to call
+ CDCTxService() perioidcally will prevent data from being sent to the
+ USB host, over the CDC serial data interface.
+
+ Typical Usage:
+
+ void main(void)
+ {
+ USBDeviceInit();
+ while(1)
+ {
+ USBDeviceTasks();
+ if((USBGetDeviceState() \< CONFIGURED_STATE) ||
+ (USBIsDeviceSuspended() == TRUE))
+ {
+ //Either the device is not configured or we are suspended
+ // so we don't want to do execute any application code
+ continue; //go back to the top of the while loop
+ }
+ else
+ {
+ //Keep trying to send data to the PC as required
+ CDCTxService();
+
+ //Run application code.
+ UserApplication();
+ }
+ }
+ }
+
+ Conditions:
+ CDCIniEP() function should have already exectuted/the device should be
+ in the CONFIGURED_STATE.
+ Remarks:
+ None
+ ************************************************************************/
+void CDCTxService(void);
+
+
+/** S T R U C T U R E S ******************************************************/
+
+/* Line Coding Structure */
+#define LINE_CODING_LENGTH 0x07
+
+typedef union _LINE_CODING
+{
+ struct
+ {
+ BYTE _byte[LINE_CODING_LENGTH];
+ };
+ struct
+ {
+ DWORD_VAL dwDTERate; // Complex data structure
+ BYTE bCharFormat;
+ BYTE bParityType;
+ BYTE bDataBits;
+ };
+} LINE_CODING;
+
+typedef union _CONTROL_SIGNAL_BITMAP
+{
+ BYTE _byte;
+ struct
+ {
+ unsigned DTE_PRESENT:1; // [0] Not Present [1] Present
+ unsigned CARRIER_CONTROL:1; // [0] Deactivate [1] Activate
+ };
+} CONTROL_SIGNAL_BITMAP;
+
+
+/* Functional Descriptor Structure - See CDC Specification 1.1 for details */
+
+/* Header Functional Descriptor */
+typedef struct __attribute__((packed)) _USB_CDC_HEADER_FN_DSC
+{
+ BYTE bFNLength;
+ BYTE bDscType;
+ BYTE bDscSubType;
+ WORD bcdCDC;
+} USB_CDC_HEADER_FN_DSC;
+
+/* Abstract Control Management Functional Descriptor */
+typedef struct __attribute__((packed)) _USB_CDC_ACM_FN_DSC
+{
+ BYTE bFNLength;
+ BYTE bDscType;
+ BYTE bDscSubType;
+ BYTE bmCapabilities;
+} USB_CDC_ACM_FN_DSC;
+
+/* Union Functional Descriptor */
+typedef struct __attribute__((packed)) _USB_CDC_UNION_FN_DSC
+{
+ BYTE bFNLength;
+ BYTE bDscType;
+ BYTE bDscSubType;
+ BYTE bMasterIntf;
+ BYTE bSaveIntf0;
+} USB_CDC_UNION_FN_DSC;
+
+/* Call Management Functional Descriptor */
+typedef struct __attribute__((packed)) _USB_CDC_CALL_MGT_FN_DSC
+{
+ BYTE bFNLength;
+ BYTE bDscType;
+ BYTE bDscSubType;
+ BYTE bmCapabilities;
+ BYTE bDataInterface;
+} USB_CDC_CALL_MGT_FN_DSC;
+
+typedef union __attribute__((packed)) _CDC_NOTICE
+{
+ LINE_CODING GetLineCoding;
+ LINE_CODING SetLineCoding;
+ unsigned char packet[CDC_COMM_IN_EP_SIZE];
+} CDC_NOTICE, *PCDC_NOTICE;
+
+/* Bit structure definition for the SerialState notification byte */
+typedef union
+{
+ BYTE byte;
+ struct
+ {
+ BYTE DCD :1;
+ BYTE DSR :1;
+ BYTE BreakState :1;
+ BYTE RingDetect :1;
+ BYTE FramingError :1;
+ BYTE ParityError :1;
+ BYTE Overrun :1;
+ BYTE Reserved :1;
+ }bits;
+}BM_SERIAL_STATE;
+
+/* Serial State Notification Packet Structure */
+typedef struct
+{
+ BYTE bmRequestType; //Always 0xA1 for serial state notification packets
+ BYTE bNotification; //Always SERIAL_STATE (0x20) for serial state notification packets
+ UINT16 wValue; //Always 0 for serial state notification packets
+ UINT16 wIndex; //Interface number
+ UINT16 wLength; //Should always be 2 for serial state notification packets
+ BM_SERIAL_STATE SerialState;
+ BYTE Reserved;
+}SERIAL_STATE_NOTIFICATION;
+
+
+/** E X T E R N S ************************************************************/
+extern BYTE cdc_rx_len;
+extern USB_HANDLE lastTransmission;
+
+extern BYTE cdc_trf_state;
+extern POINTER pCDCSrc;
+extern BYTE cdc_tx_len;
+extern BYTE cdc_mem_type;
+
+extern volatile FAR CDC_NOTICE cdc_notice;
+extern LINE_CODING line_coding;
+
+extern volatile CTRL_TRF_SETUP SetupPkt;
+extern ROM BYTE configDescriptor1[];
+
+/** Public Prototypes *************************************************/
+//------------------------------------------------------------------------------
+//This is the list of public API functions provided by usb_function_cdc.c.
+//This list is commented out, since the actual prototypes are declared above
+//with associated inline documentation.
+//------------------------------------------------------------------------------
+//void USBCheckCDCRequest(void);
+//void CDCInitEP(void);
+//BOOL USBCDCEventHandler(USB_EVENT event, void *pdata, WORD size);
+//BYTE getsUSBUSART(char *buffer, BYTE len);
+//void putUSBUSART(char *data, BYTE Length);
+//void putsUSBUSART(char *data);
+//void putrsUSBUSART(const ROM char *data);
+//void CDCTxService(void);
+//void CDCNotificationHandler(void);
+//------------------------------------------------------------------------------
+
+
+
+#endif //CDC_H
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb_hal.h b/Source/USB/USB2.9i_cdc/include/USB/usb_hal.h
new file mode 100644
index 0000000..0defc19
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb_hal.h
@@ -0,0 +1,653 @@
+/******************************************************************************
+
+ USB Hardware Abstraction Layer (HAL) (Header File)
+
+Summary:
+ This file abstracts the hardware interface.
+
+Description:
+ This file abstracts the hardware interface.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+ ..\\..\\MicrochipInclude
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+*******************************************************************************/
+//DOM-IGNORE-BEGIN
+/******************************************************************************
+
+ File Description:
+
+ This file defines the interface to the USB hardware abstraction layer.
+
+ Filename: usb_hal.h
+ Dependancies: none
+ Processor: PIC18, PIC24, or PIC32 USB Microcontrollers
+ Hardware: The code is natively intended to be used on the following
+ hardware platforms: PICDEM™ FS USB Demo Board,
+ PIC18F87J50 FS USB Plug-In Module, or
+ Explorer 16 + PIC24 USB PIM. The firmware may be
+ modified for use on other USB platforms by editing the
+ HardwareProfile.h file.
+ Compiler: Microchip C18 (for PIC18) or C30 (for PIC24)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PICmicro® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PICmicro Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+ *************************************************************************/
+
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.6- No Change
+ 2.6a
+
+ 2.7 Minor changes changes to the structure of the conditional
+ compilation statement ordering.
+
+ 2.7a No Change
+********************************************************************/
+
+#ifndef _USB_HAL_H_
+#define _USB_HAL_H_
+//DOM-IGNORE-END
+
+#if defined(__18CXX)
+ #include "USB/usb_hal_pic18.h"
+#elif defined(__C30__) || defined __XC16__
+ #if defined(__dsPIC33E__)
+ #include "USB/usb_hal_dspic33E.h"
+ #elif defined(__PIC24E__)
+ #include "USB/usb_hal_pic24e.h"
+ #else
+ #include "USB/usb_hal_pic24.h"
+ #endif
+#elif defined(__PIC32MX__)
+ #include "USB/usb_hal_pic32.h"
+#elif defined(_PIC14E)
+ #include "USB/usb_hal_pic16f1.h"
+#else
+ #error "Silicon Platform not defined"
+#endif
+
+
+/**********************
+ Interface Routines
+ **********************/
+
+/*************************************************************************
+ Function:
+ void USBHALSetBusAddress( BYTE addr )
+
+ Description:
+ This routine sets the address of the system on the USB
+ when acting as a peripheral device.
+
+ Preconditions:
+ 1. USBHALInitialize must have been called to
+ initialize the USB HAL.
+ 2. Endpoint zero (0) must be configured as appropriate
+ by calls to USBHALSetEpConfiguration.
+ 3. The system must have been enumerated on the USB (as
+ a device).
+
+ Parameters:
+ addr Desired address of this device on the USB.
+
+ Return Values:
+ None
+
+ Side Effect:
+ The bus address has been set.
+
+ Remmarks:
+ The address is assigned by the host and is received in
+ a SET_ADDRESS setup request.
+
+ *************************************************************************/
+/*
+ This routine is implemented as a macro to a lower-level level routine.
+ */
+
+#define USBHALSetBusAddress OTGCORE_SetDeviceAddr
+
+void USBHALSetBusAddress( BYTE addr );
+
+
+/*************************************************************************
+ Function:
+ void USBHALControlUsbResistors( BYTE flags );
+
+ Description:
+ This routine enables or disables the USB pull-up or
+ pull-down resistors as requested.
+
+ Precondition:
+ USBInitialize must have been called to initialize the
+ USB SW stack.
+
+ Parameters:
+ flags - This is a bit-mapped flags value indicating
+ which resistors to enable or disable (see below).
+
+ Return Values:
+ TRUE if successful, FALSE if not.
+
+ Side Effects:
+ The resistors are enabled as requested.
+
+ Remarks:
+ Used for USB peripheral control to connect to or
+ disconnect from the bus. Otherwise, used for OTG
+ SRP/HNP and host support.
+
+ *************************************************************************/
+
+/*
+ This routine is implemented as a macro to a lower-level level routine.
+ */
+ #if defined(__18CXX)
+ void USBHALControlUsbResistors( BYTE flags );
+ #else
+ #define USBHALControlUsbResistors OTGCORE_ControlUsbResistors
+ void USBHALControlUsbResistors( BYTE flags );
+#endif
+
+/* USBHALControlUsbResistors flags */
+#define USB_HAL_PULL_UP_D_PLUS 0x80 // Pull D+ line high
+#define USB_HAL_PULL_UP_D_MINUS 0x40 // Pull D- line high
+#define USB_HAL_PULL_DN_D_PLUS 0x20 // Pull D+ line low
+#define USB_HAL_PULL_DN_D_MINUS 0x10 // Pull D- line low
+/*
+ The following are defined for convenience:
+ */
+#define USB_HAL_DEV_CONN_FULL_SPD USB_HAL_PULL_UP_D_PLUS
+#define USB_HAL_DEV_CONN_LOW_SPD USB_HAL_PULL_UP_D_MINUS
+#define USB_HAL_DEV_DISCONNECT 0
+
+
+/*
+ MCHP: Define a method to check for SE0 & a way to send a reset (SE0).
+ */
+
+
+/*************************************************************************
+ Function:
+ BOOL USBHALSessionIsValid( void )
+
+ Description:
+ This routine determines if there is currently a valid
+ USB session or not.
+
+ Precondition:
+ USBInitialize must have been called to initialize the
+ USB SW stack.
+
+ Parameters:
+ None
+
+ Return Values:
+ TRUE if the session is currently valid, FALSE if not.
+
+ Remarks:
+ Only used for host and OTG support.
+
+ *************************************************************************/
+
+BOOL USBHALSessionIsValid( void );
+
+
+/*************************************************************************
+ Function:
+ USBHALControlBusPower
+
+ Description:
+ This routine provides a bitmap of the most recent
+ error conditions to occur.
+
+ Precondition:
+ USBInitialize must have been called to initialize the
+ USB SW stack.
+
+ Parameters:
+ cmd - Identifies desired command (see below).
+
+ Return Values:
+ TRUE if successful, FALSE if not.
+
+ Remarks:
+ Only used for host and OTG support.
+
+ *************************************************************************/
+
+BOOL USBHALControlBusPower( BYTE cmd );
+
+/* USBHALControlBusPower Commands */
+#define USB_VBUS_DISCHARGE 0 // Dicharge Vbus via resistor
+#define USB_VBUS_CHARGE 1 // Charge Vbus via resistor
+#define USB_VBUS_POWER_ON 3 // Supply power to Vbus
+#define USB_VBUS_POWER_OFF 4 // Do not supply power to Vbus
+/*
+ Note: All commands except USB_VBUS_POWER_ON imply that this device
+ does not actively supply power to Vbus.
+ */
+
+
+/*************************************************************************
+ Function:
+ unsigned long USBHALGetLastError( void )
+
+ Description:
+ This routine provides a bitmap of the most recent
+ error conditions to occur.
+
+ Precondition:
+ USBInitialize must have been called to initialize the
+ USB SW stack.
+
+ Parameters:
+ None
+
+ Return Values:
+ Bitmap indicating the most recent error condition(s).
+
+ Side Effect:
+ Error record is cleared.
+
+ Remarks:
+ Although record of the error state is cleared, nothing
+ is done to fix the condition or recover from the
+ error. The client must take appropriate steps.
+
+ *************************************************************************/
+
+unsigned long USBHALGetLastError( void );
+
+/*
+ USBHALGetLastError Error Bits.
+ */
+#define USBHAL_PID_ERR 0x00000001 // Packet ID Error
+#define USBHAL_CRC5 0x00000002 // (Host) Token CRC5 check failed
+#define USBHAL_HOST_EOF 0x00000002 // (Host) EOF not reached before next SOF
+#define USBHAL_CRC16 0x00000004 // Data packet CRC error
+#define USBHAL_DFN8 0x00000008 // Data field size not n*8 bits
+#define USBHAL_BTO_ERR 0x00000010 // Bus turn-around timeout
+#define USBHAL_DMA_ERR 0x00000020 // DMA error, unable to read/write memory
+#define USBHAL_BTS_ERR 0x00000080 // Bit-stuffing error
+#define USBHAL_XFER_ID 0x00000100 // Unable to identify transfer EP
+#define USBHAL_NO_EP 0x00000200 // Invalid endpoint number
+#define USBHAL_DMA_ERR2 0x00000400 // Error starting DMA transaction
+
+
+/*************************************************************************
+ Function:
+ void USBHALHandleBusEvent ( void )
+
+ Description:
+ This routine checks the USB for any events that may
+ have occured and handles them appropriately. It may
+ be called directly to poll the USB and handle events
+ or it may be called in response to an interrupt.
+
+ Precondition:
+ USBInitialize must have been called to initialize the
+ USB SW stack.
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Side Effects:
+ Depend on the event that may have occured.
+
+ Remarks:
+ None
+
+ *************************************************************************/
+
+void USBHALHandleBusEvent ( void );
+
+
+/*************************************************************************
+ Function:
+ BOOL USBHALStallPipe( TRANSFER_FLAGS pipe )
+
+ Description:
+ This routine stalls the given endpoint.
+
+ Preconditions:
+ USBHALInitialize must have been called to initialize
+ the USB HAL.
+
+ Parameters:
+ pipe - Uses the TRANSFER_FLAGS (see USBCommon.h) format to
+ identify the endpoint and direction making up the
+ pipe to stall.
+
+ Note: Only ep_num and direction fields are required.
+
+ Return Values:
+ TRUE if able to stall endpoint, FALSE if not.
+
+ Side Effects:
+ The endpoint will stall if additional data transfer is
+ attempted.
+ Given endpoint has been stalled.
+
+ Remarks:
+ Starting another data transfer automatically
+ "un-stalls" the endpoint.
+
+ *************************************************************************/
+/*
+ Note: This function is implemented as a macro, calling directly into
+ an internal HAL routine.
+ */
+
+#define USBHALStallPipe OTGCORE_StallPipe
+
+BOOL USBHALStallPipe( TRANSFER_FLAGS pipe );
+
+
+/******************************************************************************
+ Function:
+ BOOL USBHALUnstallPipe( TRANSFER_FLAGS pipe )
+
+ Description:
+ This routine clears the stall condition for the given pipe.
+
+ PreCondition:
+ Assumes OTGCORE_DeviceEnable has been called and
+ OTGCORE_StallPipe has been called on the given pipe.
+
+ Parameters:
+ pipe - Uses the TRANSFER_FLAGS (see USBCommon.h) format to
+ identify the endpoint and direction making up the
+ pipe to unstall.
+
+ Return Values:
+ TRUE if able to stall the pipe, FALSE if not.
+
+ Side Effects:
+ The BSTALL and UOWN bits (and all other control bits) in
+ the BDT for the given pipe will be cleared.
+
+ Remarks:
+ None
+
+ *****************************************************************************/
+/*
+ Note: This function is implemented as a macro, calling directly into
+ an internal HAL routine.
+ */
+
+#define USBHALUnstallPipe OTGCORE_UnstallPipe
+
+BOOL USBHALUnstallPipe( TRANSFER_FLAGS pipe );
+
+
+/**************************************************************************
+ Function:
+ USBHALGetStalledEndpoints
+
+ Description:
+ This function returns a 16-bit bitmapped value with a
+ bit set in the position of any endpoint that is stalled
+ (i.e. if endpoint 0 is stalled then bit 0 is set, if
+ endpoint 1 is stalled then bit 1 is set, etc.).
+
+ Preconditions:
+ USBHALInitialize must have been called to initialize
+ the USB HAL.
+
+ Parameters:
+ None
+
+ Return Values:
+ Bitmap of the currently stalled endpoints (see overview).
+
+ Remarks:
+ None
+ *************************************************************************/
+
+/*
+ Note: This function is implemented as a macro, calling directly into
+ a HAL routine.
+ */
+
+#define USBHALGetStalledEndpoints OTGCORE_GetStalledEndpoints
+
+UINT16 USBHALGetStalledEndpoints ( void );
+
+
+/******************************************************************************
+ Function:
+ BOOL USBHALFlushPipe( TRANSFER_FLAGS pipe )
+
+ Description:
+ This routine clears any pending transfers on the given
+ pipe.
+
+ Preconditions:
+ USBHALInitialize must have been called to initialize the
+ USB HAL.
+
+ The caller must ensure that there is no possible way for
+ hardware to be currently accessing the pipe (see notes).
+
+ Parameters:
+ pipe - Uses the TRANSFER_FLAGS (see USBCommon.h) format to
+ identify the endpoint and direction making up the
+ pipe to flush.
+
+ Return Values:
+ TRUE if successful, FALSE if not.
+
+ Side Effects:
+ Transfer data for this pipe has been zero'd out.
+
+ Remarks:
+ This routine ignores the normal HW protocol for ownership
+ of the pipe data and flushes the pipe, even if it is in
+ process. Thus, the caller must ensure that data transfer
+ cannot be in process. This situation occurs when a
+ transfer has been terminated early by the host.
+ *****************************************************************************/
+
+BOOL USBHALFlushPipe( TRANSFER_FLAGS pipe );
+
+
+/**************************************************************************
+ Function:
+ USBHALTransferData
+
+ Description:
+ This routine prepares to transfer data on the USB.
+ If the system is in device mode, the actual transfer
+ will not occur until the host peforms an OUT request
+ to the given endpoint. If the system is in host mode,
+ the transfer will not start until the token has been
+ sent on the bus.
+
+ Preconditions:
+ 1. USBHALInitialize must have been called to
+ initialize the USB HAL.
+ 2. The endpoint through which the data will be
+ transferred must be configured as appropriate by a
+ call to USBHALSetEpConfiguration.
+ 3. The bus must have been enumerated (either as a host
+ or device). Except for EP0 transfers.
+
+ Parameters:
+ flags - Flags consists of the endpoint number OR'd
+ with one or more flags indicating transfer
+ direction and such (see "Data Transfer
+ Macros" in USBCommon.h):
+
+ 7 6 5 4 3 2 1 0 - Description
+ | | | | \_____/
+ | | | | +----- Endpoint Number
+ | | | +---------- Short or zero-size pkt
+ | | +------------ Data Toggle 0/1
+ | +-------------- Force Data Toggle
+ +---------------- 1=Transmit/0=Receive
+
+ buffer Address of the buffer to receive data.
+
+ size Number of bytes of data to transfer.
+
+ Return Values:
+ TRUE if the HAL was able to successfully start the
+ data transfer, FALSE if not.
+
+ Side Effects:
+ The HAL has prepared to transfer the data on the USB.
+
+ Ramarks:
+ The HAL will continue the data transfer, keeping track
+ of the buffer address, data remaining, and ping-pong
+ buffer details internally when USBHALHandleBusEvent is
+ called (either polled or in response to an interrupt).
+ The caller will receive notification that the transfer
+ has completed when the EVT_XFER event is passed into
+ the USBHALBusEventCallout call-out function.
+
+ *************************************************************************/
+
+BOOL USBHALTransferData ( TRANSFER_FLAGS flags,
+ void *buffer,
+ unsigned int size );
+
+
+/*************************************************************************
+ Function:
+ USBHALSetEpConfiguration
+
+ Description:
+ This routine allows the caller to configure various
+ options (see "Flags for USBHALSetEpConfiguration",
+ below) and set the behavior for the given endpoint.
+
+ Precondition:
+ USBHALInitialize has been called.
+
+ Parameters:
+ ep_num - Number of endpoint to configur, Must be
+ (ep_num >=0) && (ep_num <= USB_DEV_HIGHEST_EP_NUMBER)
+ max_pkt_size Size of largest packet this enpoint can
+ transfer.
+
+ flags - Configuration flags (see below)
+
+ Return Values:
+ TRUE if successful, FALSE if not.
+
+ Side Effects:
+ The endpoint has been configured as desired.
+
+ Remarks:
+ The base address and size of the buffer is not set by
+ this routine. Those features of an endpoint are
+ dynamically managed by the USBHALTransferData routine.
+ An endpoint can be "de-configured" by setting its max
+ packet size to 0. When doing this, you should also
+ set all flags to 0.
+ *************************************************************************/
+
+BOOL USBHALSetEpConfiguration ( BYTE ep_num, UINT16 max_pkt_size, UINT16 flags );
+
+/* Flags for USBHALSetEpConfiguration */
+#if defined(__18CXX)
+ #define USB_HAL_TRANSMIT 0x0400 // Enable EP for transmitting data
+ #define USB_HAL_RECEIVE 0x0200 // Enable EP for receiving data
+ #define USB_HAL_HANDSHAKE 0x1000 // Enable EP to give ACK/NACK (non isoch)
+
+ #define USB_HAL_NO_INC 0x0010 // Use for DMA to another device FIFO
+ #define USB_HAL_HW_KEEPS 0x0020 // Cause HW to keep EP
+#else
+ #define USB_HAL_TRANSMIT 0x0400 // Enable EP for transmitting data
+ #define USB_HAL_RECEIVE 0x0800 // Enable EP for receiving data
+ #define USB_HAL_HANDSHAKE 0x0100 // Enable EP to give ACK/NACK (non isoch)
+
+ /* Does not work, Fix this if needed. 3/1/07 - Bud
+ #define USB_HAL_NO_INC 0x0010 // Use for DMA to another device FIFO
+ #define USB_HAL_HW_KEEPS 0x0020 // Cause HW to keep EP
+ */
+ #define USB_HAL_ALLOW_HUB 0x8000 // (host only) Enable low-spd hub support
+ #define USB_HAL_NO_RETRY 0x4000 // (host only) disable auto-retry on NACK
+#endif
+
+
+/*************************************************************************
+ Function:
+ USBHALInitialize
+
+ Description:
+ This call performs the basic initialization of the USB
+ HAL. This routine must be called before any of the
+ other HAL interface routines are called.
+
+ Precondition:
+ The system has been initialized.
+
+ Paramters:
+ flags - Initialization flags
+
+ Return Values:
+ TRUE if successful, FALSE if not.
+
+ Side Effects:
+ The USB HAL SW stack was initialized.
+
+ Remarks:
+ This routine can be called to reset the controller.
+
+ *************************************************************************/
+
+BOOL USBHALInitialize ( unsigned long flags );
+
+#endif // _USB_HAL_H_
+/*************************************************************************
+ * EOF
+ */
+
diff --git a/Source/USB/USB2.9i_cdc/include/USB/usb_hal_pic18.h b/Source/USB/USB2.9i_cdc/include/USB/usb_hal_pic18.h
new file mode 100644
index 0000000..50188bc
--- /dev/null
+++ b/Source/USB/USB2.9i_cdc/include/USB/usb_hal_pic18.h
@@ -0,0 +1,600 @@
+/******************************************************************************
+
+ USB Hardware Abstraction Layer (HAL) (Header File)
+
+Summary:
+ This file abstracts the hardware interface. The USB stack firmware can be
+ compiled to work on different USB microcontrollers, such as PIC18 and PIC24.
+ The USB related special function registers and bit names are generally very
+ similar between the device families, but small differences in naming exist.
+
+Description:
+ This file abstracts the hardware interface. The USB stack firmware can be
+ compiled to work on different USB microcontrollers, such as PIC18 and PIC24.
+ The USB related special function registers and bit names are generally very
+ similar between the device families, but small differences in naming exist.
+
+ In order to make the same set of firmware work accross the device families,
+ when modifying SFR contents, a slightly abstracted name is used, which is
+ then "mapped" to the appropriate real name in the usb_hal_picxx.h header.
+
+ Make sure to include the correct version of the usb_hal_picxx.h file for
+ the microcontroller family which will be used.
+
+ This file is located in the "\\\Microchip\\Include\\USB"
+ directory.
+
+ When including this file in a new project, this file can either be
+ referenced from the directory in which it was installed or copied
+ directly into the user application folder. If the first method is
+ chosen to keep the file located in the folder in which it is installed
+ then include paths need to be added so that the library and the
+ application both know where to reference each others files. If the
+ application folder is located in the same folder as the Microchip
+ folder (like the current demo folders), then the following include
+ paths need to be added to the application's project:
+
+ .
+
+ ..\\..\\MicrochipInclude
+
+ If a different directory structure is used, modify the paths as
+ required. An example using absolute paths instead of relative paths
+ would be the following:
+
+ C:\\Microchip Solutions\\Microchip\\Include
+
+ C:\\Microchip Solutions\\My Demo Application
+
+*******************************************************************************/
+//DOM-IGNORE-BEGIN
+/******************************************************************************
+
+ File Description:
+
+ This file defines the interface to the USB hardware abstraction layer.
+
+ * Filename: usb_hal_pic18.h
+ Dependencies: See INCLUDES section
+ Processor: Use this header file when using this firmware with PIC18 USB
+ microcontrollers
+ Hardware:
+ Complier: Microchip C18 (for PIC18)
+ Company: Microchip Technology, Inc.
+
+ Software License Agreement:
+
+ The software supplied herewith by Microchip Technology Incorporated
+ (the “Company”) for its PIC® Microcontroller is intended and
+ supplied to you, the Company’s customer, for use solely and
+ exclusively on Microchip PIC Microcontroller products. The
+ software is owned by the Company and/or its supplier, and is
+ protected under applicable copyright laws. All rights are reserved.
+ Any use in violation of the foregoing restrictions may subject the
+ user to criminal sanctions under applicable laws, as well as to
+ civil liability for the breach of the terms and conditions of this
+ license.
+
+ THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
+ WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
+ TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
+ IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
+ CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
+
+ *************************************************************************/
+
+//DOM-IGNORE-BEGIN
+/********************************************************************
+ Change History:
+ Rev Description
+ ---- -----------
+ 2.6 Changed the inplementation of the interrupt clearing macro
+ to be more efficient.
+
+ 2.6a Added DisableNonZeroEndpoints() function
+
+ 2.7 Added ConvertToPhysicalAddress() and ConvertToVirtualAddress()
+ macros. Needed for compatiblity with PIC32.
+
+ Added USBDisableInterrupts() macro. Fixes issue in dual role
+ example where a device in polling mode can still have interrupts
+ enabled from the host mode causing an incorrect vectoring to the
+ host interrupt controller while in device mode.
+
+ 2.7a No change
+
+ 2.8 Added USTAT_FIELDS typedef and associated macros.
+********************************************************************/
+//DOM-IGNORE-END
+
+#ifndef USB_HAL_PIC18_H
+#define USB_HAL_PIC18_H
+
+/*****************************************************************************/
+/****** include files ********************************************************/
+/*****************************************************************************/
+
+#include "Compiler.h"
+#include "usb_config.h"
+
+/*****************************************************************************/
+/****** Constant definitions *************************************************/
+/*****************************************************************************/
+
+//----- USBEnableEndpoint() input defintions ----------------------------------
+#define USB_HANDSHAKE_ENABLED 0x10
+#define USB_HANDSHAKE_DISABLED 0x00
+
+#define USB_OUT_ENABLED 0x04
+#define USB_OUT_DISABLED 0x00
+
+#define USB_IN_ENABLED 0x02
+#define USB_IN_DISABLED 0x00
+
+#define USB_ALLOW_SETUP 0x00
+#define USB_DISALLOW_SETUP 0x08
+
+#define USB_STALL_ENDPOINT 0x01
+
+//----- usb_config.h input defintions -----------------------------------------
+#define USB_PULLUP_ENABLE 0x10
+#define USB_PULLUP_DISABLED 0x00
+
+#define USB_INTERNAL_TRANSCEIVER 0x00
+#define USB_EXTERNAL_TRANSCEIVER 0x08
+
+#define USB_FULL_SPEED 0x04
+#define USB_LOW_SPEED 0x00
+
+//----- Interrupt Flag definitions --------------------------------------------
+#define USBTransactionCompleteIE UIEbits.TRNIE
+#define USBTransactionCompleteIF UIRbits.TRNIF
+#define USBTransactionCompleteIFReg UIR
+#define USBTransactionCompleteIFBitNum 0xF7 //AND mask for clearing TRNIF bit position 4
+
+#define USBResetIE UIEbits.URSTIE
+#define USBResetIF UIRbits.URSTIF
+#define USBResetIFReg UIR
+#define USBResetIFBitNum 0xFE //AND mask for clearing URSTIF bit position 0
+
+#define USBIdleIE UIEbits.IDLEIE
+#define USBIdleIF UIRbits.IDLEIF
+#define USBIdleIFReg UIR
+#define USBIdleIFBitNum 0xEF //AND mask for clearing IDLEIF bit position 5
+
+#define USBActivityIE UIEbits.ACTVIE
+#define USBActivityIF UIRbits.ACTVIF
+#define USBActivityIFReg UIR
+#define USBActivityIFBitNum 0xFB //AND mask for clearing ACTVIF bit position 2
+
+#define USBSOFIE UIEbits.SOFIE
+#define USBSOFIF UIRbits.SOFIF
+#define USBSOFIFReg UIR
+#define USBSOFIFBitNum 0xBF //AND mask for clearing SOFIF bit position 6
+
+#define USBStallIE UIEbits.STALLIE
+#define USBStallIF UIRbits.STALLIF
+#define USBStallIFReg UIR
+#define USBStallIFBitNum 0xDF //AND mask for clearing STALLIF bit position 5
+
+#define USBErrorIE UIEbits.UERRIE
+#define USBErrorIF UIRbits.UERRIF
+#define USBErrorIFReg UIR
+#define USBErrorIFBitNum 0xFD //UERRIF bit position 1. Note: This bit is read only and is cleared by clearing the enabled UEIR flags
+
+//----- Event call back defintions --------------------------------------------
+#if defined(USB_DISABLE_SOF_HANDLER)
+ #define USB_SOF_INTERRUPT 0x00
+#else
+ #define USB_SOF_INTERRUPT 0x40
+#endif
+
+#if defined(USB_DISABLE_ERROR_HANDLER)
+ #define USB_ERROR_INTERRUPT 0x02
+#else
+ #define USB_ERROR_INTERRUPT 0x02
+#endif
+
+//----- USB module control bits -----------------------------------------------
+#define USBPingPongBufferReset UCONbits.PPBRST
+#define USBSE0Event UCONbits.SE0
+#define USBSuspendControl UCONbits.SUSPND
+#define USBPacketDisable UCONbits.PKTDIS
+#define USBResumeControl UCONbits.RESUME
+
+//----- BDnSTAT bit definitions -----------------------------------------------
+#define _BSTALL 0x04 //Buffer Stall enable
+#define _DTSEN 0x08 //Data Toggle Synch enable
+#define _INCDIS 0x10 //Address increment disable
+#define _KEN 0x20 //SIE keeps buff descriptors enable
+#define _DAT0 0x00 //DATA0 packet expected next
+#define _DAT1 0x40 //DATA1 packet expected next
+#define _DTSMASK 0x40 //DTS Mask
+#define _USIE 0x80 //SIE owns buffer
+#define _UCPU 0x00 //CPU owns buffer
+#define _STAT_MASK 0xFF
+
+#define USTAT_EP0_PP_MASK ~0x02
+#define USTAT_EP_MASK 0x7E
+#define USTAT_EP0_OUT 0x00
+#define USTAT_EP0_OUT_EVEN 0x00
+#define USTAT_EP0_OUT_ODD 0x02
+#define USTAT_EP0_IN 0x04
+#define USTAT_EP0_IN_EVEN 0x04
+#define USTAT_EP0_IN_ODD 0x06
+
+#define ENDPOINT_MASK 0b01111000
+
+//----- U1EP bit definitions --------------------------------------------------
+#define UEP_STALL 0x0001
+// Cfg Control pipe for this ep
+/* Endpoint configuration options for USBEnableEndpoint() function */
+#define EP_CTRL 0x06 // Cfg Control pipe for this ep
+#define EP_OUT 0x0C // Cfg OUT only pipe for this ep
+#define EP_IN 0x0A // Cfg IN only pipe for this ep
+#define EP_OUT_IN 0x0E // Cfg both OUT & IN pipes for this ep
+
+//----- Remap the PIC18 register name space------------------------------------
+#define U1ADDR UADDR
+#define U1IE UIE
+#define U1IR UIR
+#define U1EIR UEIR
+#define U1EIE UEIE
+#define U1CON UCON
+#define U1EP0 UEP0
+#define U1CONbits UCONbits
+#define U1EP1 UEP1
+#define U1CNFG1 UCFG
+#define U1STAT USTAT
+#define U1EP0bits UEP0bits
+
+//----- Defintions for BDT address --------------------------------------------
+#if defined(__18CXX)
+ #if defined(__18F14K50) || defined(__18F13K50) || defined(__18LF14K50) || defined(__18LF13K50)
+ #define USB_BDT_ADDRESS 0x200 //See Linker Script, BDT in bank 2 on these devices - usb2:0x200-0x2FF(256-byte)
+ #elif defined(__18F47J53) || defined(__18F46J53) || defined(__18F27J53) || defined(__18F26J53) || defined(__18LF47J53) || defined(__18LF46J53) || defined(__18LF27J53) || defined(__18LF26J53)
+ #define USB_BDT_ADDRESS 0xD00 //BDT in Bank 13 on these devices
+ #elif defined(__18F97J94) || defined(__18F87J94) || defined(__18F67J94) || defined(__18F96J94) || defined(__18F86J94) || defined(__18F66J94) || defined(__18F96J99) || defined(__18F95J94) || defined(__18F86J99) || defined(__18F85J94) || defined(__18F66J99) || defined(__18F65J94)
+ #define USB_BDT_ADDRESS 0x100 //BDT in Bank 1 on these devices
+ #else
+ #define USB_BDT_ADDRESS 0x400 //All other PIC18 devices place the BDT in usb4:0x400-0x4FF(256-byte)
+ #endif
+#endif
+
+#define BDT_BASE_ADDR_TAG __attribute__ ((aligned (512)))
+#define CTRL_TRF_SETUP_ADDR_TAG
+#define CTRL_TRF_DATA_ADDR_TAG
+
+//----- Depricated defintions - will be removed at some point of time----------
+//--------- Depricated in v2.2
+#define _LS 0x00 // Use Low-Speed USB Mode
+#define _FS 0x04 // Use Full-Speed USB Mode
+#define _TRINT 0x00 // Use internal transceiver
+#define _TREXT 0x08 // Use external transceiver
+#define _PUEN 0x10 // Use internal pull-up resistor
+#define _OEMON 0x40 // Use SIE output indicator
+
+/*****************************************************************************/
+/****** Type definitions *****************************************************/
+/*****************************************************************************/
+
+// Buffer Descriptor Status Register layout.
+typedef union _BD_STAT
+{
+ BYTE Val;
+ struct{
+ //If the CPU owns the buffer then these are the values
+ unsigned BC8:1; //bit 8 of the byte count
+ unsigned BC9:1; //bit 9 of the byte count
+ unsigned BSTALL:1; //Buffer Stall Enable
+ unsigned DTSEN:1; //Data Toggle Synch Enable
+ unsigned INCDIS:1; //Address Increment Disable
+ unsigned KEN:1; //BD Keep Enable
+ unsigned DTS:1; //Data Toggle Synch Value
+ unsigned UOWN:1; //USB Ownership
+ };
+ struct{
+ //if the USB module owns the buffer then these are
+ // the values
+ unsigned :2;
+ unsigned PID0:1; //Packet Identifier
+ unsigned PID1:1;
+ unsigned PID2:1;
+ unsigned PID3:1;
+ unsigned :1;
+ };
+ struct{
+ unsigned :2;
+ unsigned PID:4; //Packet Identifier
+ unsigned :2;
+ };
+} BD_STAT; //Buffer Descriptor Status Register
+
+// BDT Entry Layout
+typedef union __BDT
+{
+ struct
+ {
+ BD_STAT STAT;
+ BYTE CNT;
+ BYTE ADRL; //Buffer Address Low
+ BYTE ADRH; //Buffer Address High
+ };
+ struct
+ {
+ unsigned :8;
+ unsigned :8;
+ WORD ADR; //Buffer Address
+ };
+ DWORD Val;
+ BYTE v[4];
+} BDT_ENTRY;
+
+// USTAT Register Layout
+typedef union __USTAT
+{
+ struct
+ {
+ unsigned char filler1:1;
+ unsigned char ping_pong:1;
+ unsigned char direction:1;
+ unsigned char endpoint_number:4;
+ };
+ BYTE Val;
+} USTAT_FIELDS;
+
+//Macros for fetching parameters from a USTAT_FIELDS variable.
+#define USBHALGetLastEndpoint(stat) stat.endpoint_number
+#define USBHALGetLastDirection(stat) stat.direction
+#define USBHALGetLastPingPong(stat) stat.ping_pong
+
+
+typedef union _POINTER
+{
+ struct
+ {
+ BYTE bLow;
+ BYTE bHigh;
+ //byte bUpper;
+ };
+ WORD _word; // bLow & bHigh
+
+ //pFunc _pFunc; // Usage: ptr.pFunc(); Init: ptr.pFunc = &;
+
+ BYTE* bRam; // Ram byte pointer: 2 bytes pointer pointing
+ // to 1 byte of data
+ WORD* wRam; // Ram word poitner: 2 bytes poitner pointing
+ // to 2 bytes of data
+
+ ROM BYTE* bRom; // Size depends on compiler setting
+ ROM WORD* wRom;
+ //rom near byte* nbRom; // Near = 2 bytes pointer
+ //rom near word* nwRom;
+ //rom far byte* fbRom; // Far = 3 bytes pointer
+ //rom far word* fwRom;
+} POINTER;
+
+/*****************************************************************************/
+/****** Function prototypes and macro functions ******************************/
+/*****************************************************************************/
+
+#define ConvertToPhysicalAddress(a) ((WORD)(a))
+#define ConvertToVirtualAddress(a) ((void *)(a))
+
+
+//------------------------------------------------------------------------------
+//This section is for the PIC18F45K50 Family microcontrollers
+//------------------------------------------------------------------------------
+#if defined(__18F45K50) || defined(__18F25K50) || defined(__18F24K50) || defined(__18LF45K50) || defined(__18LF25K50) || defined(__18LF24K50)
+ #define USBClearUSBInterrupt() PIR3bits.USBIF = 0;
+ #if defined(USB_INTERRUPT)
+ #define USBMaskInterrupts() {PIE3bits.USBIE = 0;}
+ #define USBUnmaskInterrupts() {PIE3bits.USBIE = 1;}
+ #else
+ #define USBMaskInterrupts()
+ #define USBUnmaskInterrupts()
+ #endif
+
+ #define USBInterruptFlag PIR3bits.USBIF
+
+ //STALLIE, IDLEIE, TRNIE, and URSTIE are all enabled by default and are required
+ #if defined(USB_INTERRUPT)
+ #define USBEnableInterrupts() {RCONbits.IPEN = 1;IPR3bits.USBIP = 1;PIE3bits.USBIE = 1;INTCONbits.GIEH = 1;}
+ #else
+ #define USBEnableInterrupts()
+ #endif
+
+ #define USBDisableInterrupts() {PIE3bits.USBIE = 0;}
+
+ #define SetConfigurationOptions() {\
+ U1CNFG1 = USB_PULLUP_OPTION | USB_TRANSCEIVER_OPTION | USB_SPEED_OPTION | USB_PING_PONG_MODE;\
+ U1EIE = 0x9F;\
+ UIE = 0x39 | USB_SOF_INTERRUPT | USB_ERROR_INTERRUPT;\
+ }
+#else
+//------------------------------------------------------------------------------
+//This section is for all other PIC18 USB microcontrollers
+//------------------------------------------------------------------------------
+ #define USBClearUSBInterrupt() PIR2bits.USBIF = 0;
+ #if defined(USB_INTERRUPT)
+ #define USBMaskInterrupts() {PIE2bits.USBIE = 0;}
+ #define USBUnmaskInterrupts() {PIE2bits.USBIE = 1;}
+ #else
+ #define USBMaskInterrupts()
+ #define USBUnmaskInterrupts()
+ #endif
+
+ #define USBInterruptFlag PIR2bits.USBIF
+
+ //STALLIE, IDLEIE, TRNIE, and URSTIE are all enabled by default and are required
+ #if defined(USB_INTERRUPT)
+ #define USBEnableInterrupts() {RCONbits.IPEN = 1;IPR2bits.USBIP = 1;PIE2bits.USBIE = 1;INTCONbits.GIEH = 1;}
+ #else
+ #define USBEnableInterrupts()
+ #endif
+
+ #define USBDisableInterrupts() {PIE2bits.USBIE = 0;}
+
+ #define SetConfigurationOptions() {\
+ U1CNFG1 = USB_PULLUP_OPTION | USB_TRANSCEIVER_OPTION | USB_SPEED_OPTION | USB_PING_PONG_MODE;\
+ U1EIE = 0x9F;\
+ UIE = 0x39 | USB_SOF_INTERRUPT | USB_ERROR_INTERRUPT;\
+ }
+#endif //end of #if defined(__18F45K50) || defined(__18F25K50)...
+//------------------------------------------------------------------------------
+
+
+/****************************************************************
+ Function:
+ void USBPowerModule(void)
+
+ Description:
+ This macro is used to power up the USB module if required
+ PIC18: defines as nothing
+ PIC24: defines as U1PWRCbits.USBPWR = 1;
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ ****************************************************************/
+#define USBPowerModule()
+
+/****************************************************************
+ Function:
+ void USBModuleDisable(void)
+
+ Description:
+ This macro is used to disable the USB module
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ ****************************************************************/
+#define USBModuleDisable() {\
+ UCON = 0;\
+ UIE = 0;\
+ USBDeviceState = DETACHED_STATE;\
+}
+
+/****************************************************************
+ Function:
+ USBSetBDTAddress(addr)
+
+ Description:
+ This macro is used to power up the USB module if required
+
+ Parameters:
+ None
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ ****************************************************************/
+#define USBSetBDTAddress(addr)
+
+/********************************************************************
+ * Function (macro): void USBClearInterruptFlag(register, BYTE if_and_flag_mask)
+ *
+ * PreCondition: None
+ *
+ * Input:
+ * register - the register mnemonic for the register holding the interrupt
+ flag to be cleared
+ * BYTE if_and_flag_mask - an AND mask for the interrupt flag that will be
+ cleared
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: Clears the specified USB interrupt flag.
+ *
+ * Note:
+ *******************************************************************/
+#define USBClearInterruptFlag(reg_name, if_and_flag_mask) (reg_name &= if_and_flag_mask)
+
+/********************************************************************
+ Function:
+ void USBClearInterruptRegister(WORD reg)
+
+ Summary:
+ Clears the specified interrupt register
+
+ PreCondition:
+ None
+
+ Parameters:
+ WORD reg - the register name that needs to be cleared
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *******************************************************************/
+#define USBClearInterruptRegister(reg) reg = 0;
+
+/********************************************************************
+ Function:
+ void DisableNonZeroEndpoints(UINT8 last_ep_num)
+
+ Summary:
+ Clears the control registers for the specified non-zero endpoints
+
+ PreCondition:
+ None
+
+ Parameters:
+ UINT8 last_ep_num - the last endpoint number to clear. This
+ number should include all endpoints used in any configuration.
+
+ Return Values:
+ None
+
+ Remarks:
+ None
+
+ *******************************************************************/
+#define DisableNonZeroEndpoints(last_ep_num) memset((void*)&U1EP1,0x00,(last_ep_num));
+
+/*****************************************************************************/
+/****** Compiler checks ******************************************************/
+/*****************************************************************************/
+
+//Definitions for the BDT
+#ifndef USB_PING_PONG_MODE
+ #error "No ping pong mode defined."
+#endif
+
+/*****************************************************************************/
+/****** Extern variable definitions ******************************************/
+/*****************************************************************************/
+
+#if !defined(USBDEVICE_C)
+ //extern USB_VOLATILE USB_DEVICE_STATE USBDeviceState;
+ extern USB_VOLATILE BYTE USBActiveConfiguration;
+ extern USB_VOLATILE IN_PIPE inPipes[1];
+ extern USB_VOLATILE OUT_PIPE outPipes[1];
+#endif
+
+extern volatile BDT_ENTRY* pBDTEntryOut[USB_MAX_EP_NUMBER+1];
+extern volatile BDT_ENTRY* pBDTEntryIn[USB_MAX_EP_NUMBER+1];
+
+#endif //#ifndef USB_HAL_PIC18_H
diff --git a/Source/USB/picft245.c b/Source/USB/picft245.c
new file mode 100644
index 0000000..af807a9
--- /dev/null
+++ b/Source/USB/picft245.c
@@ -0,0 +1,886 @@
+/*------------------------------------------------------------------------------
+; PICFT245
+;
+; FTDI FT245 replacement for CAN_USB in a PIC18F14K50 (C) SPROG DCC 2012
+; web: http://www.sprog-dcc.co.uk
+; e-mail: sprog@sprog-dcc.co.uk
+;
+; This program is free software: you can redistribute it and/or modify
+; it under the terms of the GNU General Public License as published by
+; the Free Software Foundation, version 3 of the License, as set out
+; at .
+;
+; This program is distributed in the hope that it will be useful,
+; but WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+; See the GNU General Public License for more details.
+;
+; As set out in the GNU General Public License, you must retain and acknowledge
+; the statements above relating to copyright and licensing. You must also
+; state clearly any modifications made. Please therefore retain this header
+; and add documentation of any changes you make. If you distribute a changed
+; version, you must make those changes publicly available.
+;
+; The GNU license requires that if you distribute this software, changed or
+; unchanged, or software which includes code from this software, including
+; the supply of hardware that incorporates this software, you MUST either
+; include the source code or a link to a location where you make the source
+; publicly available.
+;
+------------------------------------------------------------------------------*/
+
+/*------------------------------------------------------------------------------
+;
+; Revision History
+; 21/03/15 1.4 Revert to buffering complete messages rather than send short
+; packets. Improve handling of USB->CAN and CAN->USB contention.
+; 20/09/14 1.3 Fixed deadlock in state USB->CAN state machine
+; 25/08/14 1.2 Fixed inconsistent endpoint buffer sizes
+; 30/12/12 1.1 Replace CAN->USB state machine with tight loop
+; Change to Interrupt mode for USB tasks
+; Pass incoming CBUS chars direct to USBUSART instead of
+; buffering complete Gridconnect messages
+; 20/06/12 1.0 Created
+;
+;-----------------------------------------------------------------------------*/
+
+#include
+
+ //14K50
+ #pragma config CPUDIV = NOCLKDIV
+ #pragma config USBDIV = OFF
+ #pragma config FOSC = HS
+ #pragma config PLLEN = ON
+ #pragma config FCMEN = OFF
+ #pragma config IESO = OFF
+ #pragma config PWRTEN = OFF
+ #pragma config BOREN = OFF
+ #pragma config BORV = 30
+// #pragma config VREGEN = ON
+ #pragma config WDTEN = OFF
+ #pragma config WDTPS = 32768
+ #pragma config MCLRE = OFF
+ #pragma config HFOFST = OFF
+ #pragma config STVREN = ON
+ #pragma config LVP = OFF
+ #pragma config XINST = OFF
+ #pragma config BBSIZ = OFF
+ #pragma config CP0 = OFF
+ #pragma config CP1 = OFF
+ #pragma config CPB = OFF
+ #pragma config WRT0 = OFF
+ #pragma config WRT1 = OFF
+ #pragma config WRTB = OFF
+ #pragma config WRTC = OFF
+ #pragma config EBTR0 = OFF
+ #pragma config EBTR1 = OFF
+ #pragma config EBTRB = OFF
+
+#include
+#include "GenericTypeDefs.h"
+#include "Compiler.h"
+#include "./USB/usb.h"
+#include "./USB/usb_function_cdc.h"
+#include "USB/usb_device.h"
+#include "USB/usb.h"
+#include "usb_config.h"
+
+#include "HardwareProfile.h"
+#include "io.h"
+
+#pragma udata
+char USB_Out_Buffer[CDC_DATA_OUT_EP_SIZE];
+char USB_In_Buffer[CDC_DATA_IN_EP_SIZE];
+
+unsigned char NextUSBOut;
+unsigned char NextUSBOut;
+unsigned char LastUSBIn; // Number of characters in the buffer
+unsigned char USBcp; // current position within the buffer
+unsigned char USB_In_Data_Rdy;
+unsigned char USB_Out_Data_Rdy;
+USB_HANDLE lastTransmission;
+
+unsigned char usb_in;
+unsigned char usb_in_state;
+#define U_IDLE 0
+#define U_IDLE2 1
+#define U_RDY 2
+#define U_OUT 3
+
+unsigned char can_in;
+
+static void InitializeSystem(void);
+void ProcessIO(void);
+void USBDeviceTasks(void);
+void YourHighPriorityISRCode();
+void YourLowPriorityISRCode();
+void USBCBSendResume(void);
+void UserInit(void);
+unsigned char usbGetChar(void);
+unsigned char usbIsDataRdy(void);
+
+#pragma udata
+
+#pragma interrupt isr_high
+void isr_high(void) {
+ #if defined(USB_INTERRUPT)
+ USBDeviceTasks();
+ #endif
+}
+
+//
+// Low priority interrupt. Not used.
+//
+#pragma interruptlow isr_low
+void isr_low(void) {
+ Nop();
+ Nop();
+}
+
+/*
+ * Interrupt vectors
+ */
+#pragma code high_vector=0x8
+void HIGH_INT_VECT(void)
+{
+ _asm GOTO isr_high _endasm
+}
+
+#pragma code low_vector=0x18
+void LOW_INT_VECT(void)
+{
+ _asm GOTO isr_low _endasm
+}
+
+#pragma code
+
+void main(void)
+{
+ InitializeSystem();
+
+ #if defined(USB_INTERRUPT)
+ if(USB_BUS_SENSE && (USBGetDeviceState() == DETACHED_STATE))
+ {
+ USBDeviceAttach();
+ }
+ #endif
+
+ while(1)
+ {
+ // Application-specific tasks.
+ // Application related code may be added here, or in the ProcessIO() function.
+ ProcessIO();
+
+ // Non-blocking state machine to handle USB -> CAN
+ switch (usb_in_state) {
+ case U_IDLE:
+ // Wait until data is received from host
+ if (usbIsDataRdy()) {
+ usb_in = usbGetChar();
+ PORTBbits.UDAV = 1;
+ usb_in_state = U_RDY;
+ }
+ break;
+
+ case U_IDLE2:
+ // usb_in already holds a byte received from USB but CAN PIC started a transfer
+ // to USB before we could send the byte in usb_in to CAN. Spin around here and
+ // U_RDY waiting for UREQ handshake when the transfer to USB has finished.
+ usb_in_state = U_RDY;
+ break;
+
+ case U_RDY:
+ if (PORTBbits.UREQ && (PORTBbits.CDAV == 0)) {
+ // CAN PIC is ready to receive and has nothing to send to USB.
+ Nop();
+ // Drive data bits out
+ TRISC = 0;
+ Nop();
+ PORTC = usb_in;
+ Nop();
+ PORTBbits.UDAV = 0;
+ usb_in_state = U_OUT;
+ } else if (PORTBbits.CDAV == 1) {
+ // CAN PIC has a CAN frame to send to USB so give it priority.
+ // CAN PIC uses a tight loop to send data to USB so this can only happen
+ // at the beginning of a frame, not in the maiddle of a frame.
+ usb_in_state = U_IDLE2;
+ }
+ break;
+
+ case U_OUT:
+ // Wait for CAN interface to acknowledge data
+ if (PORTBbits.UREQ == 0) {
+ TRISC = 0xFF;
+ usb_in_state = U_IDLE;
+ }
+ break;
+ }
+
+ if ((usb_in_state == U_IDLE) || (usb_in_state == U_IDLE2)) {
+ // USB->CAN handshke is idle
+ if (PORTBbits.CDAV && (NextUSBOut < CDC_DATA_OUT_EP_SIZE-1)) {
+ // CAN PIC has data available and will send it in tight loop to keep
+ // the CAN buffers as empty as possible, so we loop here until the whole
+ // packet is received.
+ PORTBbits.CREQ = 1;
+ while (PORTBbits.CDAV == 1) {
+ // wait for handshake
+ ;
+ }
+ Nop();
+ Nop();
+ // put data into buffer and append a zero
+ USB_Out_Buffer[NextUSBOut] = PORTC;
+ if (PORTC == ';') {
+ // Received ';' so send the complete gridconnect packet
+ USB_Out_Data_Rdy = 1;
+ }
+ PORTBbits.CREQ = 0;
+ NextUSBOut++;
+ USB_Out_Buffer[NextUSBOut] = 0;
+ } else if (NextUSBOut >= CDC_DATA_OUT_EP_SIZE-1) {
+ // Should never happen, but send the buffer if it fills up
+ USB_Out_Data_Rdy = 1;
+ }
+ }
+ }
+}
+
+
+/********************************************************************
+ * Function: static void InitializeSystem(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: InitializeSystem is a centralize initialization
+ * routine. All required USB initialization routines
+ * are called from here.
+ *
+ * User application initialization routine should
+ * also be called from here.
+ *
+ * Note: None
+ *******************************************************************/
+static void InitializeSystem(void)
+{
+ unsigned char i;
+
+ PORTC = PORTC_INIT;
+ PORTB = PORTB_INIT;
+ PORTA = PORTA_INIT;
+
+ // Port pull-ups
+ WPUA = 0x38;
+ WPUB = 0xF0;
+
+ TRISC = PORTC_DDR;
+ TRISB = PORTB_DDR;
+ TRISA = PORTA_DDR;
+
+ USB_In_Data_Rdy = 0;
+ USB_Out_Data_Rdy = 0;
+ ANSEL = 0; // Default all pins to digital
+ ANSELH = 0;
+
+ INTCON = 0;
+
+ // Initialize the arrays
+ for (i=0; i 0)
+ {
+ USB_In_Data_Rdy = 1; // signal buffer full
+ USBcp = 0; // Reset the current position
+ }
+ }
+
+ // Send data to USB
+ if((USBUSARTIsTxTrfReady()) && USB_Out_Data_Rdy) {
+ putUSBUSART(&USB_Out_Buffer[0], NextUSBOut);
+ NextUSBOut = 0;
+ USB_Out_Data_Rdy = 0;
+ }
+
+ CDCTxService();
+} //end ProcessIO
+
+/*
+ * usbIsDataRdy()
+ *
+ * Check if there is any data available
+ */
+unsigned char usbIsDataRdy(void) {
+ if (USB_In_Data_Rdy) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/*
+ * usbGetChar()
+ *
+ * Get data from the input buffer
+ */
+unsigned char usbGetChar(void) {
+ unsigned char ret = 0;
+ if(USB_In_Data_Rdy) {
+ ret = USB_In_Buffer[USBcp];
+ ++USBcp;
+ if (USBcp == LastUSBIn)
+ // All of the data has been consumed
+ USB_In_Data_Rdy = 0;
+ }
+ return ret;
+}
+
+
+// ******************************************************************************************************
+// ************** USB Callback Functions ****************************************************************
+// ******************************************************************************************************
+// The USB firmware stack will call the callback functions USBCBxxx() in response to certain USB related
+// events. For example, if the host PC is powering down, it will stop sending out Start of Frame (SOF)
+// packets to your device. In response to this, all USB devices are supposed to decrease their power
+// consumption from the USB Vbus to <2.5mA each. The USB module detects this condition (which according
+// to the USB specifications is 3+ms of no bus activity/SOF packets) and then calls the USBCBSuspend()
+// function. You should modify these callback functions to take appropriate actions for each of these
+// conditions. For example, in the USBCBSuspend(), you may wish to add code that will decrease power
+// consumption from Vbus to <2.5mA (such as by clock switching, turning off LEDs, putting the
+// microcontroller to sleep, etc.). Then, in the USBCBWakeFromSuspend() function, you may then wish to
+// add code that undoes the power saving things done in the USBCBSuspend() function.
+
+// The USBCBSendResume() function is special, in that the USB stack will not automatically call this
+// function. This function is meant to be called from the application firmware instead. See the
+// additional comments near the function.
+
+/******************************************************************************
+ * Function: void USBCBSuspend(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: Call back that is invoked when a USB suspend is detected
+ *
+ * Note: None
+ *****************************************************************************/
+void USBCBSuspend(void)
+{
+ //Example power saving code. Insert appropriate code here for the desired
+ //application behavior. If the microcontroller will be put to sleep, a
+ //process similar to that shown below may be used:
+
+ //ConfigureIOPinsForLowPower();
+ //SaveStateOfAllInterruptEnableBits();
+ //DisableAllInterruptEnableBits();
+ //EnableOnlyTheInterruptsWhichWillBeUsedToWakeTheMicro(); //should enable at least USBActivityIF as a wake source
+ //Sleep();
+ //RestoreStateOfAllPreviouslySavedInterruptEnableBits(); //Preferrably, this should be done in the USBCBWakeFromSuspend() function instead.
+ //RestoreIOPinsToNormal(); //Preferrably, this should be done in the USBCBWakeFromSuspend() function instead.
+
+ //IMPORTANT NOTE: Do not clear the USBActivityIF (ACTVIF) bit here. This bit is
+ //cleared inside the usb_device.c file. Clearing USBActivityIF here will cause
+ //things to not work as intended.
+
+
+
+}
+
+
+
+/******************************************************************************
+ * Function: void USBCBWakeFromSuspend(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: The host may put USB peripheral devices in low power
+ * suspend mode (by "sending" 3+ms of idle). Once in suspend
+ * mode, the host may wake the device back up by sending non-
+ * idle state signalling.
+ *
+ * This call back is invoked when a wakeup from USB suspend
+ * is detected.
+ *
+ * Note: None
+ *****************************************************************************/
+void USBCBWakeFromSuspend(void)
+{
+ // If clock switching or other power savings measures were taken when
+ // executing the USBCBSuspend() function, now would be a good time to
+ // switch back to normal full power run mode conditions. The host allows
+ // a few milliseconds of wakeup time, after which the device must be
+ // fully back to normal, and capable of receiving and processing USB
+ // packets. In order to do this, the USB module must receive proper
+ // clocking (IE: 48MHz clock must be available to SIE for full speed USB
+ // operation).
+}
+
+/********************************************************************
+ * Function: void USBCB_SOF_Handler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: The USB host sends out a SOF packet to full-speed
+ * devices every 1 ms. This interrupt may be useful
+ * for isochronous pipes. End designers should
+ * implement callback routine as necessary.
+ *
+ * Note: None
+ *******************************************************************/
+void USBCB_SOF_Handler(void)
+{
+ // No need to clear UIRbits.SOFIF to 0 here.
+ // Callback caller is already doing that.
+}
+
+/*******************************************************************
+ * Function: void USBCBErrorHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: The purpose of this callback is mainly for
+ * debugging during development. Check UEIR to see
+ * which error causes the interrupt.
+ *
+ * Note: None
+ *******************************************************************/
+void USBCBErrorHandler(void)
+{
+ // No need to clear UEIR to 0 here.
+ // Callback caller is already doing that.
+
+ // Typically, user firmware does not need to do anything special
+ // if a USB error occurs. For example, if the host sends an OUT
+ // packet to your device, but the packet gets corrupted (ex:
+ // because of a bad connection, or the user unplugs the
+ // USB cable during the transmission) this will typically set
+ // one or more USB error interrupt flags. Nothing specific
+ // needs to be done however, since the SIE will automatically
+ // send a "NAK" packet to the host. In response to this, the
+ // host will normally retry to send the packet again, and no
+ // data loss occurs. The system will typically recover
+ // automatically, without the need for application firmware
+ // intervention.
+
+ // Nevertheless, this callback function is provided, such as
+ // for debugging purposes.
+}
+
+
+/*******************************************************************
+ * Function: void USBCBCheckOtherReq(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: When SETUP packets arrive from the host, some
+ * firmware must process the request and respond
+ * appropriately to fulfill the request. Some of
+ * the SETUP packets will be for standard
+ * USB "chapter 9" (as in, fulfilling chapter 9 of
+ * the official USB specifications) requests, while
+ * others may be specific to the USB device class
+ * that is being implemented. For example, a HID
+ * class device needs to be able to respond to
+ * "GET REPORT" type of requests. This
+ * is not a standard USB chapter 9 request, and
+ * therefore not handled by usb_device.c. Instead
+ * this request should be handled by class specific
+ * firmware, such as that contained in usb_function_hid.c.
+ *
+ * Note: None
+ *******************************************************************/
+void USBCBCheckOtherReq(void)
+{
+ USBCheckCDCRequest();
+}//end
+
+
+/*******************************************************************
+ * Function: void USBCBStdSetDscHandler(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: The USBCBStdSetDscHandler() callback function is
+ * called when a SETUP, bRequest: SET_DESCRIPTOR request
+ * arrives. Typically SET_DESCRIPTOR requests are
+ * not used in most applications, and it is
+ * optional to support this type of request.
+ *
+ * Note: None
+ *******************************************************************/
+void USBCBStdSetDscHandler(void)
+{
+ // Must claim session ownership if supporting this request
+}//end
+
+
+/*******************************************************************
+ * Function: void USBCBInitEP(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This function is called when the device becomes
+ * initialized, which occurs after the host sends a
+ * SET_CONFIGURATION (wValue not = 0) request. This
+ * callback function should initialize the endpoints
+ * for the device's usage according to the current
+ * configuration.
+ *
+ * Note: None
+ *******************************************************************/
+void USBCBInitEP(void)
+{
+ CDCInitEP();
+}
+
+/********************************************************************
+ * Function: void USBCBSendResume(void)
+ *
+ * PreCondition: None
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: The USB specifications allow some types of USB
+ * peripheral devices to wake up a host PC (such
+ * as if it is in a low power suspend to RAM state).
+ * This can be a very useful feature in some
+ * USB applications, such as an Infrared remote
+ * control receiver. If a user presses the "power"
+ * button on a remote control, it is nice that the
+ * IR receiver can detect this signalling, and then
+ * send a USB "command" to the PC to wake up.
+ *
+ * The USBCBSendResume() "callback" function is used
+ * to send this special USB signalling which wakes
+ * up the PC. This function may be called by
+ * application firmware to wake up the PC. This
+ * function will only be able to wake up the host if
+ * all of the below are true:
+ *
+ * 1. The USB driver used on the host PC supports
+ * the remote wakeup capability.
+ * 2. The USB configuration descriptor indicates
+ * the device is remote wakeup capable in the
+ * bmAttributes field.
+ * 3. The USB host PC is currently sleeping,
+ * and has previously sent your device a SET
+ * FEATURE setup packet which "armed" the
+ * remote wakeup capability.
+ *
+ * If the host has not armed the device to perform remote wakeup,
+ * then this function will return without actually performing a
+ * remote wakeup sequence. This is the required behavior,
+ * as a USB device that has not been armed to perform remote
+ * wakeup must not drive remote wakeup signalling onto the bus;
+ * doing so will cause USB compliance testing failure.
+ *
+ * This callback should send a RESUME signal that
+ * has the period of 1-15ms.
+ *
+ * Note: This function does nothing and returns quickly, if the USB
+ * bus and host are not in a suspended condition, or are
+ * otherwise not in a remote wakeup ready state. Therefore, it
+ * is safe to optionally call this function regularly, ex:
+ * anytime application stimulus occurs, as the function will
+ * have no effect, until the bus really is in a state ready
+ * to accept remote wakeup.
+ *
+ * When this function executes, it may perform clock switching,
+ * depending upon the application specific code in
+ * USBCBWakeFromSuspend(). This is needed, since the USB
+ * bus will no longer be suspended by the time this function
+ * returns. Therefore, the USB module will need to be ready
+ * to receive traffic from the host.
+ *
+ * The modifiable section in this routine may be changed
+ * to meet the application needs. Current implementation
+ * temporary blocks other functions from executing for a
+ * period of ~3-15 ms depending on the core frequency.
+ *
+ * According to USB 2.0 specification section 7.1.7.7,
+ * "The remote wakeup device must hold the resume signaling
+ * for at least 1 ms but for no more than 15 ms."
+ * The idea here is to use a delay counter loop, using a
+ * common value that would work over a wide range of core
+ * frequencies.
+ * That value selected is 1800. See table below:
+ * ==========================================================
+ * Core Freq(MHz) MIP RESUME Signal Period (ms)
+ * ==========================================================
+ * 48 12 1.05
+ * 4 1 12.6
+ * ==========================================================
+ * * These timing could be incorrect when using code
+ * optimization or extended instruction mode,
+ * or when having other interrupts enabled.
+ * Make sure to verify using the MPLAB SIM's Stopwatch
+ * and verify the actual signal on an oscilloscope.
+ *******************************************************************/
+void USBCBSendResume(void)
+{
+ static WORD delay_count;
+
+ //First verify that the host has armed us to perform remote wakeup.
+ //It does this by sending a SET_FEATURE request to enable remote wakeup,
+ //usually just before the host goes to standby mode (note: it will only
+ //send this SET_FEATURE request if the configuration descriptor declares
+ //the device as remote wakeup capable, AND, if the feature is enabled
+ //on the host (ex: on Windows based hosts, in the device manager
+ //properties page for the USB device, power management tab, the
+ //"Allow this device to bring the computer out of standby." checkbox
+ //should be checked).
+ if(USBGetRemoteWakeupStatus() == TRUE)
+ {
+ //Verify that the USB bus is in fact suspended, before we send
+ //remote wakeup signalling.
+ if(USBIsBusSuspended() == TRUE)
+ {
+ USBMaskInterrupts();
+
+ //Clock switch to settings consistent with normal USB operation.
+ USBCBWakeFromSuspend();
+ USBSuspendControl = 0;
+ USBBusIsSuspended = FALSE; //So we don't execute this code again,
+ //until a new suspend condition is detected.
+
+ //Section 7.1.7.7 of the USB 2.0 specifications indicates a USB
+ //device must continuously see 5ms+ of idle on the bus, before it sends
+ //remote wakeup signalling. One way to be certain that this parameter
+ //gets met, is to add a 2ms+ blocking delay here (2ms plus at
+ //least 3ms from bus idle to USBIsBusSuspended() == TRUE, yeilds
+ //5ms+ total delay since start of idle).
+ delay_count = 3600U;
+ do
+ {
+ delay_count--;
+ }while(delay_count);
+
+ //Now drive the resume K-state signalling onto the USB bus.
+ USBResumeControl = 1; // Start RESUME signaling
+ delay_count = 1800U; // Set RESUME line for 1-13 ms
+ do
+ {
+ delay_count--;
+ }while(delay_count);
+ USBResumeControl = 0; //Finished driving resume signalling
+
+ USBUnmaskInterrupts();
+ }
+ }
+}
+
+
+/*******************************************************************
+ * Function: void USBCBEP0DataReceived(void)
+ *
+ * PreCondition: ENABLE_EP0_DATA_RECEIVED_CALLBACK must be
+ * defined already (in usb_config.h)
+ *
+ * Input: None
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This function is called whenever a EP0 data
+ * packet is received. This gives the user (and
+ * thus the various class examples a way to get
+ * data that is received via the control endpoint.
+ * This function needs to be used in conjunction
+ * with the USBCBCheckOtherReq() function since
+ * the USBCBCheckOtherReq() function is the apps
+ * method for getting the initial control transfer
+ * before the data arrives.
+ *
+ * Note: None
+ *******************************************************************/
+#if defined(ENABLE_EP0_DATA_RECEIVED_CALLBACK)
+void USBCBEP0DataReceived(void)
+{
+}
+#endif
+
+/*******************************************************************
+ * Function: BOOL USER_USB_CALLBACK_EVENT_HANDLER(
+ * USB_EVENT event, void *pdata, WORD size)
+ *
+ * PreCondition: None
+ *
+ * Input: USB_EVENT event - the type of event
+ * void *pdata - pointer to the event data
+ * WORD size - size of the event data
+ *
+ * Output: None
+ *
+ * Side Effects: None
+ *
+ * Overview: This function is called from the USB stack to
+ * notify a user application that a USB event
+ * occured. This callback is in interrupt context
+ * when the USB_INTERRUPT option is selected.
+ *
+ * Note: None
+ *******************************************************************/
+BOOL USER_USB_CALLBACK_EVENT_HANDLER(int event, void *pdata, WORD size)
+{
+ switch(event)
+ {
+ case EVENT_TRANSFER:
+ //Add application specific callback task or callback function here if desired.
+ break;
+ case EVENT_SOF:
+ USBCB_SOF_Handler();
+ break;
+ case EVENT_SUSPEND:
+ USBCBSuspend();
+ break;
+ case EVENT_RESUME:
+ USBCBWakeFromSuspend();
+ break;
+ case EVENT_CONFIGURED:
+ USBCBInitEP();
+ break;
+ case EVENT_SET_DESCRIPTOR:
+ USBCBStdSetDscHandler();
+ break;
+ case EVENT_EP0_REQUEST:
+ USBCBCheckOtherReq();
+ break;
+ case EVENT_BUS_ERROR:
+ USBCBErrorHandler();
+ break;
+ case EVENT_TRANSFER_TERMINATED:
+ //Add application specific callback task or callback function here if desired.
+ //The EVENT_TRANSFER_TERMINATED event occurs when the host performs a CLEAR
+ //FEATURE (endpoint halt) request on an application endpoint which was
+ //previously armed (UOWN was = 1). Here would be a good place to:
+ //1. Determine which endpoint the transaction that just got terminated was
+ // on, by checking the handle value in the *pdata.
+ //2. Re-arm the endpoint if desired (typically would be the case for OUT
+ // endpoints).
+ break;
+ default:
+ break;
+ }
+ return TRUE;
+}
+
+/** EOF main.c *************************************************/
+
diff --git a/Source/USB/picft245.cof b/Source/USB/picft245.cof
new file mode 100644
index 0000000..337bc84
Binary files /dev/null and b/Source/USB/picft245.cof differ
diff --git a/Source/USB/picft245.hex b/Source/USB/picft245.hex
new file mode 100644
index 0000000..2f73cde
--- /dev/null
+++ b/Source/USB/picft245.hex
@@ -0,0 +1,496 @@
+:020000040000FA
+:06000000A9EF0EF0120052
+:0600080005EF0CF01200F0
+:0600180050EF0CF0120095
+:020028000000D6
+:06002A00D9CFE6FFE1CF93
+:10003000D9FFE652A0940F015F6B626A536B020E08
+:10004000E66EE66AE66A540EE66E0F0EE66E7FEC2A
+:100050000EF00B6E050EE15E0B50160E616E0F0179
+:100060009F0E5B6F7B0E606EDF6ADF500B6E0C6A5B
+:100070000C0E0B5C000E0C5810E2DF50040DF3CF99
+:10008000E9FFF4CFEAFF000EE926020EEA22EE6A4B
+:10009000EE6AEE6AEE6ADF2AE8D7648C0F015C6BC9
+:1000A0006498649C62A607D062960101586B5D6BF0
+:1000B0005E6B5F6BF7D70101010E716F726F736B2F
+:1000C000746B656BDF6A030EDF5C26E2EA6ADF347D
+:1000D000FE0BEA36E96E4E0EE926010EEA22EE6AC2
+:1000E000ED6AEA6ADF34FE0BEA36E96E480EE9266D
+:1000F000010EEA22EE6AED6ADF50EA6A690FE96EE4
+:10010000010EEA22EF6ADF50EA6A6C0FE96E010E17
+:10011000EA22EF6ADF2AD7D70101080E4E6F020EDE
+:100120004F6F0F01160E536F0201300E026F020E59
+:10013000036F080E016F840E006F0101416B406B6D
+:10014000E552E552E7CFD9FF1200D9CFE6FFE1CF64
+:10015000D9FFE6520101400507E164BA05D0626AA1
+:1001600060806088020E406F6250040B06E06050B1
+:10017000040B03E06294B2EC06F064A202D0A194F6
+:1001800091D06250010B09E06050010B06E04DDF99
+:10019000A0840101040E406F62906250100B06E0D3
+:1001A0006050100B03E09DEC06F0629862AC12D038
+:1001B00060AC0FD0010EE66EE66A000EE66EE66AEF
+:1001C000730EE66EE66A9DEC0DF00B6E060EE15EB8
+:1001D0000B50629C6250200B05E06050200B02E047
+:1001E00083EC06F06250020B14E06050020B11E049
+:1001F000010EE66EE66A000EE66EE66AE6687F0EBF
+:10020000E66E9DEC0DF00B6E060EE15E0B500F01DD
+:100210005F6B040E0101E76E4019E8AE02D0E734CF
+:1002200002D0E750405D02E2A1943CD060A639D0F4
+:10023000DF6A040EDF5C35E262A632D063CF66F17E
+:1002400001016651780BE842E842E842676F629626
+:1002500066B508D06751EA6A6C0FE96E010EEA22B2
+:10026000EF7007D06751EA6A690FE96E010EEA2262
+:10027000EF70675103E1C9EC06F010D0000EE66E96
+:10028000E66A660EE66E010EE66E720EE66EE66ACF
+:100290009DEC0DF00B6E060EE15E0B50DF2AC9D708
+:1002A00000D0A194E552E552E7CFD9FF1200D9CF93
+:1002B000E6FFE1CFD9FF020EE126FD0EDBA407D059
+:1002C000E66AFE0EDBCFE6FF23DAE552E552FD0ECD
+:1002D000DBA208D0010EE66EFE0EDBCFE6FF18DAD9
+:1002E000E552E552FE0EDB500C6A530F0B6E0F0EFB
+:1002F0000C220BC0DEFF0CC0DDFFDECFE9FFDDCF3F
+:10030000EAFFFD0EDBCFEFFF020EE15C02E2E16AE5
+:10031000E552E16EE552E7CFD9FF1200D9CFE6FFF3
+:10032000E1CFD9FF020EE126FD0EDB500FE0FE0EFD
+:10033000EA6ADB34FE0BEA36E96E4E0EE926010E60
+:10034000EA22EECFDEFFEDCFDDFF0ED0FE0EEA6A31
+:10035000DB34FE0BEA36E96E480EE926010EEA228E
+:10036000EECFDEFFEDCFDDFFD9CFE9FFDACFEAFF39
+:10037000EE50ED1003E1F36AF46A49D0DECFE9FFF5
+:10038000DDCFEAFF020EE926000EEA22FB0EDBCFEC
+:10039000EEFFFC0EDBCFEDFFDECFE9FFDDCFEAFFA6
+:1003A000EE52FA0EDBCFEFFF400E0B6EDECFE9FF11
+:1003B000DDCFEAFF0B50EF16880E0B6EDECFE9FFA4
+:1003C000DDCFEAFF0B50EF12FD0EDB500CE0FE0E0E
+:1003D000EA6ADB34FE0BEA36E96E4E0EE926010EC0
+:1003E000EA22EF740BD0FE0EEA6ADB34FE0BEA362B
+:1003F000E96E480EE926010EEA22EF74DECF0BF01B
+:10040000DDCF0CF00BC0F3FF0CC0F4FF00D0020EE8
+:10041000E15C02E2E16AE552E16EE552E7CFD9FF25
+:100420001200D9CFE6FFE1CFD9FF020EE126FE0E82
+:10043000DB5020E146C1E9FF47C1EAFFEE52080E5A
+:10044000EF6E46C1E9FF47C1EAFF020EE926000E42
+:10045000EA22300EEE6E020EED6E46C1E9FF47C194
+:10046000EAFF8C0EEF6E4EC1E9FF4FC1EAFF840E2A
+:10047000EF6E3DD0FD0EDB50E8240D6EFE0EDB501E
+:10048000040DF3500D24040DF3CF0BF0F4CF0CF05A
+:10049000000E0B26020E0C220BC0DEFF0CC0DDFF8F
+:1004A000840E0B6EDECFE9FFDDCFEAFF0B50EF12BB
+:1004B000FD0EDB50E8240D6EFE0EDB50040DF350F4
+:1004C0000D24010F040DF3CF0BF0F4CF0CF0000E50
+:1004D0000B26020E0C220BC0DEFF0CC0DDFF840ECB
+:1004E0000B6EDECFE9FFDDCFEAFF0B50EF12020EFD
+:1004F000E15C02E2E16AE552E16EE552E7CFD9FF45
+:100500001200D9CFE6FFE1CFD9FF64A84ED0FE0E8E
+:10051000EA6ADB34FE0BEA36E96E4E0EE926010E7E
+:10052000EA22EE50EFCFEAFFE96E400EEE16EE6AD9
+:10053000EE6AEE6AFE0EEA6ADB34FE0BEA36E96E1C
+:100540004E0EE926010EEA22EE50EFCFEAFFE96EE9
+:10055000EE7CFE0EEA6ADB34FE0BEA36E96E4E0EE6
+:10056000E926010EEA22EF74400E0B6EFE0EEA6AD7
+:10057000DB34FE0BEA36E96E4E0EE926010EEA2266
+:10058000EE50EFCFEAFFE96E0B50EF16FE0EEA6A6F
+:10059000DB34FE0BEA36E96E4E0EE926010EEA2246
+:1005A000EE50EFCFEAFFE96EEF7CE552E7CFD9FFDF
+:1005B0001200646A606A0101406B00D01200010100
+:1005C000405114E1646A606A160E616E0F019F0E5D
+:1005D0005B6F7B0E606ED08EA284A084F28E64B6B8
+:1005E00002D06486FCD70101010E406F12000101A8
+:1005F00071514DE1010E716F725149E1010E726F3F
+:10060000020E555D0DE14EC1E9FF4FC1EAFFEE520A
+:10061000EF6A4EC1E9FF4FC1EAFFC80EEF6E37D057
+:10062000550535E1686B44C1E9FF45C1EAFFEE526B
+:10063000080EEF6E44C1E9FF45C1EAFF020EE9264C
+:10064000000EEA22300EEE6E020EED6E44C1E9FF9E
+:1006500045C1EAFF840EEF6E010E686F46C1E9FFE7
+:1006600047C1EAFFEE52080EEF6E46C1E9FF47C1EF
+:10067000EAFF020EE926000EEA22300EEE6E020EAE
+:10068000ED6E46C1E9FF47C1EAFF800EEF6E120032
+:100690000101736B746B020E555D1AE146C1E9FFEF
+:1006A00047C1EAFFEE52080EEF6E46C1E9FF47C1AF
+:1006B000EAFF020EE926000EEA22380EEE6E020E66
+:1006C000ED6E46C1E9FF47C1EAFFC80EEF6E1FD0CD
+:1006D00059510201365D01015A510201375904E2B4
+:1006E00036C259F137C25AF1D1D84EC1E9FF4FC1D4
+:1006F000EAFF020EE926000EEA22380EEE6E020E26
+:10070000ED6E4EC1E9FF4FC1EAFFC80EEF6E120059
+:10071000D9CFE6FFE1CFD9FF020EE126000EDE6E53
+:10072000020EDD6EFD0EDB50E8240D6EFE0EDB507A
+:10073000040DF3500D24040DF3CF0BF0F4CF0CF0A7
+:10074000D9CFE9FFDACFEAFF0B50EE260C50ED22AD
+:10075000DECFE9FFDDCFEAFFEF9EFD0EDB500FE1BC
+:10076000FE0EEA6ADB34FE0BEA36E96E480EE92635
+:10077000010EEA22DECFEEFFDDCFEDFF0ED0FE0E42
+:10078000EA6ADB34FE0BEA36E96E4E0EE926010E0C
+:10079000EA22DECFEEFFDDCFEDFFDECFE9FFDDCFDA
+:1007A000EAFFEF9CDECFE9FFDDCFEAFF040EE9268A
+:1007B000000EEA22EF8C020EE15C02E2E16AE552F1
+:1007C000E16EE552E7CFD9FF12006498010158BFEE
+:1007D0002BD05DAF09D0020E556F745101E158DF87
+:1007E0000101726B716B1FD046C1E9FF47C1EAFF7F
+:1007F000EE52080EEF6E46C1E9FF47C1EAFF020E56
+:10080000E926000EEA22300EEE6E020EED6E46C1B3
+:10081000E9FF47C1EAFF8C0EEF6E4EC1E9FF4FC101
+:10082000EAFF840EEF6E31D0020130AF0DD001012E
+:10083000010E556F735101E12BDF0101726B716B7A
+:10084000705101E1D4DE21D00101020E556F46C185
+:10085000E9FF47C1EAFFEE52080EEF6E46C1E9FF1D
+:1008600047C1EAFF020EE926000EEA22300EEE6EC4
+:10087000020EED6E46C1E9FF47C1EAFF840EEF6E3E
+:10088000726B716B705101E1B2DE1200D9CFE6FFDD
+:10089000E1CFD9FFE652080EDF6E0101595D000E6F
+:1008A0005A590BE259C1DFFF545103E1010E546F55
+:1008B00004D0540502E1020E546FDF500B6E0C6A37
+:1008C0000B50595D596F0C505A595A6F4EC1E9FF80
+:1008D0004FC1EAFFEE52DFCFEFFF380E626F020E1C
+:1008E000636F58B119D0DF5016E056C1F6FF57C1FB
+:1008F000F7FF562B000E57230800F550E66E62C135
+:10090000E9FF63C1EAFF622B000E6323E552E75063
+:10091000EF6EDF06E8D717D0DF5015E056C1E9FFCC
+:1009200057C1EAFF562B000E5723EF50E66E62C107
+:10093000E9FF63C1EAFF622B000E6323E552E75033
+:10094000EF6EDF06E9D7E552E552E7CFD9FF120097
+:10095000D9CFE6FFE1CFD9FF020EE12644C1E9FF7E
+:1009600045C1EAFFEE52EFCFDFFFDFCF0BF00B50B8
+:1009700001015E5D000E5F5902E25EC1DFFFDF50E4
+:100980000B6E0C6A0B505E5D5E6F0C505F595F6FB3
+:10099000010EDB6ADF50F36E010EDBCFF4FFF35084
+:1009A000F45C16E2010EDB50EA6A380FE96E020EC3
+:1009B000EA22EF50E66E5BC1E9FF5CC1EAFF5B2B08
+:1009C000000E5C23E552E750EF6E010EDB2AE2D702
+:1009D000000ED8805E55000E5F5528E246C1E9FF43
+:1009E00047C1EAFFEE52080EEF6E46C1E9FF47C16C
+:1009F000EAFF020EE926000EEA22380EEE6E020E23
+:100A0000ED6E44C1E9FF45C1EAFFEF50400B07E13D
+:100A100046C1E9FF47C1EAFFC80EEF6E06D046C1E6
+:100A2000E9FF47C1EAFF880EEF6E28D046C1E9FF13
+:100A300047C1EAFFEE52080EEF6E46C1E9FF47C11B
+:100A4000EAFF020EE926000EEA22300EEE6E020EDA
+:100A5000ED6E46C1E9FF47C1EAFF840EEF6E6051BB
+:100A6000611107E005D061C1FAFF01016051F96E23
+:100A7000FADF01015D9F705101E1B9DD020EE15C19
+:100A800002E2E16AE552E16EE552E7CFD9FF1200DA
+:100A9000D9CFE6FFE1CFD9FFE6520101588F020E10
+:100AA000E66EE66AE66A540EE66E0F0EE66E7FECC0
+:100AB0000EF00B6E050EE15E0B50300EE66EE66A30
+:100AC000E66A000EE66E020EE66E7FEC0EF00B6E2E
+:100AD000050EE15E0B50648CDF6A030EDF5C10E2F2
+:100AE000DF50EA6A690FE96E010EEA22EF6ADF5011
+:100AF000EA6A6C0FE96E010EEA22EF6ADF2AEDD78F
+:100B0000020EE66EE66AE66A420EE66E010EE66EDA
+:100B10007FEC0EF00B6E050EE15E0B50649C010144
+:100B2000080E4E6F020E4F6F000E446F020E456F9F
+:100B300044C146F145C147F132C241F1415103E19F
+:100B4000100E406F13D0010EE66EE66A410EE66E9F
+:100B5000010EE66E010EE66EE66A9DEC0DF00B6E80
+:100B6000060EE15E0B500101200E406FE552E5528A
+:100B7000E7CFD9FF1200800E0201305D5BE1010179
+:100B8000C00E586F02013351030A34E0010A0EE02F
+:100B9000030A03E00101586B4DD00101760E566F38
+:100BA0001C0E576F120E596F5A6B44D03251F66EAD
+:100BB000F76AD890F636F736F50EF6261C0EF722B1
+:100BC0000900F5CF56F10A00F5CF57F1020E0101E9
+:100BD000F76A5625F66E5751F7220800F5CF59F1FE
+:100BE000030EF76A5625F66E5751F7220800F5CF27
+:100BF0005AF120D0030E325D1AE23251F66EF76AD6
+:100C0000D890F636F736F70EF6261C0EF7220900B6
+:100C1000F5CF56F10A00F5CF57F156C1F6FF57C18F
+:100C2000F7FF0800F5500101596F5A6B02D001011E
+:100C3000586B00D01200D9CFE6FFE1CFD9FF020EEA
+:100C4000E1260201386B396B30511F0B020A12E0AA
+:100C5000030A0DE0010A01E042D00101588F0201B0
+:100C600038810101640502E10201388338D00101B5
+:100C7000588F35D00101588F020134BF10D0345144
+:100C80000F0BE96EEA6AD890E936EA36480EE92693
+:100C9000010EEA22EECFDEFFEDCFDDFF0FD03451A3
+:100CA0000F0BE96EEA6AD890E936EA364E0EE9266D
+:100CB000010EEA22EECFDEFFEDCFDDFFDECFE9FF52
+:100CC000DDCFEAFFEF50800B09E0DECFE9FFDDCF9B
+:100CD000EAFFEF50040B02E0010E386F00D0010173
+:100CE00058AF07D0380E566F020E576F5881020E5C
+:100CF000596F020EE15C02E2E16AE552E16EE552F3
+:100D0000E7CFD9FF12000F0153A115D044C1E9FF6D
+:100D100045C1EAFFEF5080080DE14EC1E9FF4FC128
+:100D2000EAFFEF50840806E144C1E9FF45C1EAFF4C
+:100D30008C0EEF6E5391629A120060846298648206
+:100D40000101010E656F000EE66EE66AE66EE66A68
+:100D5000750EE66EE66A9DEC0DF00B6E060EE15E1A
+:100D60000B5012000101656B000EE66EE66AE66E3E
+:100D7000E66A740EE66EE66A9DEC0DF00B6E060EEA
+:100D8000E15E0B506492609462A402D06294FCD73E
+:100D90001200D9CFE6FFE1CFD9FFE652FD0E0101E7
+:100DA000661553E17E0E6615E8407F0B040DF3CF08
+:100DB00044F1F4CF45F1000E4427020E452344C10F
+:100DC00046F145C147F1467544C1E9FF45C1EAFF17
+:100DD000EF503C0BE842E8420D0835E1DF6A080EAF
+:100DE000DF5C23E244C1E9FF45C1EAFF020EE926C8
+:100DF000000EEA22EE50EFCFEAFFE96EEF50E66E0A
+:100E0000DF50EA6A300FE96E020EEA22E552E7503F
+:100E1000EF6E44C1E9FF45C1EAFF020EE926000E6C
+:100E2000EA22EE2AEF22DF2ADAD744C1E9FF45C1E0
+:100E3000EAFF020EE926000EEA22300EEE6E020EE6
+:100E4000ED6E0DD801D03AD805D0FD0E6615040818
+:100E500001E159D8E552E552E7CFD9FF120001016F
+:100E6000546B706B736B746B686B556B4EC1E9FFA1
+:100E70004FC1EAFFEF9E4E754EC1E9FF4FC1EAFF39
+:100E8000EF9E4E7546C1E9FF47C1EAFFEF9E586BE2
+:100E9000596B5A6B5D6B5E6B5F6B92D8000EE66EA2
+:100EA000E66AE66EE66A030EE66EE66A9DEC0DF013
+:100EB0000B6E060EE15E0B50E5EF03F0020E010132
+:100EC000555D02E145DD1ED0556B68511AE146C102
+:100ED000E9FF47C1EAFFEE52080EEF6E46C1E9FF97
+:100EE00047C1EAFF020EE926000EEA22300EEE6E3E
+:100EF000020EED6E46C1E9FF47C1EAFF8C0EEF6EB0
+:100F000001D0686B1200D9CFE6FFE1CFD9FFE652DE
+:100F10004EC1E9FF4FC1EAFFEF50400B01E0010E67
+:100F2000DF6E01014E75080E405D0CE132C25CFFC0
+:100F30000F015C5104E00101100E406F03D001016C
+:100F4000040E406F550528E14EC1E9FF4FC1EAFF8D
+:100F5000020EE926000EEA22380EEE6E020EED6E4B
+:100F600095DC020E0101545D07E14EC1E9FF4FC15E
+:100F7000EAFF840EEF6E0FD0DF5007E14EC1E9FFAC
+:100F80004FC1EAFFC80EEF6E06D04EC1E9FF4FC158
+:100F9000EAFF880EEF6E0FD05DAF0CD0605161118B
+:100FA00007E005D061C1FAFF01016051F96EFADF77
+:100FB00001015D9F556BE552E552E7CFD9FF120065
+:100FC00002013051600BE842E842E842E842E84260
+:100FD000000901E058D031510C0A54E00B0A43E0FB
+:100FE0000C0A35E0010A26E00B0A22E0020A20E0A2
+:100FF000030A1CE0080A10E0010A0CE00F0A08E0EE
+:10100000030A01E03FD00101588F080E406F3BD02A
+:10101000B2DD39D03DDD37D00101410E566F010EF2
+:10102000576F5881010E596F588F2DD004DE2BD089
+:101030002BD829D034510101566F576B420E5627D9
+:10104000010E57235881010E596F588F1CD0010192
+:10105000588F02013451EA6A420FE96E010EEA220A
+:1010600032C2EFFF10D0000EE66EE66AE66EE66A68
+:10107000020EE66EE66A9DEC0DF00B6E060EE15E6A
+:101080000B5001D000D01200D9CFE6FFE1CFD9FF3D
+:10109000050EE1260201320510E130511F0B000957
+:1010A0000CE10101588F030E0201315D04E10101E1
+:1010B000010E646F02D00101646B0201325101E044
+:1010C00020D130511F0B020801E01BD134510F0B0E
+:1010D000000901E116D134510F0B020801E211D1D0
+:1010E000200E0101405D01E00CD1588F020134BF98
+:1010F0001AD034510F0BE96EEA6AD890E936EA3615
+:10110000480EE926010EEA22EECFDEFFEDCFDDFF2D
+:1011100034510F0BEA6A6C0FE96E010EEA22020EDF
+:10112000EFCFDBFF19D034510F0BE96EEA6AD8908C
+:10113000E936EA364E0EE926010EEA22EECFDEFF50
+:10114000EDCFDDFF34510F0BEA6A690FE96E010E36
+:10115000EA22020EEFCFDBFFD950020FE96EDACFA1
+:10116000EAFFEF50010B03E1000EDF9401D0DF84B2
+:1011700034BF10D034510F0BE96EEA6AD890E936CB
+:10118000EA36480EE926010EEA22DECFEEFFDDCF79
+:10119000EDFF0FD034510F0BE96EEA6AD890E936B3
+:1011A000EA364E0EE926010EEA22DECFEEFFDDCF53
+:1011B000EDFF030E315D23E1DECFE9FFDDCFEAFF76
+:1011C000EF50800B13E034BF09D034510F0BEA6AA3
+:1011D0006C0FE96E010EEA22EF8208D034510F0B3A
+:1011E000EA6A690FE96E010EEA22EF82840E0B6E45
+:1011F000DECFE9FFDDCFEAFF0B50EF1282D0DF74C4
+:10120000DECFE9FFDDCFEAFFEF50800B1BE0DECF42
+:10121000E9FFDDCFEAFFEF9EDECFE9FFDDCFEAFF9A
+:10122000EF8C020EE66EE66ADECFE6FFDDCFE6FF6C
+:10123000050EE66EE66A9DEC0DF00B6E060EE15EA5
+:101240000B5005D0DECFE9FFDDCFEAFFEF8CDF7476
+:10125000D950020FE96EDACFEAFFEF50020B07E137
+:10126000DECFE9FFDDCFEAFFEF50800B2DE002017A
+:1012700034BF09D034510F0BEA6A6C0FE96E010ECE
+:10128000EA22EF9208D034510F0BEA6A690FE96E37
+:10129000010EEA22EF923B0E0B6EDECFE9FFDDCFAF
+:1012A000EAFF0B50EF16020EE66EE66ADECFE6FFAF
+:1012B000DDCFE6FF050EE66EE66A9DEC0DF00B6EE7
+:1012C000060EE15E0B5008D03B0E0B6EDECFE9FF41
+:1012D000DDCFEAFF0B50EF16020134510F0B0C6A01
+:1012E000530F0B6E0F0E0C22030E0BC0DBFF040E10
+:1012F0000CC0DBFF030EDBCFE9FF040EDBCFEAFF00
+:10130000EF90050EE15C02E2E16AE552E16EE55222
+:06131000E7CFD9FF120037
+:0A131600020130511F0B010801E035
+:101320004AD03051600BE842E842E842E842E842E5
+:10133000010801E040D0345103E0340501E03BD026
+:101340003151220A33E0030A26E0010A17E0210A9C
+:101350000EE0010A01E02FD00101910E566F010E3F
+:10136000576F080E596F5A6B5881588F24D001015E
+:10137000910E566F010E576F588F1DD036C25EF119
+:1013800037C25FF10101800E5B6F020E5C6F606B14
+:10139000616B5D8F10D00101800E566F020E576F8A
+:1013A000070E596F5A6BC10E586F05D032C28CF1BF
+:1013B0000101588F00D012000201806B4B0E816F2B
+:1013C000826B836B846B856B080E866F0101806B6B
+:1013D0001A0EE66E010EE66E57EC01F0E552E5528C
+:1013E0001E0EE66E020EE66E57EC01F0E552E55277
+:1013F000200EE66E600EE66E020EE66EE66A020EE5
+:10140000E66E8EEC01F00B6E050EE15E0B50F3CF35
+:1014100088F1F4CF89F101018A6B8B6B816B12002B
+:10142000D9CFE6FFE1CFD9FFFD0EDBCF06F0FE0EF0
+:10143000DBCF07F0050E061801E1075002E0000EB1
+:1014400031D0FB0EDBCF0BF0FC0EDBCF0CF001013B
+:1014500088510B1802E189510C1813E1200EE66E39
+:10146000600EE66E020EE66EE66A020EE66E8EEC28
+:1014700001F00B6E050EE15E0B50F3CF88F1F4CF57
+:1014800089F1FB0EDBCF0BF0FC0EDBCF0CF0010182
+:101490008A510B1802E18B510C1802E1816B866BAB
+:1014A000010E00D0E552E7CFD9FF1200D9CFE6FFF9
+:1014B000E1CFD9FF0101806B8851891102E1000E53
+:1014C00008D088C1E9FF89C1EAFFEF50800B01E035
+:1014D000010E000945E1FC0EDBCF0BF088C1E9FFEE
+:1014E00089C1EAFFEE52EF50D8800B5408E288C160
+:1014F000E9FF89C1EAFFEE52FC0EEFCFDBFF806B04
+:10150000FC0EDB50805D19E28051EA6A600FE96EE3
+:10151000020EEA22EF50E66E8051E76EFD0EDBCF41
+:10152000E9FFFE0EDBCFEAFFE750E926000EEA22D4
+:10153000E552E750EF6E802BE3D7200EE66E600E8B
+:10154000E66E020EE66EE66A020EE66E8EEC01F0C4
+:101550000B6E050EE15E0B50F3CF88F1F4CF89F1ED
+:101560000101805100D0E552E7CFD9FF1200D9CF59
+:10157000E6FFE1CFD9FFA094010181510CE1FD0EFE
+:10158000DBCF82F1FE0EDBCF83F1FC0EDBCF86F1E9
+:10159000010E876F816FA084E552E7CFD9FF12005B
+:1015A000D9CFE6FFE1CFD9FF030EE126A0940101D8
+:1015B000815102E0A0842FD0DF6AFD0EDBCF06F060
+:1015C000FE0EDBCF07F0DE5206C0DEFF07C0DDFFF8
+:1015D000DD52DF2ADF500B6E0C6AFF0E0B1801E1A3
+:1015E0000C5001E10BD0010EDBCFE9FFDB2A020E2C
+:1015F000DBCFEAFF01E3DB2AEF50EBE1FD0EDBCFAF
+:1016000082F1FE0EDBCF83F1DFCF86F10101010E07
+:10161000876F816FA084030EE15C02E2E16AE5520C
+:10162000E16EE552E7CFD9FF1200D9CFE6FFE1CF57
+:10163000D9FF030EE126A0940101815102E0A084AC
+:1016400030D0DF6AFD0EDBCF06F0FE0EDBCF07F0F9
+:10165000DE5206C0DEFF07C0DDFFDD52DF2ADF50AD
+:101660000B6E0C6AFF0E0B1801E10C5001E10CD05F
+:10167000010EDBCFF6FFDB2A020EDBCFF7FF01E323
+:10168000DB2A0800F550EAE1FD0EDBCF82F1FE0E09
+:10169000DBCF83F1DFCF86F10101876B010E816F14
+:1016A000A084030EE15C02E2E16AE552E16EE552DC
+:1016B000E7CFD9FF1200D9CFE6FFE1CFD9FF020E65
+:1016C000E126A09401018A518B1102E1000E08D09D
+:1016D0008AC1E9FF8BC1EAFFEF50800B01E0010EE8
+:1016E000000902E0A08487D0030E815D01E1816BD7
+:1016F000815102E1A0847FD0020E815D16E1E66A8D
+:10170000000EE66EE66A010EE66E020EE66E8EECE6
+:1017100001F00B6E050EE15E0B50F3CF8AF1F4CFB2
+:101720008BF10101030E816F65D0810563E1200E0D
+:101730000B6E0C6A86510B5C000E0C5803E2200EF7
+:10174000DF6E02D086C1DFFFDF50865D866F400E00
+:10175000846F020E856F010EDFCFDBFF875117E12B
+:10176000010EDB5013E082C1F6FF83C1F7FF0800D2
+:10177000F55084C1E9FF85C1EAFFEF6E842B000EAE
+:101780008523822B8323010EDB06EAD715D0010EB9
+:10179000DB5012E082C1E9FF83C1EAFFEF5084C150
+:1017A000E9FF85C1EAFFEF6E842B000E8523822BB3
+:1017B0008323010EDB06EBD7865108E1200EDF5CA8
+:1017C00003E1020E816F02D0030E816FDFCFE6FFCF
+:1017D000400EE66E020EE66E010EE66E020EE66E3C
+:1017E0008EEC01F00B6E050EE15E0B50F3CF8AF12B
+:1017F000F4CF8BF1A084020EE15C02E2E16AE552D3
+:0A180000E16EE552E7CFD9FF1200B8
+:06180A00DACFE4FFE2CF9B
+:10181000DAFFE9CFE4FFEACFE4FFF6CFE4FFF7CF4A
+:10182000E4FFF5CFE4FFF3CFE4FFF4CFE4FFFACF1A
+:10183000E4FF00EE00F00B0EE80403E3EECFE4FF5C
+:10184000FBD700EE0BF0030EE80403E3EECFE4FF5A
+:10185000FBD7E652A5EC00F0E55200EE0DF0030ECA
+:10186000E80403E3E5CFEDFFFBD700EE0AF00B0E33
+:10187000E80403E3E5CFEDFFFBD7E5CFFAFFE5CFC3
+:10188000F4FFE5CFF3FFE5CFF5FFE5CFF7FFE5CFB9
+:10189000F6FFE5CFEAFFE5CFE9FFE5CFDAFF11007C
+:1018A000D8CFE4FFE0CFE4FFE46EDACFE4FFE2CF8D
+:1018B000DAFFE65200000000E552E5CFDAFFE5501E
+:1018C000E5CFE0FFE5CFD8FF100073D8010140510C
+:1018D00002E1DFEC02F0A2D80001A851030A2DE0DA
+:1018E000010A14E0030A0EE0010A01E02CD0D2D86C
+:1018F000000907E0D8D80001A76F81880001020E17
+:10190000A86F21D00001020EA86F1DD08150400B9E
+:101910000EE08150800B0BE10000946A0000A7C02C
+:1019200082FF000081980001030EA86F05D081AEF0
+:1019300003D00001010EA86F06D081BC03D09468CB
+:101940000001A86B00D00001A85103E00001A80528
+:101950002EE18150800B24E01F0E0001A05D20E2EB
+:10196000818A81BEFED7000000000001A051EA6A12
+:10197000600FE96E000EEA2282CFEFFF3B0E825C21
+:1019800003E10001010EA46F819A0001A02B000168
+:10199000A051EA6A600FE96E000EEA22EF6A07D0F2
+:1019A0001F0E0001A05D03E30001010EA46F93D799
+:1019B0001200D9CFE6FFE1CFD9FFE652826A816AF1
+:1019C000806A380E776EF00E786E9468C00E936E53
+:1019D00092680001A36BA46B7E6A7F6AF26ADF6A79
+:1019E000DF500B6E0C6A200E0B5C000E0C5809E2E7
+:1019F000DF50EA6A600FE96E000EEA22EF6ADF2A22
+:101A0000EFD70001A06BA16BA56BA66BA86B15ECC3
+:101A100000F0E552E552E7CFD9FF1200200E010198
+:101A2000E76E4019E8AE02D0E73402D0E750405DDF
+:101A300003E36450020B01E02CD00001A35113E139
+:101A4000200EE66E800EE66E000EE66E56EC0AF094
+:101A5000E552E552E5520001A16FA151000803E2F1
+:101A6000010EA36FA26B0101815111E10001A4518C
+:101A70000EE0A0C0E6FF600EE66E000EE66EB7EC6C
+:101A80000AF0E552E552E5520001A06BA46B5BEC55
+:101A90000BF012000001A35103E0010E03D002D0AD
+:101AA000000E00D01200D9CFE6FFE1CFD9FFE652F9
+:101AB000DF6A0001A3510DE0A251EA6A800FE96ECE
+:101AC000000EEA22EFCFDFFFA22BA151A25D01E1C0
+:101AD000A36BDF5000D0E552E552E7CFD9FF1200EB
+:101AE00012001200120012008BEF09F01200DCEF5E
+:101AF00009F00101640520E1010165051DE1A094E3
+:101B0000F0DF64920101656B0001100EAA6F0E0EEA
+:101B1000AB6FAA07000EAB5BAA51AB11FAE164846C
+:101B2000080EAA6F070EAB6FAA07000EAB5BAA5197
+:101B3000AB11FAE16494A0841200D9CFE6FFE1CFA3
+:101B4000D9FFFD0EDBCF06F0FE0EDBCF07F0050E52
+:101B5000061801E1075039E0E868061802E17F0E37
+:101B6000071831E0030E061801E107502AE0020EC3
+:101B7000061801E1075023E0010E061801E10750A5
+:101B80001CE0740E061801E1075015E0750E0618EA
+:101B900001E107500EE0730E061801E1075007E05F
+:101BA000720E061801E1075001E010D00FD09ADF45
+:101BB0000DD096DF0BD095DF09D099DF07D096DFE7
+:101BC00005D092DF03D08FDF01D000D0010E00D00E
+:081BD000E552E7CFD9FF120036
+:081BD800280EF66E000EF76EF8
+:101BE000000EF86E01010900F5507A6F0900F550FA
+:101BF0007B6F03E17A6701D03DD00900F550756F26
+:101C00000900F550766F0900F550776F090009005B
+:101C1000F550E96E0900F550EA6E09000900090067
+:101C2000F550786F0900F550796F09000900F6CF7B
+:101C30007CF1F7CF7DF1F8CF7EF175C1F6FF76C16B
+:101C4000F7FF77C1F8FF0101785302E1795307E00C
+:101C50000900F550EE6E7807F8E27907F9D77CC1F4
+:101C6000F6FF7DC1F7FF7EC1F8FF01017A07000E84
+:061C70007B5BBFD71200F0
+:0A1C76001201000202000008D80469
+:101C80000CF800010102000109024300020100C03A
+:101C900031090400000102020100052400100104C2
+:101CA0002402020524060001052401000107058124
+:101CB000030A000109040100020A000000070502EE
+:101CC000022000000705820220000004030904141A
+:101CD000035300500052004F0047002000440043CF
+:101CE0000043001203430041004E005F00550053C3
+:0D1CF0000042003400881CCB1CCF1CE31CFC
+:021CFE00FE0ED8
+:101D0000E3CFE9FFFF0EE3CFEAFFE9CFF3FFEACF2E
+:101D1000F4FFFB0EE35003E1FC0EE35009E0FB0E81
+:101D2000E30602E2FC0EE306FD0EE350EE6EF1D791
+:021D300012009F
+:0E1D3200000EF36E00EE00F0030E01D812005A
+:101D4000EA6002D0EE6AFCD7F350E9601200EE6A56
+:021D5000FCD7BE
+:0E1D520011EE00F021EE00F0F86A0A9CECECB5
+:0E1D60000DF0B7EC0EF065EC0CF0FBD71200A6
+:021D6E00120061
+:020000040030CA
+:0100000000FF
+:0100010032CC
+:0100020001FC
+:010003001EDE
+:0100050000FA
+:010006008178
+:0100080003F4
+:01000900C036
+:01000A0003F2
+:01000B00E014
+:01000C0003F0
+:01000D0040B2
+:00000001FF
diff --git a/Source/USB/picft245.lkr b/Source/USB/picft245.lkr
new file mode 100644
index 0000000..097791a
--- /dev/null
+++ b/Source/USB/picft245.lkr
@@ -0,0 +1,34 @@
+// $Id: 18f14K50.lkr,v 1.1.4.1 2005/07/25 18:23:28 nairnj Exp $
+// File: 18f14K50.lkr
+// Sample linker script for the PIC18F14k50 processor
+
+LIBPATH .
+
+FILES c018i.o
+FILES clib.lib
+FILES p18f14k50.lib
+
+// Application
+CODEPAGE NAME=vectors START=0x0 END=0x27 PROTECTED
+CODEPAGE NAME=appcode START=0x28 END=0x3FFF
+
+CODEPAGE NAME=idlocs START=0x200000 END=0x200007 PROTECTED
+CODEPAGE NAME=config START=0x300000 END=0x30000D PROTECTED
+CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
+CODEPAGE NAME=eedata START=0xF00000 END=0xF000FF PROTECTED
+
+ACCESSBANK NAME=accessram START=0x0 END=0x5F
+DATABANK NAME=gpr0 START=0x60 END=0xBF
+DATABANK NAME=stack START=0x100 END=0x17f
+DATABANK NAME=gpr1 START=0x180 END=0x1F3
+DATABANK NAME=usb2 START=0x200 END=0x2FF PROTECTED
+DATABANK NAME=sfr15 START=0xF40 END=0xF5F PROTECTED
+ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
+
+SECTION NAME=CONFIG ROM=config
+
+SECTION NAME=usbram2 RAM=usb2
+SECTION NAME=USB_VARS RAM=usb2
+
+STACK SIZE=0x40 RAM=stack
+SECTION NAME=VARS RAM=accessram
diff --git a/Source/USB/picft245.map b/Source/USB/picft245.map
new file mode 100644
index 0000000..b6c7c16
--- /dev/null
+++ b/Source/USB/picft245.map
@@ -0,0 +1,966 @@
+MPLINK 5.00, LINKER
+Linker Map File - Created Sun Mar 22 15:29:10 2015
+
+ Section Info
+ Section Type Address Location Size(Bytes)
+ --------- --------- --------- --------- ---------
+ _entry_scn code 0x000000 program 0x000006
+ high_vector code 0x000008 program 0x000006
+ low_vector code 0x000018 program 0x000006
+ .cinit romdata 0x000028 program 0x000002
+ .code_usb_device.o code 0x00002a program 0x0012ec
+ .code_usb_function_cdc.o code 0x001316 program 0x0004f4
+ .code_picft245.o code 0x00180a program 0x0003ce
+ _cinit_scn code 0x001bd8 program 0x00009e
+.romdata_usb_descriptors.o romdata 0x001c76 program 0x000087
+ .idata___init.o_i romdata 0x001cfd program 0x000000
+ .romdata___init.o romdata 0x001cfd program 0x000000
+ .romdata_c018i.o romdata 0x001cfd program 0x000000
+ .romdata_picft245.o romdata 0x001cfd program 0x000000
+ .idata_picft245.o_i romdata 0x001cfd program 0x000000
+.romdata_usb_function_cdc.o romdata 0x001cfd program 0x000000
+.idata_usb_function_cdc.o_i romdata 0x001cfd program 0x000000
+ .romdata_usb_device.o romdata 0x001cfd program 0x000000
+ .idata_usb_device.o_i romdata 0x001cfd program 0x000000
+.idata_usb_descriptors.o_i romdata 0x001cfd program 0x000000
+ .idata_c018i.o_i romdata 0x001cfd program 0x000000
+ .code_c018i.o code 0x001cfe program 0x000000
+ .code_usb_descriptors.o code 0x001cfe program 0x000000
+ STRING code 0x001cfe program 0x000034
+ .code code 0x001d32 program 0x000020
+ _startup_scn code 0x001d52 program 0x00001c
+ .code___init.o code 0x001d6e program 0x000002
+.config_300000_picft245.o romdata 0x300000 program 0x000001
+.config_300001_picft245.o romdata 0x300001 program 0x000001
+.config_300002_picft245.o romdata 0x300002 program 0x000001
+.config_300003_picft245.o romdata 0x300003 program 0x000001
+.config_300005_picft245.o romdata 0x300005 program 0x000001
+.config_300006_picft245.o romdata 0x300006 program 0x000001
+.config_300008_picft245.o romdata 0x300008 program 0x000001
+.config_300009_picft245.o romdata 0x300009 program 0x000001
+.config_30000a_picft245.o romdata 0x30000a program 0x000001
+.config_30000b_picft245.o romdata 0x30000b program 0x000001
+.config_30000c_picft245.o romdata 0x30000c program 0x000001
+.config_30000d_picft245.o romdata 0x30000d program 0x000001
+ MATH_DATA udata 0x000000 data 0x00000b
+ .tmpdata udata 0x00000b data 0x000003
+ .udata_picft245.o udata 0x000060 data 0x00004c
+ .stack udata 0x000100 data 0x000040
+ .udata_usb_device.o udata 0x000140 data 0x000035
+ .udata_c018i.o udata 0x000175 data 0x00000a
+ .udata_usb_descriptors.o udata 0x00017f data 0x000000
+ .idata_usb_descriptors.o idata 0x00017f data 0x000000
+ .idata_usb_device.o idata 0x00017f data 0x000000
+.idata_usb_function_cdc.o idata 0x00017f data 0x000000
+ .idata_c018i.o idata 0x00017f data 0x000000
+ .idata_picft245.o idata 0x00017f data 0x000000
+ .udata___init.o udata 0x00017f data 0x000000
+ .idata___init.o idata 0x00017f data 0x000000
+.udata_usb_function_cdc.o udata 0x000180 data 0x000019
+ USB_BDT udata 0x000200 data 0x000040
+ usbram2 udata 0x000240 data 0x000051
+ SFR_BANKED0 udata 0x000f53 data 0x00000d
+ SFR_UNBANKED0 udata 0x000f60 data 0x0000a0
+
+
+
+ Program Memory Usage
+ Start End
+ --------- ---------
+ 0x000000 0x000005
+ 0x000008 0x00000d
+ 0x000018 0x00001d
+ 0x000028 0x001cfc
+ 0x001cfe 0x001d6f
+ 0x300000 0x300003
+ 0x300005 0x300006
+ 0x300008 0x30000d
+ 7525 out of 16664 program addresses used, program memory utilization is 45%
+
+
+
+ Symbols - Sorted by Name
+ Name Address Location Storage File
+ --------- --------- --------- --------- ---------
+ CDCInitEP 0x0013b8 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CDCTxService 0x0016b6 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ HIGH_INT_VECT 0x000008 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ InitializeSystem 0x0019b2 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ LOW_INT_VECT 0x000018 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ ProcessIO 0x001a1c program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBCheckOtherReq 0x001ae8 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBErrorHandler 0x001ae6 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBInitEP 0x001aee program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBSendResume 0x001af2 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBStdSetDscHandler 0x001aec program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBSuspend 0x001ae0 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBWakeFromSuspend 0x001ae2 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCB_SOF_Handler 0x001ae4 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCDCEventHandler 0x001420 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ USBCancelIO 0x000502 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCheckCDCRequest 0x001316 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ USBCheckStdRequest 0x000fc0 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBConfigureEndpoint 0x000710 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlEPAllowDataStage 0x000690 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBCtrlEPAllowStatusStage 0x0005ee program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlEPService 0x000d92 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlEPServiceComplete 0x0007ca program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfInHandler 0x000f06 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfOutHandler 0x000ebc program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfRxService 0x000950 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfSetupHandler 0x000e5e program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfTxService 0x00088c program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceAttach 0x0005be program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceDetach 0x0005b2 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceInit 0x00002a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceTasks 0x00014a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBEnableEndpoint 0x0002ae program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStallEndpoint 0x000422 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStallHandler 0x000d06 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdFeatureReqHandler 0x001088 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdGetDscHandler 0x000b76 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdGetStatusHandler 0x000c36 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdSetCfgHandler 0x000a90 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBSuspend 0x000d3a program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBTransferOnePacket 0x00031c program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBWakeFromSuspend 0x000d64 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USB_CD_Ptr 0x001cf5 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ USB_SD_Ptr 0x001cf7 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+USER_USB_CALLBACK_EVENT_HANDLER 0x001b3a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ _2jContinue 0x001d1e program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ _3jEnd 0x001d28 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ ___case_0_lbl00010 0x0018ee program static
+ ___case_1_lbl00011 0x001904 program static
+ ___case_2_lbl00016 0x00190c program static
+ ___case_3_lbl00018 0x00193a program static
+ ___else_lbl00015 0x00192e program static
+ ___else_lbl00026 0x0019a0 program static
+ ___if_lbl00005 0x0018d6 program static
+ ___if_lbl00009 0x001902 program static
+ ___if_lbl00013 0x001938 program static
+ ___if_lbl00014 0x001938 program static
+ ___if_lbl00017 0x001944 program static
+ ___if_lbl00023 0x001988 program static
+ ___if_lbl00024 0x0019ae program static
+ ___if_lbl00025 0x0019ae program static
+ ___if_lbl00027 0x0019ae program static
+ ___return_lbl00000 0x000004 program static
+ ___return_lbl00001 0x0018b8 program static
+ ___return_lbl00001 0x001d6c program static
+ ___return_lbl00002 0x001c74 program static
+ ___return_lbl00002 0x00000c program static
+ ___return_lbl00003 0x00001c program static
+ ___return_lbl00004 0x0019b0 program static
+ ___switchexit_lbl00008 0x001946 program static
+ ___while_lbl00006 0x0018d6 program static
+ ___while_lbl00007 0x0019b0 program static
+ ___while_lbl00021 0x001962 program static
+ ___while_lbl00022 0x001966 program static
+ __config_0 0x300000 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_1 0x300001 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_10 0x30000c program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_11 0x30000d program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_2 0x300002 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_3 0x300003 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_4 0x300005 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_5 0x300006 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_6 0x300008 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_7 0x300009 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_8 0x30000a program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_9 0x30000b program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __init 0x001d6e program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\__init.c
+ __tmplbl_0 0x001918 program static
+ __tmplbl_1 0x001912 program static
+ __tmplbl_2 0x001952 program static
+ __tmplbl_3 0x00194c program static
+ __tmplbl_4 0x001960 program static
+ __tmplbl_5 0x001958 program static
+ __zero_memory 0x001d32 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ _do_cinit 0x001bd8 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ _entry 0x000000 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ _startup 0x001d52 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ compare_l 0x001d48 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ configDescriptor1 0x001c88 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ copy_loop 0x001c4a program static
+ copy_one_byte 0x001c50 program static
+ device_dsc 0x001c76 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ done 0x001c74 program static
+ done_copying 0x001c5e program static
+ getsUSBUSART 0x0014ac program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ isr_high 0x00180a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ isr_low 0x0018a0 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ jEnd 0x001d30 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ jLoop 0x001d12 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ loop 0x001d62 program static
+ loop_h 0x001d40 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ loop_l 0x001d4a program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ main 0x0018ca program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ memset 0x001cfe program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ putUSBUSART 0x00156e program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ putrsUSBUSART 0x00162a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ putsUSBUSART 0x0015a0 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ sd000 0x001ccb program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ sd001 0x001ccf program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ sd002 0x001ce3 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ test 0x001bf2 program static
+ usbGetChar 0x001aa6 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ usbIsDataRdy 0x001a94 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ zero_block 0x001d40 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON0 0x000fc2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON0bits 0x000fc2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON1 0x000fc1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON1bits 0x000fc1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON2 0x000fc0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON2bits 0x000fc0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADRES 0x000fc3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADRESH 0x000fc4 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADRESL 0x000fc3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSEL 0x000f7e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSELH 0x000f7f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSELHbits 0x000f7f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSELbits 0x000f7e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCON 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCONbits 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCTL 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCTLbits 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BDT 0x000200 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ BSR 0x000fe0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BaudRateGen 0x00018d data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ BothEP0OutUOWNsSet 0x000168 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ CCP1CON 0x000fbd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCP1CONbits 0x000fbd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCPR1 0x000fbe data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCPR1H 0x000fbf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCPR1L 0x000fbe data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CDCDataInHandle 0x00018a data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CDCDataOutHandle 0x000188 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CM1CON0 0x000f6d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM1CON0bits 0x000f6d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON0 0x000f6b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON0bits 0x000f6b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON1 0x000f6c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON1bits 0x000f6c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CtrlTrfData 0x000238 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ DDRA 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRAbits 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRB 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRBbits 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRC 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRCbits 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ECCP1AS 0x000fb6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ECCP1ASbits 0x000fb6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EEADR 0x000fa9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EEADRbits 0x000fa9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EECON1 0x000fa6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EECON1bits 0x000fa6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EECON2 0x000fa7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EEDATA 0x000fa8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR0 0x000fe9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR0H 0x000fea data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR0L 0x000fe9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR1 0x000fe1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR1H 0x000fe2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR1L 0x000fe1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR2 0x000fd9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR2H 0x000fda data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR2L 0x000fd9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INDF0 0x000fef data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INDF1 0x000fe7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INDF2 0x000fdf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON 0x000ff2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON2 0x000ff1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON2bits 0x000ff1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON3 0x000ff0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON3bits 0x000ff0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCONbits 0x000ff2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCA 0x000f79 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCAbits 0x000f79 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCB 0x000f7a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCBbits 0x000f7a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR1 0x000f9f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR1bits 0x000f9f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR2 0x000fa2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR2bits 0x000fa2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATA 0x000f89 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATAbits 0x000f89 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATB 0x000f8a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATBbits 0x000f8a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATC 0x000f8b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATCbits 0x000f8b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LastUSBIn 0x0000a1 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ NextUSBOut 0x0000a0 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ OSCCON 0x000fd3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCON2 0x000fd2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCON2bits 0x000fd2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCONbits 0x000fd3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCTUNE 0x000f9b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCTUNEbits 0x000f9b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PC 0x000ff9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PCL 0x000ff9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PCLATH 0x000ffa data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PCLATU 0x000ffb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE1 0x000f9d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE1bits 0x000f9d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE2 0x000fa0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE2bits 0x000fa0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR1 0x000f9e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR1bits 0x000f9e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR2 0x000fa1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR2bits 0x000fa1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PLUSW0 0x000feb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PLUSW1 0x000fe3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PLUSW2 0x000fdb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTA 0x000f80 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTAbits 0x000f80 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTB 0x000f81 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTBbits 0x000f81 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTC 0x000f82 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTCbits 0x000f82 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTDEC0 0x000fed data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTDEC1 0x000fe5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTDEC2 0x000fdd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTINC0 0x000fee data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTINC1 0x000fe6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTINC2 0x000fde data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PR2 0x000fcb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PREINC0 0x000fec data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PREINC1 0x000fe4 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PREINC2 0x000fdc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PROD 0x000ff3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PRODH 0x000ff4 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PRODL 0x000ff3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PSTRCON 0x000fb9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PSTRCONbits 0x000fb9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PWM1CON 0x000fb7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PWM1CONbits 0x000fb7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCON 0x000fd0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCONbits 0x000fd0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCREG 0x000fae data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCSTA 0x000fab data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCSTAbits 0x000fab data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON0 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON0bits 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON1 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON1bits 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON2 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON2bits 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RemoteWakeup 0x000164 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ SIGN 0x000009 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\cmath18.asm
+ SLRCON 0x000f76 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SLRCONbits 0x000f76 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SPBRG 0x000faf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SPBRGH 0x000fb0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON0 0x000f68 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON0bits 0x000f68 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON1 0x000f69 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON1bits 0x000f69 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPADD 0x000fc8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPBUF 0x000fc9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON1 0x000fc6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON1bits 0x000fc6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON2 0x000fc5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON2bits 0x000fc5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPMSK 0x000f6f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPMSKbits 0x000f6f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPSTAT 0x000fc7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPSTATbits 0x000fc7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STATUS 0x000fd8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STATUSbits 0x000fd8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STKPTR 0x000ffc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STKPTRbits 0x000ffc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SetupPkt 0x000230 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ T0CON 0x000fd5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T0CONbits 0x000fd5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T1CON 0x000fcd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T1CONbits 0x000fcd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T2CON 0x000fca data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T2CONbits 0x000fca data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T3CON 0x000fb1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T3CONbits 0x000fb1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TABLAT 0x000ff5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTR 0x000ff6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTRH 0x000ff7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTRL 0x000ff6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTRU 0x000ff8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR0H 0x000fd7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR0L 0x000fd6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR1H 0x000fcf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR1L 0x000fce data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR2 0x000fcc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR3H 0x000fb3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR3L 0x000fb2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOS 0x000ffd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOSH 0x000ffe data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOSL 0x000ffd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOSU 0x000fff data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISA 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISAbits 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISB 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISBbits 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISC 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISCbits 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TXREG 0x000fad data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TXSTA 0x000fac data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TXSTAbits 0x000fac data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UADDR 0x000f5c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UADDRbits 0x000f5c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCFG 0x000f61 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCFGbits 0x000f61 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCON 0x000f64 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCONbits 0x000f64 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIE 0x000f5b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIEbits 0x000f5b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIR 0x000f5f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIRbits 0x000f5f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP0 0x000f53 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP0bits 0x000f53 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP1 0x000f54 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP1bits 0x000f54 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP2 0x000f55 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP2bits 0x000f55 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP3 0x000f56 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP3bits 0x000f56 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP4 0x000f57 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP4bits 0x000f57 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP5 0x000f58 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP5bits 0x000f58 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP6 0x000f59 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP6bits 0x000f59 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP7 0x000f5a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP7bits 0x000f5a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRMH 0x000f5e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRMHbits 0x000f5e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRML 0x000f5d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRMLbits 0x000f5d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIE 0x000f60 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIEbits 0x000f60 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIR 0x000f62 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIRbits 0x000f62 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ USBActiveConfiguration 0x000141 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBAlternateInterface 0x000142 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBBusIsSuspended 0x000165 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBDeferINDataStagePackets 0x000173 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBDeferOUTDataStagePackets 0x000174 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBDeferStatusStagePacket 0x000170 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceState 0x000140 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBStatusStageEnabledFlag1 0x000171 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBStatusStageEnabledFlag2 0x000172 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBStatusStageTimeoutCounter 0x00016f data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USB_In_Buffer 0x000080 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USB_In_Data_Rdy 0x0000a3 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USB_Out_Buffer 0x000060 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USB_Out_Data_Rdy 0x0000a4 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBcp 0x0000a2 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USTAT 0x000f63 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ USTATbits 0x000f63 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ USTATcopy 0x000166 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ VREFCON0 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON0bits 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON1 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON1bits 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON2 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON2bits 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ W 0x000fe8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WDTCON 0x000fd1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WDTCONbits 0x000fd1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUA 0x000f77 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUAbits 0x000f77 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUB 0x000f78 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUBbits 0x000f78 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WREG 0x000fe8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ __AARGB0 0x000007 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB1 0x000006 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB2 0x000005 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB3 0x000004 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB4 0x000003 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB5 0x000002 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB6 0x000001 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB7 0x000000 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AEXP 0x000008 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __FPFLAGS 0x00000a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\cmath18.asm
+ __FPFLAGSbits 0x00000a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\cmath18.asm
+ __REMB0 0x000003 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB1 0x000002 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB2 0x000001 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB3 0x000000 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __tmp_0 0x00000b data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __tmp_0 0x00000b data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ __tmp_0 0x00000b data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ can_in 0x0000a9 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ cdc_data_rx 0x000260 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_data_tx 0x000240 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_mem_type 0x000187 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_notice 0x000287 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_rx_len 0x000180 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_trf_state 0x000181 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_tx_len 0x000186 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ controlTransferState 0x000155 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ control_signal_bitmap 0x00018c data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ curr_byte 0x000178 data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ curr_entry 0x00017a data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ data_ptr 0x00017c data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ delay_count 0x0000aa data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+dummy_encapsulated_cmd_response 0x000191 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ endpoint_number 0x000167 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ ep_data_in 0x000169 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ ep_data_out 0x00016c data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ inPipes 0x000156 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ lastTransmission 0x0000a5 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ line_coding 0x000280 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ outPipes 0x00015b data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryEP0OutCurrent 0x000144 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryEP0OutNext 0x000146 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryIn 0x00014e data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryOut 0x000148 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pCDCDst 0x000184 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ pCDCSrc 0x000182 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ pDst 0x000162 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ prom 0x000175 data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ shortPacketStatus 0x000154 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ usb_in 0x0000a7 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ usb_in_state 0x0000a8 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+
+
+
+ Symbols - Sorted by Address
+ Name Address Location Storage File
+ --------- --------- --------- --------- ---------
+ _entry 0x000000 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ ___return_lbl00000 0x000004 program static
+ HIGH_INT_VECT 0x000008 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ ___return_lbl00002 0x00000c program static
+ LOW_INT_VECT 0x000018 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ ___return_lbl00003 0x00001c program static
+ USBDeviceInit 0x00002a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceTasks 0x00014a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBEnableEndpoint 0x0002ae program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBTransferOnePacket 0x00031c program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStallEndpoint 0x000422 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCancelIO 0x000502 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceDetach 0x0005b2 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBDeviceAttach 0x0005be program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBCtrlEPAllowStatusStage 0x0005ee program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlEPAllowDataStage 0x000690 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBConfigureEndpoint 0x000710 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlEPServiceComplete 0x0007ca program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfTxService 0x00088c program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfRxService 0x000950 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdSetCfgHandler 0x000a90 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdGetDscHandler 0x000b76 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdGetStatusHandler 0x000c36 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStallHandler 0x000d06 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBSuspend 0x000d3a program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBWakeFromSuspend 0x000d64 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlEPService 0x000d92 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfSetupHandler 0x000e5e program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfOutHandler 0x000ebc program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCtrlTrfInHandler 0x000f06 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCheckStdRequest 0x000fc0 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBStdFeatureReqHandler 0x001088 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBCheckCDCRequest 0x001316 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CDCInitEP 0x0013b8 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ USBCDCEventHandler 0x001420 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ getsUSBUSART 0x0014ac program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ putUSBUSART 0x00156e program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ putsUSBUSART 0x0015a0 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ putrsUSBUSART 0x00162a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CDCTxService 0x0016b6 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ isr_high 0x00180a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ isr_low 0x0018a0 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ ___return_lbl00001 0x0018b8 program static
+ main 0x0018ca program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ ___while_lbl00006 0x0018d6 program static
+ ___if_lbl00005 0x0018d6 program static
+ ___case_0_lbl00010 0x0018ee program static
+ ___if_lbl00009 0x001902 program static
+ ___case_1_lbl00011 0x001904 program static
+ ___case_2_lbl00016 0x00190c program static
+ __tmplbl_1 0x001912 program static
+ __tmplbl_0 0x001918 program static
+ ___else_lbl00015 0x00192e program static
+ ___if_lbl00013 0x001938 program static
+ ___if_lbl00014 0x001938 program static
+ ___case_3_lbl00018 0x00193a program static
+ ___if_lbl00017 0x001944 program static
+ ___switchexit_lbl00008 0x001946 program static
+ __tmplbl_3 0x00194c program static
+ __tmplbl_2 0x001952 program static
+ __tmplbl_5 0x001958 program static
+ __tmplbl_4 0x001960 program static
+ ___while_lbl00021 0x001962 program static
+ ___while_lbl00022 0x001966 program static
+ ___if_lbl00023 0x001988 program static
+ ___else_lbl00026 0x0019a0 program static
+ ___if_lbl00027 0x0019ae program static
+ ___if_lbl00025 0x0019ae program static
+ ___if_lbl00024 0x0019ae program static
+ ___return_lbl00004 0x0019b0 program static
+ ___while_lbl00007 0x0019b0 program static
+ InitializeSystem 0x0019b2 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ ProcessIO 0x001a1c program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ usbIsDataRdy 0x001a94 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ usbGetChar 0x001aa6 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBSuspend 0x001ae0 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBWakeFromSuspend 0x001ae2 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCB_SOF_Handler 0x001ae4 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBErrorHandler 0x001ae6 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBCheckOtherReq 0x001ae8 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBStdSetDscHandler 0x001aec program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBInitEP 0x001aee program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBCBSendResume 0x001af2 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+USER_USB_CALLBACK_EVENT_HANDLER 0x001b3a program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ _do_cinit 0x001bd8 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ test 0x001bf2 program static
+ copy_loop 0x001c4a program static
+ copy_one_byte 0x001c50 program static
+ done_copying 0x001c5e program static
+ done 0x001c74 program static
+ ___return_lbl00002 0x001c74 program static
+ device_dsc 0x001c76 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ configDescriptor1 0x001c88 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ sd000 0x001ccb program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ sd001 0x001ccf program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ sd002 0x001ce3 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ USB_CD_Ptr 0x001cf5 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ USB_SD_Ptr 0x001cf7 program extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\usb_descriptors.c
+ memset 0x001cfe program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ jLoop 0x001d12 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ _2jContinue 0x001d1e program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ _3jEnd 0x001d28 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ jEnd 0x001d30 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\memset.asm
+ __zero_memory 0x001d32 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ zero_block 0x001d40 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ loop_h 0x001d40 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ compare_l 0x001d48 program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ loop_l 0x001d4a program static E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ _startup 0x001d52 program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ loop 0x001d62 program static
+ ___return_lbl00001 0x001d6c program static
+ __init 0x001d6e program extern E:\3.46\pic18-lt\cxx-framework\src\traditional\stdclib\__init.c
+ __config_0 0x300000 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_1 0x300001 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_2 0x300002 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_3 0x300003 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_4 0x300005 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_5 0x300006 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_6 0x300008 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_7 0x300009 program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_8 0x30000a program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_9 0x30000b program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_10 0x30000c program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __config_11 0x30000d program static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __AARGB7 0x000000 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB3 0x000000 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB6 0x000001 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB2 0x000001 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB1 0x000002 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB5 0x000002 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __REMB0 0x000003 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB4 0x000003 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB3 0x000004 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB2 0x000005 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB1 0x000006 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AARGB0 0x000007 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ __AEXP 0x000008 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\aarg.asm
+ SIGN 0x000009 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\cmath18.asm
+ __FPFLAGS 0x00000a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\cmath18.asm
+ __FPFLAGSbits 0x00000a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\math\cmath18.asm
+ __tmp_0 0x00000b data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ __tmp_0 0x00000b data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ __tmp_0 0x00000b data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USB_Out_Buffer 0x000060 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USB_In_Buffer 0x000080 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ NextUSBOut 0x0000a0 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ LastUSBIn 0x0000a1 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBcp 0x0000a2 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USB_In_Data_Rdy 0x0000a3 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USB_Out_Data_Rdy 0x0000a4 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ lastTransmission 0x0000a5 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ usb_in 0x0000a7 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ usb_in_state 0x0000a8 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ can_in 0x0000a9 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ delay_count 0x0000aa data static D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.c
+ USBDeviceState 0x000140 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBActiveConfiguration 0x000141 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBAlternateInterface 0x000142 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryEP0OutCurrent 0x000144 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryEP0OutNext 0x000146 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryOut 0x000148 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pBDTEntryIn 0x00014e data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ shortPacketStatus 0x000154 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ controlTransferState 0x000155 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ inPipes 0x000156 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ outPipes 0x00015b data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ pDst 0x000162 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ RemoteWakeup 0x000164 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USBBusIsSuspended 0x000165 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ USTATcopy 0x000166 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ endpoint_number 0x000167 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ BothEP0OutUOWNsSet 0x000168 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ ep_data_in 0x000169 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ ep_data_out 0x00016c data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBStatusStageTimeoutCounter 0x00016f data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBDeferStatusStagePacket 0x000170 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBStatusStageEnabledFlag1 0x000171 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBStatusStageEnabledFlag2 0x000172 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBDeferINDataStagePackets 0x000173 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+USBDeferOUTDataStagePackets 0x000174 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ prom 0x000175 data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ curr_byte 0x000178 data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ curr_entry 0x00017a data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ data_ptr 0x00017c data static E:\3.46\pic18-lt\cxx-framework\src\traditional\startup\c018i.c
+ cdc_rx_len 0x000180 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_trf_state 0x000181 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ pCDCSrc 0x000182 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ pCDCDst 0x000184 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_tx_len 0x000186 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_mem_type 0x000187 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CDCDataOutHandle 0x000188 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ CDCDataInHandle 0x00018a data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ control_signal_bitmap 0x00018c data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ BaudRateGen 0x00018d data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+dummy_encapsulated_cmd_response 0x000191 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ BDT 0x000200 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ SetupPkt 0x000230 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ CtrlTrfData 0x000238 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\usb_device.c
+ cdc_data_tx 0x000240 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_data_rx 0x000260 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ line_coding 0x000280 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ cdc_notice 0x000287 data extern D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+ UEP0bits 0x000f53 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP0 0x000f53 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP1 0x000f54 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP1bits 0x000f54 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP2 0x000f55 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP2bits 0x000f55 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP3 0x000f56 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP3bits 0x000f56 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP4 0x000f57 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP4bits 0x000f57 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP5 0x000f58 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP5bits 0x000f58 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP6bits 0x000f59 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP6 0x000f59 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP7bits 0x000f5a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEP7 0x000f5a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIE 0x000f5b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIEbits 0x000f5b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UADDR 0x000f5c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UADDRbits 0x000f5c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRMLbits 0x000f5d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRML 0x000f5d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRMHbits 0x000f5e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UFRMH 0x000f5e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIRbits 0x000f5f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UEIR 0x000f5f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIE 0x000f60 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIEbits 0x000f60 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCFGbits 0x000f61 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCFG 0x000f61 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIRbits 0x000f62 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UIR 0x000f62 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ USTAT 0x000f63 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ USTATbits 0x000f63 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCON 0x000f64 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ UCONbits 0x000f64 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON0bits 0x000f68 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON0 0x000f68 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON1bits 0x000f69 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SRCON1 0x000f69 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON0bits 0x000f6b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON0 0x000f6b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON1bits 0x000f6c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM2CON1 0x000f6c data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM1CON0 0x000f6d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CM1CON0bits 0x000f6d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPMSKbits 0x000f6f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPMSK 0x000f6f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SLRCONbits 0x000f76 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SLRCON 0x000f76 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUA 0x000f77 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUAbits 0x000f77 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUB 0x000f78 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WPUBbits 0x000f78 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCA 0x000f79 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCAbits 0x000f79 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCB 0x000f7a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IOCBbits 0x000f7a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSEL 0x000f7e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSELbits 0x000f7e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSELH 0x000f7f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ANSELHbits 0x000f7f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTA 0x000f80 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTAbits 0x000f80 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTB 0x000f81 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTBbits 0x000f81 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTC 0x000f82 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PORTCbits 0x000f82 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATAbits 0x000f89 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATA 0x000f89 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATB 0x000f8a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATBbits 0x000f8a data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATCbits 0x000f8b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ LATC 0x000f8b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISA 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISAbits 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRAbits 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRA 0x000f92 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISBbits 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISB 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRB 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRBbits 0x000f93 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISC 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRCbits 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ DDRC 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TRISCbits 0x000f94 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCTUNEbits 0x000f9b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCTUNE 0x000f9b data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE1bits 0x000f9d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE1 0x000f9d data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR1bits 0x000f9e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR1 0x000f9e data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR1bits 0x000f9f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR1 0x000f9f data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE2bits 0x000fa0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIE2 0x000fa0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR2bits 0x000fa1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PIR2 0x000fa1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR2 0x000fa2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ IPR2bits 0x000fa2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EECON1bits 0x000fa6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EECON1 0x000fa6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EECON2 0x000fa7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EEDATA 0x000fa8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EEADR 0x000fa9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ EEADRbits 0x000fa9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCSTA 0x000fab data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCSTAbits 0x000fab data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TXSTA 0x000fac data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TXSTAbits 0x000fac data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TXREG 0x000fad data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCREG 0x000fae data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SPBRG 0x000faf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SPBRGH 0x000fb0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T3CONbits 0x000fb1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T3CON 0x000fb1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR3L 0x000fb2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR3H 0x000fb3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ECCP1AS 0x000fb6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ECCP1ASbits 0x000fb6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PWM1CON 0x000fb7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PWM1CONbits 0x000fb7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCON 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCONbits 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCTL 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BAUDCTLbits 0x000fb8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PSTRCON 0x000fb9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PSTRCONbits 0x000fb9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON0bits 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON0 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON0 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON0bits 0x000fba data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON1bits 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON1 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON1 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON1bits 0x000fbb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON2bits 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ REFCON2 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON2bits 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ VREFCON2 0x000fbc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCP1CON 0x000fbd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCP1CONbits 0x000fbd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCPR1 0x000fbe data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCPR1L 0x000fbe data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ CCPR1H 0x000fbf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON2bits 0x000fc0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON2 0x000fc0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON1bits 0x000fc1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON1 0x000fc1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON0 0x000fc2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADCON0bits 0x000fc2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADRES 0x000fc3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADRESL 0x000fc3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ ADRESH 0x000fc4 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON2bits 0x000fc5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON2 0x000fc5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON1bits 0x000fc6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPCON1 0x000fc6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPSTATbits 0x000fc7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPSTAT 0x000fc7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPADD 0x000fc8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ SSPBUF 0x000fc9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T2CONbits 0x000fca data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T2CON 0x000fca data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PR2 0x000fcb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR2 0x000fcc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T1CONbits 0x000fcd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T1CON 0x000fcd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR1L 0x000fce data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR1H 0x000fcf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCONbits 0x000fd0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ RCON 0x000fd0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WDTCONbits 0x000fd1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WDTCON 0x000fd1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCON2bits 0x000fd2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCON2 0x000fd2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCONbits 0x000fd3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ OSCCON 0x000fd3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T0CON 0x000fd5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ T0CONbits 0x000fd5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR0L 0x000fd6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TMR0H 0x000fd7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STATUS 0x000fd8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STATUSbits 0x000fd8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR2L 0x000fd9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR2 0x000fd9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR2H 0x000fda data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PLUSW2 0x000fdb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PREINC2 0x000fdc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTDEC2 0x000fdd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTINC2 0x000fde data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INDF2 0x000fdf data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ BSR 0x000fe0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR1L 0x000fe1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR1 0x000fe1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR1H 0x000fe2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PLUSW1 0x000fe3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PREINC1 0x000fe4 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTDEC1 0x000fe5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTINC1 0x000fe6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INDF1 0x000fe7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ W 0x000fe8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ WREG 0x000fe8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR0L 0x000fe9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR0 0x000fe9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ FSR0H 0x000fea data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PLUSW0 0x000feb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PREINC0 0x000fec data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTDEC0 0x000fed data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ POSTINC0 0x000fee data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INDF0 0x000fef data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON3bits 0x000ff0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON3 0x000ff0 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON2bits 0x000ff1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON2 0x000ff1 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCONbits 0x000ff2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ INTCON 0x000ff2 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PRODL 0x000ff3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PROD 0x000ff3 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PRODH 0x000ff4 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TABLAT 0x000ff5 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTR 0x000ff6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTRL 0x000ff6 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTRH 0x000ff7 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TBLPTRU 0x000ff8 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PCL 0x000ff9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PC 0x000ff9 data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PCLATH 0x000ffa data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ PCLATU 0x000ffb data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STKPTRbits 0x000ffc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ STKPTR 0x000ffc data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOS 0x000ffd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOSL 0x000ffd data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOSH 0x000ffe data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+ TOSU 0x000fff data extern E:\3.46\pic18-lt\cxx-framework\src\traditional\proc\p18f14k50.asm
+
+
diff --git a/Source/USB/picft245.mcp b/Source/USB/picft245.mcp
new file mode 100644
index 0000000..38723e5
--- /dev/null
+++ b/Source/USB/picft245.mcp
@@ -0,0 +1,74 @@
+[HEADER]
+magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
+file_version=1.0
+device=PIC18F14K50
+[PATH_INFO]
+BuildDirPolicy=BuildDirIsProjectDir
+dir_src=
+dir_bin=
+dir_tmp=tmp
+dir_sin=
+dir_inc=USB2.9i_cdc\include;C\MCC18\h
+dir_lib=C:\MCC18\lib
+dir_lkr=
+[CAT_FILTERS]
+filter_src=*.asm;*.c
+filter_inc=*.h;*.inc
+filter_obj=*.o
+filter_lib=*.lib
+filter_lkr=*.lkr
+[CAT_SUBFOLDERS]
+subfolder_src=USB
+subfolder_inc=
+subfolder_obj=
+subfolder_lib=
+subfolder_lkr=
+[FILE_SUBFOLDERS]
+file_000=.
+file_001=USB
+file_002=USB
+file_003=.
+file_004=.
+file_005=.
+file_006=.
+[GENERATED_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+[OTHER_FILES]
+file_000=no
+file_001=no
+file_002=no
+file_003=no
+file_004=no
+file_005=no
+file_006=no
+[FILE_INFO]
+file_000=usb_descriptors.c
+file_001=USB2.9i_cdc\USB\usb_device.c
+file_002=USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c
+file_003=picft245.c
+file_004=HardwareProfile.h
+file_005=usb_config.h
+file_006=picft245.lkr
+[SUITE_INFO]
+suite_guid={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+suite_state=
+[TOOL_SETTINGS]
+TS{DD2213A8-6310-47B1-8376-9430CDFC013F}=
+TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/o"$(BINDIR_)$(TARGETBASE).cof" /M"$(BINDIR_)$(TARGETBASE).map" /W
+TS{C2AF05E7-1416-4625-923D-E114DB6E2B96}=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}=
+[INSTRUMENTED_TRACE]
+enable=0
+transport=0
+format=0
+[CUSTOM_BUILD]
+Pre-Build=
+Pre-BuildEnabled=1
+Post-Build=
+Post-BuildEnabled=1
diff --git a/Source/USB/picft245.mcs b/Source/USB/picft245.mcs
new file mode 100644
index 0000000..042af98
--- /dev/null
+++ b/Source/USB/picft245.mcs
@@ -0,0 +1,84 @@
+[Header]
+MagicCookie={0b13fe8c-dfe0-40eb-8900-6712719559a7}
+Version=1.0
+[File000]
+Location=D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\tmp\usb_descriptors.o
+Folder=Intermediary
+DeviceName=PIC18F14K50
+LanguageToolSuiteID={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+LanguageToolID={E56A1C86-9D32-4DF6-8C34-FE0388B1B644}
+LanguageToolLocation=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mcc18.exe
+PPAD=$(BINDIR)||$(TMPDIR)|tmp||$(AINDIR)||$(INCDIR)|USB2.9i_cdc\include;C\MCC18\h||$(LIBDIR)|C:\MCC18\lib||$(LKRDIR)||
+SOLK=|usb_descriptors.c|USB2.9i_cdc\USB\usb_device.c|USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c|picft245.c|||||||picft245.lkr||
+SuiteArgsString=
+ToolArgsString=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TraceCmdString=
+DebugOptions=
+[File001]
+Location=D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\tmp\usb_device.o
+Folder=Intermediary
+DeviceName=PIC18F14K50
+LanguageToolSuiteID={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+LanguageToolID={E56A1C86-9D32-4DF6-8C34-FE0388B1B644}
+LanguageToolLocation=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mcc18.exe
+PPAD=$(BINDIR)||$(TMPDIR)|tmp||$(AINDIR)||$(INCDIR)|USB2.9i_cdc\include;C\MCC18\h||$(LIBDIR)|C:\MCC18\lib||$(LKRDIR)||
+SOLK=|usb_descriptors.c|USB2.9i_cdc\USB\usb_device.c|USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c|picft245.c|||||||picft245.lkr||
+SuiteArgsString=
+ToolArgsString=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TraceCmdString=
+DebugOptions=
+[File002]
+Location=D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\tmp\usb_function_cdc.o
+Folder=Intermediary
+DeviceName=PIC18F14K50
+LanguageToolSuiteID={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+LanguageToolID={E56A1C86-9D32-4DF6-8C34-FE0388B1B644}
+LanguageToolLocation=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mcc18.exe
+PPAD=$(BINDIR)||$(TMPDIR)|tmp||$(AINDIR)||$(INCDIR)|USB2.9i_cdc\include;C\MCC18\h||$(LIBDIR)|C:\MCC18\lib||$(LKRDIR)||
+SOLK=|usb_descriptors.c|USB2.9i_cdc\USB\usb_device.c|USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c|picft245.c|||||||picft245.lkr||
+SuiteArgsString=
+ToolArgsString=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TraceCmdString=
+DebugOptions=
+[File003]
+Location=D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\tmp\picft245.o
+Folder=Intermediary
+DeviceName=PIC18F14K50
+LanguageToolSuiteID={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+LanguageToolID={E56A1C86-9D32-4DF6-8C34-FE0388B1B644}
+LanguageToolLocation=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mcc18.exe
+PPAD=$(BINDIR)||$(TMPDIR)|tmp||$(AINDIR)||$(INCDIR)|USB2.9i_cdc\include;C\MCC18\h||$(LIBDIR)|C:\MCC18\lib||$(LKRDIR)||
+SOLK=|usb_descriptors.c|USB2.9i_cdc\USB\usb_device.c|USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c|picft245.c|||||||picft245.lkr||
+SuiteArgsString=
+ToolArgsString=-Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
+TraceCmdString=
+DebugOptions=
+[File004]
+Location=D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.cof
+Folder=Output
+DeviceName=PIC18F14K50
+LanguageToolSuiteID={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+LanguageToolID={96C98149-AA1B-4CF9-B967-FAE79CAB663C}
+LanguageToolLocation=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mplink.exe
+PPAD=$(BINDIR)||$(TMPDIR)|tmp||$(AINDIR)||$(INCDIR)|USB2.9i_cdc\include;C\MCC18\h||$(LIBDIR)|C:\MCC18\lib||$(LKRDIR)||
+SOLK=|usb_descriptors.c|USB2.9i_cdc\USB\usb_device.c|USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c|picft245.c|||||||picft245.lkr||
+SuiteArgsString=
+ToolArgsString=/o"$(BINDIR_)$(TARGETBASE).cof" /M"$(BINDIR_)$(TARGETBASE).map" /W
+TraceCmdString=
+DebugOptions=
+[File005]
+Location=D:\Projects\CBUS_MERG\mplab\cbus\can_usb4\picft245\picft245.hex
+Folder=Output
+DeviceName=PIC18F14K50
+LanguageToolSuiteID={5B7D72DD-9861-47BD-9F60-2BE967BF8416}
+LanguageToolID={96C98149-AA1B-4CF9-B967-FAE79CAB663C}
+LanguageToolLocation=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mplink.exe
+PPAD=$(BINDIR)||$(TMPDIR)|tmp||$(AINDIR)||$(INCDIR)|USB2.9i_cdc\include;C\MCC18\h||$(LIBDIR)|C:\MCC18\lib||$(LKRDIR)||
+SOLK=|usb_descriptors.c|USB2.9i_cdc\USB\usb_device.c|USB2.9i_cdc\USB\CDC Device Driver\usb_function_cdc.c|picft245.c|||||||picft245.lkr||
+SuiteArgsString=
+ToolArgsString=/o"$(BINDIR_)$(TARGETBASE).cof" /M"$(BINDIR_)$(TARGETBASE).map" /W
+TraceCmdString=
+DebugOptions=
+[TOOL_LOC_STAMPS]
+tool_loc{96C98149-AA1B-4CF9-B967-FAE79CAB663C}=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mplink.exe
+tool_loc{E56A1C86-9D32-4DF6-8C34-FE0388B1B644}=C:\Program Files (x86)\Microchip\mplabc18\v3.47\bin\mcc18.exe
diff --git a/Source/USB/picft245.mcw b/Source/USB/picft245.mcw
new file mode 100644
index 0000000..c6ec706
Binary files /dev/null and b/Source/USB/picft245.mcw differ
diff --git a/Source/USB/picft245.mptags b/Source/USB/picft245.mptags
new file mode 100644
index 0000000..e8783eb
--- /dev/null
+++ b/Source/USB/picft245.mptags
@@ -0,0 +1,252 @@
+!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
+!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
+!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
+!_TAG_PROGRAM_NAME Exuberant Ctags //
+!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
+!_TAG_PROGRAM_VERSION 5.5.4 //
+!_TAG_REVISION_NAME MCHPTags //
+!_TAG_REVISION_VERSION 6.0.1 //
+BDT E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 319;" v line:319
+BDT E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 321;" v line:321
+BDT E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 323;" v line:323
+BDT E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 325;" v line:325
+BaudRateGen E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 149;" v line:149
+BothEP0OutUOWNsSet E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 290;" v line:290
+CDAV::RB7 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 44;" d line:44
+CDCDataInHandle E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 145;" v line:145
+CDCDataOutHandle E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 144;" v line:144
+CDCInitEP E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 350;" f line:350 signature:(void)
+CDCNotificationHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 422;" f line:422 signature:(void)
+CDCNotificationHandler::{} E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 453;" d line:453 file:
+CDCNotificationInHandle E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 156;" v line:156
+CDCTxService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 892;" f line:892 signature:(void)
+CDC_COMM_EP::2 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 73;" d line:73
+CDC_COMM_INTF_ID::0x0 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 72;" d line:72
+CDC_COMM_IN_EP_SIZE::8 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 74;" d line:74
+CDC_DATA_EP::3 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 77;" d line:77
+CDC_DATA_INTF_ID::0x01 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 76;" d line:76
+CDC_DATA_IN_EP_SIZE::32 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 79;" d line:79
+CDC_DATA_OUT_EP_SIZE::32 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 78;" d line:78
+CLOCK_FREQ::48000000 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 94;" d line:94
+CREQ::RB5 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 42;" d line:42
+C_IDLE::0 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 106;" d line:106 file:
+C_WAIT::1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 107;" d line:107 file:
+CtrlTrfData E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 334;" v line:334
+DATA_PORT::PORTC E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 31;" d line:31
+DATA_PORTbits::PORTCbits E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 32;" d line:32
+GetSystemClock::CLOCK_FREQ E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 95;" d line:95
+HARDWARE_PROFILE_H E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 10;" d line:10
+HIGH_INT_VECT E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 147;" f line:147 signature:(void)
+InitializeSystem E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 109;" p line:109 file: signature:(void)
+LastUSBIn E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 93;" v line:93
+NextUSBOut E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 91;" v line:91
+NextUSBOut E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 92;" v line:92
+OldSerialStateBitmap E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 155;" v line:155
+PORTA_DDR::0xFF E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 60;" d line:60
+PORTA_INIT::0x00 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 61;" d line:61
+PORTB_DDR::0b11000000 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 47;" d line:47
+PORTB_INIT::0b00000000 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 48;" d line:48
+PORTC_DDR::0b11111111 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 35;" d line:35
+PORTC_INIT::0b00000000 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 36;" d line:36
+ProcessIO E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 110;" p line:110 file: signature:(void)
+RX_BUFFER_LENGTH::32 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 119;" d line:119 file:
+RemoteWakeup E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 286;" v line:286
+SerialStateBitmap E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 154;" v line:154
+SerialStatePacket E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 129;" v line:129
+SetupPkt E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 333;" v line:333
+UDAV::RB4 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 41;" d line:41
+UREQ::RB6 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 43;" d line:43
+USBActiveConfiguration E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 275;" v line:275
+USBAdvancePingPongBuffer::(buffer)((BYTE_VAL*)buffer)->V E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 444;" d line:444 file:
+USBAlternateInterface E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 276;" v line:276
+USBBusIsSuspended E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 287;" v line:287
+USBCBSendResume E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 114;" p line:114 file: signature:(void)
+USBCDCEventHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 480;" f line:480 signature:(USB_EVENT event, void *pdata, WORD size)
+USBCDCSetLineCoding E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 173;" p line:173 file: signature:(void)
+USBCFG_H E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 13;" d line:13
+USBCancelIO E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1311;" f line:1311 signature:(BYTE endpoint)
+USBCheckCDCRequest E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 203;" f line:203 signature:(void)
+USBCheckStdRequest E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2832;" f line:2832 file: signature:(void)
+USBCheckStdRequest E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 394;" p line:394 file: signature:(void)
+USBConfigureEndpoint E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1721;" f line:1721 file: signature:(BYTE EPNum, BYTE direction)
+USBConfigureEndpoint E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 403;" p line:403 file: signature:(BYTE EPNum, BYTE direction)
+USBCtrlEPAllowDataStage E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1668;" f line:1668 signature:(void)
+USBCtrlEPAllowStatusStage E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1598;" f line:1598 signature:(void)
+USBCtrlEPService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2516;" f line:2516 file: signature:(void)
+USBCtrlEPService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 391;" p line:391 file: signature:(void)
+USBCtrlEPServiceComplete E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1794;" f line:1794 file: signature:(void)
+USBCtrlEPServiceComplete E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 396;" p line:396 file: signature:(void)
+USBCtrlTrfInHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2741;" f line:2741 file: signature:(void)
+USBCtrlTrfInHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 393;" p line:393 file: signature:(void)
+USBCtrlTrfOutHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2688;" f line:2688 file: signature:(void)
+USBCtrlTrfOutHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 402;" p line:402 file: signature:(void)
+USBCtrlTrfRxService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2027;" f line:2027 file: signature:(void)
+USBCtrlTrfRxService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 398;" p line:398 file: signature:(void)
+USBCtrlTrfSetupHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2616;" f line:2616 file: signature:(void)
+USBCtrlTrfSetupHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 392;" p line:392 file: signature:(void)
+USBCtrlTrfTxService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1946;" f line:1946 file: signature:(void)
+USBCtrlTrfTxService E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 397;" p line:397 file: signature:(void)
+USBDeferINDataStagePackets E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 297;" v line:297
+USBDeferOUTDataStagePackets E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 298;" v line:298
+USBDeferStatusStagePacket E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 294;" v line:294
+USBDeviceAttach E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1534;" f line:1534 signature:(void)
+USBDeviceDetach E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1429;" f line:1429 signature:(void)
+USBDeviceInit E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 476;" f line:476 signature:(void)
+USBDeviceState E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 274;" v line:274
+USBDeviceTasks E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 669;" f line:669 signature:(void)
+USBDeviceTasks E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 111;" p line:111 file: signature:(void)
+USBEnableEndpoint E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1064;" f line:1064 signature:(BYTE ep, BYTE options)
+USBHALPingPongSetToEven::(buffer){((BYTE_VAL*)buffer)-> E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 446;" d line:446 file:
+USBHALPingPongSetToOdd::(buffer){((BYTE_VAL*)buffer)-> E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 445;" d line:445 file:
+USBStallEndpoint E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1258;" f line:1258 signature:(BYTE ep, BYTE dir)
+USBStallHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2349;" f line:2349 file: signature:(void)
+USBStallHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 406;" p line:406 file: signature:(void)
+USBStatusStageEnabledFlag1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 295;" v line:295
+USBStatusStageEnabledFlag2 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 296;" v line:296
+USBStatusStageTimeoutCounter E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 293;" v line:293
+USBStdFeatureReqHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2900;" f line:2900 file: signature:(void)
+USBStdFeatureReqHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 401;" p line:401 file: signature:(void)
+USBStdGetDscHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2209;" f line:2209 file: signature:(void)
+USBStdGetDscHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 395;" p line:395 file: signature:(void)
+USBStdGetStatusHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2276;" f line:2276 signature:(void)
+USBStdGetStatusHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 400;" p line:400 file: signature:(void)
+USBStdSetCfgHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2131;" f line:2131 signature:(void)
+USBStdSetCfgHandler E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 399;" p line:399 file: signature:(void)
+USBSuspend E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2392;" f line:2392 file: signature:(void)
+USBSuspend E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 405;" p line:405 file: signature:(void)
+USBTransferOnePacket E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1181;" f line:1181 signature:(BYTE ep,BYTE dir,BYTE* data,BYTE len)
+USBWakeFromSuspend E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2449;" f line:2449 file: signature:(void)
+USBWakeFromSuspend E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 404;" p line:404 file: signature:(void)
+USB_BUS_SENSE E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 257;" d line:257 file:
+USB_BUS_SENSE::1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 80;" d line:80
+USB_BUS_SENSE::1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 258;" d line:258 file:
+USB_CDC_SET_LINE_CODING_HANDLER E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 169;" p line:169 file:
+USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 82;" d line:82
+USB_CD_Ptr E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 254;" v line:254
+USB_ENABLE_ALL_HANDLERS E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 54;" d line:54
+USB_EP0_BUFF_SIZE::8 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 16;" d line:16
+USB_INTERRUPT E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 39;" d line:39
+USB_In_Buffer E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 89;" v line:89
+USB_In_Data_Rdy E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 95;" v line:95
+USB_MAX_EP_NUMBER::3 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 69;" d line:69
+USB_MAX_NUM_INT::2 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 23;" d line:23
+USB_NUM_STRING_DESCRIPTORS::3 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 51;" d line:51
+USB_Out_Buffer E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 88;" v line:88
+USB_PING_PONG_MODE::USB_PING_PONG__FULL_PING_PONG E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 36;" d line:36
+USB_PULLUP_OPTION::USB_PULLUP_ENABLE E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 42;" d line:42
+USB_SD_Ptr E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 259;" v line:259
+USB_SPEED_OPTION::USB_FULL_SPEED E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 47;" d line:47
+USB_SUPPORT_DEVICE E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 49;" d line:49
+USB_TRANSCEIVER_OPTION::USB_INTERNAL_TRANSCEIVER E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 45;" d line:45
+USB_USER_CONFIG_DESCRIPTOR::USB_CD_Ptr E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 33;" d line:33
+USB_USER_CONFIG_DESCRIPTOR_INCLUDE::externROMBYTE*ROMUSB_CD_Ptr[] E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 34;" d line:34
+USB_USER_DEVICE_DESCRIPTOR::&device_dsc E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 28;" d line:28
+USB_USER_DEVICE_DESCRIPTOR_INCLUDE::externROMUSB_DEVICE_DESCRIPTOR E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 29;" d line:29
+USB_USE_CDC E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h 66;" d line:66
+USBcp E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 94;" v line:94
+USER_USB_CALLBACK_EVENT_HANDLER E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 388;" p line:388 file: signature:(USB_EVENT event, void *pdata, WORD size)
+USTATcopy E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 288;" v line:288
+U_IDLE::0 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 100;" d line:100 file:
+U_OUT::2 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 102;" d line:102 file:
+U_RDY::1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 101;" d line:101 file:
+UserInit E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 115;" p line:115 file: signature:(void)
+YourHighPriorityISRCode E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 112;" p line:112 file:
+YourLowPriorityISRCode E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 113;" p line:113 file:
+_DTS_CHECKING_ENABLED::0 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 262;" d line:262 file:
+_DTS_CHECKING_ENABLED::_DTSEN E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 264;" d line:264 file:
+__USB_DESCRIPTORS_C E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 121;" d line:121 file:
+bDscType E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 238;" m line:238 file:
+bDscType E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 242;" m line:242 file:
+bDscType E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 248;" m line:248 file:
+bLength E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 238;" m line:238 file:
+bLength E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 242;" m line:242 file:
+bLength E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 248;" m line:248 file:
+byteToRead E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2029;" l line:2029
+byteToSend E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1948;" l line:1948
+byte_to_send E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 894;" l line:894
+can_in E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 104;" v line:104
+can_in_state E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 105;" v line:105
+cdc_data_rx E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 124;" v line:124
+cdc_data_tx E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 125;" v line:125
+cdc_mem_type E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 142;" v line:142
+cdc_notice E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 123;" v line:123
+cdc_rx_len E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 136;" v line:136
+cdc_trf_state E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 138;" v line:138
+cdc_tx_len E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 141;" v line:141
+configDescriptor1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 152;" v line:152
+controlTransferState E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 282;" v line:282
+control_signal_bitmap E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 148;" v line:148
+current_ep_data E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2903;" l line:2903
+device_dsc E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 133;" v line:133
+dummy_encapsulated_cmd_response E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 166;" v line:166
+dummy_length::0x08 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 165;" d line:165 file:
+endpoint_number E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 289;" v line:289
+ep_data_in E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 291;" v line:291
+ep_data_out E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 292;" v line:292
+getsUSBUSART E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 541;" f line:541 signature:(char *buffer, BYTE len)
+handle E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1183;" l line:1183
+handle E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1723;" l line:1723
+hid_report_in E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 342;" v line:342
+hid_report_out E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 341;" v line:341
+i E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 895;" l line:895
+i E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2030;" l line:2030
+i E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2133;" l line:2133
+i E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 478;" l line:478
+i E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 679;" l line:679
+inPipes E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 283;" v line:283
+isr_high E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 128;" f line:128 signature:(void)
+isr_low E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 138;" f line:138 signature:(void)
+lastDTS E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2743;" l line:2743
+lastTransmission E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 96;" v line:96
+len E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 687;" l line:687
+len E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 784;" l line:784
+line_coding E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 126;" v line:126
+mGetLED_1:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 101;" d line:101
+mGetLED_2:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 102;" d line:102
+mLED_1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 98;" d line:98
+mLED_1_Off:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 107;" d line:107
+mLED_1_On:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 104;" d line:104
+mLED_1_Toggle:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 110;" d line:110
+mLED_2 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 99;" d line:99
+mLED_2_Off:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 108;" d line:108
+mLED_2_On:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 105;" d line:105
+mLED_2_Toggle:: E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 111;" d line:111
+msd_buffer E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 354;" v line:354
+msd_cbw E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 347;" v line:347
+msd_csw E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 348;" v line:348
+outPipes E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 284;" v line:284
+p E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1066;" l line:1066
+p E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 1260;" l line:1260
+p E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2308;" l line:2308
+p E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2902;" l line:2902
+pBDTEntryEP0OutCurrent E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 277;" v line:277
+pBDTEntryEP0OutNext E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 278;" v line:278
+pBDTEntryIn E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 280;" v line:280
+pBDTEntryOut E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 279;" v line:279
+pCDCDst E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 140;" v line:140
+pCDCSrc E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 139;" v line:139
+pData E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 688;" l line:688
+pData E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 785;" l line:785
+pDst E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 285;" v line:285
+pFunc E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2088;" p line:2088 file:
+pFunc E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2803;" p line:2803 file:
+pUEP E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2905;" l line:2905
+pUEP E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2907;" l line:2907
+putUSBUSART E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 612;" f line:612 signature:(char *data, BYTE length)
+putrsUSBUSART E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 782;" f line:782 signature:(const ROM char *data)
+putsUSBUSART E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c 685;" f line:685 signature:(char *data)
+sd000 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 238;" v line:238
+sd001 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 242;" v line:242
+sd002 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 248;" v line:248
+self_power::1 E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h 78;" d line:78
+setup_cnt E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 2545;" l line:2545
+shortPacketStatus E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c 281;" v line:281
+string E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 238;" m line:238 file:
+string E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 242;" m line:242 file:
+string E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c 248;" m line:248 file:
+usbGetChar E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 116;" p line:116 file: signature:(void)
+usbIsDataRdy E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 117;" p line:117 file: signature:(void)
+usb_in E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 98;" v line:98
+usb_in_state E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 99;" v line:99
+usb_rx_buff E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 121;" v line:121
+usb_rx_ptr E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c 124;" v line:124
diff --git a/Source/USB/picft245.tagsrc b/Source/USB/picft245.tagsrc
new file mode 100644
index 0000000..167f3da
--- /dev/null
+++ b/Source/USB/picft245.tagsrc
@@ -0,0 +1,6 @@
+E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_descriptors.c
+E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\usb_device.c
+E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\USB2.9e_cdc\USB\CDC Device Driver\usb_function_cdc.c
+E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\picft245.c
+E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\HardwareProfile.h
+E:\Projects\CBUS\mplab\canusb\merg_can_usb4\picft245\usb_config.h
diff --git a/Source/USB/usb_config.h b/Source/USB/usb_config.h
new file mode 100644
index 0000000..508f3e0
--- /dev/null
+++ b/Source/USB/usb_config.h
@@ -0,0 +1,84 @@
+/*------------------------------------------------------------------------------
+; PICFT245
+;
+; FTDI FT245 replacement in a POC18F14K50 (C) SPROG DCC 2012
+; web: http://www.sprog-dcc.co.uk
+; e-mail: sprog@sprog-dcc.co.uk
+;-----------------------------------------------------------------------------*/
+/*********************************************************************
+ * Descriptor specific type definitions are defined in: usbd.h
+ ********************************************************************/
+
+#ifndef USBCFG_H
+#define USBCFG_H
+
+/** DEFINITIONS ****************************************************/
+#define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes.
+ // Using larger options take more SRAM, but
+ // does not provide much advantage in most types
+ // of applications. Exceptions to this, are applications
+ // that use EP0 IN or OUT for sending large amounts of
+ // application related data.
+
+#define USB_MAX_NUM_INT 2 // For tracking Alternate Setting
+
+//Device descriptor - if these two definitions are not defined then
+// a ROM USB_DEVICE_DESCRIPTOR variable by the exact name of device_dsc
+// must exist.
+#define USB_USER_DEVICE_DESCRIPTOR &device_dsc
+#define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc
+
+//Configuration descriptors - if these two definitions do not exist then
+// a ROM BYTE *ROM variable named exactly USB_CD_Ptr[] must exist.
+#define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr
+#define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE *ROM USB_CD_Ptr[]
+
+#define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG
+
+//#define USB_POLLING
+#define USB_INTERRUPT
+
+/* Parameter definitions are defined in usb_device.h */
+#define USB_PULLUP_OPTION USB_PULLUP_ENABLE
+//#define USB_PULLUP_OPTION USB_PULLUP_DISABLED
+
+#define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER
+
+#define USB_SPEED_OPTION USB_FULL_SPEED
+
+#define USB_SUPPORT_DEVICE
+
+#define USB_NUM_STRING_DESCRIPTORS 3
+
+//#define USB_INTERRUPT_LEGACY_CALLBACKS
+#define USB_ENABLE_ALL_HANDLERS
+//#define USB_ENABLE_SUSPEND_HANDLER
+//#define USB_ENABLE_WAKEUP_FROM_SUSPEND_HANDLER
+//#define USB_ENABLE_SOF_HANDLER
+//#define USB_ENABLE_ERROR_HANDLER
+//#define USB_ENABLE_OTHER_REQUEST_HANDLER
+//#define USB_ENABLE_SET_DESCRIPTOR_HANDLER
+//#define USB_ENABLE_INIT_EP_HANDLER
+//#define USB_ENABLE_EP0_DATA_HANDLER
+//#define USB_ENABLE_TRANSFER_COMPLETE_HANDLER
+
+/** DEVICE CLASS USAGE *********************************************/
+#define USB_USE_CDC
+
+/** ENDPOINTS ALLOCATION *******************************************/
+#define USB_MAX_EP_NUMBER 2
+
+/* CDC */
+#define CDC_COMM_INTF_ID 0x0
+#define CDC_COMM_EP 1
+#define CDC_COMM_IN_EP_SIZE 10
+
+#define CDC_DATA_INTF_ID 0x01
+#define CDC_DATA_EP 2
+#define CDC_DATA_OUT_EP_SIZE 32
+#define CDC_DATA_IN_EP_SIZE 32
+
+//#define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D2 //Send_Break command
+#define USB_CDC_SUPPORT_ABSTRACT_CONTROL_MANAGEMENT_CAPABILITIES_D1 //Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and Serial_State commands
+
+#endif //USBCFG_H
diff --git a/Source/USB/usb_descriptors.c b/Source/USB/usb_descriptors.c
new file mode 100644
index 0000000..7c24735
--- /dev/null
+++ b/Source/USB/usb_descriptors.c
@@ -0,0 +1,270 @@
+/********************************************************************
+-usb_descriptors.c-
+-------------------------------------------------------------------
+Filling in the descriptor values in the usb_descriptors.c file:
+-------------------------------------------------------------------
+
+[Device Descriptors]
+The device descriptor is defined as a USB_DEVICE_DESCRIPTOR type.
+This type is defined in usb_ch9.h Each entry into this structure
+needs to be the correct length for the data type of the entry.
+
+[Configuration Descriptors]
+The configuration descriptor was changed in v2.x from a structure
+to a BYTE array. Given that the configuration is now a byte array
+each byte of multi-byte fields must be listed individually. This
+means that for fields like the total size of the configuration where
+the field is a 16-bit value "64,0," is the correct entry for a
+configuration that is only 64 bytes long and not "64," which is one
+too few bytes.
+
+The configuration attribute must always have the _DEFAULT
+definition at the minimum. Additional options can be ORed
+to the _DEFAULT attribute. Available options are _SELF and _RWU.
+These definitions are defined in the usb_device.h file. The
+_SELF tells the USB host that this device is self-powered. The
+_RWU tells the USB host that this device supports Remote Wakeup.
+
+[Endpoint Descriptors]
+Like the configuration descriptor, the endpoint descriptors were
+changed in v2.x of the stack from a structure to a BYTE array. As
+endpoint descriptors also has a field that are multi-byte entities,
+please be sure to specify both bytes of the field. For example, for
+the endpoint size an endpoint that is 64 bytes needs to have the size
+defined as "64,0," instead of "64,"
+
+Take the following example:
+ // Endpoint Descriptor //
+ 0x07, //the size of this descriptor //
+ USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
+ _EP02_IN, //EndpointAddress
+ _INT, //Attributes
+ 0x08,0x00, //size (note: 2 bytes)
+ 0x02, //Interval
+
+The first two parameters are self-explanatory. They specify the
+length of this endpoint descriptor (7) and the descriptor type.
+The next parameter identifies the endpoint, the definitions are
+defined in usb_device.h and has the following naming
+convention:
+_EP<##>_
+where ## is the endpoint number and dir is the direction of
+transfer. The dir has the value of either 'OUT' or 'IN'.
+The next parameter identifies the type of the endpoint. Available
+options are _BULK, _INT, _ISO, and _CTRL. The _CTRL is not
+typically used because the default control transfer endpoint is
+not defined in the USB descriptors. When _ISO option is used,
+addition options can be ORed to _ISO. Example:
+_ISO|_AD|_FE
+This describes the endpoint as an isochronous pipe with adaptive
+and feedback attributes. See usb_device.h and the USB
+specification for details. The next parameter defines the size of
+the endpoint. The last parameter in the polling interval.
+
+-------------------------------------------------------------------
+Adding a USB String
+-------------------------------------------------------------------
+A string descriptor array should have the following format:
+
+rom struct{byte bLength;byte bDscType;word string[size];}sdxxx={
+sizeof(sdxxx),DSC_STR,};
+
+The above structure provides a means for the C compiler to
+calculate the length of string descriptor sdxxx, where xxx is the
+index number. The first two bytes of the descriptor are descriptor
+length and type. The rest are string texts which must be
+in the unicode format. The unicode format is achieved by declaring
+each character as a word type. The whole text string is declared
+as a word array with the number of characters equals to .
+ has to be manually counted and entered into the array
+declaration. Let's study this through an example:
+if the string is "USB" , then the string descriptor should be:
+(Using index 02)
+rom struct{byte bLength;byte bDscType;word string[3];}sd002={
+sizeof(sd002),DSC_STR,'U','S','B'};
+
+A USB project may have multiple strings and the firmware supports
+the management of multiple strings through a look-up table.
+The look-up table is defined as:
+rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002};
+
+The above declaration has 3 strings, sd000, sd001, and sd002.
+Strings can be removed or added. sd000 is a specialized string
+descriptor. It defines the language code, usually this is
+US English (0x0409). The index of the string must match the index
+position of the USB_SD_Ptr array, &sd000 must be in position
+USB_SD_Ptr[0], &sd001 must be in position USB_SD_Ptr[1] and so on.
+The look-up table USB_SD_Ptr is used by the get string handler
+function.
+
+-------------------------------------------------------------------
+
+The look-up table scheme also applies to the configuration
+descriptor. A USB device may have multiple configuration
+descriptors, i.e. CFG01, CFG02, etc. To add a configuration
+descriptor, user must implement a structure similar to CFG01.
+The next step is to add the configuration descriptor name, i.e.
+cfg01, cfg02,.., to the look-up table USB_CD_Ptr. USB_CD_Ptr[0]
+is a dummy place holder since configuration 0 is the un-configured
+state according to the definition in the USB specification.
+
+********************************************************************/
+
+/*********************************************************************
+ * Descriptor specific type definitions are defined in:
+ * usb_device.h
+ *
+ * Configuration options are defined in:
+ * usb_config.h
+ ********************************************************************/
+#ifndef __USB_DESCRIPTORS_C
+#define __USB_DESCRIPTORS_C
+
+/** INCLUDES *******************************************************/
+#include "./USB/usb.h"
+#include "./USB/usb_function_cdc.h"
+
+/** CONSTANTS ******************************************************/
+#if defined(__18CXX)
+#pragma romdata
+#endif
+
+/* Device Descriptor */
+ROM USB_DEVICE_DESCRIPTOR device_dsc=
+{
+ 0x12, // Size of this descriptor in bytes
+ USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
+ 0x0200, // USB Spec Release Number in BCD format
+ CDC_DEVICE, // Class Code
+ 0x00, // Subclass code
+ 0x00, // Protocol code
+ USB_EP0_BUFF_SIZE, // Max packet size for EP0, see usb_config.h
+ 0x04D8, // Vendor ID
+ 0xF80C, // Product ID: CDC RS-232 Emulation Demo
+ 0x0100, // Device release number in BCD format
+ 0x01, // Manufacturer string index
+ 0x02, // Product string index
+ 0x00, // Device serial number string index
+ 0x01 // Number of possible configurations
+};
+
+/* Configuration 1 Descriptor */
+ROM BYTE configDescriptor1[]={
+ /* Configuration Descriptor */
+ 0x09,//sizeof(USB_CFG_DSC), // Size of this descriptor in bytes
+ USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type
+ 67,0, // Total length of data for this cfg
+ 2, // Number of interfaces in this cfg
+ 1, // Index value of this configuration
+ 0, // Configuration string index
+ _DEFAULT | _SELF, // Attributes, see usb_device.h
+ 49, // Max power consumption (2X mA)
+
+ /* Interface Descriptor */
+ 9,//sizeof(USB_INTF_DSC), // Size of this descriptor in bytes
+ USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type
+ 0, // Interface Number
+ 0, // Alternate Setting Number
+ 1, // Number of endpoints in this intf
+ COMM_INTF, // Class code
+ ABSTRACT_CONTROL_MODEL, // Subclass code
+ V25TER, // Protocol code
+ 0, // Interface string index
+
+ /* CDC Class-Specific Descriptors */
+ sizeof(USB_CDC_HEADER_FN_DSC),
+ CS_INTERFACE,
+ DSC_FN_HEADER,
+ 0x10,0x01,
+
+ sizeof(USB_CDC_ACM_FN_DSC),
+ CS_INTERFACE,
+ DSC_FN_ACM,
+ USB_CDC_ACM_FN_DSC_VAL,
+
+ sizeof(USB_CDC_UNION_FN_DSC),
+ CS_INTERFACE,
+ DSC_FN_UNION,
+ CDC_COMM_INTF_ID,
+ CDC_DATA_INTF_ID,
+
+ sizeof(USB_CDC_CALL_MGT_FN_DSC),
+ CS_INTERFACE,
+ DSC_FN_CALL_MGT,
+ 0x00,
+ CDC_DATA_INTF_ID,
+
+ /* Endpoint Descriptor */
+ //sizeof(USB_EP_DSC),DSC_EP,_EP02_IN,_INT,CDC_INT_EP_SIZE,0x02,
+ 0x07,/*sizeof(USB_EP_DSC)*/
+ USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
+ _EP01_IN, //EndpointAddress
+ _INTERRUPT, //Attributes
+ 0x0A,0x00, //size
+ 0x01, //Interval
+
+ /* Interface Descriptor */
+ 9,//sizeof(USB_INTF_DSC), // Size of this descriptor in bytes
+ USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type
+ 1, // Interface Number
+ 0, // Alternate Setting Number
+ 2, // Number of endpoints in this intf
+ DATA_INTF, // Class code
+ 0, // Subclass code
+ NO_PROTOCOL, // Protocol code
+ 0, // Interface string index
+
+ /* Endpoint Descriptor */
+ //sizeof(USB_EP_DSC),DSC_EP,_EP03_OUT,_BULK,CDC_BULK_OUT_EP_SIZE,0x00,
+ 0x07,/*sizeof(USB_EP_DSC)*/
+ USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
+ _EP02_OUT, //EndpointAddress
+ _BULK, //Attributes
+ 0x20,0x00, //size
+ 0x00, //Interval
+
+ /* Endpoint Descriptor */
+ //sizeof(USB_EP_DSC),DSC_EP,_EP03_IN,_BULK,CDC_BULK_IN_EP_SIZE,0x00
+ 0x07,/*sizeof(USB_EP_DSC)*/
+ USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
+ _EP02_IN, //EndpointAddress
+ _BULK, //Attributes
+ 0x20,0x00, //size
+ 0x00, //Interval
+};
+
+
+//Language code string descriptor
+ROM struct{BYTE bLength;BYTE bDscType;WORD string[1];}sd000={
+sizeof(sd000),USB_DESCRIPTOR_STRING,{0x0409}};
+
+//Manufacturer string descriptor
+ROM struct{BYTE bLength;BYTE bDscType;WORD string[9];}sd001={
+sizeof(sd001),USB_DESCRIPTOR_STRING,
+{'S','P','R','O','G',' ','D','C','C'}
+};
+
+//Product string descriptor
+ROM struct{BYTE bLength;BYTE bDscType;WORD string[8];}sd002={
+sizeof(sd002),USB_DESCRIPTOR_STRING,
+{'C','A','N','_','U','S','B','4'}
+};
+
+//Array of configuration descriptors
+ROM BYTE *ROM USB_CD_Ptr[]=
+{
+ (ROM BYTE *ROM)&configDescriptor1
+};
+//Array of string descriptors
+ROM BYTE *ROM USB_SD_Ptr[]=
+{
+ (ROM BYTE *ROM)&sd000,
+ (ROM BYTE *ROM)&sd001,
+ (ROM BYTE *ROM)&sd002
+};
+
+#if defined(__18CXX)
+#pragma code
+#endif
+#endif
+/** EOF usb_descriptors.c ****************************************************/