Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
USBFm.LST
Package: USBFM.zip [view]
Upload User: wang202020
Upload Date: 2021-02-07
Package Size: 182k
Code Size: 427k
Category:
SCM
Development Platform:
HTML/CSS
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 1
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00001
- 00002 ; PICBASIC PRO(TM) Compiler 2.47, (c) 1998, 2006 microEngineering Labs, Inc. All Rights Reserved.
- 00000001 00003 _USED EQU 1
- 00004
- 00005 INCLUDE "D:PBP18F2550.INC"
- 00001 ;****************************************************************
- 00002 ;* 18F2550.INC *
- 00003 ;* *
- 00004 ;* By : Leonard Zerman, Jeff Schmoyer *
- 00005 ;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
- 00006 ;* All Rights Reserved *
- 00007 ;* Date : 06/05/06 *
- 00008 ;* Version : 2.47 *
- 00009 ;* Notes : *
- 00010 ;****************************************************************
- 00017 LIST
- 00018 LIST p = 18F2550, r = dec, w = -311, w = -230, f = inhx32
- 00019 INCLUDE "P18F2550.INC" ; MPASM Header
- 00001 LIST
- 00002
- 00003 ;==========================================================================
- 00004 ; MPASM PIC18F2550 processor include
- 00005 ;
- 00006 ; (c) Copyright 1999-2007 Microchip Technology, All rights reserved
- 00007 ;==========================================================================
- 00008
- 01486 LIST
- 00020 __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
- 300000 FEE4 00021 __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
- 300002 F3FF 00022 __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
- 300004 FDFF 00023 __CONFIG _CONFIG3H, _PBADEN_OFF_3H
- 300006 FFBB 00024 __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
- 00027 LIST
- 00F00000 00028 EEPROM_START EQU 0F00000h
- 00000020 00029 BLOCK_SIZE EQU 32
- 00006
- 00007
- 00008 ; Define statements.
- 00009 #define OSC 48
- 00010 #define LOADER_USED 1
- 00011 #define LCD_DREG PORTA
- 00012 #define LCD_DBIT 0
- 00013 #define LCD_RSREG PORTA
- 00014 #define LCD_RSBIT 4
- 00015 #define LCD_EREG PORTC
- 00016 #define LCD_EBIT 2
- 00017 #define LCD_BITS 4
- 00018 #define LCD_LINES 2
- 00019 #define LCD_COMMANDUS 2000
- 00020 #define LCD_DATAUS 50
- 00021
- 00000000 00022 RAM_START EQU 00000h
- 000003FF 00023 RAM_END EQU 003FFh
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 2
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00000004 00024 RAM_BANKS EQU 00004h
- 00000060 00025 BANK0_START EQU 00060h
- 000000FF 00026 BANK0_END EQU 000FFh
- 00000100 00027 BANK1_START EQU 00100h
- 000001FF 00028 BANK1_END EQU 001FFh
- 00000200 00029 BANK2_START EQU 00200h
- 000002FF 00030 BANK2_END EQU 002FFh
- 00000300 00031 BANK3_START EQU 00300h
- 000003FF 00032 BANK3_END EQU 003FFh
- 00000000 00033 BANKA_START EQU 00000h
- 0000005F 00034 BANKA_END EQU 0005Fh
- 00035
- 00000000 00036 FLAGS EQU RAM_START + 000h
- 00000001 00037 R0 EQU RAM_START + 001h
- 00000003 00038 R1 EQU RAM_START + 003h
- 00000005 00039 R2 EQU RAM_START + 005h
- 00000007 00040 R3 EQU RAM_START + 007h
- 00000009 00041 R4 EQU RAM_START + 009h
- 0000000B 00042 R5 EQU RAM_START + 00Bh
- 0000000D 00043 R6 EQU RAM_START + 00Dh
- 0000000F 00044 R7 EQU RAM_START + 00Fh
- 00000011 00045 R8 EQU RAM_START + 011h
- 00000013 00046 T1 EQU RAM_START + 013h
- 00000015 00047 GOP EQU RAM_START + 015h
- 00000016 00048 RM1 EQU RAM_START + 016h
- 00000017 00049 RM2 EQU RAM_START + 017h
- 00000018 00050 RR1 EQU RAM_START + 018h
- 00000019 00051 RR2 EQU RAM_START + 019h
- 0000001A 00052 RS1 EQU RAM_START + 01Ah
- 0000001B 00053 RS2 EQU RAM_START + 01Bh
- 0000001C 00054 _Modulante EQU RAM_START + 01Ch
- 0000001E 00055 _Frecuencia EQU RAM_START + 01Eh
- 0000001F 00056 _Residuo EQU RAM_START + 01Fh
- 00000020 00057 _USBBufferCount EQU RAM_START + 020h
- 00000021 00058 _USBBuffer EQU RAM_START + 021h
- 00000F81 00059 _PORTL EQU PORTB
- 00000F82 00060 _PORTH EQU PORTC
- 00000F93 00061 _TRISL EQU TRISB
- 00000F94 00062 _TRISH EQU TRISC
- 00063 #define _incr _PORTC??0
- 00064 #define _decr _PORTC??1
- 00065 #define _PORTC??0 PORTC, 000h
- 00066 #define _PORTC??1 PORTC, 001h
- 00067 #define _TRISC??0 TRISC, 000h
- 00068 #define _TRISC??1 TRISC, 001h
- 00069 #define _TRISC??2 TRISC, 002h
- 00070
- 00071 ; Constants.
- 00000010 00072 _USBBufferSizeMax EQU 00010h
- 00000010 00073 _USBBufferSizeTX EQU 00010h
- 00000010 00074 _USBBufferSizeRX EQU 00010h
- 0000000A 00075 _FreqMin EQU 0000Ah
- 00076
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 3
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00077 ; EEPROM data.
- 00078
- 00079
- 00080 INCLUDE "USBFM.MAC"
- 00001
- 00273 LIST
- 00081 INCLUDE "D:PBPPBPUSB18.LIB"
- 00001 ;****************************************************************
- 00002 ;* PBPUSB18.LIB *
- 00003 ;* *
- 00004 ;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
- 00005 ;* All Rights Reserved *
- 00006 ;* Date : 12/31/04 *
- 00007 ;* Version : 2.46 *
- 00008 ;* Notes : PIC18 USB library *
- 00009 ;****************************************************************
- 00010
- 00011 include "PBPPBPPIC18.LIB"
- 00001 ;******************************************************************
- 00002 ;* PBPPIC18.LIB *
- 00003 ;* *
- 00004 ;* By : Leonard Zerman, Jeff Schmoyer *
- 00005 ;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
- 00006 ;* All Rights Reserved *
- 00007 ;* Date : 06/05/06 *
- 00008 ;* Version : 2.47 *
- 00009 ;* Notes : *
- 00010 ;******************************************************************
- 00129 LIST
- 00130 ; Oscillator is 48MHz
- 01147 LIST
- 000000 01148 ORG RESET_ORG ; Reset vector at 0
- 01152 LIST
- 000000 6A00 01153 clrf FLAGS ; Clear all flags on reset
- 01157 LIST
- 000002 EFD7 F000 01158 goto INIT ; Finish initialization
- 01162 LIST
- 000008 01163 ORG RESET_ORG + 8 ; Make sure no library code in first 4 locs
- 02853 LIST
- 000008 6A06 02854 LCDOUTDEC clrf R2 + 1 ; Zero high value
- 02860 LIST
- 00000A 6E05 02861 LCDOUTDECL movwf R2 ; Save low value
- 00000C 8E15 02862 bsf GOP, 7 ; Set blanking on
- 00000E 0E27 02863 movlw high 10000 ; Find 10,000s
- 000010 6E04 02864 movwf R1 + 1
- 000012 0E10 02865 movlw low 10000
- 000014 D80C 02866 rcall lcdoutdig ; Do the work
- 000016 0E03 02867 movlw high 1000 ; Find 1,000s
- 000018 6E04 02868 movwf R1 + 1
- 00001A 0EE8 02869 movlw low 1000
- 00001C D808 02870 rcall lcdoutdig ; Do the work
- 00001E 6A04 02871 clrf R1 + 1 ; Find 100s
- 000020 0E64 02872 movlw 100
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 4
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 000022 D805 02873 rcall lcdoutdig ; Do the work
- 000024 6A04 02874 clrf R1 + 1 ; Find 10s
- 000026 0E0A 02875 movlw 10
- 000028 D802 02876 rcall lcdoutdig ; Do the work
- 00002A 5005 02877 movf R2, W ; Get the 1s
- 00002C D00B 02878 bra lcdouta ; Send the 1s
- 02879
- 00002E 6E03 02880 lcdoutdig movwf R1 ; Save last piece
- 000030 5006 02881 movf R2 + 1, W ; Move remainder to dividend
- 000032 6E02 02882 movwf R0 + 1
- 000034 5005 02883 movf R2, W
- 000036 6E01 02884 movwf R0
- 000038 EC9D F000 02885 call DIV ; Do the math
- 00003C 6601 02886 tstfsz R0 ; If zero, goto blank check
- 00003E 9E15 02887 bcf GOP, 7 ; Not zero so clear blank
- 000040 BE15 02888 btfsc GOP, 7 ; If blanking on, don't send
- 000042 0012 02889 return
- 000044 0F30 02890 lcdouta addlw '0' ; Add ASCII offset
- 02918 LIST
- 000046 6E08 02919 LCDOUT movwf R3 + 1 ; Save char
- 02920
- 000048 9482 02921 bcf LCD_EREG, LCD_EBIT ; Set E low
- 00004A 9880 02922 bcf LCD_RSREG, LCD_RSBIT ; Set command register select
- 00004C 9880 02923 bcf LCD_RWREG, LCD_RWBIT ; Set RW low (write)
- 02924
- 00004E 9494 02925 bcf (LCD_EREG) + 12h, LCD_EBIT ; Set E to output
- 000050 9892 02926 bcf (LCD_RSREG) + 12h, LCD_RSBIT ; Set RS to output
- 000052 9892 02927 bcf (LCD_RWREG) + 12h, LCD_RWBIT ; Set RW to output
- 02928 if (LCD_BITS == 8)
- 02929 clrf (LCD_DREG) + 12h ; Set port to all output
- 02930 else
- 02931 if (LCD_DBIT == 0)
- 000054 0EF0 02932 movlw 0f0h
- 02933 else
- 02934 movlw 0fh
- 02935 endif
- 000056 1692 02936 andwf (LCD_DREG) + 12h, F ; Set proper half of port to output
- 000058 5008 02937 movf R3 + 1, W ; Get back char
- 02938 endif
- 02939
- 00005A B200 02940 btfsc LCDINITFLAG ; Has lcd been inititalized?
- 00005C D022 02941 bra lcdout1 ; Yes
- 02942
- 00005E 0E3A 02943 movlw high 15000 ; Wait at least 15ms
- 000060 6E02 02944 movwf R0 + 1
- 000062 0E98 02945 movlw low 15000
- 000064 EC8F F000 02946 call PAUSEUSL
- 02947
- 000068 0E33 02948 movlw 33h ; Init lcd
- 00006A 6E07 02949 movwf R3 ; Save char
- 00006C D830 02950 rcall lcdloop ; Send init
- 02951
- 00006E 0E13 02952 movlw high 5000 ; Wait at least 5ms
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 5
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 000070 6E02 02953 movwf R0 + 1
- 000072 0E88 02954 movlw low 5000
- 000074 EC8F F000 02955 call PAUSEUSL
- 02956
- 000078 D82A 02957 rcall lcdloop ; Send init again
- 02958
- 00007A 0E64 02959 movlw 100 ; Wait at least 100us
- 00007C EC8E F000 02960 call PAUSEUS
- 02961
- 000080 D826 02962 rcall lcdloop ; Send init more time
- 02963
- 000082 0E64 02964 movlw 100 ; Wait at least 100us
- 000084 EC8E F000 02965 call PAUSEUS
- 02966
- 02967 if (LCD_BITS != 8)
- 000088 0E22 02968 movlw 22h ; Set 4-bit mode
- 00008A 6E07 02969 movwf R3 ; Save character
- 00008C D820 02970 rcall lcdloop ; Set interface to 4-bit mode
- 02971 endif
- 02972
- 02973 if (LCD_BITS == 8)
- 02974 if (LCD_LINES == 1)
- 02975 movlw 30h ; 8-bit mode, 1 line, 5x7 font
- 02976 else
- 02977 movlw 38h ; 8-bit mode, 2+ lines, 5x7 font
- 02978 endif
- 02979 else
- 02980 if (LCD_LINES == 1)
- 02981 movlw 20h ; 4-bit mode, 1 line, 5x7 font
- 02982 else
- 00008E 0E28 02983 movlw 28h ; 4-bit mode, 2+ lines, 5x7 font
- 02984 endif
- 02985 endif
- 000090 D807 02986 rcall lcdoutcom ; Send function set
- 02987
- 000092 0E0C 02988 movlw 0ch ; Display on, no cursor, no blink
- 000094 D805 02989 rcall lcdoutcom
- 02990
- 000096 0E06 02991 movlw 06h ; Lcd entry mode set, increment, no shift
- 000098 D803 02992 rcall lcdoutcom
- 02993
- 00009A 8200 02994 bsf LCDINITFLAG ; Set to initialized
- 02995
- 00009C 5008 02996 movf R3 + 1, W ; Get saved char back
- 00009E D001 02997 bra lcdout1
- 02998
- 0000A0 8000 02999 lcdoutcom bsf LCDCDFLAG ; Set command
- 03000
- 0000A2 6E07 03001 lcdout1 movwf R3 ; Save char if 4 bit
- 0000A4 A000 03002 btfss LCDCDFLAG ; Command this time?
- 0000A6 D00B 03003 bra lcdchkcd ; No
- 03004
- 0000A8 9880 03005 bcf LCD_RSREG, LCD_RSBIT ; Set command register select
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 6
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0000AA 0803 03006 sublw 3
- 0000AC E30E 03007 bnc lcdsend ; Short delay
- 03008
- 0000AE D80D 03009 rcall lcdsend ; Long delay
- 0000B0 0E07 03010 movlw high LCD_COMMANDUS ; Wait for command to complete
- 0000B2 6E02 03011 movwf R0 + 1
- 0000B4 0ED0 03012 movlw low LCD_COMMANDUS
- 0000B6 EC8F F000 03013 call PAUSEUSL
- 0000BA 80D8 03014 bsf STATUS, C ; Set no timeout for Serout2mod
- 0000BC 0012 03015 return
- 03016
- 0000BE 8000 03017 lcdchkcd bsf LCDCDFLAG ; Indicate first nibble (or command next time)
- 0000C0 08FE 03018 sublw 0feh ; Command next time? (char still in W)
- 0000C2 B4D8 03019 btfsc STATUS, Z
- 0000C4 EFD4 F000 03020 goto DUNN ; Yes - nothing to do this time (C set)
- 03021
- 0000C8 8880 03022 bsf LCD_RSREG, LCD_RSBIT ; Set data register select
- 03023
- 0000CA 03024 lcdsend
- 03025 if (LCD_BITS == 8)
- 03026 lcdloop bsf LCD_EREG, LCD_EBIT ; Enabled
- 03027 movf R3, W ; Get char back
- 03028 movwf LCD_DREG ; Write char to the port
- 03029 if (OSC > 16)
- 03030 nop ; Minimum 1us enable time
- 03031 endif
- 03032 if (OSC > 20)
- 03033 bra $ + 2
- 03034 endif
- 03035 if (OSC > 25)
- 03036 bra $ + 2
- 03037 endif
- 03038 if (OSC > 33)
- 03039 nop
- 03040 endif
- 03041 if (OSC > 40)
- 03042 bra $ + 2
- 03043 endif
- 03044 bcf LCDCDFLAG ; Indicate data next time
- 03045 bcf LCD_EREG, LCD_EBIT ; Not enabled
- 03046 else
- 03047
- 03048 if (LCD_DBIT == 0)
- 0000CA 3A07 03049 swapf R3, F ; Swap top and bottom nibbles
- 03050 endif
- 03051
- 0000CC A000 03052 btfss LCDCDFLAG ; First time through only
- 0000CE 9000 03053 lcdloop bcf LCDCDFLAG ; Indicate second nibble (and data next time)
- 03054
- 0000D0 8482 03055 bsf LCD_EREG, LCD_EBIT ; Enabled
- 03056
- 03057 if (LCD_DBIT == 0)
- 0000D2 0EF0 03058 movlw 0f0h ; Clear lcd data port
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 7
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 03059 else
- 03060 movlw 0fh ; Clear lcd data port
- 03061 endif
- 0000D4 1680 03062 andwf LCD_DREG, F
- 03063
- 0000D6 5007 03064 movf R3, W ; Isolate proper nibble of char
- 03065 if (LCD_DBIT == 0)
- 0000D8 0B0F 03066 andlw 0fh
- 03067 else
- 03068 andlw 0f0h
- 03069 endif
- 0000DA 1280 03070 iorwf LCD_DREG, F ; Write char to port
- 03071
- 03072 if (OSC > 20)
- 0000DC 0000 03073 nop ; Minimum 1us enable time
- 03074 endif
- 03075 if (OSC > 25)
- 0000DE D000 03076 bra $ + 2
- 03077 endif
- 03078 if (OSC > 33)
- 0000E0 0000 03079 nop
- 03080 endif
- 03081 if (OSC > 40)
- 0000E2 D000 03082 bra $ + 2
- 03083 endif
- 03084
- 0000E4 9482 03085 bcf LCD_EREG, LCD_EBIT ; Not enabled - that's four
- 0000E6 3A07 03086 swapf R3, F ; Get to other nibble
- 03087
- 03088 if (OSC > 20)
- 0000E8 0000 03089 nop ; Minimum 1us not-enabled time
- 03090 endif
- 03091 if (OSC > 25)
- 0000EA D000 03092 bra $ + 2
- 03093 endif
- 03094 if (OSC > 33)
- 0000EC 0000 03095 nop
- 03096 endif
- 03097 if (OSC > 40)
- 0000EE D000 03098 bra $ + 2
- 03099 endif
- 03100
- 0000F0 B000 03101 btfsc LCDCDFLAG
- 0000F2 D7ED 03102 bra lcdloop ; Send lower 4 to lcd
- 03103 endif
- 03104
- 0000F4 0E32 03105 movlw LCD_DATAUS ; Wait for data operation to complete
- 0000F6 EC8E F000 03106 call PAUSEUS
- 0000FA 80D8 03107 bsf STATUS, C ; Set no timeout for Serout2mod
- 0000FC EFD4 F000 03108 goto DUNN
- 06227 LIST
- 000100 6A04 06228 PAUSE clrf R1 + 1
- 000102 6E03 06229 PAUSEL movwf R1
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 8
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 000104 0EFF 06230 pauseloop movlw -1 ; 1 (9)
- 000106 2603 06231 addwf R1, F ; 1
- 000108 A0D8 06232 btfss STATUS, C ; 1 / 2
- 00010A 2604 06233 addwf R1 + 1, F ; 1 / 0
- 00010C A0D8 06234 btfss STATUS, C ; 2
- 00010E EFD4 F000 06235 goto DUNN
- 000112 0E03 06236 movlw (PAUSE_DELAY) >> 8 ; 1
- 000114 6E02 06237 movwf R0 + 1 ; 1
- 000116 0EE7 06238 movlw low (PAUSE_DELAY) ; 1
- 000118 D802 06239 rcall PAUSEUSL ; -2 (PAUSEUSL gives you 2 less than you ask for)
- 00011A D7F4 06240 bra pauseloop ; 2
- 06661 LIST
- 00011C 6A02 06662 PAUSEUS clrf R0 + 1 ; 1
- 00011E 0FFD 06663 PAUSEUSL addlw -3 ; 1 Subtract overhead
- 000120 6E01 06664 movwf R0 ; 1
- 000122 0EFF 06665 movlw -1 ; 1
- 000124 D000 06666 bra $ + 2 ; 2
- 000126 D001 06667 bra pauseush ; 2
- 000128 2601 06668 pauseusloop addwf R0, F ; 1
- 06669 pauseush CLRWDT?NOP ; 1
- M ifndef NO_CLRWDT
- 00012A 0004 M clrwdt
- M else
- M nop
- M endif
- 00012C D000 06670 bra $ + 2 ; 2
- 00012E D000 06671 bra $ + 2 ; 2
- 000130 A0D8 06672 btfss STATUS, C ; 1 / 2
- 000132 2602 06673 addwf R0 + 1, F ; 1 / 0
- 000134 A0D8 06674 btfss STATUS, C ; 1 / 2
- 000136 0012 06675 return ; 2 + 3 (call + setup)
- 000138 D7F7 06676 bra pauseusloop ; 2
- 07496 LIST
- 00013A 6A06 07497 DIV clrf R2 + 1
- 00013C 6A05 07498 clrf R2
- 07499
- 00013E 0E10 07500 DIV32DIV movlw 16
- 000140 6E07 07501 movwf R3
- 07502
- 000142 3402 07503 divloop rlcf R0 + 1, W
- 000144 3605 07504 rlcf R2, F
- 000146 3606 07505 rlcf R2 + 1, F
- 000148 5003 07506 movf R1, W
- 00014A 5E05 07507 subwf R2, F
- 00014C 5004 07508 movf R1 + 1, W
- 00014E 5A06 07509 subwfb R2 + 1, F
- 07510
- 000150 E205 07511 bc divok
- 000152 5003 07512 movf R1, W
- 000154 2605 07513 addwf R2, F
- 000156 5004 07514 movf R1 + 1, W
- 000158 2206 07515 addwfc R2 + 1, F
- 07516
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 9
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00015A 90D8 07517 bcf STATUS, C
- 07518
- 00015C 3601 07519 divok rlcf R0, F
- 00015E 3602 07520 rlcf R0 + 1, F
- 07521
- 000160 2E07 07522 decfsz R3, F
- 000162 D7EF 07523 bra divloop
- 000164 5001 07524 movf R0, W ; Get low byte to W
- 000166 EFD4 F000 07525 goto DUNN
- 07542 LIST
- 00016A 5003 07543 MUL movf R1, W
- 00016C 0207 07544 mulwf R3 ; R1 * R3 = PRODHL
- 07545
- 00016E CFF4 F006 07546 movff PRODH, R2 + 1
- 000172 CFF3 F005 07547 movff PRODL, R2
- 07548
- 000176 5004 07549 movf R1 + 1, W
- 000178 0208 07550 mulwf R3 + 1 ; R1 + 1 * R3 + 1 = PRODHL
- 07551
- 00017A CFF4 F002 07552 movff PRODH, R0 + 1
- 00017E CFF3 F001 07553 movff PRODL, R0
- 07554
- 000182 5003 07555 movf R1, W
- 000184 0208 07556 mulwf R3 + 1 ; R1 * R3 + 1 = PRODHL
- 07557
- 000186 50F3 07558 movf PRODL, W ; Add cross products
- 000188 2606 07559 addwf R2 + 1, F
- 00018A 50F4 07560 movf PRODH, W
- 00018C 2201 07561 addwfc R0, F
- 00018E 6AE8 07562 clrf WREG
- 000190 2202 07563 addwfc R0 + 1, F
- 07564
- 000192 5004 07565 movf R1 + 1, W
- 000194 0207 07566 mulwf R3 ; R1 + 1 * R3 = PRODHL
- 07567
- 000196 50F3 07568 movf PRODL, W ; Add cross products
- 000198 2606 07569 addwf R2 + 1, F
- 00019A 50F4 07570 movf PRODH, W
- 00019C 2201 07571 addwfc R0, F
- 00019E 6AE8 07572 clrf WREG
- 0001A0 2202 07573 addwfc R0 + 1, F
- 07574
- 0001A2 5005 07575 movf R2, W ; Get low byte to W
- 0001A4 EFD4 F000 07576 goto DUNN
- 07647 LIST
- 0001A8 0100 07648 DUNN movlb 0 ; 1 Reset banks to 0
- 07649 DUNN3 CLRWDT?NOP ; 1 Hit Watchdog timer
- M ifndef NO_CLRWDT
- 0001AA 0004 M clrwdt
- M else
- M nop
- M endif
- 0001AC 0012 07650 DUNNRET return ; 2 Done
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 10
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 07663 LIST
- 0001AE 07664 INIT
- 07708 LIST
- 0001AE 07709 main
- 0001AE EFB0 F004 00012 goto MAINPROG
- 00013 include "USB18.INC"
- 00001 ; MUID = Microchip USB Class ID
- 00002 ; Used to identify which of the USB classes owns the current
- 00003 ; session of control transfer over EP0
- 00004 #define MUID_NULL 0
- 00005 #define MUID_USB9 1
- 00006 #define MUID_HID 2
- 00007 #define MUID_CDC 3
- 00008 #define MUID_MSD 4
- 00009
- 00010 ; Buffer Descriptor Status Register Initialization Parameters
- 00011 #define _BSTALL 0x04 ; Buffer Stall enable
- 00012 #define _DTSEN 0x08 ; Data Toggle Synch enable
- 00013 #define _INCDIS 0x10 ; Address increment disable
- 00014 #define _KEN 0x20 ; SIE keeps buff descriptors enable
- 00015 #define _DAT0 0x00 ; DATA0 packet expected next
- 00016 #define _DAT1 0x40 ; DATA1 packet expected next
- 00017 #define _DTSMASK 0x40 ; DTS Mask
- 00018 #define _USIE 0x80 ; SIE owns buffer
- 00019 #define _UCPU 0x00 ; CPU owns buffer
- 00020
- 00021 ; USB Device States - To be used with [byte usb_device_state]
- 00022 #define DETACHED_STATE 0
- 00023 #define ATTACHED_STATE 1
- 00024 #define POWERED_STATE 2
- 00025 #define DEFAULT_STATE 3
- 00026 #define ADR_PENDING_STATE 4
- 00027 #define ADDRESS_STATE 5
- 00028 #define CONFIGURED_STATE 6
- 00029
- 00030 ; Memory Types for Control Transfer - used in USB_DEVICE_STATUS
- 00031 ;#define _RAM 0
- 00032 ;#define _ROM 1
- 00033
- 00034
- 00035 ; From usbdefs_std_dsc.h
- 00036 ; Descriptor Types
- 00037 #define DSC_DEV 0x01
- 00038 #define DSC_CFG 0x02
- 00039 #define DSC_STR 0x03
- 00040 #define DSC_INTF 0x04
- 00041 #define DSC_EP 0x05
- 00042
- 00043 ; USB Endpoint Definitions
- 00044 #define _EP01_OUT 0x01
- 00045 #define _EP01_IN 0x81
- 00046 #define _EP02_OUT 0x02
- 00047 #define _EP02_IN 0x82
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 11
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00048 #define _EP03_OUT 0x03
- 00049 #define _EP03_IN 0x83
- 00050 #define _EP04_OUT 0x04
- 00051 #define _EP04_IN 0x84
- 00052 #define _EP05_OUT 0x05
- 00053 #define _EP05_IN 0x85
- 00054 #define _EP06_OUT 0x06
- 00055 #define _EP06_IN 0x86
- 00056 #define _EP07_OUT 0x07
- 00057 #define _EP07_IN 0x87
- 00058 #define _EP08_OUT 0x08
- 00059 #define _EP08_IN 0x88
- 00060 #define _EP09_OUT 0x09
- 00061 #define _EP09_IN 0x89
- 00062 #define _EP10_OUT 0x0A
- 00063 #define _EP10_IN 0x8A
- 00064 #define _EP11_OUT 0x0B
- 00065 #define _EP11_IN 0x8B
- 00066 #define _EP12_OUT 0x0C
- 00067 #define _EP12_IN 0x8C
- 00068 #define _EP13_OUT 0x0D
- 00069 #define _EP13_IN 0x8D
- 00070 #define _EP14_OUT 0x0E
- 00071 #define _EP14_IN 0x8E
- 00072 #define _EP15_OUT 0x0F
- 00073 #define _EP15_IN 0x8F
- 00074
- 00075 ; Configuration Attributes
- 00076 ;#define _DEFAULT 0x01<<7 ; Default Value (Bit 7 is set)
- 00077 ;#define _SELF 0x01<<6 ; Self-powered (Supports if set)
- 00078 ;#define _RWU 0x01<<5 ; Remote Wakeup (Supports if set)
- 00079
- 00080 ; Endpoint Transfer Type
- 00081 ;#define _CTRL 0x00 ; Control Transfer
- 00082 ;#define _ISO 0x01 ; Isochronous Transfer
- 00083 ;#define _BULK 0x02 ; Bulk Transfer
- 00084 ;#define _INT 0x03 ; Interrupt Transfer
- 00085
- 00086 ; Isochronous Endpoint Synchronization Type
- 00087 ;#define _NS 0x00<<2 ; No Synchronization
- 00088 ;#define _AS 0x01<<2 ; Asynchronous
- 00089 ;#define _AD 0x02<<2 ; Adaptive
- 00090 ;#define _SY 0x03<<2 ; Synchronous
- 00091
- 00092 ; Isochronous Endpoint Usage Type
- 00093 ;#define _DE 0x00<<4 ; Data endpoint
- 00094 ;#define _FE 0x01<<4 ; Feedback endpoint
- 00095 ;#define _IE 0x02<<4 ; Implicit feedback Data endpoint
- 00096
- 00097
- 00098 ; From usb9.h
- 00099 ; Standard Request Codes
- 00100 ; USB 2.0 Spec Ref Table 9-4
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 12
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00101 #define GET_STATUS 0
- 00102 #define CLR_FEATURE 1
- 00103 #define SET_FEATURE 3
- 00104 #define SET_ADR 5
- 00105 #define GET_DSC 6
- 00106 #define SET_DSC 7
- 00107 #define GET_CFG 8
- 00108 #define SET_CFG 9
- 00109 #define GET_INTF 10
- 00110 #define SET_INTF 11
- 00111 #define SYNCH_FRAME 12
- 00112
- 00113 ; Standard Feature Selectors
- 00114 #define DEVICE_REMOTE_WAKEUP 0x01
- 00115 #define ENDPOINT_HALT 0x00
- 00116
- 00117
- 00118 ; From hid.h
- 00119 ; Class-Specific Requests
- 00120 #define GET_REPORT 0x01
- 00121 #define GET_IDLE 0x02
- 00122 #define GET_PROTOCOL 0x03
- 00123 #define SET_REPORT 0x09
- 00124 #define SET_IDLE 0x0A
- 00125 #define SET_PROTOCOL 0x0B
- 00126
- 00127 ; Class Descriptor Types
- 00128 #define DSC_HID 0x21
- 00129 #define DSC_RPT 0x22
- 00130 #define DSC_PHY 0x23
- 00131
- 00132 ; Protocol Selection
- 00133 #define BOOT_PROTOCOL 0x00
- 00134 #define RPT_PROTOCOL 0x01
- 00135
- 00136 ; HID Interface Class Code
- 00137 #define HID_INTF 0x03
- 00138
- 00139 ; HID Interface Class SubClass Codes
- 00140 #define BOOT_INTF_SUBCLASS 0x01
- 00141
- 00142 ; HID Interface Class Protocol Codes
- 00143 #define HID_PROTOCOL_NONE 0x00
- 00144 #define HID_PROTOCOL_KEYBOAD 0x01
- 00145 #define HID_PROTOCOL_MOUSE 0x02
- 00146
- 00147 ; HID Report codes used in GET_REPORT and SET_REPORT requests
- 00148 #define HID_INPUT_REPORT 1
- 00149 #define HID_OUTPUT_REPORT 2
- 00150 #define HID_FEATURE_REPORT 3
- 00151
- 00152
- 00153 ; From cdc.h
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 13
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00154 ; Class-Specific Requests
- 00155 #define SEND_ENCAPSULATED_COMMAND 0x00
- 00156 #define GET_ENCAPSULATED_RESPONSE 0x01
- 00157 #define SET_COMM_FEATURE 0x02
- 00158 #define GET_COMM_FEATURE 0x03
- 00159 #define CLEAR_COMM_FEATURE 0x04
- 00160 #define SET_LINE_CODING 0x20
- 00161 #define GET_LINE_CODING 0x21
- 00162 #define SET_CONTROL_LINE_STATE 0x22
- 00163 #define SEND_BREAK 0x23
- 00164
- 00165 ; Notifications
- 00166 ; Note: Notifications are polled over
- 00167 ; Communication Interface (Interrupt Endpoint)
- 00168 #define NETWORK_CONNECTION 0x00
- 00169 #define RESPONSE_AVAILABLE 0x01
- 00170 #define SERIAL_STATE 0x20
- 00171
- 00172 ; Device Class Code
- 00173 #define CDC_DEVICE 0x02
- 00174
- 00175 ; Communication Interface Class Code
- 00176 #define COMM_INTF 0x02
- 00177
- 00178 ; Communication Interface Class SubClass Codes
- 00179 #define ABSTRACT_CONTROL_MODEL 0x02
- 00180
- 00181 ; Communication Interface Class Control Protocol Codes
- 00182 #define V25TER 0x01 ; Common AT commands ("Hayes(TM)")
- 00183
- 00184 ; Data Interface Class Codes
- 00185 #define DATA_INTF 0x0A
- 00186
- 00187 ; Data Interface Class Protocol Codes
- 00188 #define NO_PROTOCOL 0x00 ; No class specific protocol required
- 00189
- 00190 ; Communication Feature Selector Codes
- 00191 #define ABSTRACT_STATE 0x01
- 00192 #define COUNTRY_SETTING 0x02
- 00193
- 00194 ; Functional Descriptors
- 00195 ; Type Values for the bDscType Field
- 00196 #define CS_INTERFACE 0x24
- 00197 #define CS_ENDPOINT 0x25
- 00198
- 00199 ; bDscSubType in Functional Descriptors
- 00200 #define DSC_FN_HEADER 0x00
- 00201 #define DSC_FN_CALL_MGT 0x01
- 00202 #define DSC_FN_ACM 0x02 ; ACM - Abstract Control Management
- 00203 #define DSC_FN_DLM 0x03 ; DLM - Direct Line Managment
- 00204 #define DSC_FN_TELEPHONE_RINGER 0x04
- 00205 #define DSC_FN_RPT_CAPABILITIES 0x05
- 00206 #define DSC_FN_UNION 0x06
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 14
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00207 #define DSC_FN_COUNTRY_SELECTION 0x07
- 00208 #define DSC_FN_TEL_OP_MODES 0x08
- 00209 #define DSC_FN_USB_TERMINAL 0x09
- 00210 ; more.... see Table 25 in USB CDC Specification 1.1
- 00211
- 00212 ; CDC Bulk IN transfer states
- 00213 #define CDC_TX_READY 0
- 00214 #define CDC_TX_BUSY 1
- 00215 #define CDC_TX_BUSY_ZLP 2 ; ZLP: Zero Length Packet
- 00216 #define CDC_TX_COMPLETING 3
- 00217
- 00218 #define LINE_CODING_LENGTH 0x07
- 00219 #define dummy_length 0x08
- 00220
- 00221
- 00222 ; From usbctrltrf.h
- 00223 ; Control Transfer States
- 00224 #define WAIT_SETUP 0
- 00225 #define CTRL_TRF_TX 1
- 00226 #define CTRL_TRF_RX 2
- 00227
- 00228 ; USB PID: Token Types - See chapter 8 in the USB specification
- 00229 #define SETUP_TOKEN 0x0d
- 00230 #define OUT_TOKEN 0x01
- 00231 #define IN_TOKEN 0x09
- 00232
- 00233 ; bmRequestType Definitions
- 00234 #define HOST_TO_DEV 0
- 00235 #define DEV_TO_HOST 1
- 00236
- 00237 #define STANDARD 0x00
- 00238 #define CLASS 0x01
- 00239 #define VENDOR 0x02
- 00240
- 00241 #define RCPT_DEV 0
- 00242 #define RCPT_INTF 1
- 00243 #define RCPT_EP 2
- 00244 #define RCPT_OTH 3
- 00245
- 00246
- 00247 ; From usbdrv.h
- 00248 ; UCFG Initialization Parameters
- 00249 #define _PPBM0 0x00 ; Pingpong Buffer Mode 0
- 00250 #define _PPBM1 0x01 ; Pingpong Buffer Mode 1
- 00251 #define _PPBM2 0x02 ; Pingpong Buffer Mode 2
- 00252 #define _LS 0x00 ; Use Low-Speed USB Mode
- 00253 #define _FS 0x04 ; Use Full-Speed USB Mode
- 00254 #define _TRINT 0x00 ; Use internal transceiver
- 00255 #define _TREXT 0x08 ; Use external transceiver
- 00256 #define _PUEN 0x10 ; Use internal pull-up resistor
- 00257 #define _OEMON 0x40 ; Use SIE output indicator
- 00258 #define _UTEYE 0x80 ; Use Eye-Pattern test
- 00259
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 15
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00260 ; UEPn Initialization Parameters
- 00261 #define EP_CTRL 0x06 ; Cfg Control pipe for this ep
- 00262 #define EP_OUT 0x0C ; Cfg OUT only pipe for this ep
- 00263 #define EP_IN 0x0A ; Cfg IN only pipe for this ep
- 00264 #define EP_OUT_IN 0x0E ; Cfg both OUT & IN pipes for this ep
- 00265 #define HSHK_EN 0x10 ; Enable handshake packet
- 00266
- 00267 #define OUT 0
- 00268 #define IN 1
- 00269
- 00270 #define PIC_EP_NUM_MASK 0b01111000
- 00271 #define PIC_EP_DIR_MASK 0b00000100
- 00272
- 00273 #define EP00_OUT ((0x00<<3)|(OUT<<2))
- 00274 #define EP00_IN ((0x00<<3)|(IN<<2))
- 00275 #define EP01_OUT ((0x01<<3)|(OUT<<2))
- 00276 #define EP01_IN ((0x01<<3)|(IN<<2))
- 00277 #define EP02_OUT ((0x02<<3)|(OUT<<2))
- 00278 #define EP02_IN ((0x02<<3)|(IN<<2))
- 00279 #define EP03_OUT ((0x03<<3)|(OUT<<2))
- 00280 #define EP03_IN ((0x03<<3)|(IN<<2))
- 00281 #define EP04_OUT ((0x04<<3)|(OUT<<2))
- 00282 #define EP04_IN ((0x04<<3)|(IN<<2))
- 00283 #define EP05_OUT ((0x05<<3)|(OUT<<2))
- 00284 #define EP05_IN ((0x05<<3)|(IN<<2))
- 00285 #define EP06_OUT ((0x06<<3)|(OUT<<2))
- 00286 #define EP06_IN ((0x06<<3)|(IN<<2))
- 00287 #define EP07_OUT ((0x07<<3)|(OUT<<2))
- 00288 #define EP07_IN ((0x07<<3)|(IN<<2))
- 00289 #define EP08_OUT ((0x08<<3)|(OUT<<2))
- 00290 #define EP08_IN ((0x08<<3)|(IN<<2))
- 00291 #define EP09_OUT ((0x09<<3)|(OUT<<2))
- 00292 #define EP09_IN ((0x09<<3)|(IN<<2))
- 00293 #define EP10_OUT ((0x0A<<3)|(OUT<<2))
- 00294 #define EP10_IN ((0x0A<<3)|(IN<<2))
- 00295 #define EP11_OUT ((0x0B<<3)|(OUT<<2))
- 00296 #define EP11_IN ((0x0B<<3)|(IN<<2))
- 00297 #define EP12_OUT ((0x0C<<3)|(OUT<<2))
- 00298 #define EP12_IN ((0x0C<<3)|(IN<<2))
- 00299 #define EP13_OUT ((0x0D<<3)|(OUT<<2))
- 00300 #define EP13_IN ((0x0D<<3)|(IN<<2))
- 00301 #define EP14_OUT ((0x0E<<3)|(OUT<<2))
- 00302 #define EP14_IN ((0x0E<<3)|(IN<<2))
- 00303 #define EP15_OUT ((0x0F<<3)|(OUT<<2))
- 00304 #define EP15_IN ((0x0F<<3)|(IN<<2))
- 00014 include "USBDESC.ASM" ; Application specific descriptors
- 00001 ; This file contains an include for the application specific
- 00002 ; USB descriptors. Include only ONE of the following or add
- 00003 ; your own for your own project.
- 00004
- 00005 include "DESCUSBFm.ASM" ; USB descriptors
- 00001
- 00002
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 16
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00003 #define EP0_BUFF_SIZE 64 ; 8, 16, 32, or 64
- 00004 #define MAX_NUM_INT 1 ; For tracking Alternate Setting
- 00005 #define MAX_EP_NUMBER 1 ; UEP1
- 00006 #define NUM_CONFIGURATIONS 1
- 00007 #define NUM_INTERFACES 1
- 00008
- 00009 #define MODE_PP _PPBM0
- 00010 #define UCFG_VAL _PUEN|_TRINT|_FS|MODE_PP ; Full-speed
- 00011
- 00012 ; DEVICE CLASS USAGE
- 00013 #define USB_USE_HID
- 00014
- 00015 ; HID
- 00016 ; Endpoints Allocation
- 00017 #define HID_INTF_ID 0x00
- 00018 #define HID_UEP UEP1
- 00019 #define HID_BD_OUT ep1Bo
- 00020 #define HID_INT_OUT_EP_SIZE 64
- 00021 #define HID_BD_IN ep1Bi
- 00022 #define HID_INT_IN_EP_SIZE 64
- 00023 #define HID_NUM_OF_DSC 1
- 00024
- 00025 ; ******************************************************************
- 00026 ; This table is polled by the host immediately after USB Reset has been released.
- 00027 ; This table defines the maximum packet size EP0 can take.
- 00028 ; See section 9.6.1 of the Rev 1.0 USB specification.
- 00029 ; These fields are application DEPENDENT. Modify these to meet
- 00030 ; your specifications.
- 00031 ; ******************************************************************
- 0001B2 00032 DeviceDescriptor
- 0001B2 0C12 00033 retlw (EndDeviceDescriptor-DeviceDescriptor)/2 ; bLength Length of this descriptor
- 0001B4 0C01 00034 retlw DSC_DEV ; bDescType This is a DEVICE descriptor
- 0001B6 0C10 00035 retlw 0x10 ; bcdUSBUSB Revision 1.10 (low byte)
- 0001B8 0C01 00036 retlw 0x01 ; high byte
- 0001BA 0C00 00037 retlw 0x00 ; bDeviceClass zero means each interface operates independently
- 0001BC 0C00 00038 retlw 0x00 ; bDeviceSubClass
- 0001BE 0C00 00039 retlw 0x00 ; bDeviceProtocol
- 0001C0 0C40 00040 retlw EP0_BUFF_SIZE ; bMaxPacketSize for EP0
- 00041
- 00042 ; idVendor (low byte, high byte)
- 0001C2 0C83 00043 retlw 0x83
- 0001C4 0C17 00044 retlw 0x17
- 00045
- 00046 ; idProduct (low byte, high byte)
- 0001C6 0CD9 00047 retlw 0xD9
- 0001C8 0C07 00048 retlw 0x07
- 00049
- 0001CA 0C00 00050 retlw 0x00 ; bcdDevice (low byte)
- 0001CC 0C00 00051 retlw 0x00 ; (high byte)
- 0001CE 0C01 00052 retlw 0x01 ; iManufacturer (string index)
- 0001D0 0C02 00053 retlw 0x02 ; iProduct (string index)
- 00054
- 00055 ; iSerialNumber (string index)
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 17
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0001D2 0C00 00056 retlw 0x00
- 0001D4 0C01 00057 retlw NUM_CONFIGURATIONS ; bNumConfigurations
- 0001D6 00058 EndDeviceDescriptor
- 00059
- 00060 ; ******************************************************************
- 00061 ; This table is retrieved by the host after the address has been set.
- 00062 ; This table defines the configurations available for the device.
- 00063 ; See section 9.6.2 of the Rev 1.0 USB specification (page 184).
- 00064 ; These fields are application DEPENDENT.
- 00065 ; Modify these to meet your specifications.
- 00066 ; ******************************************************************
- 00067 ; Configuration pointer table
- 0001D6 00068 USB_CD_Ptr
- 0001D6 00069 Configs
- 0001D6 01DA 00070 db low Config1, high Config1
- 0001D8 01DA 00071 db low Config1, high Config1
- 00072
- 00073 ; Configuration Descriptor
- 0001DA 00074 Config1
- 0001DA 0C09 00075 retlw (Interface1-Config1)/2 ; bLength Length of this descriptor
- 0001DC 0C02 00076 retlw DSC_CFG ; bDescType 2=CONFIGURATION
- 0001DE 00077 Config1Len
- 0001DE 0C29 00078 retlw low ((EndConfig1 - Config1)/2) ; Length of this configuration
- 0001E0 0C00 00079 retlw high ((EndConfig1 - Config1)/2)
- 0001E2 0C01 00080 retlw 0x01 ; bNumInterfaces Number of interfaces
- 0001E4 0C01 00081 retlw 0x01 ; bConfigValue Configuration Value
- 0001E6 0C00 00082 retlw 0x00 ; iConfig (string index)
- 0001E8 0CA0 00083 retlw 0xA0 ; bmAttributes attributes - bus powered
- 00084
- 00085 ; Max power consumption (2X mA)
- 0001EA 0C32 00086 retlw 0x32
- 0001EC 00087 Interface1
- 0001EC 0C09 00088 retlw (HIDDescriptor1-Interface1)/2 ; length of descriptor
- 0001EE 0C04 00089 retlw DSC_INTF
- 0001F0 0C00 00090 retlw 0x00 ; number of interface, 0 based array
- 0001F2 0C00 00091 retlw 0x00 ; alternate setting
- 0001F4 0C02 00092 retlw 0x02 ; number of endpoints used in this interface
- 0001F6 0C03 00093 retlw 0x03 ; interface class - assigned by the USB
- 0001F8 0C00 00094 retlw 0x00 ; boot device
- 0001FA 0C00 00095 retlw 0x00 ; interface protocol - mouse
- 0001FC 0C00 00096 retlw 0x00 ; index to string descriptor that describes this interface
- 0001FE 00097 HIDDescriptor1
- 0001FE 0C09 00098 retlw (Endpoint1In-HIDDescriptor1)/2 ; descriptor size (9 bytes)
- 000200 0C21 00099 retlw 0x21 ; descriptor type (HID)
- 000202 0C00 00100 retlw 0x00 ; HID class release number (1.00)
- 000204 0C01 00101 retlw 0x01
- 000206 0C00 00102 retlw 0x00 ; Localized country code (none)
- 000208 0C01 00103 retlw 0x01 ; # of HID class descriptor to follow (1)
- 00020A 0C22 00104 retlw 0x22 ; Report descriptor type (HID)
- 00020C 00105 ReportDescriptor1Len
- 00020C 0C28 00106 retlw low ((EndReportDescriptor1-ReportDescriptor1)/2)
- 00020E 0C00 00107 retlw high ((EndReportDescriptor1-ReportDescriptor1)/2)
- 000210 00108 Endpoint1In
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 18
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 000210 0C07 00109 retlw (EndPoint1Out-Endpoint1In)/2 ; length of descriptor
- 000212 0C05 00110 retlw DSC_EP
- 000214 0C81 00111 retlw 0x81 ; EP1, In
- 000216 0C03 00112 retlw 0x03 ; Interrupt
- 000218 0C40 00113 retlw 0x40 ; This should be the size of the endpoint buffer
- 00021A 0C00 00114 retlw 0x00
- 00021C 0C0A 00115 retlw 0x0A ; Polling interval
- 00021E 00116 EndPoint1Out
- 00021E 0C07 00117 retlw (EndConfig1-EndPoint1Out)/2 ; Length of this Endpoint Descriptor
- 000220 0C05 00118 retlw DSC_EP ; bDescriptorType = 5 for Endpoint Descriptor
- 000222 0C01 00119 retlw 0x01 ; Endpoint number & direction
- 000224 0C03 00120 retlw 0x03 ; Transfer type supported by this Endpoint
- 000226 0C40 00121 retlw 0x40 ; This should be the size of the endpoint buffer
- 000228 0C00 00122 retlw 0x00
- 00022A 0C0A 00123 retlw 0x0A ; Polling interval
- 00022C 00124 EndConfig1
- 00125
- 00022C 00126 ReportDescriptor1
- 00127 ; vendor defined usage page
- 00022C 0C06 00128 retlw 0x06
- 00022E 0C00 00129 retlw 0x00
- 000230 0CFF 00130 retlw 0xFF
- 00131
- 00132 ; vendor defined usage
- 000232 0C09 00133 retlw 0x09
- 000234 0C00 00134 retlw 0x00
- 00135
- 00136 ; collection(application)
- 000236 0CA1 00137 retlw 0xA1
- 000238 0C01 00138 retlw 0x01
- 00139
- 00140 ; *** INPUT REPORT ***
- 00141
- 00142 ; vendor defined usage
- 00023A 0C09 00143 retlw 0x09
- 00023C 0C01 00144 retlw 0x01
- 00145
- 00023E 0C15 00146 retlw 0x15 ; logical minimum (-128)
- 000240 0C80 00147 retlw 0x80 ;
- 000242 0C25 00148 retlw 0x25 ; logical maximum (127)
- 000244 0C7F 00149 retlw 0x7F ;
- 000246 0C35 00150 retlw 0x35 ; Physical Minimum (0)
- 000248 0C00 00151 retlw 0x00 ;
- 00024A 0C45 00152 retlw 0x45 ; Physical Maximum (255)
- 00024C 0CFF 00153 retlw 0xFF ;
- 00154
- 00155 ; report size in bits
- 00024E 0C75 00156 retlw 0x75
- 000250 0C08 00157 retlw 0x08
- 00158
- 00159 ; report count (number of fields)
- 000252 0C95 00160 retlw 0x95
- 000254 0C10 00161 retlw 0x10
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 19
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00162
- 00163 ; Input (Data, Variable, Absolute)
- 000256 0C81 00164 retlw 0x81
- 000258 0C02 00165 retlw 0x02
- 00166
- 00167 ; *** OUTPUT REPORT ***
- 00168
- 00169 ; vendor defined usage
- 00025A 0C09 00170 retlw 0x09 ; usage (Vendor Defined)
- 00025C 0C02 00171 retlw 0x02 ;
- 00172
- 00025E 0C15 00173 retlw 0x15 ; logical minimum (-128)
- 000260 0C80 00174 retlw 0x80 ;
- 000262 0C25 00175 retlw 0x25 ; logical maximum (127)
- 000264 0C7F 00176 retlw 0x7F ;
- 000266 0C35 00177 retlw 0x35 ; Physical Minimum (0)
- 000268 0C00 00178 retlw 0x00 ;
- 00026A 0C45 00179 retlw 0x45 ; Physical Maximum (255)
- 00026C 0CFF 00180 retlw 0xFF ;
- 00181
- 00182 ; report size in bits
- 00026E 0C75 00183 retlw 0x75
- 000270 0C08 00184 retlw 0x08
- 00185
- 00186 ; report count (number of fields)
- 000272 0C95 00187 retlw 0x95
- 000274 0C10 00188 retlw 0x10
- 00189
- 00190 ; Output (Data, Variable, Absolute)
- 000276 0C91 00191 retlw 0x91
- 000278 0C02 00192 retlw 0x02
- 00193
- 00027A 0CC0 00194 retlw 0xC0 ; end collection
- 00195
- 00027C 00196 EndReportDescriptor1
- 00197
- 00198 ; String pointer table
- 00027C 00199 USB_SD_Ptr
- 00027C 00200 Strings
- 00027C 0284 00201 db low String0, high String0
- 00027E 028C 00202 db low String1, high String1
- 000280 02B8 00203 db low String2, high String2
- 000282 02E8 00204 db low String3, high String3
- 00205
- 000284 00206 String0
- 000284 0C04 00207 retlw (String1-String0)/2 ; Length of string
- 000286 0C03 00208 retlw DSC_STR ; Descriptor type 3
- 000288 0C09 00209 retlw 0x09 ; Language ID (as defined by MS 0x0409)
- 00028A 0C04 00210 retlw 0x04
- 00211
- 00212 ; company name
- 00028C 00213 String1
- 00028C 0C16 00214 retlw (String2-String1)/2
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 20
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00028E 0C03 00215 retlw DSC_STR
- 00216
- 000290 0C54 00217 retlw 'T'
- 000292 0C00 00218 retlw 0x00
- 000294 0C72 00219 retlw 'r'
- 000296 0C00 00220 retlw 0x00
- 000298 0C61 00221 retlw 'a'
- 00029A 0C00 00222 retlw 0x00
- 00029C 0C6E 00223 retlw 'n'
- 00029E 0C00 00224 retlw 0x00
- 0002A0 0C73 00225 retlw 's'
- 0002A2 0C00 00226 retlw 0x00
- 0002A4 0C6D 00227 retlw 'm'
- 0002A6 0C00 00228 retlw 0x00
- 0002A8 0C69 00229 retlw 'i'
- 0002AA 0C00 00230 retlw 0x00
- 0002AC 0C73 00231 retlw 's'
- 0002AE 0C00 00232 retlw 0x00
- 0002B0 0C6F 00233 retlw 'o'
- 0002B2 0C00 00234 retlw 0x00
- 0002B4 0C72 00235 retlw 'r'
- 0002B6 0C00 00236 retlw 0x00
- 00237
- 00238
- 00239 ; product name
- 0002B8 00240 String2
- 0002B8 0C18 00241 retlw (String3-String2)/2
- 0002BA 0C03 00242 retlw DSC_STR
- 00243
- 0002BC 0C46 00244 retlw 'F'
- 0002BE 0C00 00245 retlw 0x00
- 0002C0 0C6D 00246 retlw 'm'
- 0002C2 0C00 00247 retlw 0x00
- 0002C4 0C4D 00248 retlw 'M'
- 0002C6 0C00 00249 retlw 0x00
- 0002C8 0C6F 00250 retlw 'o'
- 0002CA 0C00 00251 retlw 0x00
- 0002CC 0C64 00252 retlw 'd'
- 0002CE 0C00 00253 retlw 0x00
- 0002D0 0C75 00254 retlw 'u'
- 0002D2 0C00 00255 retlw 0x00
- 0002D4 0C6C 00256 retlw 'l'
- 0002D6 0C00 00257 retlw 0x00
- 0002D8 0C61 00258 retlw 'a'
- 0002DA 0C00 00259 retlw 0x00
- 0002DC 0C74 00260 retlw 't'
- 0002DE 0C00 00261 retlw 0x00
- 0002E0 0C6F 00262 retlw 'o'
- 0002E2 0C00 00263 retlw 0x00
- 0002E4 0C72 00264 retlw 'r'
- 0002E6 0C00 00265 retlw 0x00
- 00266
- 00267 ; serial number
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 21
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0002E8 00268 String3
- 0002E8 0C02 00269 retlw (String4-String3)/2
- 0002EA 0C03 00270 retlw DSC_STR
- 00271
- 00272
- 0002EC 00273 String4
- 00274
- 00275
- 00015 include "USB18MEM.ASM"
- 00001 ; Buffer Descriptor Byte Aliases
- 00002 #define Stat 0 ; Buffer Descriptor Status Register
- 00003 #define Cnt 1 ; Buffer Count
- 00004 ;#define ADR 2 ; Buffer Address
- 00005 #define ADRL 2 ; Buffer Address Low
- 00006 #define ADRH 3 ; Buffer Address High
- 00007
- 00008 ; Stat Bit Aliases
- 00009 #define BC8 0 ; Upper Count Bit
- 00010 #define BC9 1 ; Upper Count Bit
- 00011 #define BSTALL 2 ; Buffer Stall Enable
- 00012 #define DTSEN 3 ; Data Toggle Synch Enable
- 00013 #define INCDIS 4 ; Address Increment Disable
- 00014 #define KEN 5 ; BD Keep Enable
- 00015 #define DTS 6 ; Data Toggle Synch Value
- 00016 #define UOWN 7 ; USB Ownership
- 00017 #define PID 2 ; Packet Identifier (4 bits)
- 00018 ;#define PID0 2
- 00019 ;#define PID1 3
- 00020 ;#define PID2 4
- 00021 ;#define PID3 5
- 00022
- 00023
- 000002EC 00024 SavedOrg equ $ ; Save current org
- 000400 00025 org 0x400 ; Bank 4
- 00026
- 00027 ; Buffer Descriptor Table (BDT) RAM
- 00028
- 00029 #if(0 <= MAX_EP_NUMBER) ; (See usbmmap.c & usbmmap.h)
- 000400 00030 ep0Bo res 4 ; Endpoint #0 BD Out
- 000404 00031 ep0Bi res 4 ; Endpoint #0 BD In
- 00032 #endif
- 00033
- 00034 #if(1 <= MAX_EP_NUMBER)
- 000408 00035 ep1Bo res 4 ; Endpoint #1 BD Out
- 00040C 00036 ep1Bi res 4 ; Endpoint #1 BD In
- 00037 #endif
- 00038
- 00039 #if(2 <= MAX_EP_NUMBER)
- 00040 ep2Bo res 4 ; Endpoint #2 BD Out
- 00041 ep2Bi res 4 ; Endpoint #2 BD In
- 00042 #endif
- 00043
- 00044 #if(3 <= MAX_EP_NUMBER)
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 22
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00045 ep3Bo res 4 ; Endpoint #3 BD Out
- 00046 ep3Bi res 4 ; Endpoint #3 BD In
- 00047 #endif
- 00048
- 00049 #if(4 <= MAX_EP_NUMBER)
- 00050 ep4Bo res 4 ; Endpoint #4 BD Out
- 00051 ep4Bi res 4 ; Endpoint #4 BD In
- 00052 #endif
- 00053
- 00054 #if(5 <= MAX_EP_NUMBER)
- 00055 ep5Bo res 4 ; Endpoint #5 BD Out
- 00056 ep5Bi res 4 ; Endpoint #5 BD In
- 00057 #endif
- 00058
- 00059 #if(6 <= MAX_EP_NUMBER)
- 00060 ep6Bo res 4 ; Endpoint #6 BD Out
- 00061 ep6Bi res 4 ; Endpoint #6 BD In
- 00062 #endif
- 00063
- 00064 #if(7 <= MAX_EP_NUMBER)
- 00065 ep7Bo res 4 ; Endpoint #7 BD Out
- 00066 ep7Bi res 4 ; Endpoint #7 BD In
- 00067 #endif
- 00068
- 00069 #if(8 <= MAX_EP_NUMBER)
- 00070 ep8Bo res 4 ; Endpoint #8 BD Out
- 00071 ep8Bi res 4 ; Endpoint #8 BD In
- 00072 #endif
- 00073
- 00074 #if(9 <= MAX_EP_NUMBER)
- 00075 ep9Bo res 4 ; Endpoint #9 BD Out
- 00076 ep9Bi res 4 ; Endpoint #9 BD In
- 00077 #endif
- 00078
- 00079 #if(10 <= MAX_EP_NUMBER)
- 00080 ep10Bo res 4 ; Endpoint #10 BD Out
- 00081 ep10Bi res 4 ; Endpoint #10 BD In
- 00082 #endif
- 00083
- 00084 #if(11 <= MAX_EP_NUMBER)
- 00085 ep11Bo res 4 ; Endpoint #11 BD Out
- 00086 ep11Bi res 4 ; Endpoint #11 BD In
- 00087 #endif
- 00088
- 00089 #if(12 <= MAX_EP_NUMBER)
- 00090 ep12Bo res 4 ; Endpoint #12 BD Out
- 00091 ep12Bi res 4 ; Endpoint #12 BD In
- 00092 #endif
- 00093
- 00094 #if(13 <= MAX_EP_NUMBER)
- 00095 ep13Bo res 4 ; Endpoint #13 BD Out
- 00096 ep13Bi res 4 ; Endpoint #13 BD In
- 00097 #endif
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 23
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00098
- 00099 #if(14 <= MAX_EP_NUMBER)
- 00100 ep14Bo res 4 ; Endpoint #14 BD Out
- 00101 ep14Bi res 4 ; Endpoint #14 BD In
- 00102 #endif
- 00103
- 00104 #if(15 <= MAX_EP_NUMBER)
- 00105 ep15Bo res 4 ; Endpoint #15 BD Out
- 00106 ep15Bi res 4 ; Endpoint #15 BD In
- 00107 #endif
- 00108
- 00109
- 00110 ; General RAM (in bank 4)
- 000410 00111 usb_temp res 2 ; Temporary storage
- 000412 00112 pSrc res 2 ; Source pointer
- 000414 00113 pDst res 2 ; Destination pointer
- 00114
- 00115 ; (See usbctrltrf.c)
- 000416 00116 ctrl_trf_state res 1 ; Control Transfer State
- 000417 00117 ctrl_trf_session_owner res 1 ; Current transfer session owner
- 000418 00118 wCount res 2 ; Data counter
- 00119
- 00120 ; (See usbmmap.c)
- 00041A 00121 usb_device_state res 1 ; Device States: DETACHED, ATTACHED, ...
- 00041B 00122 usb_active_cfg res 1 ; Value of current configuration
- 00041C 00123 usb_alt_intf res MAX_NUM_INT ; Array to keep track of the current alternate setting for each
- interface ID
- 00041D 00124 usb_stat res 1
- 00125
- 00126 ; usb_stat bit aliases
- 00127 #define RemoteWakeup 0 ; [0]Disabled [1]Enabled
- 00128 #define ctrl_trf_mem 1 ; [0]RAM [1]ROM
- 00129 #define cdc_mem_type 2 ; [0]RAM [1]ROM
- 00130
- 00131 ; Endpoint 0 buffers
- 00041E 00132 SetupPkt res EP0_BUFF_SIZE ; (See usbmmap.c & usbdefs_ep0_buff.h - CTRL_TRF_SETUP)
- 00045E 00133 CtrlTrfData res EP0_BUFF_SIZE ; (See usbmmap.c & usbdefs_ep0_buff.h - CTRL_TRF_DATA)
- 00134
- 00135 ; SetupPkt Byte and Bit Aliases
- 00136 #define bmRequestType 0
- 00137 #define bRequest 1
- 00138 #define wValue 2
- 00139 #define wIndex 4
- 00140 #define wLength 6
- 00141
- 00142 #define Recipient 0 ; Device,Interface,Endpoint,Other (5 bits)
- 00143 #define RequestType 5 ; Standard,Class,Vendor,Reserved (2 bits)
- 00144 #define DataDir 7 ; Host-to-device,Device-to-host
- 00145 #define bFeature 2 ; DEVICE_REMOTE_WAKEUP,ENDPOINT_HALT
- 00146
- 00147 #define bReportID 2 ; In a SET_REPORT or GET_REPORT request
- 00148 #define bReportType 3 ; In a SET_REPORT or GET_REPORT request
- 00149
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 24
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00150 #define bDscIndex 2 ; For Configuration and String DSC Only
- 00151 #define bDscType 3 ; Device,Configuration,String
- 00152 #define wLangID 4 ; Language ID
- 00153
- 00154 #define bDevADR 2 ; Device Address 0-127
- 00155 #define bDevADRH 3 ; Must equal zero
- 00156
- 00157 #define bCfgValue 2 ; Configuration Value 0-255
- 00158 #define bCfgRSD 3 ; Must equal zero (Reserved)
- 00159
- 00160 #define bAltID 2 ; Alternate Setting Value 0-255
- 00161 #define bAltID_H 3 ; Must equal zero (Reserved)
- 00162 #define bIntfID 4 ; Interface Number Value 0-255
- 00163 #define bIntfID_H 5 ; Must equal zero
- 00164
- 00165 #define bEPID 4 ; Endpoint ID (Number & Direction)
- 00166 #define bEPID_H 5 ; Must equal zero
- 00167
- 00168 #define EPNum 0 ; Endpoint Number 0-15 (4 bits)
- 00169 #define EPDir 7 ; Endpoint Direction: 0-OUT, 1-IN
- 00170
- 00171
- 00172 ; HID RAM (in bank 4)
- 00173
- 00174 #ifdef USB_USE_HID
- 00049E 00175 idle_rate res 1
- 00049F 00176 active_protocol res 1 ; [0] Boot Protocol [1] Report Protocol
- 00177 #endif
- 00178
- 00179
- 00180 ; CDC RAM (in bank 4)
- 00181
- 00182 #ifdef USB_USE_CDC ; (See usbmmap.c & usbmmap.h)
- 00183 line_coding res LINE_CODING_LENGTH
- 00184 control_signal_bitmap res 1
- 00185 dummy_encapsulated_cmd_response res dummy_length
- 00186
- 00187 ; line_coding Byte and Bit Aliases
- 00188 #define dwDTERate 0 ; Complex data structure
- 00189 #define bCharFormat 4
- 00190 #define bParityType 5
- 00191 #define bDataBits 6
- 00192
- 00193 ; control_signal_bitmap Byte and Bit Aliases
- 00194 #define DTE_PRESENT 0 ; [0] Not Present [1] Present
- 00195 #define CARRIER_CONTROL 1 ; [0] Deactivate [1] Activate
- 00196 #endif
- 00197
- 00198
- 00199 ; All previous RAM must be in bank 4
- 00200 ; The following buffers may be in any dual-port RAM bank
- 00201
- 00202 ; HID Buffer RAM
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 25
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00203
- 00204 #ifdef USB_USE_HID
- 0004A0 00205 hid_report_out res HID_INT_OUT_EP_SIZE + 1 ; (See usbmmap.c & usbmmap.h)
- 0004E1 00206 hid_report_in res HID_INT_IN_EP_SIZE + 1 ; +1 for size at front
- 00207 #endif
- 00208
- 00209
- 00210 ; CDC Buffer RAM
- 00211
- 00212 #ifdef USB_USE_CDC ; (See usbmmap.c & usbmmap.h)
- 00213 cdc_notice res CDC_INT_EP_SIZE + 1 ; +1 for size at front
- 00214 cdc_data_rx res CDC_BULK_OUT_EP_SIZE + 1 ; +1 for size at front
- 00215 cdc_data_tx res CDC_BULK_IN_EP_SIZE + 1 ; +1 for size at front
- 00216 #endif
- 00217
- 00218
- 0002EC 00219 org SavedOrg ; Restore previous org
- 00016 include "USB18.ASM"
- 00001 ; USB18.ASM
- 00002
- 00003 ; Put Address into source pointer
- 00004 mSetSourcePointer macro Address
- 00005 movlw low (Address)
- 00006 movwf pSrc
- 00007 movlw high (Address)
- 00008 movwf pSrc + 1
- 00009 endm
- 00010
- 00011 ; Put Address into destination pointer
- 00012 mSetDestinationPointer macro Address
- 00013 movlw low (Address)
- 00014 movwf pDst
- 00015 movlw high (Address)
- 00016 movwf pDst + 1
- 00017 endm
- 00018
- 00019 ; Get count from first location of ROM table pointed to by pSrc
- 00020 mGetRomTableCount macro
- 00021 movff pSrc, TBLPTRL ; Set source address
- 00022 movff pSrc + 1, TBLPTRH
- 00023 clrf TBLPTRU
- 00024 tblrd * ; Read count
- 00025 movff TABLAT, wCount
- 00026 clrf wCount + 1
- 00027 endm
- 00028
- 00029
- 00030 ; From usb9.c line 70
- 00031 ;/******************************************************************************
- 00032 ; * Function: void USBCheckStdRequest(void)
- 00033 ; *
- 00034 ; * PreCondition: None
- 00035 ; *
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 26
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00036 ; * Input: None
- 00037 ; *
- 00038 ; * Output: None
- 00039 ; *
- 00040 ; * Side Effects: None
- 00041 ; *
- 00042 ; * Overview: This routine checks the setup data packet to see if it
- 00043 ; * knows how to handle it
- 00044 ; *
- 00045 ; * Note: None
- 00046 ; *****************************************************************************/
- 0002EC 00047 USBCheckStdRequest
- 0002EC 0104 00048 movlb high 0x400 ; Point to proper bank
- 0002EE 511E 00049 movf SetupPkt, W ; RequestType = STANDARD?
- 0002F0 0B60 00050 andlw 0x60 ; Mask to proper bits
- 0002F2 0800 00051 sublw (STANDARD) << 5
- 0002F4 E13E 00052 bnz USBCheckStdRequestExit ; No
- 0002F6 0E05 00053 movlw SET_ADR ; Handle request
- 0002F8 631F 00054 cpfseq SetupPkt + bRequest
- 0002FA D003 00055 bra USBCheckStdRequest1
- 0002FC 0E04 00056 movlw ADR_PENDING_STATE
- 0002FE 6F1A 00057 movwf usb_device_state
- 000300 D036 00058 bra USBStdSetSessionOwnerUSB9
- 00059
- 00060 ; GET_DESCRIPTOR request?
- 000302 00061 USBCheckStdRequest1
- 000302 0E06 00062 movlw GET_DSC
- 000304 631F 00063 cpfseq SetupPkt + bRequest
- 000306 D001 00064 bra USBCheckStdRequest2
- 000308 D035 00065 bra USBStdGetDscHandler
- 00066
- 00067 ; GET_CONFIGURATION request?
- 00030A 00068 USBCheckStdRequest2
- 00030A 0E08 00069 movlw GET_CFG
- 00030C 631F 00070 cpfseq SetupPkt + bRequest
- 00030E D009 00071 bra USBCheckStdRequest3
- 00072 mSetSourcePointer usb_active_cfg
- 000310 0E1B M movlw low (usb_active_cfg)
- 000312 6F12 M movwf pSrc
- 000314 0E04 M movlw high (usb_active_cfg)
- 000316 6F13 M movwf pSrc + 1
- 000318 0E01 00073 movlw 1
- 00031A 6F18 00074 movwf wCount
- 00031C 6B19 00075 clrf wCount + 1
- 00031E 931D 00076 bcf usb_stat, ctrl_trf_mem ; Indicate RAM
- 000320 D026 00077 bra USBStdSetSessionOwnerUSB9
- 00078
- 00079 ; SET_CONFIGURATION request?
- 000322 00080 USBCheckStdRequest3
- 000322 0E09 00081 movlw SET_CFG
- 000324 631F 00082 cpfseq SetupPkt + bRequest
- 000326 D001 00083 bra USBCheckStdRequest4
- 000328 D06A 00084 bra USBStdSetCfgHandler
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 27
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00085
- 00086 ; GET_STATUS request?
- 00032A 00087 USBCheckStdRequest4
- 00032A 0E00 00088 movlw GET_STATUS
- 00032C 631F 00089 cpfseq SetupPkt + bRequest
- 00032E D001 00090 bra USBCheckStdRequest5
- 000330 D07E 00091 bra USBStdGetStatusHandler
- 00092
- 00093 ; CLEAR_FEATURE request?
- 000332 00094 USBCheckStdRequest5
- 000332 0E01 00095 movlw CLR_FEATURE
- 000334 631F 00096 cpfseq SetupPkt + bRequest
- 000336 D001 00097 bra USBCheckStdRequest6
- 000338 D09F 00098 bra USBStdFeatureReqHandler
- 00099
- 00100 ; SET_FEATURE request?
- 00033A 00101 USBCheckStdRequest6
- 00033A 0E03 00102 movlw SET_FEATURE
- 00033C 631F 00103 cpfseq SetupPkt + bRequest
- 00033E D001 00104 bra USBCheckStdRequest7
- 000340 D09B 00105 bra USBStdFeatureReqHandler
- 00106
- 00107 ; GET_INTERFACE request?
- 000342 00108 USBCheckStdRequest7
- 000342 0E0A 00109 movlw GET_INTF
- 000344 631F 00110 cpfseq SetupPkt + bRequest
- 000346 D00B 00111 bra USBCheckStdRequest8
- 00112 mSetSourcePointer usb_alt_intf
- 000348 0E1C M movlw low (usb_alt_intf)
- 00034A 6F12 M movwf pSrc
- 00034C 0E04 M movlw high (usb_alt_intf)
- 00034E 6F13 M movwf pSrc + 1
- 000350 5122 00113 movf SetupPkt + bIntfID, W
- 000352 2712 00114 addwf pSrc, F
- 000354 0E01 00115 movlw 1
- 000356 6F18 00116 movwf wCount
- 000358 6B19 00117 clrf wCount + 1
- 00035A 931D 00118 bcf usb_stat, ctrl_trf_mem ; Indicate RAM
- 00035C D008 00119 bra USBStdSetSessionOwnerUSB9
- 00120
- 00121 ; SET_INTERFACE request?
- 00035E 00122 USBCheckStdRequest8
- 00035E 0E0B 00123 movlw SET_INTF
- 000360 631F 00124 cpfseq SetupPkt + bRequest
- 000362 0012 00125 return
- 000364 EE24 F01C 00126 lfsr 2, usb_alt_intf
- 000368 5122 00127 movf SetupPkt + bIntfID, W
- 00036A C420 FFDB 00128 movff SetupPkt + bAltID, PLUSW2
- 00129 ; Branch here after decoding one of the above USB standard requests.
- 00130 ; Assign a value to ctrl_trf_session_owner, to prevent stalling
- 00036E 00131 USBStdSetSessionOwnerUSB9
- 00036E 0E01 00132 movlw MUID_USB9
- 000370 6F17 00133 movwf ctrl_trf_session_owner
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 28
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 000372 00134 USBCheckStdRequestExit
- 000372 0012 00135 return
- 00136
- 00137 ; From usb9.c line 136
- 00138 ;/******************************************************************************
- 00139 ; * Function: void USBStdGetDscHandler(void)
- 00140 ; *
- 00141 ; * PreCondition: None
- 00142 ; *
- 00143 ; * Input: None
- 00144 ; *
- 00145 ; * Output: None
- 00146 ; *
- 00147 ; * Side Effects: None
- 00148 ; *
- 00149 ; * Overview: This routine handles the standard GET_DESCRIPTOR request.
- 00150 ; * It utilizes tables dynamically looks up descriptor size.
- 00151 ; * This routine should never have to be modified if the tables
- 00152 ; * in usbdsc.c are declared correctly.
- 00153 ; *
- 00154 ; * Note: None
- 00155 ; *****************************************************************************/
- 000374 00156 USBStdGetDscHandler
- 00157 ; movlb high 0x400 ; Point to proper bank
- 000374 0E80 00158 movlw 0x80
- 000376 631E 00159 cpfseq SetupPkt + bmRequestType
- 000378 0012 00160 return
- 00037A 0E01 00161 movlw DSC_DEV
- 00037C 6321 00162 cpfseq SetupPkt + bDscType
- 00037E D00F 00163 bra USBStdGetDscHandler1
- 00164 mSetSourcePointer DeviceDescriptor
- 000380 0EB2 M movlw low (DeviceDescriptor)
- 000382 6F12 M movwf pSrc
- 000384 0E01 M movlw high (DeviceDescriptor)
- 000386 6F13 M movwf pSrc + 1
- 00165 mGetRomTableCount ; Set wCount
- 000388 C412 FFF6 M movff pSrc, TBLPTRL ; Set source address
- 00038C C413 FFF7 M movff pSrc + 1, TBLPTRH
- 000390 6AF8 M clrf TBLPTRU
- 000392 0008 M tblrd * ; Read count
- 000394 CFF5 F418 M movff TABLAT, wCount
- 000398 6B19 M clrf wCount + 1
- 00039A 831D 00166 bsf usb_stat, ctrl_trf_mem ; Indicate ROM
- 00039C D7E8 00167 bra USBStdSetSessionOwnerUSB9
- 00039E 00168 USBStdGetDscHandler1
- 00039E 0E02 00169 movlw DSC_CFG
- 0003A0 6321 00170 cpfseq SetupPkt + bDscType
- 0003A2 D012 00171 bra USBStdGetDscHandler2
- 00172 mSetSourcePointer Config1
- 0003A4 0EDA M movlw low (Config1)
- 0003A6 6F12 M movwf pSrc
- 0003A8 0E01 M movlw high (Config1)
- 0003AA 6F13 M movwf pSrc + 1
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 29
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0003AC 0EDE 00173 movlw low Config1Len ; Set wCount to total length
- 0003AE 6EF6 00174 movwf TBLPTRL
- 0003B0 0E01 00175 movlw high Config1Len
- 0003B2 6EF7 00176 movwf TBLPTRH
- 0003B4 6AF8 00177 clrf TBLPTRU
- 0003B6 0009 00178 tblrd *+ ; Read count low
- 0003B8 CFF5 F418 00179 movff TABLAT, wCount
- 0003BC 0009 00180 tblrd *+ ; Ignore RETLW opcode
- 0003BE 0009 00181 tblrd *+ ; Read count high
- 0003C0 CFF5 F419 00182 movff TABLAT, wCount + 1
- 0003C4 831D 00183 bsf usb_stat, ctrl_trf_mem ; Indicate ROM
- 0003C6 D7D3 00184 bra USBStdSetSessionOwnerUSB9
- 0003C8 00185 USBStdGetDscHandler2
- 0003C8 0E03 00186 movlw DSC_STR
- 0003CA 6321 00187 cpfseq SetupPkt + bDscType
- 0003CC 0012 00188 return
- 0003CE 6AF8 00189 clrf TBLPTRU
- 0003D0 6AF7 00190 clrf TBLPTRH
- 0003D2 4520 00191 rlncf SetupPkt + bDscIndex, W ; Index * 2
- 0003D4 0F7C 00192 addlw low (USB_SD_Ptr) ; Add element offset to low address
- 0003D6 6EF6 00193 movwf TBLPTRL
- 0003D8 0E02 00194 movlw high (USB_SD_Ptr)
- 0003DA 22F7 00195 addwfc TBLPTRH, F
- 0003DC 0009 00196 tblrd *+ ; Get the data to TABLAT and move pointer forward
- 0003DE CFF5 F412 00197 movff TABLAT, pSrc ; Get low source address
- 0003E2 0008 00198 tblrd *
- 0003E4 CFF5 F413 00199 movff TABLAT, pSrc + 1 ; Get high source address
- 00200 mGetRomTableCount ; Set wCount
- 0003E8 C412 FFF6 M movff pSrc, TBLPTRL ; Set source address
- 0003EC C413 FFF7 M movff pSrc + 1, TBLPTRH
- 0003F0 6AF8 M clrf TBLPTRU
- 0003F2 0008 M tblrd * ; Read count
- 0003F4 CFF5 F418 M movff TABLAT, wCount
- 0003F8 6B19 M clrf wCount + 1
- 0003FA 831D 00201 bsf usb_stat, ctrl_trf_mem ; Indicate ROM
- 0003FC D7B8 00202 bra USBStdSetSessionOwnerUSB9
- 00203
- 00204
- 00205 ; From usb9.c line 180
- 00206 ;/******************************************************************************
- 00207 ; * Function: void USBStdSetCfgHandler(void)
- 00208 ; *
- 00209 ; * PreCondition: None
- 00210 ; *
- 00211 ; * Input: None
- 00212 ; *
- 00213 ; * Output: None
- 00214 ; *
- 00215 ; * Side Effects: None
- 00216 ; *
- 00217 ; * Overview: This routine first disables all endpoints by clearing
- 00218 ; * UEP registers. It then configures (initializes) endpoints
- 00219 ; * specified in the modifiable section.
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 30
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00220 ; *
- 00221 ; * Note: None
- 00222 ; *****************************************************************************/
- 0003FE 00223 USBStdSetCfgHandler
- 00224 ; movlb high 0x400 ; Point to proper bank
- 0003FE 0E01 00225 movlw MUID_USB9
- 000400 6F17 00226 movwf ctrl_trf_session_owner
- 000402 EE2F F071 00227 lfsr 2, UEP1 ; Reset all non-EP0 UEPn registers
- 000406 0E0F 00228 movlw 15
- 000408 00229 USBStdSetCfgHandlerClearEPLoop
- 000408 6ADE 00230 clrf POSTINC2
- 00040A 2EE8 00231 decfsz WREG, F
- 00040C D7FD 00232 bra USBStdSetCfgHandlerClearEPLoop
- 00040E EE24 F01C 00233 lfsr 2, usb_alt_intf ; Clear usb_alt_intf array
- 000412 0E01 00234 movlw MAX_NUM_INT
- 000414 00235 USBStdSetCfgHandlerClearAltLoop
- 000414 6ADE 00236 clrf POSTINC2
- 000416 2EE8 00237 decfsz WREG, F
- 000418 D7FD 00238 bra USBStdSetCfgHandlerClearAltLoop
- 00041A 5120 00239 movf SetupPkt + bCfgValue, W
- 00041C 6F1B 00240 movwf usb_active_cfg
- 00041E E103 00241 bnz USBStdSetCfgHandler1
- 000420 0E05 00242 movlw ADDRESS_STATE ; SetupPkt + bCfgValue = 0
- 000422 6F1A 00243 movwf usb_device_state
- 000424 0012 00244 return
- 000426 00245 USBStdSetCfgHandler1
- 000426 0E06 00246 movlw CONFIGURED_STATE
- 000428 6F1A 00247 movwf usb_device_state
- 00248 #ifdef USB_USE_HID
- 00042A DA08 00249 rcall HIDInitEP
- 00250 #endif
- 00251 #ifdef USB_USE_CDC
- 00252 rcall CDCInitEP
- 00253 #endif
- 00042C 0012 00254 return
- 00255
- 00256
- 00257 ; From usb9.c line 224
- 00258 ;/******************************************************************************
- 00259 ; * Function: void USBStdGetStatusHandler(void)
- 00260 ; *
- 00261 ; * PreCondition: None
- 00262 ; *
- 00263 ; * Input: None
- 00264 ; *
- 00265 ; * Output: None
- 00266 ; *
- 00267 ; * Side Effects: None
- 00268 ; *
- 00269 ; * Overview: This routine handles the standard GET_STATUS request
- 00270 ; *
- 00271 ; * Note: None
- 00272 ; *****************************************************************************/
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 31
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00042E 00273 USBStdGetStatusHandler
- 00274 ; movlb high 0x400 ; Point to proper bank
- 00042E 6B5E 00275 clrf CtrlTrfData ; Initialize content
- 000430 6B5F 00276 clrf CtrlTrfData + 1
- 000432 511E 00277 movf SetupPkt, W ; Recipient = RCPT_DEV?
- 000434 0B1F 00278 andlw 0x1f ; Mask to lower 5 bits
- 000436 0800 00279 sublw RCPT_DEV
- 000438 E103 00280 bnz USBStdGetStatusHandler1 ; No
- 00281 ;
- 00282 ; Recipient of this Setup packet was "Device": set bits to indicate power & remote wakeup
- 00283 ; Decoding of "Self-powered" & "Remote Wakeup"
- 00284 ; _byte0: bit0: Self-Powered Status [0] Bus-Powered [1] Self-Powered
- 00285 ; bit1: RemoteWakeup [0] Disabled [1] Enabled
- 00286 ;
- 00287 #ifdef USB_SELF_POWER
- 00288 bsf CtrlTrfData, 0
- 00289 #endif
- 00043A B11D 00290 btfsc usb_stat, RemoteWakeup
- 00043C 835E 00291 bsf CtrlTrfData, 1
- 00043E D00E 00292 bra USBStdGetStatusSetSessionOwner
- 00293 ;
- 000440 00294 USBStdGetStatusHandler1
- 000440 511E 00295 movf SetupPkt, W ; Recipient = RCPT_INTF?
- 000442 0B1F 00296 andlw 0x1f ; Mask to lower 5 bits
- 000444 0801 00297 sublw RCPT_INTF
- 000446 E101 00298 bnz USBStdGetStatusHandler2 ; No
- 00299 ;
- 00300 ; Recipient of this Setup packet was "Interface": No data to update
- 000448 D009 00301 bra USBStdGetStatusSetSessionOwner
- 00302 ;
- 00044A 00303 USBStdGetStatusHandler2
- 00044A 511E 00304 movf SetupPkt, W ; Recipient = RCPT_EP?
- 00044C 0B1F 00305 andlw 0x1f ; Mask to lower 5 bits
- 00044E 0802 00306 sublw RCPT_EP
- 000450 E107 00307 bnz USBStdGetStatusHandler3 ; No
- 00308 ;
- 00309 ; Recipient of this Setup packet was "Endpoint"
- 000452 D834 00310 rcall USBCalcEPAddress ; Put endpoint buffer address in FSR2
- 000454 50DF 00311 movf INDF2, W
- 000456 0B04 00312 andlw _BSTALL
- 000458 E001 00313 bz USBStdGetStatusSetSessionOwner
- 00045A 815E 00314 bsf CtrlTrfData, 0
- 00045C 00315 USBStdGetStatusSetSessionOwner
- 00045C 0E01 00316 movlw MUID_USB9
- 00045E 6F17 00317 movwf ctrl_trf_session_owner
- 000460 00318 USBStdGetStatusHandler3
- 000460 0E01 00319 movlw MUID_USB9
- 000462 6317 00320 cpfseq ctrl_trf_session_owner
- 000464 0012 00321 return
- 00322 mSetSourcePointer CtrlTrfData
- 000466 0E5E M movlw low (CtrlTrfData)
- 000468 6F12 M movwf pSrc
- 00046A 0E04 M movlw high (CtrlTrfData)
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 32
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00046C 6F13 M movwf pSrc + 1
- 00046E 0E02 00323 movlw 2 ; Set count
- 000470 6F18 00324 movwf wCount
- 000472 6B19 00325 clrf wCount + 1
- 000474 931D 00326 bcf usb_stat, ctrl_trf_mem ; Indicate RAM
- 000476 0012 00327 return
- 00328
- 00329 ; From usb9.c line 281
- 00330 ;/******************************************************************************
- 00331 ; * Function: void USBStdFeatureReqHandler(void)
- 00332 ; *
- 00333 ; * PreCondition: None
- 00334 ; *
- 00335 ; * Input: None
- 00336 ; *
- 00337 ; * Output: None
- 00338 ; *
- 00339 ; * Side Effects: None
- 00340 ; *
- 00341 ; * Overview: This routine handles the standard SET & CLEAR FEATURES
- 00342 ; * requests
- 00343 ; *
- 00344 ; * Note: None
- 00345 ; *****************************************************************************/
- 000478 00346 USBStdFeatureReqHandler
- 00347 ; movlb high 0x400 ; Point to proper bank
- 000478 0E01 00348 movlw DEVICE_REMOTE_WAKEUP ; If Feature = DEVICE_REMOTE_WAKEUP &
- 00047A 6320 00349 cpfseq SetupPkt + bFeature
- 00047C D009 00350 bra USBStdFeatureReqHandler1
- 00047E 511E 00351 movf SetupPkt, W ; Recipient = RCPT_DEV?
- 000480 0B1F 00352 andlw 0x1f ; Mask to lower 5 bits
- 000482 0800 00353 sublw RCPT_DEV
- 000484 E105 00354 bnz USBStdFeatureReqHandler1 ; No
- 000486 811D 00355 bsf usb_stat, RemoteWakeup ; Preset RemoteWakeup to 1
- 000488 0E03 00356 movlw SET_FEATURE ; Request = SET_FEATURE?
- 00048A 631F 00357 cpfseq SetupPkt + bRequest
- 00048C 911D 00358 bcf usb_stat, RemoteWakeup ; No, RemoteWakeup = 0
- 00048E D76F 00359 bra USBStdSetSessionOwnerUSB9
- 000490 00360 USBStdFeatureReqHandler1
- 000490 0E00 00361 movlw ENDPOINT_HALT ; If Feature = ENDPOINT_HALT &
- 000492 6320 00362 cpfseq SetupPkt + bFeature
- 000494 00363 USBStdFeatureReqHandlerExit
- 000494 0012 00364 return
- 000496 511E 00365 movf SetupPkt, W ; Recepient = RCPT_EP &
- 000498 0B1F 00366 andlw 0x1f ; Mask to lower 5 bits
- 00049A 0802 00367 sublw RCPT_EP
- 00049C E1FB 00368 bnz USBStdFeatureReqHandlerExit
- 00049E 5122 00369 movf SetupPkt + bEPID, W ; EPNum != 0
- 0004A0 0B0F 00370 andlw 0x0f ; Mask to EPNum
- 0004A2 E0F8 00371 bz USBStdFeatureReqHandlerExit
- 0004A4 D80B 00372 rcall USBCalcEPAddress ; Put endpoint buffer address in FSR2
- 0004A6 0E03 00373 movlw SET_FEATURE ; Request = SET_FEATURE?
- 0004A8 631F 00374 cpfseq SetupPkt + bRequest
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 33
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0004AA D003 00375 bra USBStdFeatureReqHandler2 ; No
- 0004AC 0E84 00376 movlw _USIE|_BSTALL
- 0004AE 6EDF 00377 movwf INDF2 ; Put in endpoint buffer
- 0004B0 D75E 00378 bra USBStdSetSessionOwnerUSB9
- 0004B2 00379 USBStdFeatureReqHandler2
- 0004B2 0E00 00380 movlw _UCPU ; IN
- 0004B4 AF22 00381 btfss SetupPkt + bEPID, EPDir ; EPDir = 1 (IN)?
- 0004B6 0E88 00382 movlw _USIE|_DAT0|_DTSEN ; No - OUT
- 0004B8 6EDF 00383 movwf INDF2 ; Put in endpoint buffer
- 0004BA D759 00384 bra USBStdSetSessionOwnerUSB9
- 00385
- 00386
- 00387 ; Put endpoint buffer address in FSR2 (ep0Bo+(EPNum*8)+(EPDir*4))
- 0004BC 00388 USBCalcEPAddress
- 0004BC EE24 F000 00389 lfsr 2, ep0Bo ; Point FSR2 to beginning of buffer area
- 0004C0 4522 00390 rlncf SetupPkt + bEPID, W ; Move endpoint direction to C
- 0004C2 3522 00391 rlcf SetupPkt + bEPID, W ; Endpoint number * 8 (roll in ep direction)
- 0004C4 46E8 00392 rlncf WREG, F
- 0004C6 46E8 00393 rlncf WREG, F
- 0004C8 26D9 00394 addwf FSR2L, F ; Add to FSR2 (can't overflow to FSR2H)
- 0004CA 0012 00395 return
- 00396
- 00397
- 00398
- 00399 ; From usbctrltrf.c line 78
- 00400 ;/******************************************************************************
- 00401 ; * Function: void USBCtrlEPService(void)
- 00402 ; *
- 00403 ; * PreCondition: USTAT is loaded with a valid endpoint address.
- 00404 ; *
- 00405 ; * Input: None
- 00406 ; *
- 00407 ; * Output: None
- 00408 ; *
- 00409 ; * Side Effects: None
- 00410 ; *
- 00411 ; * Overview: USBCtrlEPService checks for three transaction types that
- 00412 ; * it knows how to service and services them:
- 00413 ; * 1. EP0 SETUP
- 00414 ; * 2. EP0 OUT
- 00415 ; * 3. EP0 IN
- 00416 ; * It ignores all other types (i.e. EP1, EP2, etc.)
- 00417 ; *
- 00418 ; * Note: None
- 00419 ; *****************************************************************************/
- 0004CC 00420 USBCtrlEPService
- 00421 ; movlb high 0x400 ; Point to proper bank
- 0004CC 0E00 00422 movlw EP00_OUT
- 0004CE 626C 00423 cpfseq USTAT
- 0004D0 D005 00424 bra USBCtrlEPService1
- 0004D2 5100 00425 movf ep0Bo + Stat, W
- 0004D4 0B3C 00426 andlw 0x3c ; Mask to PID
- 0004D6 0834 00427 sublw (SETUP_TOKEN) << 2
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 34
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0004D8 E005 00428 bz USBCtrlTrfSetupHandler
- 0004DA D010 00429 bra USBCtrlTrfOutHandler
- 0004DC 00430 USBCtrlEPService1
- 0004DC 0E04 00431 movlw EP00_IN
- 0004DE 626C 00432 cpfseq USTAT
- 0004E0 0012 00433 return
- 0004E2 D015 00434 bra USBCtrlTrfInHandler
- 00435
- 00436
- 00437 ; From usbctrltrf.c line 133
- 00438 ;/******************************************************************************
- 00439 ; * Function: void USBCtrlTrfSetupHandler(void)
- 00440 ; *
- 00441 ; * PreCondition: SetupPkt buffer is loaded with valid USB Setup Data
- 00442 ; *
- 00443 ; * Input: None
- 00444 ; *
- 00445 ; * Output: None
- 00446 ; *
- 00447 ; * Side Effects: None
- 00448 ; *
- 00449 ; * Overview: This routine is a task dispatcher and has 3 stages.
- 00450 ; * 1. It initializes the control transfer state machine.
- 00451 ; * 2. It calls on each of the module that may know how to
- 00452 ; * service the Setup Request from the host.
- 00453 ; * Module Example: USB9, HID, CDC, MSD, ...
- 00454 ; * As new classes are added, ClassReqHandler table in
- 00455 ; * usbdsc.c should be updated to call all available
- 00456 ; * class handlers.
- 00457 ; * 3. Once each of the modules has had a chance to check if
- 00458 ; * it is responsible for servicing the request, stage 3
- 00459 ; * then checks direction of the transfer to determine how
- 00460 ; * to prepare EP0 for the control transfer.
- 00461 ; * Refer to USBCtrlEPServiceComplete() for more details.
- 00462 ; *
- 00463 ; * Note: Microchip USB Firmware has three different states for
- 00464 ; * the control transfer state machine:
- 00465 ; * 1. WAIT_SETUP
- 00466 ; * 2. CTRL_TRF_TX
- 00467 ; * 3. CTRL_TRF_RX
- 00468 ; * Refer to firmware manual to find out how one state
- 00469 ; * is transitioned to another.
- 00470 ; *
- 00471 ; * A Control Transfer is composed of many USB transactions.
- 00472 ; * When transferring data over multiple transactions,
- 00473 ; * it is important to keep track of data source, data
- 00474 ; * destination, and data count. These three parameters are
- 00475 ; * stored in pSrc,pDst, and wCount. A flag is used to
- 00476 ; * note if the data source is from ROM or RAM.
- 00477 ; *
- 00478 ; *****************************************************************************/
- 0004E4 00479 USBCtrlTrfSetupHandler
- 00480 ; movlb high 0x400 ; Point to proper bank
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 35
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 0004E4 0E00 00481 movlw WAIT_SETUP
- 0004E6 6F16 00482 movwf ctrl_trf_state
- 0004E8 0E00 00483 movlw MUID_NULL ; Set owner to NULL
- 0004EA 6F17 00484 movwf ctrl_trf_session_owner
- 0004EC 6B18 00485 clrf wCount
- 0004EE 6B19 00486 clrf wCount + 1
- 0004F0 DEFD 00487 rcall USBCheckStdRequest
- 0004F2 0E00 00488 movlw MUID_NULL
- 0004F4 6317 00489 cpfseq ctrl_trf_session_owner
- 0004F6 D079 00490 bra USBCtrlEPServiceComplete
- 00491 #ifdef USB_USE_HID
- 0004F8 D945 00492 rcall USBCheckHIDRequest
- 00493 #endif ; USB_USE_HID
- 00494 #ifdef USB_USE_CDC
- 00495 rcall USBCheckCDCRequest
- 00496 #endif ; USB_USE_CDC
- 0004FA D077 00497 bra USBCtrlEPServiceComplete
- 00498
- 00499
- 00500 ; From usbctrltrf.c line 176
- 00501 ;/******************************************************************************
- 00502 ; * Function: void USBCtrlTrfOutHandler(void)
- 00503 ; *
- 00504 ; * PreCondition: None
- 00505 ; *
- 00506 ; * Input: None
- 00507 ; *
- 00508 ; * Output: None
- 00509 ; *
- 00510 ; * Side Effects: None
- 00511 ; *
- 00512 ; * Overview: This routine handles an OUT transaction according to
- 00513 ; * which control transfer state is currently active.
- 00514 ; *
- 00515 ; * Note: Note that if the the control transfer was from
- 00516 ; * host to device, the session owner should be notified
- 00517 ; * at the end of each OUT transaction to service the
- 00518 ; * received data.
- 00519 ; *
- 00520 ; *****************************************************************************/
- 0004FC 00521 USBCtrlTrfOutHandler
- 00522 ; movlb high 0x400 ; Point to proper bank
- 0004FC 0E02 00523 movlw CTRL_TRF_RX
- 0004FE 6316 00524 cpfseq ctrl_trf_state
- 000500 D0AF 00525 bra USBPrepareForNextSetupTrf
- 000502 D857 00526 rcall USBCtrlTrfRxService
- 000504 0EC8 00527 movlw _USIE|_DAT1|_DTSEN
- 000506 BD00 00528 btfsc ep0Bo + Stat, DTS
- 000508 0E88 00529 movlw _USIE|_DAT0|_DTSEN
- 00050A 6F00 00530 movwf ep0Bo + Stat
- 00050C 0012 00531 return
- 00532
- 00533
- MPASM 5.22 USBFM.ASM 1-25-2010 15:59:32 PAGE 36
- LOC OBJECT CODE LINE SOURCE TEXT
- VALUE
- 00534 ; From usbctrltrf.c line 221
- 00535 ;/******************************************************************************
- 00536 ; * Function: void USBCtrlTrfInHandler(void)
- 00537 ; *
- 00538 ; * PreCondition: None
- 00539 ; *
- 00540 ; * Input: None
- 00541 ; *
- 00542 ; * Output: None
- 00543 ; *
- 00544 ; * Side Effects: None
- 00545 ; *
- 00546 ; * Overview: This routine handles an IN transaction according to
- 00547 ; * which control transfer state is currently active.
- 00548 ; *
- 00549 ; *
- 00550 ; * Note: A Set Address Request must not change the acutal address
- 00551 ; * of the device until the completion of the control
- 00552 ; * transfer. The end of the control transfer for Set Address
- 00553 ; * Request is an IN transaction. Therefore it is necessary
- 00554 ; * to service this unique situation when the condition is
- 00555 ; * right. Macro mUSBCheckAdrPendingState is defined in