MP2COD 3.90, COFF to COD File Converter Copyright (c) 2004 Microchip Technology Inc. Listing File Generated: Tue May 24 22:24:37 2005 Address Value Disassembly Source File ------- ------- ----------------------- ------------------------------------------------------------------------------- ----- /* $Id: c018i.c,v 1.3 2004/07/30 17:28:43 ConnerJ Exp $ */ C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c /* Copyright (c)1999 Microchip Technology */ C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c /* MPLAB-C18 startup code, including initialized data */ C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c /* external reference to the user's main routine */ C:\mcc18\src\traditional\startup\c018i.c extern void main (void); C:\mcc18\src\traditional\startup\c018i.c /* prototype for the startup function */ C:\mcc18\src\traditional\startup\c018i.c void _entry (void); C:\mcc18\src\traditional\startup\c018i.c void _startup (void); C:\mcc18\src\traditional\startup\c018i.c /* prototype for the initialized data setup */ C:\mcc18\src\traditional\startup\c018i.c void _do_cinit (void); C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c extern volatile near unsigned long short TBLPTR; C:\mcc18\src\traditional\startup\c018i.c extern near unsigned FSR0; C:\mcc18\src\traditional\startup\c018i.c extern near char FPFLAGS; C:\mcc18\src\traditional\startup\c018i.c #define RND 6 C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c #pragma code _entry_scn=0x000000 C:\mcc18\src\traditional\startup\c018i.c void C:\mcc18\src\traditional\startup\c018i.c _entry (void) C:\mcc18\src\traditional\startup\c018i.c { C:\mcc18\src\traditional\startup\c018i.c 000000 ef1f GOTO 0xc3e _asm goto _startup _endasm C:\mcc18\src\traditional\startup\c018i.c 000002 f006 C:\mcc18\src\traditional\startup\c018i.c 000004 0012 RETURN 0x0 } C:\mcc18\src\traditional\startup\c018i.c #pragma code _startup_scn C:\mcc18\src\traditional\startup\c018i.c void C:\mcc18\src\traditional\startup\c018i.c _startup (void) C:\mcc18\src\traditional\startup\c018i.c { C:\mcc18\src\traditional\startup\c018i.c _asm C:\mcc18\src\traditional\startup\c018i.c // Initialize the stack pointer C:\mcc18\src\traditional\startup\c018i.c 000c3e ee13 LFSR 0x1,0x300 lfsr 1, _stack C:\mcc18\src\traditional\startup\c018i.c 000c40 f000 000c42 ee23 LFSR 0x2,0x300 lfsr 2, _stack C:\mcc18\src\traditional\startup\c018i.c 000c44 f000 C:\mcc18\src\traditional\startup\c018i.c 000c46 6af8 CLRF 0xf8,0x0 clrf TBLPTRU, 0 // 1st silicon doesn't do this on POR C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c 000c48 9c01 BCF 0x1,0x6,0x0 bcf FPFLAGS,RND,0 // Initialize rounding flag for floating point libs C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c _endasm C:\mcc18\src\traditional\startup\c018i.c 000c4a ecb5 CALL 0xb6a,0x0 _do_cinit (); C:\mcc18\src\traditional\startup\c018i.c 000c4c f005 C:\mcc18\src\traditional\startup\c018i.c loop: C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c // Call the user's main routine C:\mcc18\src\traditional\startup\c018i.c 000c4e ec04 CALL 0xc08,0x0 main (); C:\mcc18\src\traditional\startup\c018i.c 000c50 f006 C:\mcc18\src\traditional\startup\c018i.c 000c52 d7fd BRA 0xc4e goto loop; C:\mcc18\src\traditional\startup\c018i.c 000c54 0012 RETURN 0x0 } /* end _startup() */ C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c /* MPLAB-C18 initialized data memory support */ C:\mcc18\src\traditional\startup\c018i.c /* The linker will populate the _cinit table */ C:\mcc18\src\traditional\startup\c018i.c extern far rom struct C:\mcc18\src\traditional\startup\c018i.c { C:\mcc18\src\traditional\startup\c018i.c unsigned short num_init; C:\mcc18\src\traditional\startup\c018i.c struct _init_entry C:\mcc18\src\traditional\startup\c018i.c { C:\mcc18\src\traditional\startup\c018i.c unsigned long from; C:\mcc18\src\traditional\startup\c018i.c unsigned long to; C:\mcc18\src\traditional\startup\c018i.c unsigned long size; C:\mcc18\src\traditional\startup\c018i.c } C:\mcc18\src\traditional\startup\c018i.c entries[]; C:\mcc18\src\traditional\startup\c018i.c } C:\mcc18\src\traditional\startup\c018i.c _cinit; C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c #pragma code _cinit_scn C:\mcc18\src\traditional\startup\c018i.c void C:\mcc18\src\traditional\startup\c018i.c _do_cinit (void) C:\mcc18\src\traditional\startup\c018i.c { C:\mcc18\src\traditional\startup\c018i.c /* we'll make the assumption in the following code that these statics C:\mcc18\src\traditional\startup\c018i.c * will be allocated into the same bank. C:\mcc18\src\traditional\startup\c018i.c */ C:\mcc18\src\traditional\startup\c018i.c static short long prom; C:\mcc18\src\traditional\startup\c018i.c static unsigned short curr_byte; C:\mcc18\src\traditional\startup\c018i.c static unsigned short curr_entry; C:\mcc18\src\traditional\startup\c018i.c static short long data_ptr; C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c // Initialized data... C:\mcc18\src\traditional\startup\c018i.c 000b6a 0e2a MOVLW 0x2a TBLPTR = (short long)&_cinit; C:\mcc18\src\traditional\startup\c018i.c 000b6c 6ef6 MOVWF 0xf6,0x0 000b6e 0e00 MOVLW 0x0 000b70 6ef7 MOVWF 0xf7,0x0 000b72 0e00 MOVLW 0x0 000b74 6ef8 MOVWF 0xf8,0x0 _asm C:\mcc18\src\traditional\startup\c018i.c 000b76 0100 MOVLB 0x0 movlb data_ptr C:\mcc18\src\traditional\startup\c018i.c 000b78 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000b7a 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000b7c 6fc2 MOVWF 0xc2,0x1 movwf curr_entry, 1 C:\mcc18\src\traditional\startup\c018i.c 000b7e 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000b80 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000b82 6fc3 MOVWF 0xc3,0x1 movwf curr_entry+1, 1 C:\mcc18\src\traditional\startup\c018i.c _endasm C:\mcc18\src\traditional\startup\c018i.c //while (curr_entry) C:\mcc18\src\traditional\startup\c018i.c //{ C:\mcc18\src\traditional\startup\c018i.c test: C:\mcc18\src\traditional\startup\c018i.c _asm C:\mcc18\src\traditional\startup\c018i.c 000b84 e103 BNZ 0xb8c bnz 3 C:\mcc18\src\traditional\startup\c018i.c 000b86 67c2 TSTFSZ 0xc2,0x1 tstfsz curr_entry, 1 C:\mcc18\src\traditional\startup\c018i.c 000b88 d001 BRA 0xb8c bra 1 C:\mcc18\src\traditional\startup\c018i.c _endasm C:\mcc18\src\traditional\startup\c018i.c 000b8a d03d BRA 0xc06 goto done; C:\mcc18\src\traditional\startup\c018i.c /* Count down so we only have to look up the data in _cinit C:\mcc18\src\traditional\startup\c018i.c * once. C:\mcc18\src\traditional\startup\c018i.c * C:\mcc18\src\traditional\startup\c018i.c * At this point we know that TBLPTR points to the top of the current C:\mcc18\src\traditional\startup\c018i.c * entry in _cinit, so we can just start reading the from, to, and C:\mcc18\src\traditional\startup\c018i.c * size values. C:\mcc18\src\traditional\startup\c018i.c */ C:\mcc18\src\traditional\startup\c018i.c _asm C:\mcc18\src\traditional\startup\c018i.c /* read the source address */ C:\mcc18\src\traditional\startup\c018i.c 000b8c 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000b8e 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000b90 6fbd MOVWF 0xbd,0x1 movwf prom, 1 C:\mcc18\src\traditional\startup\c018i.c 000b92 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000b94 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000b96 6fbe MOVWF 0xbe,0x1 movwf prom+1, 1 C:\mcc18\src\traditional\startup\c018i.c 000b98 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000b9a 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000b9c 6fbf MOVWF 0xbf,0x1 movwf prom+2, 1 C:\mcc18\src\traditional\startup\c018i.c /* skip a byte since it's stored as a 32bit int */ C:\mcc18\src\traditional\startup\c018i.c 000b9e 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c /* read the destination address directly into FSR0 */ C:\mcc18\src\traditional\startup\c018i.c 000ba0 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000ba2 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000ba4 6ee9 MOVWF 0xe9,0x0 movwf FSR0L, 0 C:\mcc18\src\traditional\startup\c018i.c 000ba6 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000ba8 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000baa 6eea MOVWF 0xea,0x0 movwf FSR0H, 0 C:\mcc18\src\traditional\startup\c018i.c /* skip two bytes since it's stored as a 32bit int */ C:\mcc18\src\traditional\startup\c018i.c 000bac 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000bae 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c /* read the destination address directly into FSR0 */ C:\mcc18\src\traditional\startup\c018i.c 000bb0 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000bb2 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000bb4 6fc0 MOVWF 0xc0,0x1 movwf curr_byte, 1 C:\mcc18\src\traditional\startup\c018i.c 000bb6 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000bb8 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000bba 6fc1 MOVWF 0xc1,0x1 movwf curr_byte+1, 1 C:\mcc18\src\traditional\startup\c018i.c /* skip two bytes since it's stored as a 32bit int */ C:\mcc18\src\traditional\startup\c018i.c 000bbc 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000bbe 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c _endasm C:\mcc18\src\traditional\startup\c018i.c //prom = data_ptr->from; C:\mcc18\src\traditional\startup\c018i.c //FSR0 = data_ptr->to; C:\mcc18\src\traditional\startup\c018i.c //curr_byte = (unsigned short) data_ptr->size; C:\mcc18\src\traditional\startup\c018i.c /* the table pointer now points to the next entry. Save it C:\mcc18\src\traditional\startup\c018i.c * off since we'll be using the table pointer to do the copying C:\mcc18\src\traditional\startup\c018i.c * for the entry. C:\mcc18\src\traditional\startup\c018i.c */ C:\mcc18\src\traditional\startup\c018i.c 000bc0 cff6 MOVFF 0xff6,0xc4 data_ptr = TBLPTR; C:\mcc18\src\traditional\startup\c018i.c 000bc2 f0c4 000bc4 cff7 MOVFF 0xff7,0xc5 000bc6 f0c5 000bc8 cff8 MOVFF 0xff8,0xc6 000bca f0c6 C:\mcc18\src\traditional\startup\c018i.c /* now assign the source address to the table pointer */ C:\mcc18\src\traditional\startup\c018i.c 000bcc c0bd MOVFF 0xbd,0xff6 TBLPTR = prom; C:\mcc18\src\traditional\startup\c018i.c 000bce fff6 000bd0 c0be MOVFF 0xbe,0xff7 000bd2 fff7 000bd4 c0bf MOVFF 0xbf,0xff8 000bd6 fff8 C:\mcc18\src\traditional\startup\c018i.c /* do the copy loop */ C:\mcc18\src\traditional\startup\c018i.c _asm C:\mcc18\src\traditional\startup\c018i.c // determine if we have any more bytes to copy C:\mcc18\src\traditional\startup\c018i.c 000bd8 0100 MOVLB 0x0 movlb curr_byte C:\mcc18\src\traditional\startup\c018i.c 000bda 53c0 MOVF 0xc0,0x1,0x1 movf curr_byte, 1, 1 C:\mcc18\src\traditional\startup\c018i.c copy_loop: C:\mcc18\src\traditional\startup\c018i.c 000bdc e102 BNZ 0xbe2 bnz 2 // copy_one_byte C:\mcc18\src\traditional\startup\c018i.c 000bde 53c1 MOVF 0xc1,0x1,0x1 movf curr_byte + 1, 1, 1 C:\mcc18\src\traditional\startup\c018i.c 000be0 e007 BZ 0xbf0 bz 7 // done_copying C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c copy_one_byte: C:\mcc18\src\traditional\startup\c018i.c 000be2 0009 TBLRDPOSTINC tblrdpostinc C:\mcc18\src\traditional\startup\c018i.c 000be4 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\mcc18\src\traditional\startup\c018i.c 000be6 6eee MOVWF 0xee,0x0 movwf POSTINC0, 0 C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c // decrement byte counter C:\mcc18\src\traditional\startup\c018i.c 000be8 07c0 DECF 0xc0,0x1,0x1 decf curr_byte, 1, 1 C:\mcc18\src\traditional\startup\c018i.c 000bea e2f8 BC 0xbdc bc -8 // copy_loop C:\mcc18\src\traditional\startup\c018i.c 000bec 07c1 DECF 0xc1,0x1,0x1 decf curr_byte + 1, 1, 1 C:\mcc18\src\traditional\startup\c018i.c 000bee d7f9 BRA 0xbe2 bra -7 // copy_one_byte C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c done_copying: C:\mcc18\src\traditional\startup\c018i.c C:\mcc18\src\traditional\startup\c018i.c _endasm C:\mcc18\src\traditional\startup\c018i.c /* restore the table pointer for the next entry */ C:\mcc18\src\traditional\startup\c018i.c 000bf0 c0c4 MOVFF 0xc4,0xff6 TBLPTR = data_ptr; C:\mcc18\src\traditional\startup\c018i.c 000bf2 fff6 000bf4 c0c5 MOVFF 0xc5,0xff7 000bf6 fff7 000bf8 c0c6 MOVFF 0xc6,0xff8 000bfa fff8 /* next entry... */ C:\mcc18\src\traditional\startup\c018i.c 000bfc 0100 MOVLB 0x0 curr_entry--; C:\mcc18\src\traditional\startup\c018i.c 000bfe 07c2 DECF 0xc2,0x1,0x1 000c00 0e00 MOVLW 0x0 000c02 5bc3 SUBWFB 0xc3,0x1,0x1 000c04 d7bf BRA 0xb84 goto test; C:\mcc18\src\traditional\startup\c018i.c done: C:\mcc18\src\traditional\startup\c018i.c ; C:\mcc18\src\traditional\startup\c018i.c 000c06 0012 RETURN 0x0 } C:\mcc18\src\traditional\startup\c018i.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\main.c * FileName: main.c C:\MCHPFSUSB\fw\cdc\main.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\main.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\main.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\main.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\main.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\main.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\main.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\main.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\main.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\main.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\main.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\main.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\main.c * license. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\main.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\main.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\main.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\main.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\main.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\main.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\main.c * Rawin Rojvanit 11/19/04 Original. C:\MCHPFSUSB\fw\cdc\main.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\main.c #include C:\MCHPFSUSB\fw\cdc\main.c #include "system\typedefs.h" // Required C:\MCHPFSUSB\fw\cdc\main.c #include "system\usb\usb.h" // Required C:\MCHPFSUSB\fw\cdc\main.c #include "io_cfg.h" // Required C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c #include "system\usb\usb_compile_time_validation.h" // Optional C:\MCHPFSUSB\fw\cdc\main.c #include "user\user.h" // Modifiable C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /** V A R I A B L E S ********************************************************/ C:\MCHPFSUSB\fw\cdc\main.c #pragma udata C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\MCHPFSUSB\fw\cdc\main.c static void InitializeSystem(void); C:\MCHPFSUSB\fw\cdc\main.c void USBTasks(void); C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /** V E C T O R R E M A P P I N G *******************************************/ C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c //extern void _startup (void); // See c018i.c in your C18 compiler dir C:\MCHPFSUSB\fw\cdc\main.c //#pragma code _RESET_INTERRUPT_VECTOR = 0x000800 C:\MCHPFSUSB\fw\cdc\main.c //void _reset (void) C:\MCHPFSUSB\fw\cdc\main.c //{ C:\MCHPFSUSB\fw\cdc\main.c // _asm goto _startup _endasm C:\MCHPFSUSB\fw\cdc\main.c //} C:\MCHPFSUSB\fw\cdc\main.c //#pragma code C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /** D E C L A R A T I O N S **************************************************/ C:\MCHPFSUSB\fw\cdc\main.c #pragma code C:\MCHPFSUSB\fw\cdc\main.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\main.c * Function: void main(void) C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Input: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Output: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Overview: Main program entry point. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Note: None C:\MCHPFSUSB\fw\cdc\main.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\main.c void main(void) C:\MCHPFSUSB\fw\cdc\main.c { C:\MCHPFSUSB\fw\cdc\main.c 000c08 d804 RCALL 0xc12 InitializeSystem(); C:\MCHPFSUSB\fw\cdc\main.c 000c10 d7fc BRA 0xc0a while(1) C:\MCHPFSUSB\fw\cdc\main.c { C:\MCHPFSUSB\fw\cdc\main.c 000c0a d811 RCALL 0xc2e USBTasks(); // USB Tasks C:\MCHPFSUSB\fw\cdc\main.c 000c0c ece5 CALL 0x9ca,0x0 ProcessIO(); // See user\user.c & .h C:\MCHPFSUSB\fw\cdc\main.c 000c0e f004 }//end while C:\MCHPFSUSB\fw\cdc\main.c }//end main C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\main.c * Function: static void InitializeSystem(void) C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Input: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Output: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Overview: InitializeSystem is a centralize initialization routine. C:\MCHPFSUSB\fw\cdc\main.c * All required USB initialization routines are called from C:\MCHPFSUSB\fw\cdc\main.c * here. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * User application initialization routine should also be C:\MCHPFSUSB\fw\cdc\main.c * called from here. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Note: None C:\MCHPFSUSB\fw\cdc\main.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\main.c static void InitializeSystem(void) C:\MCHPFSUSB\fw\cdc\main.c { C:\MCHPFSUSB\fw\cdc\main.c 000c12 0e0f MOVLW 0xf ADCON1 |= 0x0F; // Default all pins to digital C:\MCHPFSUSB\fw\cdc\main.c 000c14 12c1 IORWF 0xc1,0x1,0x0 C:\MCHPFSUSB\fw\cdc\main.c #if defined(USE_USB_BUS_SENSE_IO) C:\MCHPFSUSB\fw\cdc\main.c 000c16 8292 BSF 0x92,0x1,0x0 tris_usb_bus_sense = INPUT_PIN; // See io_cfg.h C:\MCHPFSUSB\fw\cdc\main.c #endif C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c #if defined(USE_SELF_POWER_SENSE_IO) C:\MCHPFSUSB\fw\cdc\main.c 000c18 8492 BSF 0x92,0x2,0x0 tris_self_power = INPUT_PIN; C:\MCHPFSUSB\fw\cdc\main.c #endif C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c 000c1a 0e14 MOVLW 0x14 mInitializeUSBDriver(); // See usbdrv.h C:\MCHPFSUSB\fw\cdc\main.c 000c1c 6e6f MOVWF 0x6f,0x0 000c1e 0100 MOVLB 0x0 000c20 6bcf CLRF 0xcf,0x1 000c22 0100 MOVLB 0x0 000c24 6bd0 CLRF 0xd0,0x1 000c26 0100 MOVLB 0x0 000c28 6bd1 CLRF 0xd1,0x1 C:\MCHPFSUSB\fw\cdc\main.c 000c2a efe1 GOTO 0x9c2 UserInit(); // See user.c & .h C:\MCHPFSUSB\fw\cdc\main.c 000c2c f004 C:\MCHPFSUSB\fw\cdc\main.c }//end InitializeSystem C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\main.c * Function: void USBTasks(void) C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * PreCondition: InitializeSystem has been called. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Input: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Output: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Overview: Service loop for USB tasks. C:\MCHPFSUSB\fw\cdc\main.c * C:\MCHPFSUSB\fw\cdc\main.c * Note: None C:\MCHPFSUSB\fw\cdc\main.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\main.c void USBTasks(void) C:\MCHPFSUSB\fw\cdc\main.c { C:\MCHPFSUSB\fw\cdc\main.c /* C:\MCHPFSUSB\fw\cdc\main.c * Servicing Hardware C:\MCHPFSUSB\fw\cdc\main.c */ C:\MCHPFSUSB\fw\cdc\main.c 000c2e ec20 CALL 0x840,0x0 USBCheckBusStatus(); // Must use polling method C:\MCHPFSUSB\fw\cdc\main.c 000c30 f004 000c32 be6f BTFSC 0x6f,0x7,0x0 if(UCFGbits.UTEYE!=1) C:\MCHPFSUSB\fw\cdc\main.c 000c34 d002 BRA 0xc3a 000c36 ec42 CALL 0x884,0x0 USBDriverService(); // Interrupt or polling method C:\MCHPFSUSB\fw\cdc\main.c 000c38 f004 C:\MCHPFSUSB\fw\cdc\main.c #if defined(USB_USE_CDC) C:\MCHPFSUSB\fw\cdc\main.c 000c3a ef08 GOTO 0x210 CDCTxService(); C:\MCHPFSUSB\fw\cdc\main.c 000c3c f001 #endif C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c }// end USBTasks C:\MCHPFSUSB\fw\cdc\main.c C:\MCHPFSUSB\fw\cdc\main.c /** EOF main.c ***************************************************************/ C:\MCHPFSUSB\fw\cdc\main.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * FileName: usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * license. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Rawin Rojvanit 11/19/04 Original. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * -usbmmap.c- C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * USB Memory Map C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * This file is the USB memory manager; it serves as a compile-time memory C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * allocator for the USB endpoints. It uses the compile time options passed C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * from usbcfg.h to instantiate endpoints and endpoint buffer. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Each endpoint requires to have a set of Buffer Descriptor registers(BDT). C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * A BDT is 4-byte long and has a specific RAM location for each endpoint. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The BDT for endpoint 0 out is located at address 0x400 to 0x403. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The BDT for endpoint 0 in is located at address 0x404 to 0x407. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The BDT for endpoint 1 out is located at address 0x408 to 0x40B. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * and so on... The above allocation assumes the Ping-Pong Buffer Mode 0 is C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * used. These locations are already hard-wired in the silicon. The point C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * of doing instantiation, i.e. volatile far BDT ep0Bo;, is to provide the C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C compiler a way to address each variable directly. This is very important C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * because when a register can be accessed directly, it saves execution time C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * and reduces program size. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Endpoints are defined using the endpoint number and the direction C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * of transfer. For simplicity, usbmmap.c only uses the endpoint number C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * in the BDT register allocation scheme. This means if the usbcfg.h states C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * that the MAX_EP_NUMBER is number 1, then four BDTs will be C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * instantiated: one each for endpoint0 in and endpoint0 out, which must C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * always be instantiated for control transfer by default, and one each sets C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * for endpoint1 in and endpoint1 out. The naming convention for instantiating C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * BDT is C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * ep<#>B C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * where # is the endpoint number, and d is the direction of C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * transfer, which could be either or . C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The USB memory manager uses MAX_EP_NUMBER, as defined in usbcfg.h, to define C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * the endpoints to be instantiated. This represents the highest endpoint C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * number to be allocated, not how many endpoints are used. Since the BDTs for C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * endpoints have hardware-assigned addresses in Bank 4, setting this value too C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * high may lead to inefficient use of data RAM. For example, if an application C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * uses only endpoints EP0 and EP4, then the MAX_EP_NUMBER is 4, and not 2. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The in-between endpoint BDTs in this example (EP1, EP2, and EP3) go unused, C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * and the 24 bytes of memory associated with them are wasted. It does not make C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * much sense to skip endpoints, but the final decision lies with the user. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The next step is to assign the instantiated BDTs to different C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * USB functions. The firmware framework fundamentally assumes that every USB C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * function should know which endpoint it is using, i.e., the default control C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * transfer should know that it is using endpoint 0 in and endpoint 0 out. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * A HID class can choose which endpoint it wants to use, but once chosen, it C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * should always know the number of the endpoint. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The assignment of endpoints to USB functions is managed centrally C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * in usbcfg.h. This helps prevent the mistake of having more C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * than one USB function using the same endpoint. The "Endpoint Allocation" C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * section in usbcfg.h provides examples for how to map USB endpoints to USB C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * functions. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Quite a few things can be mapped in that section. There is no C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * one correct way to do the mapping and the user has the choice to C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * choose a method that is most suitable to the application. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Typically, however, a user will want to map the following for a given C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * USB interface function: C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * 1. The USB interface ID C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * 2. The endpoint control registers (UEPn) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * 3. The BDT registers (ep<#>B) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * 4. The endpoint size C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Example: Assume a USB device class "foo", which uses one out endpoint C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * of size 64-byte and one in endpoint of size 64-byte, then: C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * #define FOO_INTF_ID 0x00 C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * #define FOO_UEP UEP1 C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * #define FOO_BD_OUT ep1Bo C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * #define FOO_BD_IN ep1Bi C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * #define FOO_EP_SIZE 64 C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The mapping above has chosen class "foo" to use endpoint 1. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The names are arbitrary and can be anything other than FOO_??????. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * For abstraction, the code for class "foo" should use the abstract C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * definitions of FOO_BD_OUT,FOO_BD_IN, and not ep1Bo or ep1Bi. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Note that the endpoint size defined in the usbcfg.h file is again C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * used in the usbmmap.c file. This shows that the relationship between C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * the two files are tightly related. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The endpoint buffer for each USB function must be located in the C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * dual-port RAM area and has to come after all the BDTs have been C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * instantiated. An example declaration is: C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * volatile far unsigned char[FOO_EP_SIZE] data; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * The 'volatile' keyword tells the compiler not to perform any code C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * optimization on this variable because its content could be modified C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * by the hardware. The 'far' keyword tells the compiler that this variable C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * is not located in the Access RAM area (0x000 - 0x05F). C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * For the variable to be globally accessible by other files, it should be C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * declared in the header file usbmmap.h as an extern definition, such as C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * extern volatile far unsigned char[FOO_EP_SIZE] data; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Conclusion: C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * In a short summary, the dependencies between usbcfg and usbmmap can C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * be shown as: C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * usbcfg[MAX_EP_NUMBER] -> usbmmap C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * usbmmap[ep<#>B] -> usbcfg C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * usbcfg[EP size] -> usbmmap C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * usbcfg[abstract ep definitions] -> usb9/hid/cdc/etc class code C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * usbmmap[endpoint buffer variable] -> usb9/hid/cdc/etc class code C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Data mapping provides a means for direct addressing of BDT and endpoint C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * buffer. This means less usage of pointers, which equates to a faster and C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * smaller program code. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /** U S B G L O B A L V A R I A B L E S ************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #pragma udata C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c byte usb_device_state; // Device States: DETACHED, ATTACHED, ... C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c USB_DEVICE_STATUS usb_stat; // Global USB flags C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c byte usb_active_cfg; // Value of current configuration C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c byte usb_alt_intf[MAX_NUM_INT]; // Array to keep track of the current alternate C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c // setting for each interface ID C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /** U S B F I X E D L O C A T I O N V A R I A B L E S *********************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #pragma udata usbram4=0x400 //See Linker Script,usb4:0x400-0x4FF(256-byte) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Section A: Buffer Descriptor Table C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - 0x400 - 0x4FF(max) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - MAX_EP_NUMBER is defined in autofiles\usbcfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - BDT data type is defined in system\usb\usbmmap.h C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(0 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep0Bo; //Endpoint #0 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep0Bi; //Endpoint #0 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(1 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep1Bo; //Endpoint #1 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep1Bi; //Endpoint #1 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(2 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep2Bo; //Endpoint #2 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep2Bi; //Endpoint #2 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(3 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep3Bo; //Endpoint #3 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep3Bi; //Endpoint #3 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(4 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep4Bo; //Endpoint #4 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep4Bi; //Endpoint #4 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(5 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep5Bo; //Endpoint #5 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep5Bi; //Endpoint #5 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(6 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep6Bo; //Endpoint #6 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep6Bi; //Endpoint #6 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(7 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep7Bo; //Endpoint #7 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep7Bi; //Endpoint #7 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(8 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep8Bo; //Endpoint #8 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep8Bi; //Endpoint #8 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(9 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep9Bo; //Endpoint #9 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep9Bi; //Endpoint #9 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(10 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep10Bo; //Endpoint #10 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep10Bi; //Endpoint #10 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(11 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep11Bo; //Endpoint #11 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep11Bi; //Endpoint #11 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(12 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep12Bo; //Endpoint #12 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep12Bi; //Endpoint #12 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(13 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep13Bo; //Endpoint #13 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep13Bi; //Endpoint #13 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(14 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep14Bo; //Endpoint #14 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep14Bi; //Endpoint #14 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if(15 <= MAX_EP_NUMBER) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep15Bo; //Endpoint #15 BD Out C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far BDT ep15Bi; //Endpoint #15 BD In C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Section B: EP0 Buffer Space C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c ****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - Two buffer areas are defined: C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * A. CTRL_TRF_SETUP C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - Size = EP0_BUFF_SIZE as defined in autofiles\usbcfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - Detailed data structure allows direct adddressing of bits and bytes. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * B. CTRL_TRF_DATA C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - Size = EP0_BUFF_SIZE as defined in autofiles\usbcfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - Data structure allows direct adddressing of the first 8 bytes. C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * - Both data types are defined in system\usb\usbdefs\usbdefs_ep0_buff.h C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far CTRL_TRF_SETUP SetupPkt; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far CTRL_TRF_DATA CtrlTrfData; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * Section C: CDC Buffer C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c ****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #pragma udata usbram5a=0x500 //See Linker Script,usb5:0x500-... C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #if defined(USB_USE_CDC) C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far unsigned char cdc_notice[CDC_INT_EP_SIZE]; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far unsigned char cdc_data_rx[CDC_BULK_OUT_EP_SIZE]; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c volatile far unsigned char cdc_data_tx[CDC_BULK_IN_EP_SIZE]; C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #endif C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c #pragma udata C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /** EOF usbmmap.c ************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbmmap.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * FileName: usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * license. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Rawin Rojvanit 11/19/04 Original. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #include C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #include "io_cfg.h" // Required for USBCheckBusStatus() C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /** V A R I A B L E S ********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #pragma udata C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBModuleEnable(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBModuleDisable(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBSuspend(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBWakeFromSuspend(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBProtocolResetHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USB_SOF_Handler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBStallHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBErrorHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /** D E C L A R A T I O N S **************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #pragma code C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBCheckBusStatus(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: This routine enables/disables the USB module by monitoring C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the USB power signal. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBCheckBusStatus(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Bus Attachment & Detachment Detection C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * usb_bus_sense is an i/o pin defined in io_cfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #define USB_BUS_ATTACHED 1 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c #define USB_BUS_DETACHED 0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000840 a280 BTFSS 0x80,0x1,0x0 if(usb_bus_sense == USB_BUS_ATTACHED) // Is USB bus attached? C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000842 d004 BRA 0x84c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000844 b66d BTFSC 0x6d,0x3,0x0 if(UCONbits.USBEN == 0) // Is the module off? C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000846 d004 BRA 0x850 000848 d80f RCALL 0x868 USBModuleEnable(); // Is off, enable it C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c } C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00084a d002 BRA 0x850 else C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00084c b66d BTFSC 0x6d,0x3,0x0 if(UCONbits.USBEN == 1) // Is the module on? C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00084e d813 RCALL 0x876 USBModuleDisable(); // Is on, disable it C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c }//end if(usb_bus_sense...) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * After enabling the USB module, it takes some time for the voltage C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * on the D+ or D- line to rise high enough to get out of the SE0 condition. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * The USB Reset interrupt should not be unmasked until the SE0 condition is C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * cleared. This helps preventing the firmware from misinterpreting this C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * unique event as a USB bus reset from the USB host. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000850 0100 MOVLB 0x0 if(usb_device_state == ATTACHED_STATE) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000852 05cf DECF 0xcf,0x0,0x1 000854 e108 BNZ 0x866 { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000856 ba6d BTFSC 0x6d,0x5,0x0 if(!UCONbits.SE0) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000858 d006 BRA 0x866 { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00085a 6a68 CLRF 0x68,0x0 UIR = 0; // Clear all USB interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00085c 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00085e 8069 BSF 0x69,0x0,0x0 UIEbits.URSTIE = 1; // Unmask RESET interrupt C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000860 8869 BSF 0x69,0x4,0x0 UIEbits.IDLEIE = 1; // Unmask IDLE interrupt C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000862 0e02 MOVLW 0x2 usb_device_state = POWERED_STATE; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000864 6fcf MOVWF 0xcf,0x1 }//end if // else wait until SE0 is cleared C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c }//end if(usb_device_state == ATTACHED_STATE) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000866 0012 RETURN 0x0 }//end USBCheckBusStatus C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBModuleEnable(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: This routine enables the USB module. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * An end designer should never have to call this routine C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * manually. This routine should only be called from C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * USBCheckBusStatus(). C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: See USBCheckBusStatus() for more information. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBModuleEnable(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000868 6a6d CLRF 0x6d,0x0 UCON = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00086a 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00086c 866d BSF 0x6d,0x3,0x0 UCONbits.USBEN = 1; // Enable module & attach to bus C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00086e 0100 MOVLB 0x0 usb_device_state = ATTACHED_STATE; // Defined in usbmmap.c & .h C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000870 0e01 MOVLW 0x1 000872 6fcf MOVWF 0xcf,0x1 000874 0012 RETURN 0x0 }//end USBModuleEnable C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBModuleDisable(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: This routine disables the USB module. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * An end designer should never have to call this routine C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * manually. This routine should only be called from C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * USBCheckBusStatus(). C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: See USBCheckBusStatus() for more information. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBModuleDisable(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000876 6a6d CLRF 0x6d,0x0 UCON = 0; // Disable module & detach from bus C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000878 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00087a 0100 MOVLB 0x0 usb_device_state = DETACHED_STATE; // Defined in usbmmap.c & .h C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00087c 6bcf CLRF 0xcf,0x1 00087e 0012 RETURN 0x0 }//end USBModuleDisable C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBSoftDetach(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: The device will have to be re-enumerated to function again. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: USBSoftDetach electrically disconnects the device from C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the bus. This is done by stop supplying Vusb voltage to C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * pull-up resistor. The pull-down resistors on the host C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * side will pull both differential signal lines low and C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the host registers the event as a disconnect. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Since the USB cable is not physically disconnected, the C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * power supply through the cable can still be sensed by C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the device. The next time USBCheckBusStatus() function C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * is called, it will reconnect the device back to the bus. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBSoftDetach(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000880 ef3b GOTO 0x876 USBModuleDisable(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000882 f004 }//end USBSoftDetach C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBDriverService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: This routine is the heart of this firmware. It manages C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * all USB interrupts. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: Device state transitions through the following stages: C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * DETACHED -> ATTACHED -> POWERED -> DEFAULT -> C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ADDRESS_PENDING -> ADDRESSED -> CONFIGURED -> READY C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBDriverService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if USB cable is not even attached. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000884 0100 MOVLB 0x0 if(usb_device_state == DETACHED_STATE) return; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000886 51cf MOVF 0xcf,0x0,0x1 000888 e101 BNZ 0x88c 00088a 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Task A: Service USB Activity Interrupt C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00088c 5068 MOVF 0x68,0x0,0x0 if(UIRbits.ACTVIF && UIEbits.ACTVIE) USBWakeFromSuspend(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00088e 0b04 ANDLW 0x4 000890 e004 BZ 0x89a 000892 5069 MOVF 0x69,0x0,0x0 000894 0b04 ANDLW 0x4 000896 e001 BZ 0x89a 000898 d83c RCALL 0x912 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if the device is in suspend mode. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00089a b26d BTFSC 0x6d,0x1,0x0 if(UCONbits.SUSPND==1) return; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00089c 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Task B: Service USB Bus Reset Interrupt. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * When bus reset is received during suspend, ACTVIF will be set first, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * once the UCONbits.SUSPND is clear, then the URSTIF bit will be asserted. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * This is why URSTIF is checked after ACTVIF. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00089e 5068 MOVF 0x68,0x0,0x0 if(UIRbits.URSTIF && UIEbits.URSTIE) USBProtocolResetHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008a0 0b01 ANDLW 0x1 0008a2 e004 BZ 0x8ac 0008a4 5069 MOVF 0x69,0x0,0x0 0008a6 0b01 ANDLW 0x1 0008a8 e001 BZ 0x8ac 0008aa d854 RCALL 0x954 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Task C: Service other USB interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008ac 5068 MOVF 0x68,0x0,0x0 if(UIRbits.IDLEIF && UIEbits.IDLEIE) USBSuspend(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008ae 0b10 ANDLW 0x10 0008b0 e004 BZ 0x8ba 0008b2 5069 MOVF 0x69,0x0,0x0 0008b4 0b10 ANDLW 0x10 0008b6 e001 BZ 0x8ba 0008b8 d824 RCALL 0x902 0008ba 5068 MOVF 0x68,0x0,0x0 if(UIRbits.SOFIF && UIEbits.SOFIE) USB_SOF_Handler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008bc 0b40 ANDLW 0x40 0008be e004 BZ 0x8c8 0008c0 5069 MOVF 0x69,0x0,0x0 0008c2 0b40 ANDLW 0x40 0008c4 e001 BZ 0x8c8 0008c6 d83b RCALL 0x93e 0008c8 5068 MOVF 0x68,0x0,0x0 if(UIRbits.STALLIF && UIEbits.STALLIE) USBStallHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008ca 0b20 ANDLW 0x20 0008cc e004 BZ 0x8d6 0008ce 5069 MOVF 0x69,0x0,0x0 0008d0 0b20 ANDLW 0x20 0008d2 e001 BZ 0x8d6 0008d4 d836 RCALL 0x942 0008d6 5068 MOVF 0x68,0x0,0x0 if(UIRbits.UERRIF && UIEbits.UERRIE) USBErrorHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008d8 0b02 ANDLW 0x2 0008da e004 BZ 0x8e4 0008dc 5069 MOVF 0x69,0x0,0x0 0008de 0b02 ANDLW 0x2 0008e0 e001 BZ 0x8e4 0008e2 d836 RCALL 0x950 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if the host has not sent a bus reset. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Once bus reset is received, the device transitions into the DEFAULT C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * state and is ready for communication. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008e4 0e03 MOVLW 0x3 if(usb_device_state < DEFAULT_STATE) return; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008e6 0100 MOVLB 0x0 0008e8 5dcf SUBWF 0xcf,0x0,0x1 0008ea e201 BC 0x8ee 0008ec 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Task D: Servicing USB Transaction Complete Interrupt C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008ee 5068 MOVF 0x68,0x0,0x0 if(UIRbits.TRNIF && UIEbits.TRNIE) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008f0 0b08 ANDLW 0x8 0008f2 e006 BZ 0x900 0008f4 5069 MOVF 0x69,0x0,0x0 0008f6 0b08 ANDLW 0x8 0008f8 e003 BZ 0x900 { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * USBCtrlEPService only services transactions over EP0. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * It ignores all other EP transactions. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008fa ec98 CALL 0x330,0x0 USBCtrlEPService(); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008fc f001 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Other EP can be serviced later by responsible device class firmware. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Each device driver knows when an OUT or IN transaction is ready by C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * checking the buffer ownership bit. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * An OUT EP should always be owned by SIE until the data is ready. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * An IN EP should always be owned by CPU until the data is ready. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Because of this logic, it is not necessary to save the USTAT value C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * of non-EP0 transactions. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0008fe 9668 BCF 0x68,0x3,0x0 UIRbits.TRNIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c }//end if(UIRbits.TRNIF && UIEbits.TRNIE) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000900 0012 RETURN 0x0 }//end USBDriverService C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBSuspend(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBSuspend(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * NOTE: Do not clear UIRbits.ACTVIF here! C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Reason: C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ACTVIF is only generated once an IDLEIF has been generated. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * This is a 1:1 ratio interrupt generation. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * For every IDLEIF, there will be only one ACTVIF regardless of C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the number of subsequent bus transitions. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * If the ACTIF is cleared here, a problem could occur when: C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * [ IDLE ][bus activity -> C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * <--- 3 ms -----> ^ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ^ ACTVIF=1 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * IDLEIF=1 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * # # # # (#=Program polling flags) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ^ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * This polling loop will see both C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * IDLEIF=1 and ACTVIF=1. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * However, the program services IDLEIF first C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * because ACTIVIE=0. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * If this routine clears the only ACTIVIF, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * then it can never get out of the suspend C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * mode. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000902 8469 BSF 0x69,0x2,0x0 UIEbits.ACTVIE = 1; // Enable bus activity interrupt C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000904 9868 BCF 0x68,0x4,0x0 UIRbits.IDLEIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000906 826d BSF 0x6d,0x1,0x0 UCONbits.SUSPND = 1; // Put USB module in power conserve C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c // mode, SIE clock inactive C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * At this point the PIC can go into sleep,idle, or C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * switch to a slower clock, etc. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* Modifiable Section */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000908 9aa1 BCF 0xa1,0x5,0x0 PIR2bits.USBIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00090a 8aa0 BSF 0xa0,0x5,0x0 PIE2bits.USBIE = 1; // Set USB wakeup source C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00090c 0003 SLEEP Sleep(); // Goto sleep C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00090e 9aa0 BCF 0xa0,0x5,0x0 PIE2bits.USBIE = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* End Modifiable Section */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000910 0012 RETURN 0x0 }//end USBSuspend C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBWakeFromSuspend(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBWakeFromSuspend(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * If using clock switching, this is the place to restore the C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * original clock frequency. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000912 926d BCF 0x6d,0x1,0x0 UCONbits.SUSPND = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000914 9469 BCF 0x69,0x2,0x0 UIEbits.ACTVIE = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000916 9468 BCF 0x68,0x2,0x0 UIRbits.ACTVIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000918 0012 RETURN 0x0 }//end USBWakeFromSuspend C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBRemoteWakeup(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: This function should be called by user when the device C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * is waken up by an external stimulus other than ACTIVIF. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Please read the note below to understand the limitations. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: The modifiable section in this routine should be changed C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * to meet the application needs. Current implementation C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * temporary blocks other functions from executing for a C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * period of 1-13 ms depending on the core frequency. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * According to USB 2.0 specification section 7.1.7.7, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * "The remote wakeup device must hold the resume signaling C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * for at lest 1 ms but for no more than 15 ms." C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * The idea here is to use a delay counter loop, using a C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * common value that would work over a wide range of core C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * frequencies. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * That value selected is 1800. See table below: C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ========================================================== C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Core Freq(MHz) MIP RESUME Signal Period (ms) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ========================================================== C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * 48 12 1.05 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * 4 1 12.6 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * ========================================================== C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * * These timing could be incorrect when using code C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * optimization or extended instruction mode, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * or when having other interrupts enabled. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Make sure to verify using the MPLAB SIM's Stopwatch C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBRemoteWakeup(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c static word delay_count; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00091a 0100 MOVLB 0x0 if(usb_stat.RemoteWakeup == 1) // Check if RemoteWakeup function C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00091c a1d0 BTFSS 0xd0,0x0,0x1 00091e d00e BRA 0x93c { // has been enabled by the host. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000920 dff8 RCALL 0x912 USBWakeFromSuspend(); // Unsuspend USB modue C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000922 846d BSF 0x6d,0x2,0x0 UCONbits.RESUME = 1; // Start RESUME signaling C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* Modifiable Section */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000924 0100 MOVLB 0x0 delay_count = 1800U; // Set RESUME line for 1-13 ms C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000926 0e08 MOVLW 0x8 000928 6fd3 MOVWF 0xd3,0x1 00092a 0e07 MOVLW 0x7 00092c 6fd4 MOVWF 0xd4,0x1 do C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00092e 07d3 DECF 0xd3,0x1,0x1 delay_count--; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000930 0e00 MOVLW 0x0 000932 5bd4 SUBWFB 0xd4,0x1,0x1 000934 51d3 MOVF 0xd3,0x0,0x1 }while(delay_count); C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000936 11d4 IORWF 0xd4,0x0,0x1 000938 e1fa BNZ 0x92e C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* End Modifiable Section */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00093a 946d BCF 0x6d,0x2,0x0 UCONbits.RESUME = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c }//endif C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00093c 0012 RETURN 0x0 }//end USBRemoteWakeup C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USB_SOF_Handler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: The USB host sends out a SOF packet to full-speed devices C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * every 1 ms. This interrupt may be useful for isochronous C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * pipes. End designers should implement callback routine C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * as necessary. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USB_SOF_Handler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* Callback routine here */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00093e 9c68 BCF 0x68,0x6,0x0 UIRbits.SOFIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000940 0012 RETURN 0x0 }//end USB_SOF_Handler C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBStallHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: A STALL packet is sent to the host by the SIE. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: The STALLIF is set anytime the SIE sends out a STALL C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * packet regardless of which endpoint causes it. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * A Setup transaction overrides the STALL function. A stalled C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * endpoint stops stalling once it receives a setup packet. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * In this case, the SIE will accepts the Setup packet and C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * set the TRNIF flag to notify the firmware. STALL function C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * for that particular endpoint pipe will be automatically C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * disabled (direction specific). C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * There are a few reasons for an endpoint to be stalled. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * 1. When a non-supported USB request is received. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Example: GET_DESCRIPTOR(DEVICE_QUALIFIER) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * 2. When an endpoint is currently halted. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * 3. When the device class specifies that an endpoint must C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * stall in response to a specific event. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Example: Mass Storage Device Class C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * If the CBW is not valid, the device shall C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * STALL the Bulk-In pipe. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * See USB Mass Storage Class Bulk-only Transport C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Specification for more details. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: UEPn.EPSTALL can be scanned to see which endpoint causes C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the stall event. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * If C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBStallHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Does not really have to do anything here, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * even for the control endpoint. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * All BDs of Endpoint 0 are owned by SIE right now, C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * but once a Setup Transaction is received, the ownership C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * for EP0_OUT will be returned to CPU. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * When the Setup Transaction is serviced, the ownership C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * for EP0_IN will then be forced back to CPU by firmware. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000942 a070 BTFSS 0x70,0x0,0x0 if(UEP0bits.EPSTALL == 1) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000944 d003 BRA 0x94c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000946 ecac CALL 0x558,0x0 USBPrepareForNextSetupTrf(); // Firmware work-around C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000948 f002 00094a 9070 BCF 0x70,0x0,0x0 UEP0bits.EPSTALL = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c } C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00094c 9a68 BCF 0x68,0x5,0x0 UIRbits.STALLIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00094e 0012 RETURN 0x0 }//end USBStallHandler C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBErrorHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: The purpose of this interrupt is mainly for debugging C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * during development. Check UEIR to see which error causes C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * the interrupt. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBErrorHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000950 9268 BCF 0x68,0x1,0x0 UIRbits.UERRIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000952 0012 RETURN 0x0 }//end USBErrorHandler C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Function: void USBProtocolResetHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * PreCondition: A USB bus reset is received from the host. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Side Effects: Currently, this routine flushes any pending USB C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * transactions. It empties out the USTAT FIFO. This action C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * might not be desirable in some applications. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Overview: Once a USB bus reset is received from the host, this C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * routine should be called. It resets the device address to C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * zero, disables all non-EP0 endpoints, initializes EP0 to C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * be ready for default communication, clears all USB C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * interrupt flags, unmasks applicable USB interrupts, and C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * reinitializes internal state-machine variables. C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c void USBProtocolResetHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000954 6a6a CLRF 0x6a,0x0 UEIR = 0; // Clear all USB error flags C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000956 6a68 CLRF 0x68,0x0 UIR = 0; // Clears all USB interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000958 0e9f MOVLW 0x9f UEIE = 0b10011111; // Unmask all USB error interrupts C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00095a 6e6b MOVWF 0x6b,0x0 00095c 0e7b MOVLW 0x7b UIE = 0b01111011; // Enable all interrupts except ACTVIE C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00095e 6e69 MOVWF 0x69,0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000960 6a6e CLRF 0x6e,0x0 UADDR = 0x00; // Reset to default address C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000962 0e0f MOVLW 0xf mDisableEP1to15(); // Reset all non-EP0 UEPn registers C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000964 6ee6 MOVWF 0xe6,0x0 000966 0e71 MOVLW 0x71 000968 6ee6 MOVWF 0xe6,0x0 00096a 0e0f MOVLW 0xf 00096c 6ee6 MOVWF 0xe6,0x0 00096e d814 RCALL 0x998 000970 52e5 MOVF 0xe5,0x1,0x0 000972 52e5 MOVF 0xe5,0x1,0x0 000974 52e5 MOVF 0xe5,0x1,0x0 000976 0e16 MOVLW 0x16 UEP0 = EP_CTRL|HSHK_EN; // Init EP0 as a Ctrl EP, see usbdrv.h C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000978 6e70 MOVWF 0x70,0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00097a a668 BTFSS 0x68,0x3,0x0 while(UIRbits.TRNIF == 1) // Flush any pending transactions C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00097c d002 BRA 0x982 000980 d7fc BRA 0x97a 00097e 9668 BCF 0x68,0x3,0x0 UIRbits.TRNIF = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000982 986d BCF 0x6d,0x4,0x0 UCONbits.PKTDIS = 0; // Make sure packet processing is enabled C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000984 ecac CALL 0x558,0x0 USBPrepareForNextSetupTrf(); // Declared in usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000986 f002 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000988 0100 MOVLB 0x0 usb_stat.RemoteWakeup = 0; // Default status flag to disable C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00098a 91d0 BCF 0xd0,0x0,0x1 00098c 0100 MOVLB 0x0 usb_active_cfg = 0; // Clear active configuration C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00098e 6bd1 CLRF 0xd1,0x1 000990 0100 MOVLB 0x0 usb_device_state = DEFAULT_STATE; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000992 0e03 MOVLW 0x3 000994 6fcf MOVWF 0xcf,0x1 000996 0012 RETURN 0x0 }//end USBProtocolResetHandler C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /* Auxiliary Function */ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 000998 cfd9 MOVFF 0xfd9,0xfe6 void ClearArray(byte* startAdr,byte count) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 00099a ffe6 00099c cfe1 MOVFF 0xfe1,0xfd9 00099e ffd9 { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009a0 0efd MOVLW 0xfd *startAdr; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009a2 cfdb MOVFF 0xfdb,0xfe9 0009a4 ffe9 0009a6 0efe MOVLW 0xfe 0009a8 cfdb MOVFF 0xfdb,0xfea 0009aa ffea 0009ac 0efc MOVLW 0xfc while(count) C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009ae 50db MOVF 0xdb,0x0,0x0 0009b0 e004 BZ 0x9ba 0009b8 d7f9 BRA 0x9ac { C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c _asm C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009b2 6aee CLRF 0xee,0x0 clrf POSTINC0,0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c _endasm C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009b4 0efc MOVLW 0xfc count--; C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009b6 06db DECF 0xdb,0x1,0x0 }//end while C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009ba 52e5 MOVF 0xe5,0x1,0x0 }//end ClearArray C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c 0009bc cfe7 MOVFF 0xfe7,0xfd9 0009be ffd9 0009c0 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /** EOF usbdrv.c *************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbdrv\usbdrv.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * FileName: usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * license. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Rawin Rojvanit 11/19/04 Original. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #include C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #include "io_cfg.h" // Required for self_power status C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /** V A R I A B L E S ********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #pragma udata C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdGetDscHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdSetCfgHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdGetStatusHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdFeatureReqHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /** D E C L A R A T I O N S **************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #pragma code C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Function: void USBCheckStdRequest(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Overview: This routine checks the setup data packet to see if it C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * knows how to handle it C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBCheckStdRequest(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0005c0 0104 MOVLB 0x4 if(SetupPkt.RequestType != STANDARD) return; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0005c2 5120 MOVF 0x20,0x0,0x1 0005c4 0b60 ANDLW 0x60 0005c6 42e8 RRNCF 0xe8,0x1,0x0 0005c8 42e8 RRNCF 0xe8,0x1,0x0 0005ca 42e8 RRNCF 0xe8,0x1,0x0 0005cc 42e8 RRNCF 0xe8,0x1,0x0 0005ce 42e8 RRNCF 0xe8,0x1,0x0 0005d0 0900 IORLW 0x0 0005d2 e001 BZ 0x5d6 0005d4 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0005d6 5121 MOVF 0x21,0x0,0x1 switch(SetupPkt.bRequest) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0005d8 0a07 XORLW 0x7 0005da e040 BZ 0x65c 0005dc 0a0b XORLW 0xb 0005de e03e BZ 0x65c 0005e0 0a07 XORLW 0x7 0005e2 e033 BZ 0x64a 0005e4 0a01 XORLW 0x1 0005e6 e023 BZ 0x62e 0005e8 0a0b XORLW 0xb 0005ea e01f BZ 0x62a 0005ec 0a02 XORLW 0x2 0005ee e01d BZ 0x62a 0005f0 0a03 XORLW 0x3 0005f2 e019 BZ 0x626 0005f4 0a08 XORLW 0x8 0005f6 e010 BZ 0x618 0005f8 0a01 XORLW 0x1 0005fa e00c BZ 0x614 0005fc 0a0f XORLW 0xf 0005fe e008 BZ 0x610 000600 0a03 XORLW 0x3 000602 e001 BZ 0x606 000604 0012 RETURN 0x0 { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case SET_ADR: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000606 d914 RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000608 0100 MOVLB 0x0 usb_device_state = ADR_PENDING_STATE; // Update state only C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00060a 0e04 MOVLW 0x4 00060c 6fcf MOVWF 0xcf,0x1 /* See USBCtrlTrfInHandler() in usbctrltrf.c for the next step */ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00060e 0012 RETURN 0x0 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case GET_DSC: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000610 ef2f GOTO 0x65e USBStdGetDscHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000612 f003 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case SET_CFG: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000614 ef66 GOTO 0x6cc USBStdSetCfgHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000616 f003 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case GET_CFG: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000618 d90b RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00061a 0100 MOVLB 0x0 pSrc.bRam = (byte*)&usb_active_cfg; // Set Source C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00061c 0ed1 MOVLW 0xd1 00061e 6fc9 MOVWF 0xc9,0x1 000620 0e00 MOVLW 0x0 000622 6fca MOVWF 0xca,0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c LSB(wCount) = 1; // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000624 d00c BRA 0x63e break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case GET_STATUS: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000626 ef81 GOTO 0x702 USBStdGetStatusHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000628 f003 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case CLR_FEATURE: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case SET_FEATURE: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00062a efb5 GOTO 0x76a USBStdFeatureReqHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00062c f003 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case GET_INTF: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00062e d904 RCALL 0x838 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000630 0100 MOVLB 0x0 pSrc.bRam = (byte*)&usb_alt_intf+SetupPkt.bIntfID; // Set source C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000632 6fc9 MOVWF 0xc9,0x1 000634 6bca CLRF 0xca,0x1 000636 0ed2 MOVLW 0xd2 000638 27c9 ADDWF 0xc9,0x1,0x1 00063a 0e00 MOVLW 0x0 00063c 23ca ADDWFC 0xca,0x1,0x1 00063e 0100 MOVLB 0x0 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000640 93d0 BCF 0xd0,0x1,0x1 000642 0100 MOVLB 0x0 LSB(wCount) = 1; // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000644 0e01 MOVLW 0x1 000646 6fcd MOVWF 0xcd,0x1 000648 0012 RETURN 0x0 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case SET_INTF: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00064a d8f6 RCALL 0x838 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00064c 6aea CLRF 0xea,0x0 usb_alt_intf[SetupPkt.bIntfID] = SetupPkt.bAltID; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00064e 0fd2 ADDLW 0xd2 000650 6ee9 MOVWF 0xe9,0x0 000652 0e00 MOVLW 0x0 000654 22ea ADDWFC 0xea,0x1,0x0 000656 c422 MOVFF 0x422,0xfef 000658 ffef 00065a 0012 RETURN 0x0 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case SET_DSC: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case SYNCH_FRAME: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c default: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c }//end switch C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00065c 0012 RETURN 0x0 }//end USBCheckStdRequest C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Function: void USBStdGetDscHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Overview: This routine handles the standard GET_DESCRIPTOR request. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * It utilizes tables dynamically looks up descriptor size. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * This routine should never have to be modified if the tables C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * in usbdsc.c are declared correctly. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdGetDscHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00065e 0e80 MOVLW 0x80 if(SetupPkt.bmRequestType == 0x80) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000660 0104 MOVLB 0x4 000662 5d20 SUBWF 0x20,0x0,0x1 000664 e132 BNZ 0x6ca { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000666 5123 MOVF 0x23,0x0,0x1 switch(SetupPkt.bDscType) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000668 0a03 XORLW 0x3 00066a e01f BZ 0x6aa 00066c 0a01 XORLW 0x1 00066e e00a BZ 0x684 000670 0a03 XORLW 0x3 000672 e129 BNZ 0x6c6 { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case DSC_DEV: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000674 d8dd RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000676 0100 MOVLB 0x0 pSrc.bRom = (rom byte*)&device_dsc; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000678 0e9c MOVLW 0x9c 00067a 6fc9 MOVWF 0xc9,0x1 00067c 0e0a MOVLW 0xa 00067e 6fca MOVWF 0xca,0x1 000680 0e12 MOVLW 0x12 wCount._word = sizeof(device_dsc); // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000682 d01e BRA 0x6c0 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case DSC_CFG: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000684 d8af RCALL 0x7e4 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007e4 d825 RCALL 0x830 000830 0100 MOVLB 0x0 000832 0e01 MOVLW 0x1 000834 6fc8 MOVWF 0xc8,0x1 000836 0012 RETURN 0x0 000686 0e5d MOVLW 0x5d pSrc.bRom = *(USB_CD_Ptr+SetupPkt.bDscIndex); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000688 26f6 ADDWF 0xf6,0x1,0x0 00068a 0e0b MOVLW 0xb 00068c d8bd RCALL 0x808 0007e6 0104 MOVLB 0x4 0007e8 5122 MOVF 0x22,0x0,0x1 0007ea 6ef6 MOVWF 0xf6,0x0 0007ec 6af7 CLRF 0xf7,0x0 0007ee 90d8 BCF 0xd8,0x0,0x0 0007f0 36f6 RLCF 0xf6,0x1,0x0 0007f2 36f7 RLCF 0xf7,0x1,0x0 0007f4 0012 RETURN 0x0 000808 22f7 ADDWFC 0xf7,0x1,0x0 00080a 0009 TBLRDPOSTINC 00080c cff5 MOVFF 0xff5,0xc9 00080e f0c9 000810 000a TBLRDPOSTDEC 000812 cff5 MOVFF 0xff5,0xca 000814 f0ca 000816 0012 RETURN 0x0 00068e 0e02 MOVLW 0x2 wCount._word = *(pSrc.wRom+1); // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000690 0100 MOVLB 0x0 000692 6af7 CLRF 0xf7,0x0 000694 25c9 ADDWF 0xc9,0x0,0x1 000696 6ef6 MOVWF 0xf6,0x0 000698 51ca MOVF 0xca,0x0,0x1 00069a 22f7 ADDWFC 0xf7,0x1,0x0 00069c 0009 TBLRDPOSTINC 00069e cff5 MOVFF 0xff5,0xcd 0006a0 f0cd 0006a2 000a TBLRDPOSTDEC 0006a4 cff5 MOVFF 0xff5,0xce 0006a6 f0ce 0006a8 d00e BRA 0x6c6 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case DSC_STR: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006aa d89c RCALL 0x7e4 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006ac 0e61 MOVLW 0x61 pSrc.bRom = *(USB_SD_Ptr+SetupPkt.bDscIndex); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006ae 26f6 ADDWF 0xf6,0x1,0x0 0006b0 0e0b MOVLW 0xb 0006b2 d8aa RCALL 0x808 0006b4 c0c9 MOVFF 0xc9,0xff6 wCount._word = *pSrc.bRom; // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006b6 fff6 0006b8 c0ca MOVFF 0xca,0xff7 0006ba fff7 0006bc 0008 TBLRD 0006be 50f5 MOVF 0xf5,0x0,0x0 0006c0 0100 MOVLB 0x0 0006c2 6fcd MOVWF 0xcd,0x1 0006c4 6bce CLRF 0xce,0x1 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c }//end switch C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006c6 0100 MOVLB 0x0 usb_stat.ctrl_trf_mem = _ROM; // Set memory type C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006c8 83d0 BSF 0xd0,0x1,0x1 }//end if C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006ca 0012 RETURN 0x0 }//end USBStdGetDscHandler C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Function: void USBStdSetCfgHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Overview: This routine first disables all endpoints by clearing C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * UEP registers. It then configures (initializes) endpoints C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * specified in the modifiable section. C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdSetCfgHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006cc d8b1 RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006ce 0e0f MOVLW 0xf mDisableEP1to15(); // See usbdrv.h C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006d0 6ee6 MOVWF 0xe6,0x0 0006d2 0e71 MOVLW 0x71 0006d4 6ee6 MOVWF 0xe6,0x0 0006d6 0e0f MOVLW 0xf 0006d8 d89f RCALL 0x818 000818 6ee6 MOVWF 0xe6,0x0 00081a eccc CALL 0x998,0x0 00081c f004 00081e 52e5 MOVF 0xe5,0x1,0x0 000820 52e5 MOVF 0xe5,0x1,0x0 000822 52e5 MOVF 0xe5,0x1,0x0 000824 0012 RETURN 0x0 0006da 0e01 MOVLW 0x1 ClearArray((byte*)&usb_alt_intf,MAX_NUM_INT); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006dc 6ee6 MOVWF 0xe6,0x0 0006de 0ed2 MOVLW 0xd2 0006e0 6ee6 MOVWF 0xe6,0x0 0006e2 0e00 MOVLW 0x0 0006e4 d899 RCALL 0x818 0006e6 c422 MOVFF 0x422,0xd1 usb_active_cfg = SetupPkt.bCfgValue; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006e8 f0d1 0006ea 0104 MOVLB 0x4 if(SetupPkt.bCfgValue == 0) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006ec 5122 MOVF 0x22,0x0,0x1 0006ee e104 BNZ 0x6f8 0006f0 0100 MOVLB 0x0 usb_device_state = ADDRESS_STATE; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006f2 0e05 MOVLW 0x5 0006f4 6fcf MOVWF 0xcf,0x1 0006f6 0012 RETURN 0x0 else C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006f8 0100 MOVLB 0x0 usb_device_state = CONFIGURED_STATE; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006fa 0e06 MOVLW 0x6 0006fc 6fcf MOVWF 0xcf,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /* Modifiable Section */ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c #if defined(USB_USE_CDC) // See autofiles\usbcfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0006fe ef6e GOTO 0xdc CDCInitEP(); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000700 f000 #endif C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /* End modifiable section */ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c }//end if(SetupPkt.bcfgValue == 0) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c }//end USBStdSetCfgHandler C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Function: void USBStdGetStatusHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Overview: This routine handles the standard GET_STATUS request C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdGetStatusHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000702 0104 MOVLB 0x4 CtrlTrfData._byte0 = 0; // Initialize content C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000704 6b28 CLRF 0x28,0x1 000706 6b29 CLRF 0x29,0x1 CtrlTrfData._byte1 = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000708 0104 MOVLB 0x4 switch(SetupPkt.Recipient) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00070a 5120 MOVF 0x20,0x0,0x1 00070c 0b1f ANDLW 0x1f 00070e 0a02 XORLW 0x2 000710 e011 BZ 0x734 000712 0a03 XORLW 0x3 000714 e00d BZ 0x730 000716 0a01 XORLW 0x1 000718 e11a BNZ 0x74e { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case RCPT_DEV: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00071a d88a RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * _byte0: bit0: Self-Powered Status [0] Bus-Powered [1] Self-Powered C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * bit1: RemoteWakeup [0] Disabled [1] Enabled C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00071c a480 BTFSS 0x80,0x2,0x0 if(self_power == 1) // self_power defined in io_cfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00071e d002 BRA 0x724 000720 0104 MOVLB 0x4 CtrlTrfData._byte0|=0b000000001; // Set bit0 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000722 8128 BSF 0x28,0x0,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000724 0100 MOVLB 0x0 if(usb_stat.RemoteWakeup == 1) // usb_stat defined in usbmmap.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000726 a1d0 BTFSS 0xd0,0x0,0x1 000728 d012 BRA 0x74e 00072a 0104 MOVLB 0x4 CtrlTrfData._byte0|=0b00000010; // Set bit1 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00072c 8328 BSF 0x28,0x1,0x1 00072e d00f BRA 0x74e break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case RCPT_INTF: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000730 d87f RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; // No data to update C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000732 d00d BRA 0x74e break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c case RCPT_EP: C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000734 d84b RCALL 0x7cc ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007cc d835 RCALL 0x838 000838 dffb RCALL 0x830 /* C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * _byte0: bit0: Halt Status [0] Not Halted [1] Halted C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000736 e001 BZ 0x73a pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000738 0e01 MOVLW 0x1 00073a d85d RCALL 0x7f6 0007ce 0b0f ANDLW 0xf 0007d0 0d08 MULLW 0x8 0007d2 50f3 MOVF 0xf3,0x0,0x0 0007d4 6a03 CLRF 0x3,0x0 0007d6 0f00 ADDLW 0x0 0007d8 6e02 MOVWF 0x2,0x0 0007da 0e04 MOVLW 0x4 0007dc 2203 ADDWFC 0x3,0x1,0x0 0007de 5124 MOVF 0x24,0x0,0x1 0007e0 0b80 ANDLW 0x80 0007e2 0012 RETURN 0x0 0007f6 0d04 MULLW 0x4 0007f8 50f3 MOVF 0xf3,0x0,0x0 0007fa 0100 MOVLB 0x0 0007fc 2402 ADDWF 0x2,0x0,0x0 0007fe 6fcb MOVWF 0xcb,0x1 000800 0e00 MOVLW 0x0 000802 2003 ADDWFC 0x3,0x0,0x0 000804 6fcc MOVWF 0xcc,0x1 000806 0012 RETURN 0x0 00083a 0104 MOVLB 0x4 00083c 5124 MOVF 0x24,0x0,0x1 00083e 0012 RETURN 0x0 00073c c0cb MOVFF 0xcb,0xfe9 if(*pDst.bRam & _BSTALL) // Use _BSTALL as a bit mask C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00073e ffe9 000740 6eea MOVWF 0xea,0x0 000742 50ef MOVF 0xef,0x0,0x0 000744 0b04 ANDLW 0x4 000746 e003 BZ 0x74e 000748 0104 MOVLB 0x4 CtrlTrfData._byte0=0x01;// Set bit0 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00074a 0e01 MOVLW 0x1 00074c 6f28 MOVWF 0x28,0x1 break; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c }//end switch C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00074e 0100 MOVLB 0x0 if(ctrl_trf_session_owner == MUID_USB9) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000750 05c8 DECF 0xc8,0x0,0x1 000752 e10a BNZ 0x768 { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000754 0100 MOVLB 0x0 pSrc.bRam = (byte*)&CtrlTrfData; // Set Source C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000756 0e28 MOVLW 0x28 000758 6fc9 MOVWF 0xc9,0x1 00075a 0e04 MOVLW 0x4 00075c 6fca MOVWF 0xca,0x1 00075e 0100 MOVLB 0x0 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000760 93d0 BCF 0xd0,0x1,0x1 000762 0100 MOVLB 0x0 LSB(wCount) = 2; // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000764 0e02 MOVLW 0x2 000766 6fcd MOVWF 0xcd,0x1 }//end if(...) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000768 0012 RETURN 0x0 }//end USBStdGetStatusHandler C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Function: void USBStdFeatureReqHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Overview: This routine handles the standard SET & CLEAR FEATURES C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * requests C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c void USBStdFeatureReqHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00076a 0104 MOVLB 0x4 if((SetupPkt.bFeature == DEVICE_REMOTE_WAKEUP)&& C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00076c 0522 DECF 0x22,0x0,0x1 00076e e10e BNZ 0x78c (SetupPkt.Recipient == RCPT_DEV)) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000770 5120 MOVF 0x20,0x0,0x1 000772 0b1f ANDLW 0x1f 000774 0900 IORLW 0x0 000776 e10a BNZ 0x78c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000778 d85b RCALL 0x830 ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00077a 0e03 MOVLW 0x3 if(SetupPkt.bRequest == SET_FEATURE) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00077c 0104 MOVLB 0x4 00077e 5d21 SUBWF 0x21,0x0,0x1 000780 e103 BNZ 0x788 000782 0100 MOVLB 0x0 usb_stat.RemoteWakeup = 1; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000784 81d0 BSF 0xd0,0x0,0x1 000786 d002 BRA 0x78c else C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000788 0100 MOVLB 0x0 usb_stat.RemoteWakeup = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00078a 91d0 BCF 0xd0,0x0,0x1 }//end if C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00078c 0104 MOVLB 0x4 if((SetupPkt.bFeature == ENDPOINT_HALT)&& C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00078e 5122 MOVF 0x22,0x0,0x1 000790 e11c BNZ 0x7ca (SetupPkt.Recipient == RCPT_EP)&& C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 000792 5120 MOVF 0x20,0x0,0x1 000794 0b1f ANDLW 0x1f 000796 0802 SUBLW 0x2 000798 e118 BNZ 0x7ca 00079a 5124 MOVF 0x24,0x0,0x1 (SetupPkt.EPNum != 0)) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 00079c 0b0f ANDLW 0xf 00079e 0900 IORLW 0x0 0007a0 e014 BZ 0x7ca { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007a2 d814 RCALL 0x7cc ctrl_trf_session_owner = MUID_USB9; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /* Must do address calculation here */ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007a4 e001 BZ 0x7a8 pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007a6 0e01 MOVLW 0x1 0007a8 d826 RCALL 0x7f6 C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007aa 0e03 MOVLW 0x3 if(SetupPkt.bRequest == SET_FEATURE) C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007ac 0104 MOVLB 0x4 0007ae 5d21 SUBWF 0x21,0x0,0x1 0007b0 e104 BNZ 0x7ba 0007b2 0e84 MOVLW 0x84 *pDst.bRam = _USIE|_BSTALL; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007b4 d838 RCALL 0x826 0007b6 6eef MOVWF 0xef,0x0 0007b8 0012 RETURN 0x0 else C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c { C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007ba af24 BTFSS 0x24,0x7,0x1 if(SetupPkt.EPDir == 1) // IN C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007bc d003 BRA 0x7c4 0007be d833 RCALL 0x826 *pDst.bRam = _UCPU; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007c0 6aef CLRF 0xef,0x0 0007c2 0012 RETURN 0x0 else C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007c4 0e88 MOVLW 0x88 *pDst.bRam = _USIE|_DAT0|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007c6 d82f RCALL 0x826 0007c8 6eef MOVWF 0xef,0x0 000826 c0cb MOVFF 0xcb,0xfe9 000828 ffe9 00082a c0cc MOVFF 0xcc,0xfea 00082c ffea 00082e 0012 RETURN 0x0 }//end if C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c }//end if C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c 0007ca 0012 RETURN 0x0 }//end USBStdFeatureReqHandler C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /** EOF usb9.c ***************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usb9\usb9.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * FileName: usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * license. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * -usbdsc.c- C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * This file contains the USB descriptor information. It is used C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * in conjunction with the usbdsc.h file. When a descriptor is added C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * or removed from the main configuration descriptor, i.e. CFG01, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * the user must also change the descriptor structure defined in C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * the usbdsc.h file. The structure is used to calculate the C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * descriptor size, i.e. sizeof(CFG01). C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * A typical configuration descriptor consists of: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * At least one configuration descriptor (USB_CFG_DSC) C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * One or more interface descriptors (USB_INTF_DSC) C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * One or more endpoint descriptors (USB_EP_DSC) C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Naming Convention: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * To resolve ambiguity, the naming convention are as followed: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * - USB_CFG_DSC type should be named cdxx, where xx is the C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * configuration number. This number should match the actual C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * index value of this configuration. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * - USB_INTF_DSC type should be named ia, where yy is the C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * interface number and zz is the alternate interface number. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * - USB_EP_DSC type should be named ep<##>_ia, where C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * ## is the endpoint number and d is the direction of transfer. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The interface name should also be listed as a suffix to identify C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * which interface does the endpoint belong to. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Example: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * If a device has one configuration, two interfaces; interface 0 C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * has two endpoints (in and out), and interface 1 has one endpoint(in). C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Then the CFG01 structure in the usbdsc.h should be: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * #define CFG01 rom struct \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * { USB_CFG_DSC cd01; \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * USB_INTF_DSC i00a00; \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * USB_EP_DSC ep01o_i00a00; \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * USB_EP_DSC ep01i_i00a00; \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * USB_INTF_DSC i01a00; \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * USB_EP_DSC ep02i_i01a00; \ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * } cfg01 C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Note the hierarchy of the descriptors above, it follows the USB C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * specification requirement. All endpoints belonging to an interface C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * should be listed immediately after that interface. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Filling in the descriptor values in the usbdsc.c file: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Most items should be self-explanatory, however, a few will be C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * explained for clarification. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * [Configuration Descriptor(USB_CFG_DSC)] C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The configuration attribute must always have the _DEFAULT C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * definition at the minimum. Additional options can be ORed C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * to the _DEFAULT attribute. Available options are _SELF and _RWU. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * These definitions are defined in the usbdefs_std_dsc.h file. The C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * _SELF tells the USB host that this device is self-powered. The C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * _RWU tells the USB host that this device supports Remote Wakeup. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * [Endpoint Descriptor(USB_EP_DSC)] C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Assume the following example: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * sizeof(USB_EP_DSC),DSC_EP,_EP01_OUT,_BULK,64,0x00 C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The first two parameters are self-explanatory. They specify the C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * length of this endpoint descriptor (7) and the descriptor type. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The next parameter identifies the endpoint, the definitions are C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * defined in usbdefs_std_dsc.h and has the following naming C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * convention: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * _EP<##>_ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * where ## is the endpoint number and dir is the direction of C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * transfer. The dir has the value of either 'OUT' or 'IN'. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The next parameter identifies the type of the endpoint. Available C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * options are _BULK, _INT, _ISO, and _CTRL. The _CTRL is not C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * typically used because the default control transfer endpoint is C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * not defined in the USB descriptors. When _ISO option is used, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * addition options can be ORed to _ISO. Example: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * _ISO|_AD|_FE C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * This describes the endpoint as an isochronous pipe with adaptive C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * and feedback attributes. See usbdefs_std_dsc.h and the USB C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * specification for details. The next parameter defines the size of C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * the endpoint. The last parameter in the polling interval. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Adding a USB String C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * A string descriptor array should have the following format: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * rom struct{byte bLength;byte bDscType;word string[size];}sdxxx={ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * sizeof(sdxxx),DSC_STR,}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The above structure provides a means for the C compiler to C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * calculate the length of string descriptor sdxxx, where xxx is the C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * index number. The first two bytes of the descriptor are descriptor C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * length and type. The rest are string texts which must be C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * in the unicode format. The unicode format is achieved by declaring C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * each character as a word type. The whole text string is declared C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * as a word array with the number of characters equals to . C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * has to be manually counted and entered into the array C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * declaration. Let's study this through an example: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * if the string is "USB" , then the string descriptor should be: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * (Using index 02) C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * rom struct{byte bLength;byte bDscType;word string[3];}sd002={ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * sizeof(sd002),DSC_STR,'U','S','B'}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * A USB project may have multiple strings and the firmware supports C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * the management of multiple strings through a look-up table. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The look-up table is defined as: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The above declaration has 3 strings, sd000, sd001, and sd002. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Strings can be removed or added. sd000 is a specialized string C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * descriptor. It defines the language code, usually this is C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * US English (0x0409). The index of the string must match the index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * position of the USB_SD_Ptr array, &sd000 must be in position C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * USB_SD_Ptr[0], &sd001 must be in position USB_SD_Ptr[1] and so on. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The look-up table USB_SD_Ptr is used by the get string handler C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * function in usb9.c. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The look-up table scheme also applies to the configuration C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * descriptor. A USB device may have multiple configuration C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * descriptors, i.e. CFG01, CFG02, etc. To add a configuration C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * descriptor, user must implement a structure similar to CFG01. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * The next step is to add the configuration descriptor name, i.e. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * cfg01, cfg02,.., to the look-up table USB_CD_Ptr. USB_CD_Ptr[0] C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * is a dummy place holder since configuration 0 is the un-configured C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * state according to the definition in the USB specification. C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Descriptor specific type definitions are defined in: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * system\usb\usbdefs\usbdefs_std_dsc.h C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * Configuration information is defined in: C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c * autofiles\usbcfg.h C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /** I N C L U D E S *************************************************/ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /** C O N S T A N T S ************************************************/ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c #pragma romdata C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Device Descriptor */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom USB_DEV_DSC device_dsc= C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c { C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_DEV_DSC), // Size of this descriptor in bytes C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c DSC_DEV, // DEVICE descriptor type C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x0200, // USB Spec Release Number in BCD format C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c CDC_DEVICE, // Class Code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x00, // Subclass code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x00, // Protocol code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c EP0_BUFF_SIZE, // Max packet size for EP0, see usbcfg.h C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x04D8, // Vendor ID C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x000A, // Product ID: CDC RS-232 Emulation Demo C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x0000, // Device release number in BCD format C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x01, // Manufacturer string index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x02, // Product string index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x00, // Device serial number string index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0x01 // Number of possible configurations C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c }; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Configuration 1 Descriptor */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c CFG01= C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c { C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Configuration Descriptor */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_CFG_DSC), // Size of this descriptor in bytes C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c DSC_CFG, // CONFIGURATION descriptor type C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(cfg01), // Total length of data for this cfg C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 2, // Number of interfaces in this cfg C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 1, // Index value of this configuration C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Configuration string index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c _DEFAULT, // Attributes, see usbdefs_std_dsc.h C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 50, // Max power consumption (2X mA) C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Interface Descriptor */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_INTF_DSC), // Size of this descriptor in bytes C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c DSC_INTF, // INTERFACE descriptor type C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Interface Number C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Alternate Setting Number C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 1, // Number of endpoints in this intf C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c COMM_INTF, // Class code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c ABSTRACT_CONTROL_MODEL, // Subclass code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c V25TER, // Protocol code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Interface string index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* CDC Class-Specific Descriptors */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_CDC_HEADER_FN_DSC),CS_INTERFACE,DSC_FN_HEADER,0x0110, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_CDC_ACM_FN_DSC),CS_INTERFACE,DSC_FN_ACM,0x02, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_CDC_UNION_FN_DSC),CS_INTERFACE,DSC_FN_UNION,CDC_COMM_INTF_ID,CDC_DATA_INTF_ID, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_CDC_CALL_MGT_FN_DSC),CS_INTERFACE,DSC_FN_CALL_MGT,0x00,CDC_DATA_INTF_ID, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Endpoint Descriptor */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP02_IN,_INT,CDC_INT_EP_SIZE,0x02, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Interface Descriptor */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_INTF_DSC), // Size of this descriptor in bytes C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c DSC_INTF, // INTERFACE descriptor type C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 1, // Interface Number C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Alternate Setting Number C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 2, // Number of endpoints in this intf C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c DATA_INTF, // Class code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Subclass code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c NO_PROTOCOL, // Protocol code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 0, // Interface string index C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /* Endpoint Descriptors */ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP03_OUT,_BULK,CDC_BULK_OUT_EP_SIZE,0x00, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP03_IN,_BULK,CDC_BULK_IN_EP_SIZE,0x00 C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c }; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[1];}sd000={ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(sd000),DSC_STR,0x0409}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[25];}sd001={ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(sd001),DSC_STR, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 'M','i','c','r','o','c','h','i','p',' ', C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[25];}sd002={ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c sizeof(sd002),DSC_STR, C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 'C','D','C',' ','R','S','-','2','3','2',' ', C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c 'E','m','u','l','a','t','i','o','n',' ','D','e','m','o'}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom const unsigned char *rom USB_CD_Ptr[]={&cfg01,&cfg01}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c rom pFunc ClassReqHandler[1]= C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c { C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c &USBCheckCDCRequest C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c }; C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c #pragma code C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /** EOF usbdsc.c ****************************************************/ C:\MCHPFSUSB\fw\cdc\autofiles\usbdsc.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * FileName: usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * license. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Rawin Rojvanit 11/19/04 Original. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c #include C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /** V A R I A B L E S ********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c #pragma udata C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c byte ctrl_trf_state; // Control Transfer State C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c byte ctrl_trf_session_owner; // Current transfer session owner C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c POINTER pSrc; // Data source pointer C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c POINTER pDst; // Data destination pointer C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c WORD wCount; // Data counter C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfSetupHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfOutHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfInHandler(void); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /** D E C L A R A T I O N S **************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c #pragma code C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlEPService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: USTAT is loaded with a valid endpoint address. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: USBCtrlEPService checks for three transaction types that C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * it knows how to service and services them: C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 1. EP0 SETUP C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 2. EP0 OUT C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 3. EP0 IN C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * It ignores all other types (i.e. EP1, EP2, etc.) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlEPService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000330 506c MOVF 0x6c,0x0,0x0 if(USTAT == EP00_OUT) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000332 e002 BZ 0x338 000334 0e00 MOVLW 0x0 000336 d001 BRA 0x33a 000338 0e01 MOVLW 0x1 00033a 0900 IORLW 0x0 00033c e00b BZ 0x354 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00033e 0104 MOVLB 0x4 if(ep0Bo.Stat.PID == SETUP_TOKEN) // EP0 SETUP C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000340 5100 MOVF 0x0,0x0,0x1 000342 0b3c ANDLW 0x3c 000344 42e8 RRNCF 0xe8,0x1,0x0 000346 42e8 RRNCF 0xe8,0x1,0x0 000348 080d SUBLW 0xd 00034a e102 BNZ 0x350 00034c efb3 GOTO 0x366 USBCtrlTrfSetupHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00034e f001 else // EP0 OUT C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000350 efe8 GOTO 0x3d0 USBCtrlTrfOutHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000352 f001 } C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000354 506c MOVF 0x6c,0x0,0x0 else if(USTAT == EP00_IN) // EP0 IN C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000356 e002 BZ 0x35c 000358 0e00 MOVLW 0x0 00035a d001 BRA 0x35e 00035c 0e01 MOVLW 0x1 00035e 0904 IORLW 0x4 000360 e001 BZ 0x364 000362 d845 RCALL 0x3ee USBCtrlTrfInHandler(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000364 0012 RETURN 0x0 }//end USBCtrlEPService C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfSetupHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: SetupPkt buffer is loaded with valid USB Setup Data C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine is a task dispatcher and has 3 stages. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 1. It initializes the control transfer state machine. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 2. It calls on each of the module that may know how to C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * service the Setup Request from the host. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Module Example: USB9, HID, CDC, MSD, ... C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * As new classes are added, ClassReqHandler table in C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * usbdsc.c should be updated to call all available C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * class handlers. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 3. Once each of the modules has had a chance to check if C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * it is responsible for servicing the request, stage 3 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * then checks direction of the transfer to determine how C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * to prepare EP0 for the control transfer. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Refer to USBCtrlEPServiceComplete() for more details. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: Microchip USB Firmware has three different states for C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * the control transfer state machine: C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 1. WAIT_SETUP C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 2. CTRL_TRF_TX C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 3. CTRL_TRF_RX C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Refer to firmware manual to find out how one state C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * is transitioned to another. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * A Control Transfer is composed of many USB transactions. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * When transferring data over multiple transactions, C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * it is important to keep track of data source, data C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * destination, and data count. These three parameters are C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * stored in pSrc,pDst, and wCount. A flag is used to C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * note if the data source is from ROM or RAM. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000366 cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfSetupHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000368 ffe6 00036a cfe1 MOVFF 0xfe1,0xfd9 00036c ffd9 00036e 52e6 MOVF 0xe6,0x1,0x0 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c byte i; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* Stage 1 */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000370 0100 MOVLB 0x0 ctrl_trf_state = WAIT_SETUP; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000372 6bc7 CLRF 0xc7,0x1 000374 6bc8 CLRF 0xc8,0x1 ctrl_trf_session_owner = MUID_NULL; // Set owner to NULL C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000376 6bcd CLRF 0xcd,0x1 wCount._word = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000378 6bce CLRF 0xce,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* Stage 2 */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00037a ece0 CALL 0x5c0,0x0 USBCheckStdRequest(); // See system\usb9\usb9.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00037c f002 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00037e 6adf CLRF 0xdf,0x0 for(i=0;i < (sizeof(ClassReqHandler)/sizeof(pFunc));i++) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000380 50df MOVF 0xdf,0x0,0x0 000382 6e02 MOVWF 0x2,0x0 000384 6a03 CLRF 0x3,0x0 000386 0e01 MOVLW 0x1 000388 5c02 SUBWF 0x2,0x0,0x0 00038a 0e00 MOVLW 0x0 00038c 5803 SUBWFB 0x3,0x0,0x0 00038e e21a BC 0x3c4 0003c0 2adf INCF 0xdf,0x1,0x0 0003c2 d7de BRA 0x380 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000390 0100 MOVLB 0x0 if(ctrl_trf_session_owner != MUID_NULL)break; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000392 51c8 MOVF 0xc8,0x0,0x1 000394 e117 BNZ 0x3c4 000396 6af7 CLRF 0xf7,0x0 ClassReqHandler[i](); // See autofiles\usbdsc.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000398 34df RLCF 0xdf,0x0,0x0 00039a 0bfe ANDLW 0xfe 00039c 36f7 RLCF 0xf7,0x1,0x0 00039e 6ef6 MOVWF 0xf6,0x0 0003a0 0e67 MOVLW 0x67 0003a2 26f6 ADDWF 0xf6,0x1,0x0 0003a4 0e0b MOVLW 0xb 0003a6 22f7 ADDWFC 0xf7,0x1,0x0 0003a8 0009 TBLRDPOSTINC 0003aa cff5 MOVFF 0xff5,0x2 0003ac f002 0003ae 0008 TBLRD 0003b0 cff5 MOVFF 0xff5,0x3 0003b2 f003 0003b4 d004 BRA 0x3be 0003b6 c003 MOVFF 0x3,0xffa 0003b8 fffa 0003ba 5002 MOVF 0x2,0x0,0x0 0003bc 6ef9 MOVWF 0xf9,0x0 0003be dffb RCALL 0x3b6 }//end while C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* Stage 3 */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003c4 d890 RCALL 0x4e6 USBCtrlEPServiceComplete(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003c6 52e5 MOVF 0xe5,0x1,0x0 }//end USBCtrlTrfSetupHandler C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003c8 52e5 MOVF 0xe5,0x1,0x0 0003ca cfe7 MOVFF 0xfe7,0xfd9 0003cc ffd9 0003ce 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfOutHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine handles an OUT transaction according to C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * which control transfer state is currently active. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: Note that if the the control transfer was from C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * host to device, the session owner should be notified C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * at the end of each OUT transaction to service the C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * received data. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfOutHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003d0 0e02 MOVLW 0x2 if(ctrl_trf_state == CTRL_TRF_RX) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003d2 0100 MOVLB 0x0 0003d4 5dc7 SUBWF 0xc7,0x0,0x1 0003d6 e109 BNZ 0x3ea { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003d8 d862 RCALL 0x49e USBCtrlTrfRxService(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Don't have to worry about overwriting _KEEP bit C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * because if _KEEP was set, TRNIF would not have been C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * generated in the first place. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003da 0104 MOVLB 0x4 if(ep0Bo.Stat.DTS == 0) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003dc bd00 BTFSC 0x0,0x6,0x1 0003de d002 BRA 0x3e4 0003e0 0ec8 MOVLW 0xc8 ep0Bo.Stat._byte = _USIE|_DAT1|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003e2 d001 BRA 0x3e6 else C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003e4 0e88 MOVLW 0x88 ep0Bo.Stat._byte = _USIE|_DAT0|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003e6 6f00 MOVWF 0x0,0x1 } C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003e8 0012 RETURN 0x0 else // CTRL_TRF_TX C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003ea efac GOTO 0x558 USBPrepareForNextSetupTrf(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003ec f002 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c }//end USBCtrlTrfOutHandler C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfInHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine handles an IN transaction according to C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * which control transfer state is currently active. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: A Set Address Request must not change the acutal address C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * of the device until the completion of the control C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * transfer. The end of the control transfer for Set Address C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Request is an IN transaction. Therefore it is necessary C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * to service this unique situation when the condition is C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * right. Macro mUSBCheckAdrPendingState is defined in C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * usb9.h and its function is to specifically service this C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * event. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfInHandler(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003ee 0e04 MOVLW 0x4 mUSBCheckAdrPendingState(); // Must check if in ADR_PENDING_STATE C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0003f0 0100 MOVLB 0x0 0003f2 5dcf SUBWF 0xcf,0x0,0x1 0003f4 e109 BNZ 0x408 0003f6 c422 MOVFF 0x422,0xf6e 0003f8 ff6e 0003fa 506e MOVF 0x6e,0x0,0x0 0003fc 0800 SUBLW 0x0 0003fe e202 BC 0x404 000400 0e05 MOVLW 0x5 000402 d001 BRA 0x406 000404 0e03 MOVLW 0x3 000406 6fcf MOVWF 0xcf,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000408 0100 MOVLB 0x0 if(ctrl_trf_state == CTRL_TRF_TX) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00040a 05c7 DECF 0xc7,0x0,0x1 00040c e109 BNZ 0x420 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00040e d80a RCALL 0x424 USBCtrlTrfTxService(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000410 0104 MOVLB 0x4 if(ep0Bi.Stat.DTS == 0) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000412 bd04 BTFSC 0x4,0x6,0x1 000414 d002 BRA 0x41a 000416 0ec8 MOVLW 0xc8 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000418 d001 BRA 0x41c else C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00041a 0e88 MOVLW 0x88 ep0Bi.Stat._byte = _USIE|_DAT0|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00041c 6f04 MOVWF 0x4,0x1 } C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00041e 0012 RETURN 0x0 else // CTRL_TRF_RX C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000420 efac GOTO 0x558 USBPrepareForNextSetupTrf(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000422 f002 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c }//end USBCtrlTrfInHandler C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfTxService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: pSrc, wCount, and usb_stat.ctrl_trf_mem are setup properly. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine should be called from only two places. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * One from USBCtrlEPServiceComplete() and one from C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * USBCtrlTrfInHandler(). It takes care of managing a C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * transfer over multiple USB transactions. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: This routine works with isochronous endpoint larger than C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 256 bytes and is shown here as an example of how to deal C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * with BC9 and BC8. In reality, a control endpoint can never C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * be larger than 64 bytes. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000424 d8b8 RCALL 0x596 void USBCtrlTrfTxService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000596 cfd9 MOVFF 0xfd9,0xfe6 000598 ffe6 00059a cfe1 MOVFF 0xfe1,0xfd9 00059c ffd9 00059e 0e02 MOVLW 0x2 0005a0 26e1 ADDWF 0xe1,0x1,0x0 0005a2 0012 RETURN 0x0 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c WORD byte_to_send; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * First, have to figure out how many byte of data to send. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000426 0100 MOVLB 0x0 if(wCount._word < EP0_BUFF_SIZE) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000428 0e08 MOVLW 0x8 00042a 5dcd SUBWF 0xcd,0x0,0x1 00042c 0e00 MOVLW 0x0 00042e 59ce SUBWFB 0xce,0x0,0x1 000430 e205 BC 0x43c 000432 c0cd MOVFF 0xcd,0xfde byte_to_send._word = wCount._word; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000434 ffde 000436 c0ce MOVFF 0xce,0xfdd 000438 ffdd 00043a d003 BRA 0x442 else C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00043c 0e08 MOVLW 0x8 byte_to_send._word = EP0_BUFF_SIZE; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00043e 6ede MOVWF 0xde,0x0 000440 6add CLRF 0xdd,0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Next, load the number of bytes to send to BC9..0 in buffer descriptor C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000442 0104 MOVLB 0x4 ep0Bi.Stat.BC9 = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000444 9304 BCF 0x4,0x1,0x1 000446 9104 BCF 0x4,0x0,0x1 ep0Bi.Stat.BC8 = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000448 0e01 MOVLW 0x1 ep0Bi.Stat._byte |= MSB(byte_to_send); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00044a 50db MOVF 0xdb,0x0,0x0 00044c 1304 IORWF 0x4,0x1,0x1 00044e cfdf MOVFF 0xfdf,0x405 ep0Bi.Cnt = LSB(byte_to_send); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000450 f405 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Subtract the number of bytes just about to be sent from the total. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000452 0e00 MOVLW 0x0 wCount._word = wCount._word - byte_to_send._word; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000454 50db MOVF 0xdb,0x0,0x0 000456 0100 MOVLB 0x0 000458 5fcd SUBWF 0xcd,0x1,0x1 00045a 0e01 MOVLW 0x1 00045c 50db MOVF 0xdb,0x0,0x0 00045e 5bce SUBWFB 0xce,0x1,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000460 0e28 MOVLW 0x28 pDst.bRam = (byte*)&CtrlTrfData; // Set destination pointer C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000462 6fcb MOVWF 0xcb,0x1 000464 0e04 MOVLW 0x4 000466 6fcc MOVWF 0xcc,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000468 0100 MOVLB 0x0 if(usb_stat.ctrl_trf_mem == _ROM) // Determine type of memory source C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00046a a3d0 BTFSS 0xd0,0x1,0x1 00046c d00c BRA 0x486 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00046e d88c RCALL 0x588 while(byte_to_send._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000470 e015 BZ 0x49c 000484 d7f4 BRA 0x46e { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000472 c0c9 MOVFF 0xc9,0xff6 *pDst.bRam = *pSrc.bRom; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000474 fff6 000476 c0ca MOVFF 0xca,0xff7 000478 fff7 00047a 0008 TBLRD 00047c 50f5 MOVF 0xf5,0x0,0x0 00047e d874 RCALL 0x568 000568 c0cb MOVFF 0xcb,0xfe9 00056a ffe9 00056c c0cc MOVFF 0xcc,0xfea 00056e ffea 000570 6eef MOVWF 0xef,0x0 000572 0100 MOVLB 0x0 pDst.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000574 efd8 GOTO 0x5b0 000576 f002 pSrc.bRom++; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000480 e2f6 BC 0x46e byte_to_send._word--; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000482 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_send._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c } C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c else // RAM C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000486 d880 RCALL 0x588 while(byte_to_send._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000488 e009 BZ 0x49c 00049a d7f5 BRA 0x486 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00048a c0c9 MOVFF 0xc9,0xfe9 *pDst.bRam = *pSrc.bRam; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00048c ffe9 00048e c0ca MOVFF 0xca,0xfea 000490 ffea 000492 50ef MOVF 0xef,0x0,0x0 000494 d869 RCALL 0x568 pDst.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c pSrc.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000496 e2f7 BC 0x486 byte_to_send._word--; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000498 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_send._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c }//end if(usb_stat.ctrl_trf_mem == _ROM) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00049c d083 BRA 0x5a4 }//end USBCtrlTrfTxService C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0005a4 cfd9 MOVFF 0xfd9,0xfe1 0005a6 ffe1 0005a8 52e5 MOVF 0xe5,0x1,0x0 0005aa cfe7 MOVFF 0xfe7,0xfd9 0005ac ffd9 0005ae 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfRxService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: pDst and wCount are setup properly. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * pSrc is always &CtrlTrfData C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * usb_stat.ctrl_trf_mem is always _RAM. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * wCount should be set to 0 at the start of each control C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * transfer. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: *** This routine is only partially complete. Check for C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * new version of the firmware. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00049e d87b RCALL 0x596 void USBCtrlTrfRxService(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c WORD byte_to_read; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004a0 0e03 MOVLW 0x3 MSB(byte_to_read) = 0x03 & ep0Bo.Stat._byte; // Filter out last 2 bits C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004a2 0104 MOVLB 0x4 0004a4 1500 ANDWF 0x0,0x0,0x1 0004a6 6ee7 MOVWF 0xe7,0x0 0004a8 0e01 MOVLW 0x1 0004aa cfe7 MOVFF 0xfe7,0xfdb 0004ac ffdb 0004ae c401 MOVFF 0x401,0xfdf LSB(byte_to_read) = ep0Bo.Cnt; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004b0 ffdf C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Accumulate total number of bytes read C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004b2 50de MOVF 0xde,0x0,0x0 wCount._word = wCount._word + byte_to_read._word; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004b4 0100 MOVLB 0x0 0004b6 27cd ADDWF 0xcd,0x1,0x1 0004b8 50dd MOVF 0xdd,0x0,0x0 0004ba 23ce ADDWFC 0xce,0x1,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004bc 0e28 MOVLW 0x28 pSrc.bRam = (byte*)&CtrlTrfData; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004be 6fc9 MOVWF 0xc9,0x1 0004c0 0e04 MOVLW 0x4 0004c2 6fca MOVWF 0xca,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004c4 d861 RCALL 0x588 while(byte_to_read._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004c6 e00e BZ 0x4e4 0004e2 d7f0 BRA 0x4c4 000588 cfd9 MOVFF 0xfd9,0xfe9 00058a ffe9 00058c cfda MOVFF 0xfda,0xfea 00058e ffea 000590 50ee MOVF 0xee,0x0,0x0 000592 10ed IORWF 0xed,0x0,0x0 000594 0012 RETURN 0x0 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004c8 c0c9 MOVFF 0xc9,0xfe9 *pDst.bRam = *pSrc.bRam; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004ca ffe9 0004cc c0ca MOVFF 0xca,0xfea 0004ce ffea 0004d0 50ef MOVF 0xef,0x0,0x0 0004d2 c0cb MOVFF 0xcb,0xfe9 0004d4 ffe9 0004d6 c0cc MOVFF 0xcc,0xfea 0004d8 ffea 0004da 6eef MOVWF 0xef,0x0 0004dc d869 RCALL 0x5b0 pDst.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0005b0 2bcb INCF 0xcb,0x1,0x1 0005b2 0e00 MOVLW 0x0 0005b4 23cc ADDWFC 0xcc,0x1,0x1 0005b6 2bc9 INCF 0xc9,0x1,0x1 pSrc.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0005b8 23ca ADDWFC 0xca,0x1,0x1 0004de e2f2 BC 0x4c4 byte_to_read._word--; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004e0 06db DECF 0xdb,0x1,0x0 0005ba 06df DECF 0xdf,0x1,0x0 0005bc 0e01 MOVLW 0x1 0005be 0012 RETURN 0x0 }//end while(byte_to_read._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004e4 d05f BRA 0x5a4 }//end USBCtrlTrfRxService C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlEPServiceComplete(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine wrap up the ramaining tasks in servicing C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * a Setup Request. Its main task is to set the endpoint C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * controls appropriately for a given situation. See code C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * below. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * There are three main scenarios: C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * a) There was no handler for the Request, in this case C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * a STALL should be sent out. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * b) The host has requested a read control transfer, C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * endpoints are required to be setup in a specific way. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * c) The host has requested a write control transfer, or C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * a control data stage is not required, endpoints are C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * required to be setup in a specific way. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Packet processing is resumed by clearing PKTDIS bit. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlEPServiceComplete(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004e6 0100 MOVLB 0x0 if(ctrl_trf_session_owner == MUID_NULL) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004e8 51c8 MOVF 0xc8,0x0,0x1 0004ea e105 BNZ 0x4f6 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * If no one knows how to service this request then stall. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Must also prepare EP0 to receive the next SETUP transaction. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004ec d845 RCALL 0x578 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c ep0Bo.ADR = (byte*)&SetupPkt; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004ee 0e84 MOVLW 0x84 ep0Bo.Stat._byte = _USIE|_BSTALL; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004f0 6f00 MOVWF 0x0,0x1 0004f2 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_BSTALL; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c } C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004f4 d01d BRA 0x530 else // A module has claimed ownership of the control transfer session. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004f6 0104 MOVLB 0x4 if(SetupPkt.DataDir == DEV_TO_HOST) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004f8 af20 BTFSS 0x20,0x7,0x1 0004fa d01c BRA 0x534 { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004fc 0100 MOVLB 0x0 if(SetupPkt.wLength < wCount._word) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 0004fe 51cd MOVF 0xcd,0x0,0x1 000500 0104 MOVLB 0x4 000502 5d26 SUBWF 0x26,0x0,0x1 000504 0100 MOVLB 0x0 000506 51ce MOVF 0xce,0x0,0x1 000508 0104 MOVLB 0x4 00050a 5927 SUBWFB 0x27,0x0,0x1 00050c e204 BC 0x516 00050e c426 MOVFF 0x426,0xcd wCount._word = SetupPkt.wLength; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000510 f0cd 000512 c427 MOVFF 0x427,0xce 000514 f0ce 000516 df86 RCALL 0x424 USBCtrlTrfTxService(); C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000518 0100 MOVLB 0x0 ctrl_trf_state = CTRL_TRF_TX; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00051a 0e01 MOVLW 0x1 00051c 6fc7 MOVWF 0xc7,0x1 /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Control Read: C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * ... | C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 1. Prepare OUT EP to respond to early termination C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * NOTE: C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * If something went wrong during the control transfer, C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * the last status stage may not be sent by the host. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * When this happens, two different things could happen C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * depending on the host. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * a) The host could send out a RESET. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * b) The host could send out a new SETUP transaction C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * without sending a RESET first. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * To properly handle case (b), the OUT EP must be setup C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * to receive either a zero length OUT transaction, or a C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * new SETUP transaction. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Since the SETUP transaction requires the DTS bit to be C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * DAT0 while the zero length OUT status requires the DTS C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * bit to be DAT1, the DTS bit check by the hardware should C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * be disabled. This way the SIE could accept either of C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * the two transactions. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Furthermore, the Cnt byte should be set to prepare for C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * the SETUP data (8-byte or more), and the buffer address C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * should be pointed to SetupPkt. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00051e d82c RCALL 0x578 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c ep0Bo.ADR = (byte*)&SetupPkt; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000520 0e80 MOVLW 0x80 ep0Bo.Stat._byte = _USIE; // Note: DTSEN is 0! C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000522 6f00 MOVWF 0x0,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 2. Prepare IN EP to transfer data, Cnt should have C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * been initialized by responsible request owner. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000524 0104 MOVLB 0x4 ep0Bi.ADR = (byte*)&CtrlTrfData; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000526 0e28 MOVLW 0x28 000528 6f06 MOVWF 0x6,0x1 00052a 0e04 MOVLW 0x4 00052c 6f07 MOVWF 0x7,0x1 00052e 0ec8 MOVLW 0xc8 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000530 6f04 MOVWF 0x4,0x1 } C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000532 d010 BRA 0x554 else // (SetupPkt.DataDir == HOST_TO_DEV) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000534 0100 MOVLB 0x0 ctrl_trf_state = CTRL_TRF_RX; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000536 0e02 MOVLW 0x2 000538 6fc7 MOVWF 0xc7,0x1 /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Control Write: C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * ... | C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 1. Prepare IN EP to respond to early termination C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * This is the same as a Zero Length Packet Response C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * for control transfer without a data stage C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00053a 0104 MOVLB 0x4 ep0Bi.Cnt = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00053c 6b05 CLRF 0x5,0x1 00053e 0ec8 MOVLW 0xc8 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000540 6f04 MOVWF 0x4,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * 2. Prepare OUT EP to receive data. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000542 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000544 0e08 MOVLW 0x8 000546 6f01 MOVWF 0x1,0x1 000548 0e28 MOVLW 0x28 ep0Bo.ADR = (byte*)&CtrlTrfData; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00054a 6f02 MOVWF 0x2,0x1 00054c 0e04 MOVLW 0x4 00054e 6f03 MOVWF 0x3,0x1 000550 0ec8 MOVLW 0xc8 ep0Bo.Stat._byte = _USIE|_DAT1|_DTSEN; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000552 6f00 MOVWF 0x0,0x1 }//end if(SetupPkt.DataDir == DEV_TO_HOST) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c }//end if(ctrl_trf_session_owner == MUID_NULL) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /* C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PKTDIS bit is set when a Setup Transaction is received. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Clear to resume packet processing. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c */ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000554 986d BCF 0x6d,0x4,0x0 UCONbits.PKTDIS = 0; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000556 0012 RETURN 0x0 }//end USBCtrlEPServiceComplete C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBPrepareForNextSetupTrf(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Overview: The routine forces EP0 OUT to be ready for a new Setup C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * transaction, and forces EP0 IN to be owned by CPU. C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c void USBPrepareForNextSetupTrf(void) C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c { C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000558 0100 MOVLB 0x0 ctrl_trf_state = WAIT_SETUP; // See usbctrltrf.h C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 00055a 6bc7 CLRF 0xc7,0x1 00055c d80d RCALL 0x578 ep0Bo.Cnt = EP0_BUFF_SIZE; // Defined in usbcfg.h C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000578 0104 MOVLB 0x4 00057a 0e08 MOVLW 0x8 00057c 6f01 MOVWF 0x1,0x1 00057e 0e20 MOVLW 0x20 ep0Bo.ADR = (byte*)&SetupPkt; C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000580 6f02 MOVWF 0x2,0x1 000582 0e04 MOVLW 0x4 000584 6f03 MOVWF 0x3,0x1 000586 0012 RETURN 0x0 00055e 0e88 MOVLW 0x88 ep0Bo.Stat._byte = _USIE|_DAT0|_DTSEN; // EP0 buff dsc init, see usbmmap.h C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000560 6f00 MOVWF 0x0,0x1 000562 0104 MOVLB 0x4 ep0Bi.Stat._byte = _UCPU; // EP0 IN buffer initialization C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c 000564 6b04 CLRF 0x4,0x1 000566 0012 RETURN 0x0 }//end USBPrepareForNextSetupTrf C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /** EOF usbctrltrf.c *********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\usbctrltrf\usbctrltrf.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Microchip USB C18 Firmware Version 1.0 C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\user\user.c * FileName: user.c C:\MCHPFSUSB\fw\cdc\user\user.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\user\user.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\user\user.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\user\user.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\user\user.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\user\user.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\user\user.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\user\user.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\user\user.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\user\user.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\user\user.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\user\user.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\user\user.c * license. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\user\user.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\user\user.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\user\user.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\user\user.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\user\user.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\user\user.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\user\user.c * Rawin Rojvanit 11/19/04 Original. C:\MCHPFSUSB\fw\cdc\user\user.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\user\user.c * CDC RS-232 Emulation Tutorial Instructions: C:\MCHPFSUSB\fw\cdc\user\user.c ****************************************************************************** C:\MCHPFSUSB\fw\cdc\user\user.c * Refer to Application Note AN956 for explanation of the CDC class. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * First take a look at Exercise_Example() and study how functions are called. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * There are five exercises, each one has a solution in the CDC\user\solutions. C:\MCHPFSUSB\fw\cdc\user\user.c * Scroll down and look for Exercise_01,_02,_03,_04, and _05. C:\MCHPFSUSB\fw\cdc\user\user.c * Instructions on what to do is inside each function. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c #include C:\MCHPFSUSB\fw\cdc\user\user.c #include C:\MCHPFSUSB\fw\cdc\user\user.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c #include "io_cfg.h" // I/O pin mapping C:\MCHPFSUSB\fw\cdc\user\user.c #include "user\user.h" C:\MCHPFSUSB\fw\cdc\user\user.c #include "user\temperature.h" C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /** V A R I A B L E S ********************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c #pragma udata C:\MCHPFSUSB\fw\cdc\user\user.c byte old_sw2,old_sw3; C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c char input_buffer[64]; C:\MCHPFSUSB\fw\cdc\user\user.c //char output_buffer[64]; C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c //rom char welcome[]={"PIC18F2550 Full-Speed USB - CDC RS-232 Emulation Demo\r\n\r\n"}; C:\MCHPFSUSB\fw\cdc\user\user.c //rom char ansi_clrscr[]={"\x1b[2J"}; // ANSI Clear Screen Command C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c void InitializeUSART(void); C:\MCHPFSUSB\fw\cdc\user\user.c void BlinkUSBStatus(void); C:\MCHPFSUSB\fw\cdc\user\user.c BOOL Switch2IsPressed(void); C:\MCHPFSUSB\fw\cdc\user\user.c BOOL Switch3IsPressed(void); C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /** D E C L A R A T I O N S **************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c #pragma code C:\MCHPFSUSB\fw\cdc\user\user.c void UserInit(void) C:\MCHPFSUSB\fw\cdc\user\user.c { C:\MCHPFSUSB\fw\cdc\user\user.c 0009c2 0ef8 MOVLW 0xf8 mInitAllLEDs(); C:\MCHPFSUSB\fw\cdc\user\user.c 0009c4 168a ANDWF 0x8a,0x1,0x0 0009c6 1693 ANDWF 0x93,0x1,0x0 // mInitAllSwitches(); C:\MCHPFSUSB\fw\cdc\user\user.c // old_sw2 = sw2; C:\MCHPFSUSB\fw\cdc\user\user.c // old_sw3 = sw3; C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c // InitTempSensor(); C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c // InitializeUSART(); C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c 0009c8 0012 RETURN 0x0 }//end UserInit C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c //void InitializeUSART(void) C:\MCHPFSUSB\fw\cdc\user\user.c //{ C:\MCHPFSUSB\fw\cdc\user\user.c // TRISCbits.TRISC7=1; // RX C:\MCHPFSUSB\fw\cdc\user\user.c // TRISCbits.TRISC6=0; // TX C:\MCHPFSUSB\fw\cdc\user\user.c // SPBRG = 0x71; C:\MCHPFSUSB\fw\cdc\user\user.c // SPBRGH = 0x02; // 0x0271 for 48MHz -> 19200 baud C:\MCHPFSUSB\fw\cdc\user\user.c // TXSTA = 0x24; // TX enable BRGH=1 C:\MCHPFSUSB\fw\cdc\user\user.c // RCSTA = 0x90; // continuous RX C:\MCHPFSUSB\fw\cdc\user\user.c // BAUDCON = 0x08; // BRG16 = 1 C:\MCHPFSUSB\fw\cdc\user\user.c //}//end InitializeUSART C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\user\user.c * Function: void ProcessIO(void) C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Input: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Output: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Overview: This function is a place holder for other user routines. C:\MCHPFSUSB\fw\cdc\user\user.c * It is a mixture of both USB and non-USB tasks. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Note: None C:\MCHPFSUSB\fw\cdc\user\user.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c void ProcessIO(void) C:\MCHPFSUSB\fw\cdc\user\user.c { C:\MCHPFSUSB\fw\cdc\user\user.c 0009ca d827 RCALL 0xa1a BlinkUSBStatus(); C:\MCHPFSUSB\fw\cdc\user\user.c // User Application USB tasks C:\MCHPFSUSB\fw\cdc\user\user.c 0009cc 0e06 MOVLW 0x6 if((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1)) return; C:\MCHPFSUSB\fw\cdc\user\user.c 0009ce 0100 MOVLB 0x0 0009d0 5dcf SUBWF 0xcf,0x0,0x1 0009d2 e322 BNC 0xa18 0009d4 506d MOVF 0x6d,0x0,0x0 0009d6 0b02 ANDLW 0x2 0009d8 e001 BZ 0x9dc 0009da 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c 0009dc 0e01 MOVLW 0x1 if(getsUSBUSART(input_buffer,1)) C:\MCHPFSUSB\fw\cdc\user\user.c 0009de 6ee6 MOVWF 0xe6,0x0 0009e0 0e62 MOVLW 0x62 0009e2 6ee6 MOVWF 0xe6,0x0 0009e4 0e00 MOVLW 0x0 0009e6 6ee6 MOVWF 0xe6,0x0 0009e8 ec96 CALL 0x12c,0x0 0009ea f000 0009ec 52e5 MOVF 0xe5,0x1,0x0 0009ee 52e5 MOVF 0xe5,0x1,0x0 0009f0 52e5 MOVF 0xe5,0x1,0x0 0009f2 0900 IORLW 0x0 0009f4 e011 BZ 0xa18 { C:\MCHPFSUSB\fw\cdc\user\user.c 0009f6 0100 MOVLB 0x0 if(mUSBUSARTIsTxTrfReady()) C:\MCHPFSUSB\fw\cdc\user\user.c 0009f8 51a3 MOVF 0xa3,0x0,0x1 0009fa e10e BNZ 0xa18 { C:\MCHPFSUSB\fw\cdc\user\user.c 0009fc 0100 MOVLB 0x0 input_buffer[0]++; C:\MCHPFSUSB\fw\cdc\user\user.c 0009fe 2b62 INCF 0x62,0x1,0x1 000a00 0100 MOVLB 0x0 mUSBUSARTTxRam((byte *)input_buffer,1); C:\MCHPFSUSB\fw\cdc\user\user.c 000a02 0e62 MOVLW 0x62 000a04 6fa4 MOVWF 0xa4,0x1 000a06 0e00 MOVLW 0x0 000a08 6fa5 MOVWF 0xa5,0x1 000a0a 0100 MOVLB 0x0 000a0c 0e01 MOVLW 0x1 000a0e 6fa8 MOVWF 0xa8,0x1 000a10 0100 MOVLB 0x0 000a12 6ba9 CLRF 0xa9,0x1 000a14 0100 MOVLB 0x0 000a16 6fa3 MOVWF 0xa3,0x1 } C:\MCHPFSUSB\fw\cdc\user\user.c } C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c 000a18 0012 RETURN 0x0 }//end ProcessIO C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\user\user.c * Function: void BlinkUSBStatus(void) C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Input: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Output: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Overview: BlinkUSBStatus turns on and off LEDs corresponding to C:\MCHPFSUSB\fw\cdc\user\user.c * the USB device state. C:\MCHPFSUSB\fw\cdc\user\user.c * C:\MCHPFSUSB\fw\cdc\user\user.c * Note: mLED macros can be found in io_cfg.h C:\MCHPFSUSB\fw\cdc\user\user.c * usb_device_state is declared in usbmmap.c and is modified C:\MCHPFSUSB\fw\cdc\user\user.c * in usbdrv.c, usbctrltrf.c, and usb9.c C:\MCHPFSUSB\fw\cdc\user\user.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c void BlinkUSBStatus(void) C:\MCHPFSUSB\fw\cdc\user\user.c { C:\MCHPFSUSB\fw\cdc\user\user.c static word led_count=0; C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c 000a1a 0100 MOVLB 0x0 if(led_count == 0)led_count = 10000U; C:\MCHPFSUSB\fw\cdc\user\user.c 000a1c 51d5 MOVF 0xd5,0x0,0x1 000a1e 11d6 IORWF 0xd6,0x0,0x1 000a20 e104 BNZ 0xa2a 000a22 0e10 MOVLW 0x10 000a24 6fd5 MOVWF 0xd5,0x1 000a26 0e27 MOVLW 0x27 000a28 6fd6 MOVWF 0xd6,0x1 000a2a 07d5 DECF 0xd5,0x1,0x1 led_count--; C:\MCHPFSUSB\fw\cdc\user\user.c 000a2c 0e00 MOVLW 0x0 000a2e 5bd6 SUBWFB 0xd6,0x1,0x1 C:\MCHPFSUSB\fw\cdc\user\user.c #define mLED_Both_Off() {mLED_1_Off();mLED_2_Off();} C:\MCHPFSUSB\fw\cdc\user\user.c #define mLED_Both_On() {mLED_1_On();mLED_2_On();} C:\MCHPFSUSB\fw\cdc\user\user.c #define mLED_Only_1_On() {mLED_1_On();mLED_2_Off();} C:\MCHPFSUSB\fw\cdc\user\user.c #define mLED_Only_2_On() {mLED_1_Off();mLED_2_On();} C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c 000a30 a26d BTFSS 0x6d,0x1,0x0 if(UCONbits.SUSPND == 1) C:\MCHPFSUSB\fw\cdc\user\user.c 000a32 d008 BRA 0xa44 { C:\MCHPFSUSB\fw\cdc\user\user.c 000a34 51d5 MOVF 0xd5,0x0,0x1 if(led_count==0) C:\MCHPFSUSB\fw\cdc\user\user.c 000a36 11d6 IORWF 0xd6,0x0,0x1 000a38 e130 BNZ 0xa9a { C:\MCHPFSUSB\fw\cdc\user\user.c 000a3a 708a BTG 0x8a,0x0,0x0 mLED_1_Toggle(); C:\MCHPFSUSB\fw\cdc\user\user.c 000a3c 508a MOVF 0x8a,0x0,0x0 mLED_2 = mLED_1; // Both blink at the same time C:\MCHPFSUSB\fw\cdc\user\user.c 000a3e 0b01 ANDLW 0x1 000a40 e113 BNZ 0xa68 }//end if C:\MCHPFSUSB\fw\cdc\user\user.c } C:\MCHPFSUSB\fw\cdc\user\user.c 000a42 d028 BRA 0xa94 else C:\MCHPFSUSB\fw\cdc\user\user.c { C:\MCHPFSUSB\fw\cdc\user\user.c 000a44 0100 MOVLB 0x0 if(usb_device_state == DETACHED_STATE) C:\MCHPFSUSB\fw\cdc\user\user.c 000a46 51cf MOVF 0xcf,0x0,0x1 000a48 e102 BNZ 0xa4e { C:\MCHPFSUSB\fw\cdc\user\user.c 000a4a 908a BCF 0x8a,0x0,0x0 mLED_Both_Off(); C:\MCHPFSUSB\fw\cdc\user\user.c } C:\MCHPFSUSB\fw\cdc\user\user.c 000a4c d023 BRA 0xa94 else if(usb_device_state == ATTACHED_STATE) C:\MCHPFSUSB\fw\cdc\user\user.c 000a4e 05cf DECF 0xcf,0x0,0x1 000a50 e102 BNZ 0xa56 { C:\MCHPFSUSB\fw\cdc\user\user.c 000a52 808a BSF 0x8a,0x0,0x0 mLED_Both_On(); C:\MCHPFSUSB\fw\cdc\user\user.c } C:\MCHPFSUSB\fw\cdc\user\user.c 000a54 d009 BRA 0xa68 else if(usb_device_state == POWERED_STATE) C:\MCHPFSUSB\fw\cdc\user\user.c 000a56 0e02 MOVLW 0x2 000a58 5dcf SUBWF 0xcf,0x0,0x1 000a5a e102 BNZ 0xa60 { C:\MCHPFSUSB\fw\cdc\user\user.c 000a5c 808a BSF 0x8a,0x0,0x0 mLED_Only_1_On(); C:\MCHPFSUSB\fw\cdc\user\user.c } C:\MCHPFSUSB\fw\cdc\user\user.c 000a5e d01a BRA 0xa94 else if(usb_device_state == DEFAULT_STATE) C:\MCHPFSUSB\fw\cdc\user\user.c 000a60 0e03 MOVLW 0x3 000a62 5dcf SUBWF 0xcf,0x0,0x1 000a64 e103 BNZ 0xa6c { C:\MCHPFSUSB\fw\cdc\user\user.c 000a66 908a BCF 0x8a,0x0,0x0 mLED_Only_2_On(); C:\MCHPFSUSB\fw\cdc\user\user.c 000a68 828a BSF 0x8a,0x1,0x0 } C:\MCHPFSUSB\fw\cdc\user\user.c 000a6a 0012 RETURN 0x0 else if(usb_device_state == ADDRESS_STATE) C:\MCHPFSUSB\fw\cdc\user\user.c 000a6c 0e05 MOVLW 0x5 000a6e 5dcf SUBWF 0xcf,0x0,0x1 000a70 e106 BNZ 0xa7e { C:\MCHPFSUSB\fw\cdc\user\user.c 000a72 0100 MOVLB 0x0 if(led_count == 0) C:\MCHPFSUSB\fw\cdc\user\user.c 000a74 51d5 MOVF 0xd5,0x0,0x1 000a76 11d6 IORWF 0xd6,0x0,0x1 000a78 e110 BNZ 0xa9a { C:\MCHPFSUSB\fw\cdc\user\user.c 000a7a 708a BTG 0x8a,0x0,0x0 mLED_1_Toggle(); C:\MCHPFSUSB\fw\cdc\user\user.c mLED_2_Off(); C:\MCHPFSUSB\fw\cdc\user\user.c }//end if C:\MCHPFSUSB\fw\cdc\user\user.c } C:\MCHPFSUSB\fw\cdc\user\user.c 000a7c d00b BRA 0xa94 else if(usb_device_state == CONFIGURED_STATE) C:\MCHPFSUSB\fw\cdc\user\user.c 000a7e 0e06 MOVLW 0x6 000a80 5dcf SUBWF 0xcf,0x0,0x1 000a82 e10b BNZ 0xa9a { C:\MCHPFSUSB\fw\cdc\user\user.c 000a84 0100 MOVLB 0x0 if(led_count==0) C:\MCHPFSUSB\fw\cdc\user\user.c 000a86 51d5 MOVF 0xd5,0x0,0x1 000a88 11d6 IORWF 0xd6,0x0,0x1 000a8a e107 BNZ 0xa9a { C:\MCHPFSUSB\fw\cdc\user\user.c 000a8c 708a BTG 0x8a,0x0,0x0 mLED_1_Toggle(); C:\MCHPFSUSB\fw\cdc\user\user.c 000a8e 508a MOVF 0x8a,0x0,0x0 mLED_2 = !mLED_1; // Alternate blink C:\MCHPFSUSB\fw\cdc\user\user.c 000a90 0b01 ANDLW 0x1 000a92 e002 BZ 0xa98 000a94 928a BCF 0x8a,0x1,0x0 000a96 0012 RETURN 0x0 000a98 828a BSF 0x8a,0x1,0x0 }//end if C:\MCHPFSUSB\fw\cdc\user\user.c }//end if(...) C:\MCHPFSUSB\fw\cdc\user\user.c }//end if(UCONbits.SUSPND...) C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c 000a9a 0012 RETURN 0x0 }//end BlinkUSBStatus C:\MCHPFSUSB\fw\cdc\user\user.c C:\MCHPFSUSB\fw\cdc\user\user.c /** EOF user.c ***************************************************************/ C:\MCHPFSUSB\fw\cdc\user\user.c /********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Microchip USB C18 Firmware - CDC Version 1.0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c ********************************************************************* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * FileName: cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Dependencies: See INCLUDES section below C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Processor: PIC18 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Compiler: C18 2.30.01+ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Company: Microchip Technology, Inc. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Software License Agreement C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The software supplied herewith by Microchip Technology Incorporated C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * supplied to you, the Company’s customer, for use solely and C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * exclusively on Microchip PICmicro Microcontroller products. The C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * software is owned by the Company and/or its supplier, and is C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * protected under applicable copyright laws. All rights are reserved. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Any use in violation of the foregoing restrictions may subject the C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * user to criminal sanctions under applicable laws, as well as to C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * civil liability for the breach of the terms and conditions of this C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * license. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Author Date Comment C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Rawin Rojvanit 11/19/04 Original. RS-232 Emulation Subset C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c ********************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** I N C L U D E S **********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #include C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #include "system\typedefs.h" C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #include "system\usb\usb.h" C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #ifdef USB_USE_CDC C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** V A R I A B L E S ********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #pragma udata C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte cdc_rx_len; // total rx length C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte cdc_trf_state; // States are defined cdc.h C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c POINTER pCDCSrc; // Dedicated source pointer C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c POINTER pCDCDst; // Dedicated destination pointer C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte cdc_tx_len; // total tx length C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte cdc_mem_type; // _ROM, _RAM C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c LINE_CODING line_coding; // Buffer to store line coding information C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c CONTROL_SIGNAL_BITMAP control_signal_bitmap; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * SEND_ENCAPSULATED_COMMAND and GET_ENCAPSULATED_RESPONSE are required C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * requests according to the CDC specification. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * However, it is not really being used here, therefore a dummy buffer is C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * used for conformance. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #define dummy_length 0x08 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte dummy_encapsulated_cmd_response[dummy_length]; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** D E C L A R A T I O N S **************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #pragma code C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** C L A S S S P E C I F I C R E Q ****************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Function: void USBCheckCDCRequest(void) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Overview: This routine checks the setup data packet to see if it C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * knows how to handle it C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c void USBCheckCDCRequest(void) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If request recipient is not an interface then return C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000038 0104 MOVLB 0x4 if(SetupPkt.Recipient != RCPT_INTF) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00003a 5120 MOVF 0x20,0x0,0x1 00003c 0b1f ANDLW 0x1f 00003e 0801 SUBLW 0x1 000040 e001 BZ 0x44 000042 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If request type is not class-specific then return C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000044 5120 MOVF 0x20,0x0,0x1 if(SetupPkt.RequestType != CLASS) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000046 0b60 ANDLW 0x60 000048 42e8 RRNCF 0xe8,0x1,0x0 00004a 42e8 RRNCF 0xe8,0x1,0x0 00004c 42e8 RRNCF 0xe8,0x1,0x0 00004e 42e8 RRNCF 0xe8,0x1,0x0 000050 42e8 RRNCF 0xe8,0x1,0x0 000052 0801 SUBLW 0x1 000054 e001 BZ 0x58 000056 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Interface ID must match interface numbers associated with C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * CDC class, else return C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000058 5124 MOVF 0x24,0x0,0x1 if((SetupPkt.bIntfID != CDC_COMM_INTF_ID)&& C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00005a e003 BZ 0x62 (SetupPkt.bIntfID != CDC_DATA_INTF_ID)) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00005c 0524 DECF 0x24,0x0,0x1 00005e e001 BZ 0x62 000060 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000062 5121 MOVF 0x21,0x0,0x1 switch(SetupPkt.bRequest) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000064 0a23 XORLW 0x23 000066 e039 BZ 0xda 000068 0a01 XORLW 0x1 00006a e033 BZ 0xd2 00006c 0a03 XORLW 0x3 00006e e025 BZ 0xba 000070 0a01 XORLW 0x1 000072 e01c BZ 0xac 000074 0a24 XORLW 0x24 000076 e031 BZ 0xda 000078 0a07 XORLW 0x7 00007a e02f BZ 0xda 00007c 0a01 XORLW 0x1 00007e e02d BZ 0xda 000080 0a03 XORLW 0x3 000082 e00e BZ 0xa0 000084 0a01 XORLW 0x1 000086 e001 BZ 0x8a 000088 0012 RETURN 0x0 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case SEND_ENCAPSULATED_COMMAND: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00008a d94e RCALL 0x328 ctrl_trf_session_owner = MUID_CDC; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00008c 0100 MOVLB 0x0 pSrc.bRam = (byte*)&dummy_encapsulated_cmd_response; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00008e 0eb5 MOVLW 0xb5 000090 6fc9 MOVWF 0xc9,0x1 000092 0e00 MOVLW 0x0 000094 6fca MOVWF 0xca,0x1 000096 0100 MOVLB 0x0 usb_stat.ctrl_trf_mem = _RAM; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000098 93d0 BCF 0xd0,0x1,0x1 00009a 0100 MOVLB 0x0 LSB(wCount) = dummy_length; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00009c 0e08 MOVLW 0x8 00009e d017 BRA 0xce break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case GET_ENCAPSULATED_RESPONSE: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000a0 d943 RCALL 0x328 ctrl_trf_session_owner = MUID_CDC; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c // Populate dummy_encapsulated_cmd_response first. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000a2 0100 MOVLB 0x0 pDst.bRam = (byte*)&dummy_encapsulated_cmd_response; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000a4 0eb5 MOVLW 0xb5 0000a6 6fcb MOVWF 0xcb,0x1 0000a8 0e00 MOVLW 0x0 0000aa d005 BRA 0xb6 break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case SET_COMM_FEATURE: // Optional C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case GET_COMM_FEATURE: // Optional C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case CLEAR_COMM_FEATURE: // Optional C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case SET_LINE_CODING: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000ac d93d RCALL 0x328 ctrl_trf_session_owner = MUID_CDC; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000ae 0100 MOVLB 0x0 pDst.bRam = (byte*)&line_coding; // Set destination C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000b0 0eaa MOVLW 0xaa 0000b2 6fcb MOVWF 0xcb,0x1 0000b4 0e00 MOVLW 0x0 0000b6 6fcc MOVWF 0xcc,0x1 0000b8 0012 RETURN 0x0 break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case GET_LINE_CODING: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000ba d936 RCALL 0x328 ctrl_trf_session_owner = MUID_CDC; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000328 0100 MOVLB 0x0 00032a 0e03 MOVLW 0x3 00032c 6fc8 MOVWF 0xc8,0x1 00032e 0012 RETURN 0x0 0000bc 0100 MOVLB 0x0 pSrc.bRam = (byte*)&line_coding; // Set source C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000be 0eaa MOVLW 0xaa 0000c0 6fc9 MOVWF 0xc9,0x1 0000c2 0e00 MOVLW 0x0 0000c4 6fca MOVWF 0xca,0x1 0000c6 0100 MOVLB 0x0 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000c8 93d0 BCF 0xd0,0x1,0x1 0000ca 0100 MOVLB 0x0 LSB(wCount) = LINE_CODING_LENGTH; // Set data count C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000cc 0e07 MOVLW 0x7 0000ce 6fcd MOVWF 0xcd,0x1 0000d0 0012 RETURN 0x0 break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case SET_CONTROL_LINE_STATE: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000d2 d92a RCALL 0x328 ctrl_trf_session_owner = MUID_CDC; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000d4 c422 MOVFF 0x422,0xb1 control_signal_bitmap._byte = LSB(SetupPkt.W_Value); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000d6 f0b1 0000d8 0012 RETURN 0x0 break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c case SEND_BREAK: // Optional C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c default: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c break; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c }//end switch(SetupPkt.bRequest) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000da 0012 RETURN 0x0 }//end USBCheckCDCRequest C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** U S E R A P I ***********************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Function: void CDCInitEP(void) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Overview: CDCInitEP initializes CDC endpoints, buffer descriptors, C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * internal state-machine, and variables. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * It should be called after the USB host has sent out a C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * SET_CONFIGURATION request. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * See USBStdSetCfgHandler() in usb9.c for examples. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c void CDCInitEP(void) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c //Abstract line coding information C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000dc 0100 MOVLB 0x0 line_coding.dwDTERate._dword = 115200; // baud rate C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000de 6baa CLRF 0xaa,0x1 0000e0 0ec2 MOVLW 0xc2 0000e2 6fab MOVWF 0xab,0x1 0000e4 0e01 MOVLW 0x1 0000e6 6fac MOVWF 0xac,0x1 0000e8 6bad CLRF 0xad,0x1 0000ea 6bae CLRF 0xae,0x1 line_coding.bCharFormat = 0x00; // 1 stop bit C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000ec 6baf CLRF 0xaf,0x1 line_coding.bParityType = 0x00; // None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000ee 0e08 MOVLW 0x8 line_coding.bDataBits = 0x08; // 5,6,7,8, or 16 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000f0 6fb0 MOVWF 0xb0,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000f2 6ba3 CLRF 0xa3,0x1 cdc_trf_state = CDC_TX_READY; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000f4 6ba2 CLRF 0xa2,0x1 cdc_rx_len = 0; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000f6 0e1a MOVLW 0x1a CDC_COMM_UEP = EP_IN|HSHK_EN; // Enable 1 Comm pipe C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000f8 6e72 MOVWF 0x72,0x0 0000fa 0e1e MOVLW 0x1e CDC_DATA_UEP = EP_OUT_IN|HSHK_EN; // Enable 2 data pipes C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000fc 6e73 MOVWF 0x73,0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Do not have to init Cnt of IN pipes here. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Reason: Number of bytes to send to the host C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * varies from one transaction to C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * another. Cnt should equal the exact C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * number of bytes to transmit for C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * a given IN transaction. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * This number of bytes will only C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * be known right before the data is C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * sent. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0000fe 0104 MOVLB 0x4 CDC_INT_BD_IN.ADR = (byte*)&cdc_notice; // Set buffer address C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000100 0e00 MOVLW 0x0 000102 6f16 MOVWF 0x16,0x1 000104 0e05 MOVLW 0x5 000106 6f17 MOVWF 0x17,0x1 000108 0e40 MOVLW 0x40 CDC_INT_BD_IN.Stat._byte = _UCPU|_DAT1; // Set status C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00010a 6f14 MOVWF 0x14,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00010c 0104 MOVLB 0x4 CDC_BULK_BD_OUT.Cnt = sizeof(cdc_data_rx); // Set buffer size C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00010e 6f19 MOVWF 0x19,0x1 000110 0e08 MOVLW 0x8 CDC_BULK_BD_OUT.ADR = (byte*)&cdc_data_rx; // Set buffer address C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000112 6f1a MOVWF 0x1a,0x1 000114 0e05 MOVLW 0x5 000116 6f1b MOVWF 0x1b,0x1 000118 0e88 MOVLW 0x88 CDC_BULK_BD_OUT.Stat._byte = _USIE|_DAT0|_DTSEN;// Set status C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00011a 6f18 MOVWF 0x18,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00011c 0104 MOVLB 0x4 CDC_BULK_BD_IN.ADR = (byte*)&cdc_data_tx; // Set buffer size C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00011e 0e48 MOVLW 0x48 000120 6f1e MOVWF 0x1e,0x1 000122 0e05 MOVLW 0x5 000124 6f1f MOVWF 0x1f,0x1 000126 0e40 MOVLW 0x40 CDC_BULK_BD_IN.Stat._byte = _UCPU|_DAT1; // Set buffer address C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000128 6f1c MOVWF 0x1c,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00012a 0012 RETURN 0x0 }//end CDCInitEP C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Function: byte getsUSBUSART(char *buffer, C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * byte len) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PreCondition: Value of input argument 'len' should be smaller than the C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * maximum endpoint size responsible for receiving bulk C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * data from USB host for CDC class. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input argument 'buffer' should point to a buffer area that C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * is bigger or equal to the size specified by 'len'. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input: buffer : Pointer to where received bytes are to be stored C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * len : The number of bytes expected. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Output: The number of bytes copied to buffer. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Side Effects: Publicly accessible variable cdc_rx_len is updated with C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * the number of bytes copied to buffer. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Once getsUSBUSART is called, subsequent retrieval of C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * cdc_rx_len can be done by calling macro mCDCGetRxLength(). C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Overview: getsUSBUSART copies a string of bytes received through C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * USB CDC Bulk OUT endpoint to a user's specified location. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * It is a non-blocking function. It does not wait C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * for data if there is no data available. Instead it returns C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * '0' to notify the caller that there is no data available. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Note: If the actual number of bytes received is larger than the C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * number of bytes expected (len), only the expected number C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * of bytes specified will be copied to buffer. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If the actual number of bytes received is smaller than the C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * number of bytes expected (len), only the actual number C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * of bytes received will be copied to buffer. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00012c cfd9 MOVFF 0xfd9,0xfe6 byte getsUSBUSART(char *buffer, byte len) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00012e ffe6 000130 cfe1 MOVFF 0xfe1,0xfd9 000132 ffd9 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000134 0100 MOVLB 0x0 cdc_rx_len = 0; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000136 6ba2 CLRF 0xa2,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000138 0104 MOVLB 0x4 if(!mCDCUsartRxIsBusy()) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00013a bf18 BTFSC 0x18,0x7,0x1 00013c d030 BRA 0x19e { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Adjust the expected number of bytes to equal C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * the actual number of bytes received. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00013e 0efc MOVLW 0xfc if(len > CDC_BULK_BD_OUT.Cnt) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000140 cfdb MOVFF 0xfdb,0x2 000142 f002 000144 5119 MOVF 0x19,0x0,0x1 000146 80d8 BSF 0xd8,0x0,0x0 000148 5402 SUBFWB 0x2,0x0,0x0 00014a e203 BC 0x152 00014c 0efc MOVLW 0xfc len = CDC_BULK_BD_OUT.Cnt; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00014e c419 MOVFF 0x419,0xfdb 000150 ffdb C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Copy data from dual-ram buffer to user's buffer C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000152 0100 MOVLB 0x0 for(cdc_rx_len = 0; cdc_rx_len < len; cdc_rx_len++) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000154 6ba2 CLRF 0xa2,0x1 000156 0efc MOVLW 0xfc 000158 50db MOVF 0xdb,0x0,0x0 00015a 5da2 SUBWF 0xa2,0x0,0x1 00015c e219 BC 0x190 00018c 2ba2 INCF 0xa2,0x1,0x1 00018e d7e3 BRA 0x156 00015e 51a2 MOVF 0xa2,0x0,0x1 buffer[cdc_rx_len] = cdc_data_rx[cdc_rx_len]; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000160 6aea CLRF 0xea,0x0 000162 0f08 ADDLW 0x8 000164 6ee9 MOVWF 0xe9,0x0 000166 0e05 MOVLW 0x5 000168 22ea ADDWFC 0xea,0x1,0x0 00016a 50ef MOVF 0xef,0x0,0x0 00016c 6ee6 MOVWF 0xe6,0x0 00016e 51a2 MOVF 0xa2,0x0,0x1 000170 6ee7 MOVWF 0xe7,0x0 000172 0efd MOVLW 0xfd 000174 cfdb MOVFF 0xfdb,0xfe9 000176 ffe9 000178 0efe MOVLW 0xfe 00017a cfdb MOVFF 0xfdb,0xfea 00017c ffea 00017e 50e7 MOVF 0xe7,0x0,0x0 000180 26e9 ADDWF 0xe9,0x1,0x0 000182 0e00 MOVLW 0x0 000184 22ea ADDWFC 0xea,0x1,0x0 000186 52e5 MOVF 0xe5,0x1,0x0 000188 50e7 MOVF 0xe7,0x0,0x0 00018a 6eef MOVWF 0xef,0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Prepare dual-ram buffer for next OUT transaction C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000190 0104 MOVLB 0x4 CDC_BULK_BD_OUT.Cnt = sizeof(cdc_data_rx); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000192 0e40 MOVLW 0x40 000194 6f19 MOVWF 0x19,0x1 000196 1718 ANDWF 0x18,0x1,0x1 mUSBBufferReady(CDC_BULK_BD_OUT); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000198 7d18 BTG 0x18,0x6,0x1 00019a 0e88 MOVLW 0x88 00019c 1318 IORWF 0x18,0x1,0x1 }//end if C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00019e 0100 MOVLB 0x0 return cdc_rx_len; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001a0 51a2 MOVF 0xa2,0x0,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001a2 52e5 MOVF 0xe5,0x1,0x0 }//end getsUSBUSART C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001a4 cfe7 MOVFF 0xfe7,0xfd9 0001a6 ffd9 0001a8 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Function: void putsUSBUSART(char *data) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PreCondition: cdc_trf_state must be in the CDC_TX_READY state. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The string of characters pointed to by 'data' must equal C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * to or smaller than 255 bytes. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input: data : Pointer to a null-terminated string of data. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If a null character is not found, 255 bytes C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * of data will be transferred to the host. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Overview: putsUSBUSART writes a string of data to the USB including C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * the null character. Use this version, 'puts', to transfer C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * data located in data memory. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Note: The transfer mechanism for device-to-host(put) is more C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * flexible than host-to-device(get). It can handle C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * a string of data larger than the maximum size of bulk IN C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * endpoint. A state machine is used to transfer a long C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * string of data over multiple USB transactions. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * See CDCTxService() for more details. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001aa d8ac RCALL 0x304 void putsUSBUSART(char *data) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte len; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * User should have checked that cdc_trf_state is in CDC_TX_READY state C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * before calling this function. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * As a safety precaution, this fuction checks the state one more time C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * to make sure it does not override any pending transactions. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Currently it just quits the routine without reporting any errors back C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * to the user. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Bottomline: User MUST make sure that mUSBUSARTIsTxTrfReady()==1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * before calling this function! C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Example: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * if(mUSBUSARTIsTxTrfReady()) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * putsUSBUSART(pData); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * IMPORTANT: Never use the following blocking while loop to wait: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * while(!mUSBUSARTIsTxTrfReady()) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * putsUSBUSART(pData); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The whole firmware framework is written based on cooperative C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * multi-tasking and a blocking code is not acceptable. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Use a state machine instead. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001ac 0100 MOVLB 0x0 if(cdc_trf_state != CDC_TX_READY) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001ae 51a3 MOVF 0xa3,0x0,0x1 0001b0 e114 BNZ 0x1da C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * While loop counts the number of bytes to send including the C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * null character. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001b2 6adf CLRF 0xdf,0x0 len = 0; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c do C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001b4 d8b2 RCALL 0x31a len++; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00031a 2adf INCF 0xdf,0x1,0x0 0001b6 e102 BNZ 0x1bc if(len == 255) break; // Break loop once max len is reached. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001b8 5003 MOVF 0x3,0x0,0x0 0001ba e00b BZ 0x1d2 00031c 50df MOVF 0xdf,0x0,0x0 00031e 6e02 MOVWF 0x2,0x0 000320 6a03 CLRF 0x3,0x0 000322 0eff MOVLW 0xff 000324 1802 XORWF 0x2,0x0,0x0 000326 0012 RETURN 0x0 0001bc 0efd MOVLW 0xfd }while(*data++); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001be cfdb MOVFF 0xfdb,0xfe9 0001c0 ffe9 0001c2 2adb INCF 0xdb,0x1,0x0 0001c4 0efe MOVLW 0xfe 0001c6 cfdb MOVFF 0xfdb,0xfea 0001c8 ffea 0001ca e301 BNC 0x1ce 0001cc 2adb INCF 0xdb,0x1,0x0 0001ce 50ef MOVF 0xef,0x0,0x0 0001d0 e1f1 BNZ 0x1b4 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Re-adjust pointer to its initial location C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001d2 d875 RCALL 0x2be data-=len; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002be 50df MOVF 0xdf,0x0,0x0 0002c0 6e02 MOVWF 0x2,0x0 0002c2 6a03 CLRF 0x3,0x0 0002c4 50d9 MOVF 0xd9,0x0,0x0 0002c6 0ffd ADDLW 0xfd 0002c8 6ee9 MOVWF 0xe9,0x0 0002ca 0eff MOVLW 0xff 0002cc 20da ADDWFC 0xda,0x0,0x0 0002ce 6eea MOVWF 0xea,0x0 0002d0 5002 MOVF 0x2,0x0,0x0 0002d2 5eee SUBWF 0xee,0x1,0x0 0002d4 5003 MOVF 0x3,0x0,0x0 0002d6 5aed SUBWFB 0xed,0x1,0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Second piece of information (length of data to send) is ready. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Call mUSBUSARTTxRam to setup the transfer. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The actual transfer process will be handled by CDCTxService(), C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * which should be called once per Main Program loop. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001d4 6ba9 CLRF 0xa9,0x1 mUSBUSARTTxRam((byte*)data,len); // See cdc.h C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001d6 0e01 MOVLW 0x1 0001d8 6fa3 MOVWF 0xa3,0x1 0002d8 0efd MOVLW 0xfd 0002da cfdb MOVFF 0xfdb,0xa4 0002dc f0a4 0002de 0efe MOVLW 0xfe 0002e0 cfdb MOVFF 0xfdb,0xa5 0002e2 f0a5 0002e4 cfdf MOVFF 0xfdf,0xa8 0002e6 f0a8 0002e8 0100 MOVLB 0x0 0002ea 0012 RETURN 0x0 0001da d09a BRA 0x310 }//end putsUSBUSART C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Function: void putrsUSBUSART(const rom char *data) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PreCondition: cdc_trf_state must be in the CDC_TX_READY state. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The string of characters pointed to by 'data' must equal C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * to or smaller than 255 bytes. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input: data : Pointer to a null-terminated string of data. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If a null character is not found, 255 bytes C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * of data will be transferred to the host. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Overview: putrsUSBUSART writes a string of data to the USB including C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * the null character. Use this version, 'putrs', to transfer C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * data literals and data located in program memory. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Note: The transfer mechanism for device-to-host(put) is more C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * flexible than host-to-device(get). It can handle C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * a string of data larger than the maximum size of bulk IN C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * endpoint. A state machine is used to transfer a long C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * string of data over multiple USB transactions. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * See CDCTxService() for more details. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001dc d893 RCALL 0x304 void putrsUSBUSART(const rom char *data) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000304 cfd9 MOVFF 0xfd9,0xfe6 000306 ffe6 000308 cfe1 MOVFF 0xfe1,0xfd9 00030a ffd9 00030c 52e6 MOVF 0xe6,0x1,0x0 00030e 0012 RETURN 0x0 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte len; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * User should have checked that cdc_trf_state is in CDC_TX_READY state C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * before calling this function. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * As a safety precaution, this fuction checks the state one more time C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * to make sure it does not override any pending transactions. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Currently it just quits the routine without reporting any errors back C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * to the user. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Bottomline: User MUST make sure that mUSBUSARTIsTxTrfReady() C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * before calling this function! C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Example: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * if(mUSBUSARTIsTxTrfReady()) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * putsUSBUSART(pData); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * IMPORTANT: Never use the following blocking while loop to wait: C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * while(cdc_trf_state != CDC_TX_READY) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * putsUSBUSART(pData); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The whole firmware framework is written based on cooperative C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * multi-tasking and a blocking code is not acceptable. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Use a state machine instead. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001de 0100 MOVLB 0x0 if(cdc_trf_state != CDC_TX_READY) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001e0 51a3 MOVF 0xa3,0x0,0x1 0001e2 e115 BNZ 0x20e C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * While loop counts the number of bytes to send including the C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * null character. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001e4 6adf CLRF 0xdf,0x0 len = 0; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c do C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001e6 d899 RCALL 0x31a len++; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001e8 e102 BNZ 0x1ee if(len == 255) break; // Break loop once max len is reached. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001ea 5003 MOVF 0x3,0x0,0x0 0001ec e00c BZ 0x206 0001ee 0efd MOVLW 0xfd }while(*data++); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0001f0 cfdb MOVFF 0xfdb,0xff6 0001f2 fff6 0001f4 2adb INCF 0xdb,0x1,0x0 0001f6 0efe MOVLW 0xfe 0001f8 cfdb MOVFF 0xfdb,0xff7 0001fa fff7 0001fc e301 BNC 0x200 0001fe 2adb INCF 0xdb,0x1,0x0 000200 0008 TBLRD 000202 50f5 MOVF 0xf5,0x0,0x0 000204 e1f0 BNZ 0x1e6 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Re-adjust pointer to its initial location C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000206 d85b RCALL 0x2be data-=len; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Second piece of information (length of data to send) is ready. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Call mUSBUSARTTxRom to setup the transfer. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * The actual transfer process will be handled by CDCTxService(), C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * which should be called once per Main Program loop. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000208 0e01 MOVLW 0x1 mUSBUSARTTxRom((rom byte*)data,len); // See cdc.h C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00020a 6fa9 MOVWF 0xa9,0x1 00020c 6fa3 MOVWF 0xa3,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00020e d080 BRA 0x310 }//end putrsUSBUSART C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /****************************************************************************** C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Function: void CDCTxService(void) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * PreCondition: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Input: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Output: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Side Effects: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Overview: CDCTxService handles device-to-host transaction(s). C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * This function should be called once per Main Program loop. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Note: None C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c *****************************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000210 d879 RCALL 0x304 void CDCTxService(void) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte byte_to_send; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000212 0104 MOVLB 0x4 if(mCDCUsartTxIsBusy()) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000214 bf1c BTFSC 0x1c,0x7,0x1 000216 d052 BRA 0x2bc /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Completing stage is necessary while [ mCDCUSartTxIsBusy()==1 ]. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * By having this stage, user can always check cdc_trf_state, C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * and not having to call mCDCUsartTxIsBusy() directly. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000218 0e03 MOVLW 0x3 if(cdc_trf_state == CDC_TX_COMPLETING) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00021a 0100 MOVLB 0x0 00021c 5da3 SUBWF 0xa3,0x0,0x1 00021e e101 BNZ 0x222 000220 6ba3 CLRF 0xa3,0x1 cdc_trf_state = CDC_TX_READY; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If CDC_TX_READY state, nothing to do, just return. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000222 51a3 MOVF 0xa3,0x0,0x1 if(cdc_trf_state == CDC_TX_READY) return; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000224 e04b BZ 0x2bc C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * If CDC_TX_BUSY_ZLP state, send zero length packet C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000226 0e02 MOVLW 0x2 if(cdc_trf_state == CDC_TX_BUSY_ZLP) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000228 5da3 SUBWF 0xa3,0x0,0x1 00022a e103 BNZ 0x232 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00022c 0104 MOVLB 0x4 CDC_BULK_BD_IN.Cnt = 0; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00022e 6b1d CLRF 0x1d,0x1 cdc_trf_state = CDC_TX_COMPLETING; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c } C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000230 d03c BRA 0x2aa else if(cdc_trf_state == CDC_TX_BUSY) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000232 05a3 DECF 0xa3,0x0,0x1 000234 e13d BNZ 0x2b0 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * First, have to figure out how many byte of data to send. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000236 0e40 MOVLW 0x40 if(cdc_tx_len > sizeof(cdc_data_tx)) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000238 6e02 MOVWF 0x2,0x0 00023a 6a03 CLRF 0x3,0x0 00023c 51a8 MOVF 0xa8,0x0,0x1 00023e 5c02 SUBWF 0x2,0x0,0x0 000240 0e00 MOVLW 0x0 000242 5803 SUBWFB 0x3,0x0,0x0 000244 e203 BC 0x24c 000246 0e40 MOVLW 0x40 byte_to_send = sizeof(cdc_data_tx); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000248 6edf MOVWF 0xdf,0x0 00024a d002 BRA 0x250 else C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00024c c0a8 MOVFF 0xa8,0xfdf byte_to_send = cdc_tx_len; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00024e ffdf C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Next, load the number of bytes to send to Cnt in buffer descriptor C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000250 cfdf MOVFF 0xfdf,0x41d CDC_BULK_BD_IN.Cnt = byte_to_send; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000252 f41d C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Subtract the number of bytes just about to be sent from the total. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000254 50df MOVF 0xdf,0x0,0x0 cdc_tx_len = cdc_tx_len - byte_to_send; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000256 5da8 SUBWF 0xa8,0x0,0x1 000258 6fa8 MOVWF 0xa8,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00025a 0e48 MOVLW 0x48 pCDCDst.bRam = (byte*)&cdc_data_tx; // Set destination pointer C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00025c 6fa6 MOVWF 0xa6,0x1 00025e 0e05 MOVLW 0x5 000260 6fa7 MOVWF 0xa7,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000262 05a9 DECF 0xa9,0x0,0x1 if(cdc_mem_type == _ROM) // Determine type of memory source C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000264 e10a BNZ 0x27a { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000266 50df MOVF 0xdf,0x0,0x0 while(byte_to_send) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000268 e011 BZ 0x28c 000278 d7f6 BRA 0x266 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00026a c0a4 MOVFF 0xa4,0xff6 *pCDCDst.bRam = *pCDCSrc.bRom; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00026c fff6 00026e c0a5 MOVFF 0xa5,0xff7 000270 fff7 000272 0008 TBLRD 000274 50f5 MOVF 0xf5,0x0,0x0 000276 d83a RCALL 0x2ec 0002ec c0a6 MOVFF 0xa6,0xfe9 0002ee ffe9 0002f0 c0a7 MOVFF 0xa7,0xfea 0002f2 ffea 0002f4 6eef MOVWF 0xef,0x0 0002f6 2ba6 INCF 0xa6,0x1,0x1 pCDCDst.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002f8 0e00 MOVLW 0x0 0002fa 23a7 ADDWFC 0xa7,0x1,0x1 0002fc 2ba4 INCF 0xa4,0x1,0x1 pCDCSrc.bRom++; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002fe 23a5 ADDWFC 0xa5,0x1,0x1 000300 06df DECF 0xdf,0x1,0x0 byte_to_send--; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000302 0012 RETURN 0x0 }//end while(byte_to_send) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c } C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c else // _RAM C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00027a 50df MOVF 0xdf,0x0,0x0 while(byte_to_send) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00027c e007 BZ 0x28c 00028a d7f7 BRA 0x27a { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00027e c0a4 MOVFF 0xa4,0xfe9 *pCDCDst.bRam = *pCDCSrc.bRam; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000280 ffe9 000282 c0a5 MOVFF 0xa5,0xfea 000284 ffea 000286 50ef MOVF 0xef,0x0,0x0 000288 d831 RCALL 0x2ec pCDCDst.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c pCDCSrc.bRam++; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c byte_to_send--; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c }//end while(byte_to_send._word) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c }//end if(cdc_mem_type...) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Lastly, determine if a zero length packet state is necessary. C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * See explanation in USB Specification 2.0: Section 5.8.3 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00028c 0100 MOVLB 0x0 if(cdc_tx_len == 0) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 00028e 51a8 MOVF 0xa8,0x0,0x1 000290 e10f BNZ 0x2b0 { C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000292 0104 MOVLB 0x4 if(CDC_BULK_BD_IN.Cnt == sizeof(cdc_data_tx)) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000294 511d MOVF 0x1d,0x0,0x1 000296 6e02 MOVWF 0x2,0x0 000298 6a03 CLRF 0x3,0x0 00029a 0e40 MOVLW 0x40 00029c 1802 XORWF 0x2,0x0,0x0 00029e e105 BNZ 0x2aa 0002a0 5003 MOVF 0x3,0x0,0x0 0002a2 e103 BNZ 0x2aa 0002a4 0100 MOVLB 0x0 cdc_trf_state = CDC_TX_BUSY_ZLP; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002a6 0e02 MOVLW 0x2 0002a8 d002 BRA 0x2ae else C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002aa 0100 MOVLB 0x0 cdc_trf_state = CDC_TX_COMPLETING; C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002ac 0e03 MOVLW 0x3 0002ae 6fa3 MOVWF 0xa3,0x1 }//end if(cdc_tx_len...) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c }//end if(cdc_tx_sate == CDC_TX_BUSY) C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /* C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c * Both CDC_TX_BUSY and CDC_TX_BUSY_ZLP states use the following macro C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c */ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002b0 0e40 MOVLW 0x40 mUSBBufferReady(CDC_BULK_BD_IN); C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002b2 0104 MOVLB 0x4 0002b4 171c ANDWF 0x1c,0x1,0x1 0002b6 7d1c BTG 0x1c,0x6,0x1 0002b8 0e88 MOVLW 0x88 0002ba 131c IORWF 0x1c,0x1,0x1 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 0002bc d029 BRA 0x310 }//end CDCTxService C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c 000310 52e5 MOVF 0xe5,0x1,0x0 000312 52e5 MOVF 0xe5,0x1,0x0 000314 cfe7 MOVFF 0xfe7,0xfd9 000316 ffd9 000318 0012 RETURN 0x0 C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c #endif //USB_USE_CDC C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c /** EOF cdc.c ****************************************************************/ C:\MCHPFSUSB\fw\cdc\system\usb\class\cdc\cdc.c LIST P=18F2550 C:\MCC18\SRC\TRADIT~1\PROC\p18f2550.asm LIST C:\MCC18\SRC\TRADIT~1\PROC\p18f2550.asm END C:\MCC18\SRC\TRADIT~1\PROC\p18f2550.asm ; RCS Header $Id: cmath18.asm,v 1.4 2004/10/01 19:13:22 GrosbaJ Exp $ C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm ; CMATH18 DATA DEFINITION FILE C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm ;******************************************************************************* C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm ; VARIABLE ALLOCATION - Core math library routines C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm ;******************************************************************************* C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm MATH_DATA UDATA_ACS C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm SIGN RES 1 ; save location for sign in MSB C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm FPFLAGSbits C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm FPFLAGS RES 1 ; floating point library exception flags C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm GLOBAL SIGN, FPFLAGS, FPFLAGSbits C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm END C:\MCC18\SRC\TRADIT~1\MATH\cmath18.asm