MP2COD 4.02, COFF to COD File Converter Copyright (c) 2006 Microchip Technology Inc. Listing File Generated: Sat Jan 27 09:34:56 2007 Address Value Disassembly Source File ------- ------- ----------------------- ------------------------------------------------------------------------------- ----- /* $Id: c018i.c,v 1.3.14.1 2006/01/24 14:50:12 rhinec Exp $ */ C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c /* Copyright (c)1999 Microchip Technology */ C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c /* MPLAB-C18 startup code, including initialized data */ C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c /* external reference to the user's main routine */ C:\MCC18\src\traditional\startup\c018iBL.c extern void main (void); C:\MCC18\src\traditional\startup\c018iBL.c /* prototype for the startup function */ C:\MCC18\src\traditional\startup\c018iBL.c void _entry (void); C:\MCC18\src\traditional\startup\c018iBL.c void _startup (void); C:\MCC18\src\traditional\startup\c018iBL.c /* prototype for the initialized data setup */ C:\MCC18\src\traditional\startup\c018iBL.c void _do_cinit (void); C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c extern volatile near unsigned long short TBLPTR; C:\MCC18\src\traditional\startup\c018iBL.c extern near unsigned FSR0; C:\MCC18\src\traditional\startup\c018iBL.c extern near char __FPFLAGS; C:\MCC18\src\traditional\startup\c018iBL.c #define RND 6 C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c #pragma code _entry_scn=0x000800 C:\MCC18\src\traditional\startup\c018iBL.c void C:\MCC18\src\traditional\startup\c018iBL.c _entry (void) C:\MCC18\src\traditional\startup\c018iBL.c { C:\MCC18\src\traditional\startup\c018iBL.c 000800 ef83 GOTO 0x4506 _asm goto _startup _endasm C:\MCC18\src\traditional\startup\c018iBL.c 000802 f022 C:\MCC18\src\traditional\startup\c018iBL.c 000804 0012 RETURN 0x0 } C:\MCC18\src\traditional\startup\c018iBL.c #pragma code _startup_scn C:\MCC18\src\traditional\startup\c018iBL.c void C:\MCC18\src\traditional\startup\c018iBL.c _startup (void) C:\MCC18\src\traditional\startup\c018iBL.c { C:\MCC18\src\traditional\startup\c018iBL.c _asm C:\MCC18\src\traditional\startup\c018iBL.c // Initialize the stack pointer C:\MCC18\src\traditional\startup\c018iBL.c 004506 ee13 LFSR 0x1,0x300 lfsr 1, _stack C:\MCC18\src\traditional\startup\c018iBL.c 004508 f000 00450a ee23 LFSR 0x2,0x300 lfsr 2, _stack C:\MCC18\src\traditional\startup\c018iBL.c 00450c f000 C:\MCC18\src\traditional\startup\c018iBL.c 00450e 6af8 CLRF 0xf8,0x0 clrf TBLPTRU, 0 // 1st silicon doesn't do this on POR C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c 004510 9c17 BCF 0x17,0x6,0x0 bcf __FPFLAGS,RND,0 // Initialize rounding flag for floating point libs C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c _endasm C:\MCC18\src\traditional\startup\c018iBL.c 004512 ecb6 CALL 0x416c,0x0 _do_cinit (); C:\MCC18\src\traditional\startup\c018iBL.c 004514 f020 C:\MCC18\src\traditional\startup\c018iBL.c loop: C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c // Call the user's main routine C:\MCC18\src\traditional\startup\c018iBL.c 004516 ec48 CALL 0x4490,0x0 main (); C:\MCC18\src\traditional\startup\c018iBL.c 004518 f022 C:\MCC18\src\traditional\startup\c018iBL.c 00451a d7fd BRA 0x4516 goto loop; C:\MCC18\src\traditional\startup\c018iBL.c 00451c 0012 RETURN 0x0 } /* end _startup() */ C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c /* MPLAB-C18 initialized data memory support */ C:\MCC18\src\traditional\startup\c018iBL.c /* The linker will populate the _cinit table */ C:\MCC18\src\traditional\startup\c018iBL.c extern far rom struct C:\MCC18\src\traditional\startup\c018iBL.c { C:\MCC18\src\traditional\startup\c018iBL.c unsigned short num_init; C:\MCC18\src\traditional\startup\c018iBL.c struct _init_entry C:\MCC18\src\traditional\startup\c018iBL.c { C:\MCC18\src\traditional\startup\c018iBL.c unsigned long from; C:\MCC18\src\traditional\startup\c018iBL.c unsigned long to; C:\MCC18\src\traditional\startup\c018iBL.c unsigned long size; C:\MCC18\src\traditional\startup\c018iBL.c } C:\MCC18\src\traditional\startup\c018iBL.c entries[]; C:\MCC18\src\traditional\startup\c018iBL.c } C:\MCC18\src\traditional\startup\c018iBL.c _cinit; C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c #pragma code _cinit_scn C:\MCC18\src\traditional\startup\c018iBL.c void C:\MCC18\src\traditional\startup\c018iBL.c _do_cinit (void) C:\MCC18\src\traditional\startup\c018iBL.c { C:\MCC18\src\traditional\startup\c018iBL.c /* we'll make the assumption in the following code that these statics C:\MCC18\src\traditional\startup\c018iBL.c * will be allocated into the same bank. C:\MCC18\src\traditional\startup\c018iBL.c */ C:\MCC18\src\traditional\startup\c018iBL.c static short long prom; C:\MCC18\src\traditional\startup\c018iBL.c static unsigned short curr_byte; C:\MCC18\src\traditional\startup\c018iBL.c static unsigned short curr_entry; C:\MCC18\src\traditional\startup\c018iBL.c static short long data_ptr; C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c // Initialized data... C:\MCC18\src\traditional\startup\c018iBL.c 00416c 0e2a MOVLW 0x2a TBLPTR = (short long)&_cinit; C:\MCC18\src\traditional\startup\c018iBL.c 00416e 6ef6 MOVWF 0xf6,0x0 004170 0e08 MOVLW 0x8 004172 6ef7 MOVWF 0xf7,0x0 004174 0e00 MOVLW 0x0 004176 6ef8 MOVWF 0xf8,0x0 _asm C:\MCC18\src\traditional\startup\c018iBL.c 004178 0101 MOVLB 0x1 movlb data_ptr C:\MCC18\src\traditional\startup\c018iBL.c 00417a 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 00417c 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 00417e 6fc8 MOVWF 0xc8,0x1 movwf curr_entry, 1 C:\MCC18\src\traditional\startup\c018iBL.c 004180 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 004182 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 004184 6fc9 MOVWF 0xc9,0x1 movwf curr_entry+1, 1 C:\MCC18\src\traditional\startup\c018iBL.c _endasm C:\MCC18\src\traditional\startup\c018iBL.c //while (curr_entry) C:\MCC18\src\traditional\startup\c018iBL.c //{ C:\MCC18\src\traditional\startup\c018iBL.c test: C:\MCC18\src\traditional\startup\c018iBL.c _asm C:\MCC18\src\traditional\startup\c018iBL.c 004186 e103 BNZ 0x418e bnz 3 C:\MCC18\src\traditional\startup\c018iBL.c 004188 67c8 TSTFSZ 0xc8,0x1 tstfsz curr_entry, 1 C:\MCC18\src\traditional\startup\c018iBL.c 00418a d001 BRA 0x418e bra 1 C:\MCC18\src\traditional\startup\c018iBL.c _endasm C:\MCC18\src\traditional\startup\c018iBL.c 00418c d03d BRA 0x4208 goto done; C:\MCC18\src\traditional\startup\c018iBL.c /* Count down so we only have to look up the data in _cinit C:\MCC18\src\traditional\startup\c018iBL.c * once. C:\MCC18\src\traditional\startup\c018iBL.c * C:\MCC18\src\traditional\startup\c018iBL.c * At this point we know that TBLPTR points to the top of the current C:\MCC18\src\traditional\startup\c018iBL.c * entry in _cinit, so we can just start reading the from, to, and C:\MCC18\src\traditional\startup\c018iBL.c * size values. C:\MCC18\src\traditional\startup\c018iBL.c */ C:\MCC18\src\traditional\startup\c018iBL.c _asm C:\MCC18\src\traditional\startup\c018iBL.c /* read the source address */ C:\MCC18\src\traditional\startup\c018iBL.c 00418e 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 004190 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 004192 6fc3 MOVWF 0xc3,0x1 movwf prom, 1 C:\MCC18\src\traditional\startup\c018iBL.c 004194 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 004196 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 004198 6fc4 MOVWF 0xc4,0x1 movwf prom+1, 1 C:\MCC18\src\traditional\startup\c018iBL.c 00419a 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 00419c 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 00419e 6fc5 MOVWF 0xc5,0x1 movwf prom+2, 1 C:\MCC18\src\traditional\startup\c018iBL.c /* skip a byte since it's stored as a 32bit int */ C:\MCC18\src\traditional\startup\c018iBL.c 0041a0 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c /* read the destination address directly into FSR0 */ C:\MCC18\src\traditional\startup\c018iBL.c 0041a2 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041a4 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 0041a6 6ee9 MOVWF 0xe9,0x0 movwf FSR0L, 0 C:\MCC18\src\traditional\startup\c018iBL.c 0041a8 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041aa 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 0041ac 6eea MOVWF 0xea,0x0 movwf FSR0H, 0 C:\MCC18\src\traditional\startup\c018iBL.c /* skip two bytes since it's stored as a 32bit int */ C:\MCC18\src\traditional\startup\c018iBL.c 0041ae 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041b0 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c /* read the destination address directly into FSR0 */ C:\MCC18\src\traditional\startup\c018iBL.c 0041b2 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041b4 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 0041b6 6fc6 MOVWF 0xc6,0x1 movwf curr_byte, 1 C:\MCC18\src\traditional\startup\c018iBL.c 0041b8 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041ba 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 0041bc 6fc7 MOVWF 0xc7,0x1 movwf curr_byte+1, 1 C:\MCC18\src\traditional\startup\c018iBL.c /* skip two bytes since it's stored as a 32bit int */ C:\MCC18\src\traditional\startup\c018iBL.c 0041be 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041c0 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c _endasm C:\MCC18\src\traditional\startup\c018iBL.c //prom = data_ptr->from; C:\MCC18\src\traditional\startup\c018iBL.c //FSR0 = data_ptr->to; C:\MCC18\src\traditional\startup\c018iBL.c //curr_byte = (unsigned short) data_ptr->size; C:\MCC18\src\traditional\startup\c018iBL.c /* the table pointer now points to the next entry. Save it C:\MCC18\src\traditional\startup\c018iBL.c * off since we'll be using the table pointer to do the copying C:\MCC18\src\traditional\startup\c018iBL.c * for the entry. C:\MCC18\src\traditional\startup\c018iBL.c */ C:\MCC18\src\traditional\startup\c018iBL.c 0041c2 cff6 MOVFF 0xff6,0x1ca data_ptr = TBLPTR; C:\MCC18\src\traditional\startup\c018iBL.c 0041c4 f1ca 0041c6 cff7 MOVFF 0xff7,0x1cb 0041c8 f1cb 0041ca cff8 MOVFF 0xff8,0x1cc 0041cc f1cc C:\MCC18\src\traditional\startup\c018iBL.c /* now assign the source address to the table pointer */ C:\MCC18\src\traditional\startup\c018iBL.c 0041ce c1c3 MOVFF 0x1c3,0xff6 TBLPTR = prom; C:\MCC18\src\traditional\startup\c018iBL.c 0041d0 fff6 0041d2 c1c4 MOVFF 0x1c4,0xff7 0041d4 fff7 0041d6 c1c5 MOVFF 0x1c5,0xff8 0041d8 fff8 C:\MCC18\src\traditional\startup\c018iBL.c /* do the copy loop */ C:\MCC18\src\traditional\startup\c018iBL.c _asm C:\MCC18\src\traditional\startup\c018iBL.c // determine if we have any more bytes to copy C:\MCC18\src\traditional\startup\c018iBL.c 0041da 0101 MOVLB 0x1 movlb curr_byte C:\MCC18\src\traditional\startup\c018iBL.c 0041dc 53c6 MOVF 0xc6,0x1,0x1 movf curr_byte, 1, 1 C:\MCC18\src\traditional\startup\c018iBL.c copy_loop: C:\MCC18\src\traditional\startup\c018iBL.c 0041de e102 BNZ 0x41e4 bnz 2 // copy_one_byte C:\MCC18\src\traditional\startup\c018iBL.c 0041e0 53c7 MOVF 0xc7,0x1,0x1 movf curr_byte + 1, 1, 1 C:\MCC18\src\traditional\startup\c018iBL.c 0041e2 e007 BZ 0x41f2 bz 7 // done_copying C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c copy_one_byte: C:\MCC18\src\traditional\startup\c018iBL.c 0041e4 0009 TBLRDPOSTINC tblrdpostinc C:\MCC18\src\traditional\startup\c018iBL.c 0041e6 50f5 MOVF 0xf5,0x0,0x0 movf TABLAT, 0, 0 C:\MCC18\src\traditional\startup\c018iBL.c 0041e8 6eee MOVWF 0xee,0x0 movwf POSTINC0, 0 C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c // decrement byte counter C:\MCC18\src\traditional\startup\c018iBL.c 0041ea 07c6 DECF 0xc6,0x1,0x1 decf curr_byte, 1, 1 C:\MCC18\src\traditional\startup\c018iBL.c 0041ec e2f8 BC 0x41de bc -8 // copy_loop C:\MCC18\src\traditional\startup\c018iBL.c 0041ee 07c7 DECF 0xc7,0x1,0x1 decf curr_byte + 1, 1, 1 C:\MCC18\src\traditional\startup\c018iBL.c 0041f0 d7f9 BRA 0x41e4 bra -7 // copy_one_byte C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c done_copying: C:\MCC18\src\traditional\startup\c018iBL.c C:\MCC18\src\traditional\startup\c018iBL.c _endasm C:\MCC18\src\traditional\startup\c018iBL.c /* restore the table pointer for the next entry */ C:\MCC18\src\traditional\startup\c018iBL.c 0041f2 c1ca MOVFF 0x1ca,0xff6 TBLPTR = data_ptr; C:\MCC18\src\traditional\startup\c018iBL.c 0041f4 fff6 0041f6 c1cb MOVFF 0x1cb,0xff7 0041f8 fff7 0041fa c1cc MOVFF 0x1cc,0xff8 0041fc fff8 /* next entry... */ C:\MCC18\src\traditional\startup\c018iBL.c 0041fe 0101 MOVLB 0x1 curr_entry--; C:\MCC18\src\traditional\startup\c018iBL.c 004200 07c8 DECF 0xc8,0x1,0x1 004202 0e00 MOVLW 0x0 004204 5bc9 SUBWFB 0xc9,0x1,0x1 004206 d7bf BRA 0x4186 goto test; C:\MCC18\src\traditional\startup\c018iBL.c done: C:\MCC18\src\traditional\startup\c018iBL.c ; C:\MCC18\src\traditional\startup\c018iBL.c 004208 0012 RETURN 0x0 } C:\MCC18\src\traditional\startup\c018iBL.c /********************************************************************* C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c ********************************************************************* C:\Projects\UBW\FW\2455\D\main.c * FileName: main.c C:\Projects\UBW\FW\2455\D\main.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\main.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\main.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\main.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Software License Agreement C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\main.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\main.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\main.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\main.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\main.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\main.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\main.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\main.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\main.c * license. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\main.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\main.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\main.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\main.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\main.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Author Date Comment C:\Projects\UBW\FW\2455\D\main.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\2455\D\main.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\2455\D\main.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\2455\D\main.c #include C:\Projects\UBW\FW\2455\D\main.c #include "system\typedefs.h" // Required C:\Projects\UBW\FW\2455\D\main.c #include "system\usb\usb.h" // Required C:\Projects\UBW\FW\2455\D\main.c #include "io_cfg.h" // Required C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c #include "system\usb\usb_compile_time_validation.h" // Optional C:\Projects\UBW\FW\2455\D\main.c #include "user\user.h" // Modifiable C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\2455\D\main.c #pragma udata C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\2455\D\main.c static void InitializeSystem(void); C:\Projects\UBW\FW\2455\D\main.c void USBTasks(void); C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c #pragma code high_vector_section = 0x000808 C:\Projects\UBW\FW\2455\D\main.c void high_vector (void) C:\Projects\UBW\FW\2455\D\main.c { C:\Projects\UBW\FW\2455\D\main.c 000808 efbb GOTO 0xb76 _asm goto high_ISR _endasm C:\Projects\UBW\FW\2455\D\main.c 00080a f005 00080c 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\main.c #pragma code low_vector_section = 0x000818 C:\Projects\UBW\FW\2455\D\main.c void low_vector (void) C:\Projects\UBW\FW\2455\D\main.c { C:\Projects\UBW\FW\2455\D\main.c 000818 ef22 GOTO 0x844 _asm goto low_ISR _endasm C:\Projects\UBW\FW\2455\D\main.c 00081a f004 00081c 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\main.c #pragma code C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\2455\D\main.c #pragma code C:\Projects\UBW\FW\2455\D\main.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\main.c * Function: void main(void) C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * PreCondition: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Input: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Output: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Side Effects: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Overview: Main program entry point. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Note: None C:\Projects\UBW\FW\2455\D\main.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\main.c void main(void) C:\Projects\UBW\FW\2455\D\main.c { C:\Projects\UBW\FW\2455\D\main.c 004490 d805 RCALL 0x449c InitializeSystem(); C:\Projects\UBW\FW\2455\D\main.c 004498 d7fc BRA 0x4492 while(1) C:\Projects\UBW\FW\2455\D\main.c { C:\Projects\UBW\FW\2455\D\main.c 004492 d811 RCALL 0x44b6 USBTasks(); // USB Tasks C:\Projects\UBW\FW\2455\D\main.c 004494 ec8f CALL 0xd1e,0x0 ProcessIO(); // See user\user.c & .h C:\Projects\UBW\FW\2455\D\main.c 004496 f006 }//end while C:\Projects\UBW\FW\2455\D\main.c 00449a 0012 RETURN 0x0 }//end main C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\main.c * Function: static void InitializeSystem(void) C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * PreCondition: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Input: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Output: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Side Effects: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Overview: InitializeSystem is a centralize initialization routine. C:\Projects\UBW\FW\2455\D\main.c * All required USB initialization routines are called from C:\Projects\UBW\FW\2455\D\main.c * here. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * User application initialization routine should also be C:\Projects\UBW\FW\2455\D\main.c * called from here. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Note: None C:\Projects\UBW\FW\2455\D\main.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\main.c static void InitializeSystem(void) C:\Projects\UBW\FW\2455\D\main.c { C:\Projects\UBW\FW\2455\D\main.c 00449c 0e0f MOVLW 0xf ADCON1 |= 0x0F; // Default all pins to digital C:\Projects\UBW\FW\2455\D\main.c 00449e 12c1 IORWF 0xc1,0x1,0x0 C:\Projects\UBW\FW\2455\D\main.c 0044a0 0e14 MOVLW 0x14 mInitializeUSBDriver(); // See usbdrv.h C:\Projects\UBW\FW\2455\D\main.c 0044a2 6e6f MOVWF 0x6f,0x0 0044a4 0101 MOVLB 0x1 0044a6 6bd5 CLRF 0xd5,0x1 0044a8 0101 MOVLB 0x1 0044aa 6bd6 CLRF 0xd6,0x1 0044ac 0101 MOVLB 0x1 0044ae 6bd7 CLRF 0xd7,0x1 C:\Projects\UBW\FW\2455\D\main.c 0044b0 ecc4 CALL 0xb88,0x0 UserInit(); // See user.c & .h C:\Projects\UBW\FW\2455\D\main.c 0044b2 f005 C:\Projects\UBW\FW\2455\D\main.c 0044b4 0012 RETURN 0x0 }//end InitializeSystem C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\main.c * Function: void USBTasks(void) C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * PreCondition: InitializeSystem has been called. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Input: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Output: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Side Effects: None C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Overview: Service loop for USB tasks. C:\Projects\UBW\FW\2455\D\main.c * C:\Projects\UBW\FW\2455\D\main.c * Note: None C:\Projects\UBW\FW\2455\D\main.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\main.c void USBTasks(void) C:\Projects\UBW\FW\2455\D\main.c { C:\Projects\UBW\FW\2455\D\main.c /* C:\Projects\UBW\FW\2455\D\main.c * Servicing Hardware C:\Projects\UBW\FW\2455\D\main.c */ C:\Projects\UBW\FW\2455\D\main.c 0044b6 ec73 CALL 0x3ce6,0x0 USBCheckBusStatus(); // Must use polling method C:\Projects\UBW\FW\2455\D\main.c 0044b8 f01e 0044ba be6f BTFSC 0x6f,0x7,0x0 if(UCFGbits.UTEYE!=1) C:\Projects\UBW\FW\2455\D\main.c 0044bc d002 BRA 0x44c2 0044be ec93 CALL 0x3d26,0x0 USBDriverService(); // Interrupt or polling method C:\Projects\UBW\FW\2455\D\main.c 0044c0 f01e C:\Projects\UBW\FW\2455\D\main.c #if defined(USB_USE_CDC) C:\Projects\UBW\FW\2455\D\main.c 0044c2 ecbd CALL 0x357a,0x0 CDCTxService(); C:\Projects\UBW\FW\2455\D\main.c 0044c4 f01a #endif C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c 0044c6 0012 RETURN 0x0 }// end USBTasks C:\Projects\UBW\FW\2455\D\main.c C:\Projects\UBW\FW\2455\D\main.c /** EOF main.c ***************************************************************/ C:\Projects\UBW\FW\2455\D\main.c /********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c ********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * FileName: usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Software License Agreement C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * license. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Author Date Comment C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * -usbmmap.c- C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * USB Memory Map C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * This file is the USB memory manager; it serves as a compile-time memory C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * allocator for the USB endpoints. It uses the compile time options passed C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * from usbcfg.h to instantiate endpoints and endpoint buffer. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Each endpoint requires to have a set of Buffer Descriptor registers(BDT). C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * A BDT is 4-byte long and has a specific RAM location for each endpoint. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The BDT for endpoint 0 out is located at address 0x400 to 0x403. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The BDT for endpoint 0 in is located at address 0x404 to 0x407. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The BDT for endpoint 1 out is located at address 0x408 to 0x40B. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * and so on... The above allocation assumes the Ping-Pong Buffer Mode 0 is C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * used. These locations are already hard-wired in the silicon. The point C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * of doing instantiation, i.e. volatile far BDT ep0Bo;, is to provide the C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C compiler a way to address each variable directly. This is very important C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * because when a register can be accessed directly, it saves execution time C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * and reduces program size. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Endpoints are defined using the endpoint number and the direction C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * of transfer. For simplicity, usbmmap.c only uses the endpoint number C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * in the BDT register allocation scheme. This means if the usbcfg.h states C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * that the MAX_EP_NUMBER is number 1, then four BDTs will be C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * instantiated: one each for endpoint0 in and endpoint0 out, which must C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * always be instantiated for control transfer by default, and one each sets C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * for endpoint1 in and endpoint1 out. The naming convention for instantiating C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * BDT is C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * ep<#>B C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * where # is the endpoint number, and d is the direction of C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * transfer, which could be either or . C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The USB memory manager uses MAX_EP_NUMBER, as defined in usbcfg.h, to define C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * the endpoints to be instantiated. This represents the highest endpoint C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * number to be allocated, not how many endpoints are used. Since the BDTs for C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * endpoints have hardware-assigned addresses in Bank 4, setting this value too C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * high may lead to inefficient use of data RAM. For example, if an application C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * uses only endpoints EP0 and EP4, then the MAX_EP_NUMBER is 4, and not 2. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The in-between endpoint BDTs in this example (EP1, EP2, and EP3) go unused, C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * and the 24 bytes of memory associated with them are wasted. It does not make C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * much sense to skip endpoints, but the final decision lies with the user. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The next step is to assign the instantiated BDTs to different C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * USB functions. The firmware framework fundamentally assumes that every USB C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * function should know which endpoint it is using, i.e., the default control C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * transfer should know that it is using endpoint 0 in and endpoint 0 out. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * A HID class can choose which endpoint it wants to use, but once chosen, it C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * should always know the number of the endpoint. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The assignment of endpoints to USB functions is managed centrally C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * in usbcfg.h. This helps prevent the mistake of having more C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * than one USB function using the same endpoint. The "Endpoint Allocation" C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * section in usbcfg.h provides examples for how to map USB endpoints to USB C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * functions. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Quite a few things can be mapped in that section. There is no C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * one correct way to do the mapping and the user has the choice to C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * choose a method that is most suitable to the application. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Typically, however, a user will want to map the following for a given C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * USB interface function: C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * 1. The USB interface ID C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * 2. The endpoint control registers (UEPn) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * 3. The BDT registers (ep<#>B) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * 4. The endpoint size C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Example: Assume a USB device class "foo", which uses one out endpoint C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * of size 64-byte and one in endpoint of size 64-byte, then: C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * #define FOO_INTF_ID 0x00 C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * #define FOO_UEP UEP1 C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * #define FOO_BD_OUT ep1Bo C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * #define FOO_BD_IN ep1Bi C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * #define FOO_EP_SIZE 64 C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The mapping above has chosen class "foo" to use endpoint 1. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The names are arbitrary and can be anything other than FOO_??????. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * For abstraction, the code for class "foo" should use the abstract C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * definitions of FOO_BD_OUT,FOO_BD_IN, and not ep1Bo or ep1Bi. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Note that the endpoint size defined in the usbcfg.h file is again C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * used in the usbmmap.c file. This shows that the relationship between C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * the two files are tightly related. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The endpoint buffer for each USB function must be located in the C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * dual-port RAM area and has to come after all the BDTs have been C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * instantiated. An example declaration is: C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * volatile far unsigned char[FOO_EP_SIZE] data; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * The 'volatile' keyword tells the compiler not to perform any code C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * optimization on this variable because its content could be modified C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * by the hardware. The 'far' keyword tells the compiler that this variable C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * is not located in the Access RAM area (0x000 - 0x05F). C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * For the variable to be globally accessible by other files, it should be C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * declared in the header file usbmmap.h as an extern definition, such as C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * extern volatile far unsigned char[FOO_EP_SIZE] data; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Conclusion: C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * In a short summary, the dependencies between usbcfg and usbmmap can C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * be shown as: C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * usbcfg[MAX_EP_NUMBER] -> usbmmap C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * usbmmap[ep<#>B] -> usbcfg C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * usbcfg[EP size] -> usbmmap C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * usbcfg[abstract ep definitions] -> usb9/hid/cdc/etc class code C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * usbmmap[endpoint buffer variable] -> usb9/hid/cdc/etc class code C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Data mapping provides a means for direct addressing of BDT and endpoint C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * buffer. This means less usage of pointers, which equates to a faster and C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * smaller program code. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #include "system\typedefs.h" C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #include "system\usb\usb.h" C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /** U S B G L O B A L V A R I A B L E S ************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #pragma udata C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c byte usb_device_state; // Device States: DETACHED, ATTACHED, ... C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c USB_DEVICE_STATUS usb_stat; // Global USB flags C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c byte usb_active_cfg; // Value of current configuration C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c byte usb_alt_intf[MAX_NUM_INT]; // Array to keep track of the current alternate C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c // setting for each interface ID C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\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:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #pragma udata usbram4=0x400 //See Linker Script,usb4:0x400-0x4FF(256-byte) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Section A: Buffer Descriptor Table C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - 0x400 - 0x4FF(max) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - MAX_EP_NUMBER is defined in autofiles\usbcfg.h C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - BDT data type is defined in system\usb\usbmmap.h C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(0 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep0Bo; //Endpoint #0 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep0Bi; //Endpoint #0 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(1 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep1Bo; //Endpoint #1 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep1Bi; //Endpoint #1 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(2 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep2Bo; //Endpoint #2 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep2Bi; //Endpoint #2 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(3 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep3Bo; //Endpoint #3 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep3Bi; //Endpoint #3 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(4 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep4Bo; //Endpoint #4 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep4Bi; //Endpoint #4 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(5 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep5Bo; //Endpoint #5 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep5Bi; //Endpoint #5 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(6 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep6Bo; //Endpoint #6 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep6Bi; //Endpoint #6 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(7 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep7Bo; //Endpoint #7 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep7Bi; //Endpoint #7 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(8 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep8Bo; //Endpoint #8 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep8Bi; //Endpoint #8 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(9 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep9Bo; //Endpoint #9 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep9Bi; //Endpoint #9 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(10 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep10Bo; //Endpoint #10 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep10Bi; //Endpoint #10 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(11 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep11Bo; //Endpoint #11 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep11Bi; //Endpoint #11 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(12 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep12Bo; //Endpoint #12 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep12Bi; //Endpoint #12 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(13 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep13Bo; //Endpoint #13 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep13Bi; //Endpoint #13 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(14 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep14Bo; //Endpoint #14 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep14Bi; //Endpoint #14 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if(15 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep15Bo; //Endpoint #15 BD Out C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far BDT ep15Bi; //Endpoint #15 BD In C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Section B: EP0 Buffer Space C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c ****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - Two buffer areas are defined: C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * A. CTRL_TRF_SETUP C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - Size = EP0_BUFF_SIZE as defined in autofiles\usbcfg.h C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - Detailed data structure allows direct adddressing of bits and bytes. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * B. CTRL_TRF_DATA C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - Size = EP0_BUFF_SIZE as defined in autofiles\usbcfg.h C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - Data structure allows direct adddressing of the first 8 bytes. C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * - Both data types are defined in system\usb\usbdefs\usbdefs_ep0_buff.h C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far CTRL_TRF_SETUP SetupPkt; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far CTRL_TRF_DATA CtrlTrfData; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * Section C: CDC Buffer C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c ****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c * C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #pragma udata usbram5a=0x500 //See Linker Script,usb5:0x500-... C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #if defined(USB_USE_CDC) C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far unsigned char cdc_notice[CDC_INT_EP_SIZE]; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far unsigned char cdc_data_rx[CDC_BULK_OUT_EP_SIZE]; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c volatile far unsigned char cdc_data_tx[CDC_BULK_IN_EP_SIZE]; C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c #pragma udata C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /** EOF usbmmap.c ************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbmmap.c /********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c ********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * FileName: usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Software License Agreement C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * license. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Author Date Comment C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #include C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #include "system\typedefs.h" C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #include "system\usb\usb.h" C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #include "io_cfg.h" // Required for USBCheckBusStatus() C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #pragma udata C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBModuleEnable(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBModuleDisable(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBSuspend(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBWakeFromSuspend(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBProtocolResetHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USB_SOF_Handler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBStallHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBErrorHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #pragma code C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBCheckBusStatus(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: This routine enables/disables the USB module by monitoring C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the USB power signal. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBCheckBusStatus(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Bus Attachment & Detachment Detection C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * usb_bus_sense is an i/o pin defined in io_cfg.h C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #define USB_BUS_ATTACHED 1 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c #define USB_BUS_DETACHED 0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c if(usb_bus_sense == USB_BUS_ATTACHED) // Is USB bus attached? C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003ce6 a66d BTFSS 0x6d,0x3,0x0 if(UCONbits.USBEN == 0) // Is the module off? C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003ce8 d810 RCALL 0x3d0a USBModuleEnable(); // Is off, enable it C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c } C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cea d002 BRA 0x3cf0 else C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cec b66d BTFSC 0x6d,0x3,0x0 if(UCONbits.USBEN == 1) // Is the module on? C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cee d814 RCALL 0x3d18 USBModuleDisable(); // Is on, disable it C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c }//end if(usb_bus_sense...) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * After enabling the USB module, it takes some time for the voltage C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * on the D+ or D- line to rise high enough to get out of the SE0 condition. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * The USB Reset interrupt should not be unmasked until the SE0 condition is C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * cleared. This helps preventing the firmware from misinterpreting this C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * unique event as a USB bus reset from the USB host. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cf0 0101 MOVLB 0x1 if(usb_device_state == ATTACHED_STATE) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cf2 05d5 DECF 0xd5,0x0,0x1 003cf4 e109 BNZ 0x3d08 { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cf6 ba6d BTFSC 0x6d,0x5,0x0 if(!UCONbits.SE0) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cf8 d007 BRA 0x3d08 { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cfa 6a68 CLRF 0x68,0x0 UIR = 0; // Clear all USB interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cfc 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003cfe 8069 BSF 0x69,0x0,0x0 UIEbits.URSTIE = 1; // Unmask RESET interrupt C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d00 8869 BSF 0x69,0x4,0x0 UIEbits.IDLEIE = 1; // Unmask IDLE interrupt C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d02 0101 MOVLB 0x1 usb_device_state = POWERED_STATE; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d04 0e02 MOVLW 0x2 003d06 6fd5 MOVWF 0xd5,0x1 }//end if // else wait until SE0 is cleared C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c }//end if(usb_device_state == ATTACHED_STATE) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d08 0012 RETURN 0x0 }//end USBCheckBusStatus C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBModuleEnable(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: This routine enables the USB module. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * An end designer should never have to call this routine C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * manually. This routine should only be called from C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * USBCheckBusStatus(). C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: See USBCheckBusStatus() for more information. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBModuleEnable(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d0a 6a6d CLRF 0x6d,0x0 UCON = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d0c 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d0e 866d BSF 0x6d,0x3,0x0 UCONbits.USBEN = 1; // Enable module & attach to bus C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d10 0101 MOVLB 0x1 usb_device_state = ATTACHED_STATE; // Defined in usbmmap.c & .h C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d12 0e01 MOVLW 0x1 003d14 6fd5 MOVWF 0xd5,0x1 003d16 0012 RETURN 0x0 }//end USBModuleEnable C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBModuleDisable(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: This routine disables the USB module. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * An end designer should never have to call this routine C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * manually. This routine should only be called from C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * USBCheckBusStatus(). C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: See USBCheckBusStatus() for more information. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBModuleDisable(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d18 6a6d CLRF 0x6d,0x0 UCON = 0; // Disable module & detach from bus C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d1a 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d1c 0101 MOVLB 0x1 usb_device_state = DETACHED_STATE; // Defined in usbmmap.c & .h C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d1e 6bd5 CLRF 0xd5,0x1 003d20 0012 RETURN 0x0 }//end USBModuleDisable C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBSoftDetach(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: The device will have to be re-enumerated to function again. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: USBSoftDetach electrically disconnects the device from C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the bus. This is done by stop supplying Vusb voltage to C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * pull-up resistor. The pull-down resistors on the host C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * side will pull both differential signal lines low and C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the host registers the event as a disconnect. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Since the USB cable is not physically disconnected, the C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * power supply through the cable can still be sensed by C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the device. The next time USBCheckBusStatus() function C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * is called, it will reconnect the device back to the bus. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBSoftDetach(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d22 dffa RCALL 0x3d18 USBModuleDisable(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d24 0012 RETURN 0x0 }//end USBSoftDetach C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBDriverService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: This routine is the heart of this firmware. It manages C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * all USB interrupts. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: Device state transitions through the following stages: C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * DETACHED -> ATTACHED -> POWERED -> DEFAULT -> C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ADDRESS_PENDING -> ADDRESSED -> CONFIGURED -> READY C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBDriverService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if USB cable is not even attached. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d26 0101 MOVLB 0x1 if(usb_device_state == DETACHED_STATE) return; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d28 51d5 MOVF 0xd5,0x0,0x1 003d2a e101 BNZ 0x3d2e 003d2c d03a BRA 0x3da2 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Task A: Service USB Activity Interrupt C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d2e 5068 MOVF 0x68,0x0,0x0 if(UIRbits.ACTVIF && UIEbits.ACTVIE) USBWakeFromSuspend(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d30 0b04 ANDLW 0x4 003d32 e004 BZ 0x3d3c 003d34 5069 MOVF 0x69,0x0,0x0 003d36 0b04 ANDLW 0x4 003d38 e001 BZ 0x3d3c 003d3a d83c RCALL 0x3db4 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if the device is in suspend mode. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d3c b26d BTFSC 0x6d,0x1,0x0 if(UCONbits.SUSPND==1) return; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d3e d031 BRA 0x3da2 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Task B: Service USB Bus Reset Interrupt. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * When bus reset is received during suspend, ACTVIF will be set first, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * once the UCONbits.SUSPND is clear, then the URSTIF bit will be asserted. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * This is why URSTIF is checked after ACTVIF. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d40 5068 MOVF 0x68,0x0,0x0 if(UIRbits.URSTIF && UIEbits.URSTIE) USBProtocolResetHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d42 0b01 ANDLW 0x1 003d44 e004 BZ 0x3d4e 003d46 5069 MOVF 0x69,0x0,0x0 003d48 0b01 ANDLW 0x1 003d4a e001 BZ 0x3d4e 003d4c d856 RCALL 0x3dfa C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Task C: Service other USB interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d4e 5068 MOVF 0x68,0x0,0x0 if(UIRbits.IDLEIF && UIEbits.IDLEIE) USBSuspend(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d50 0b10 ANDLW 0x10 003d52 e004 BZ 0x3d5c 003d54 5069 MOVF 0x69,0x0,0x0 003d56 0b10 ANDLW 0x10 003d58 e001 BZ 0x3d5c 003d5a d824 RCALL 0x3da4 003d5c 5068 MOVF 0x68,0x0,0x0 if(UIRbits.SOFIF && UIEbits.SOFIE) USB_SOF_Handler(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d5e 0b40 ANDLW 0x40 003d60 e004 BZ 0x3d6a 003d62 5069 MOVF 0x69,0x0,0x0 003d64 0b40 ANDLW 0x40 003d66 e001 BZ 0x3d6a 003d68 d83d RCALL 0x3de4 003d6a 5068 MOVF 0x68,0x0,0x0 if(UIRbits.STALLIF && UIEbits.STALLIE) USBStallHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d6c 0b20 ANDLW 0x20 003d6e e004 BZ 0x3d78 003d70 5069 MOVF 0x69,0x0,0x0 003d72 0b20 ANDLW 0x20 003d74 e001 BZ 0x3d78 003d76 d838 RCALL 0x3de8 003d78 5068 MOVF 0x68,0x0,0x0 if(UIRbits.UERRIF && UIEbits.UERRIE) USBErrorHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d7a 0b02 ANDLW 0x2 003d7c e004 BZ 0x3d86 003d7e 5069 MOVF 0x69,0x0,0x0 003d80 0b02 ANDLW 0x2 003d82 e001 BZ 0x3d86 003d84 d838 RCALL 0x3df6 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if the host has not sent a bus reset. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Once bus reset is received, the device transitions into the DEFAULT C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * state and is ready for communication. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d86 0e03 MOVLW 0x3 if(usb_device_state < DEFAULT_STATE) return; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d88 0101 MOVLB 0x1 003d8a 5dd5 SUBWF 0xd5,0x0,0x1 003d8c e201 BC 0x3d90 003d8e d009 BRA 0x3da2 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Task D: Servicing USB Transaction Complete Interrupt C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d90 5068 MOVF 0x68,0x0,0x0 if(UIRbits.TRNIF && UIEbits.TRNIE) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d92 0b08 ANDLW 0x8 003d94 e006 BZ 0x3da2 003d96 5069 MOVF 0x69,0x0,0x0 003d98 0b08 ANDLW 0x8 003d9a e003 BZ 0x3da2 { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * USBCtrlEPService only services transactions over EP0. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * It ignores all other EP transactions. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d9c ec47 CALL 0x368e,0x0 USBCtrlEPService(); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003d9e f01b C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Other EP can be serviced later by responsible device class firmware. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Each device driver knows when an OUT or IN transaction is ready by C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * checking the buffer ownership bit. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * An OUT EP should always be owned by SIE until the data is ready. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * An IN EP should always be owned by CPU until the data is ready. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Because of this logic, it is not necessary to save the USTAT value C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * of non-EP0 transactions. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003da0 9668 BCF 0x68,0x3,0x0 UIRbits.TRNIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c }//end if(UIRbits.TRNIF && UIEbits.TRNIE) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003da2 0012 RETURN 0x0 }//end USBDriverService C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBSuspend(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBSuspend(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * NOTE: Do not clear UIRbits.ACTVIF here! C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Reason: C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ACTVIF is only generated once an IDLEIF has been generated. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * This is a 1:1 ratio interrupt generation. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * For every IDLEIF, there will be only one ACTVIF regardless of C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the number of subsequent bus transitions. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * If the ACTIF is cleared here, a problem could occur when: C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * [ IDLE ][bus activity -> C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * <--- 3 ms -----> ^ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ^ ACTVIF=1 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * IDLEIF=1 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * # # # # (#=Program polling flags) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ^ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * This polling loop will see both C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * IDLEIF=1 and ACTVIF=1. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * However, the program services IDLEIF first C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * because ACTIVIE=0. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * If this routine clears the only ACTIVIF, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * then it can never get out of the suspend C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * mode. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003da4 8469 BSF 0x69,0x2,0x0 UIEbits.ACTVIE = 1; // Enable bus activity interrupt C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003da6 9868 BCF 0x68,0x4,0x0 UIRbits.IDLEIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003da8 826d BSF 0x6d,0x1,0x0 UCONbits.SUSPND = 1; // Put USB module in power conserve C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c // mode, SIE clock inactive C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * At this point the PIC can go into sleep,idle, or C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * switch to a slower clock, etc. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* Modifiable Section */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003daa 9aa1 BCF 0xa1,0x5,0x0 PIR2bits.USBIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dac 8aa0 BSF 0xa0,0x5,0x0 PIE2bits.USBIE = 1; // Set USB wakeup source C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dae 0003 SLEEP Sleep(); // Goto sleep C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003db0 9aa0 BCF 0xa0,0x5,0x0 PIE2bits.USBIE = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* End Modifiable Section */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003db2 0012 RETURN 0x0 }//end USBSuspend C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBWakeFromSuspend(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBWakeFromSuspend(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * If using clock switching, this is the place to restore the C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * original clock frequency. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003db4 926d BCF 0x6d,0x1,0x0 UCONbits.SUSPND = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003db6 9469 BCF 0x69,0x2,0x0 UIEbits.ACTVIE = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003db8 9468 BCF 0x68,0x2,0x0 UIRbits.ACTVIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dba 0012 RETURN 0x0 }//end USBWakeFromSuspend C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBRemoteWakeup(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: This function should be called by user when the device C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * is waken up by an external stimulus other than ACTIVIF. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Please read the note below to understand the limitations. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: The modifiable section in this routine should be changed C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * to meet the application needs. Current implementation C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * temporary blocks other functions from executing for a C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * period of 1-13 ms depending on the core frequency. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * According to USB 2.0 specification section 7.1.7.7, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * "The remote wakeup device must hold the resume signaling C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * for at lest 1 ms but for no more than 15 ms." C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * The idea here is to use a delay counter loop, using a C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * common value that would work over a wide range of core C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * frequencies. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * That value selected is 1800. See table below: C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ========================================================== C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Core Freq(MHz) MIP RESUME Signal Period (ms) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ========================================================== C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * 48 12 1.05 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * 4 1 12.6 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * ========================================================== C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * * These timing could be incorrect when using code C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * optimization or extended instruction mode, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * or when having other interrupts enabled. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Make sure to verify using the MPLAB SIM's Stopwatch C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBRemoteWakeup(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c static word delay_count; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dbc 0101 MOVLB 0x1 if(usb_stat.RemoteWakeup == 1) // Check if RemoteWakeup function C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dbe a1d6 BTFSS 0xd6,0x0,0x1 003dc0 d010 BRA 0x3de2 { // has been enabled by the host. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dc2 dff8 RCALL 0x3db4 USBWakeFromSuspend(); // Unsuspend USB modue C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dc4 846d BSF 0x6d,0x2,0x0 UCONbits.RESUME = 1; // Start RESUME signaling C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* Modifiable Section */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dc6 0101 MOVLB 0x1 delay_count = 1800U; // Set RESUME line for 1-13 ms C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dc8 0e08 MOVLW 0x8 003dca 6fdc MOVWF 0xdc,0x1 003dcc 0e07 MOVLW 0x7 003dce 6fdd MOVWF 0xdd,0x1 do C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dd0 0101 MOVLB 0x1 delay_count--; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dd2 07dc DECF 0xdc,0x1,0x1 003dd4 0e00 MOVLW 0x0 003dd6 5bdd SUBWFB 0xdd,0x1,0x1 003dd8 0101 MOVLB 0x1 }while(delay_count); C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dda 51dc MOVF 0xdc,0x0,0x1 003ddc 11dd IORWF 0xdd,0x0,0x1 003dde e1f8 BNZ 0x3dd0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* End Modifiable Section */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003de0 946d BCF 0x6d,0x2,0x0 UCONbits.RESUME = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c }//endif C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003de2 0012 RETURN 0x0 }//end USBRemoteWakeup C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USB_SOF_Handler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: The USB host sends out a SOF packet to full-speed devices C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * every 1 ms. This interrupt may be useful for isochronous C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * pipes. End designers should implement callback routine C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * as necessary. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USB_SOF_Handler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* Callback routine here */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003de4 9c68 BCF 0x68,0x6,0x0 UIRbits.SOFIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003de6 0012 RETURN 0x0 }//end USB_SOF_Handler C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBStallHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: A STALL packet is sent to the host by the SIE. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: The STALLIF is set anytime the SIE sends out a STALL C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * packet regardless of which endpoint causes it. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * A Setup transaction overrides the STALL function. A stalled C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * endpoint stops stalling once it receives a setup packet. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * In this case, the SIE will accepts the Setup packet and C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * set the TRNIF flag to notify the firmware. STALL function C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * for that particular endpoint pipe will be automatically C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * disabled (direction specific). C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * There are a few reasons for an endpoint to be stalled. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * 1. When a non-supported USB request is received. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Example: GET_DESCRIPTOR(DEVICE_QUALIFIER) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * 2. When an endpoint is currently halted. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * 3. When the device class specifies that an endpoint must C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * stall in response to a specific event. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Example: Mass Storage Device Class C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * If the CBW is not valid, the device shall C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * STALL the Bulk-In pipe. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * See USB Mass Storage Class Bulk-only Transport C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Specification for more details. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: UEPn.EPSTALL can be scanned to see which endpoint causes C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the stall event. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * If C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBStallHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Does not really have to do anything here, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * even for the control endpoint. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * All BDs of Endpoint 0 are owned by SIE right now, C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * but once a Setup Transaction is received, the ownership C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * for EP0_OUT will be returned to CPU. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * When the Setup Transaction is serviced, the ownership C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * for EP0_IN will then be forced back to CPU by firmware. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003de8 a070 BTFSS 0x70,0x0,0x0 if(UEP0bits.EPSTALL == 1) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dea d003 BRA 0x3df2 { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dec ecd4 CALL 0x39a8,0x0 USBPrepareForNextSetupTrf(); // Firmware work-around C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dee f01c 003df0 9070 BCF 0x70,0x0,0x0 UEP0bits.EPSTALL = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c } C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003df2 9a68 BCF 0x68,0x5,0x0 UIRbits.STALLIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003df4 0012 RETURN 0x0 }//end USBStallHandler C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBErrorHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: The purpose of this interrupt is mainly for debugging C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * during development. Check UEIR to see which error causes C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * the interrupt. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBErrorHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003df6 9268 BCF 0x68,0x1,0x0 UIRbits.UERRIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003df8 0012 RETURN 0x0 }//end USBErrorHandler C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Function: void USBProtocolResetHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * PreCondition: A USB bus reset is received from the host. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Side Effects: Currently, this routine flushes any pending USB C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * transactions. It empties out the USTAT FIFO. This action C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * might not be desirable in some applications. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Overview: Once a USB bus reset is received from the host, this C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * routine should be called. It resets the device address to C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * zero, disables all non-EP0 endpoints, initializes EP0 to C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * be ready for default communication, clears all USB C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * interrupt flags, unmasks applicable USB interrupts, and C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * reinitializes internal state-machine variables. C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c void USBProtocolResetHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dfa 6a6a CLRF 0x6a,0x0 UEIR = 0; // Clear all USB error flags C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dfc 6a68 CLRF 0x68,0x0 UIR = 0; // Clears all USB interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003dfe 0e9f MOVLW 0x9f UEIE = 0b10011111; // Unmask all USB error interrupts C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e00 6e6b MOVWF 0x6b,0x0 003e02 0e7b MOVLW 0x7b UIE = 0b01111011; // Enable all interrupts except ACTVIE C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e04 6e69 MOVWF 0x69,0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e06 6a6e CLRF 0x6e,0x0 UADDR = 0x00; // Reset to default address C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e08 0e0f MOVLW 0xf mDisableEP1to15(); // Reset all non-EP0 UEPn registers C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e0a 6ee6 MOVWF 0xe6,0x0 003e0c 0e71 MOVLW 0x71 003e0e 6ee6 MOVWF 0xe6,0x0 003e10 0e0f MOVLW 0xf 003e12 6ee6 MOVWF 0xe6,0x0 003e14 d814 RCALL 0x3e3e 003e16 52e5 MOVF 0xe5,0x1,0x0 003e18 52e5 MOVF 0xe5,0x1,0x0 003e1a 52e5 MOVF 0xe5,0x1,0x0 003e1c 0e16 MOVLW 0x16 UEP0 = EP_CTRL|HSHK_EN; // Init EP0 as a Ctrl EP, see usbdrv.h C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e1e 6e70 MOVWF 0x70,0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e20 a668 BTFSS 0x68,0x3,0x0 while(UIRbits.TRNIF == 1) // Flush any pending transactions C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e22 d002 BRA 0x3e28 003e26 d7fc BRA 0x3e20 003e24 9668 BCF 0x68,0x3,0x0 UIRbits.TRNIF = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e28 986d BCF 0x6d,0x4,0x0 UCONbits.PKTDIS = 0; // Make sure packet processing is enabled C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e2a ecd4 CALL 0x39a8,0x0 USBPrepareForNextSetupTrf(); // Declared in usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e2c f01c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e2e 0101 MOVLB 0x1 usb_stat.RemoteWakeup = 0; // Default status flag to disable C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e30 91d6 BCF 0xd6,0x0,0x1 003e32 0101 MOVLB 0x1 usb_active_cfg = 0; // Clear active configuration C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e34 6bd7 CLRF 0xd7,0x1 003e36 0101 MOVLB 0x1 usb_device_state = DEFAULT_STATE; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e38 0e03 MOVLW 0x3 003e3a 6fd5 MOVWF 0xd5,0x1 003e3c 0012 RETURN 0x0 }//end USBProtocolResetHandler C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /* Auxiliary Function */ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e3e cfd9 MOVFF 0xfd9,0xfe6 void ClearArray(byte* startAdr,byte count) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e40 ffe6 003e42 cfe1 MOVFF 0xfe1,0xfd9 003e44 ffd9 { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e46 0efd MOVLW 0xfd *startAdr; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e48 cfdb MOVFF 0xfdb,0xfe9 003e4a ffe9 003e4c 0efe MOVLW 0xfe 003e4e cfdb MOVFF 0xfdb,0xfea 003e50 ffea 003e52 0efc MOVLW 0xfc while(count) C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e54 50db MOVF 0xdb,0x0,0x0 003e56 e004 BZ 0x3e60 003e5e d7f9 BRA 0x3e52 { C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c _asm C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e58 6aee CLRF 0xee,0x0 clrf POSTINC0,0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c _endasm C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e5a 0efc MOVLW 0xfc count--; C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e5c 06db DECF 0xdb,0x1,0x0 }//end while C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e60 52e5 MOVF 0xe5,0x1,0x0 }//end ClearArray C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c 003e62 cfe7 MOVFF 0xfe7,0xfd9 003e64 ffd9 003e66 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /** EOF usbdrv.c *************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbdrv\usbdrv.c /********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c ********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * FileName: usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Software License Agreement C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * license. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Author Date Comment C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #include C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #include "system\typedefs.h" C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #include "system\usb\usb.h" C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #include "io_cfg.h" // Required for self_power status C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #pragma udata C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdGetDscHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdSetCfgHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdGetStatusHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdFeatureReqHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #pragma code C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Function: void USBCheckStdRequest(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Overview: This routine checks the setup data packet to see if it C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * knows how to handle it C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBCheckStdRequest(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 0039c8 0104 MOVLB 0x4 if(SetupPkt.RequestType != STANDARD) return; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 0039ca 5120 MOVF 0x20,0x0,0x1 0039cc 0b60 ANDLW 0x60 0039ce 42e8 RRNCF 0xe8,0x1,0x0 0039d0 42e8 RRNCF 0xe8,0x1,0x0 0039d2 42e8 RRNCF 0xe8,0x1,0x0 0039d4 42e8 RRNCF 0xe8,0x1,0x0 0039d6 42e8 RRNCF 0xe8,0x1,0x0 0039d8 0900 IORLW 0x0 0039da e001 BZ 0x39de 0039dc d058 BRA 0x3a8e C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 0039de 0104 MOVLB 0x4 switch(SetupPkt.bRequest) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 0039e0 5121 MOVF 0x21,0x0,0x1 0039e2 0a07 XORLW 0x7 0039e4 e053 BZ 0x3a8c 0039e6 0a0b XORLW 0xb 0039e8 e051 BZ 0x3a8c 0039ea 0a07 XORLW 0x7 0039ec e042 BZ 0x3a72 0039ee 0a01 XORLW 0x1 0039f0 e02c BZ 0x3a4a 0039f2 0a0b XORLW 0xb 0039f4 e028 BZ 0x3a46 0039f6 0a02 XORLW 0x2 0039f8 e026 BZ 0x3a46 0039fa 0a03 XORLW 0x3 0039fc e022 BZ 0x3a42 0039fe 0a08 XORLW 0x8 003a00 e012 BZ 0x3a26 003a02 0a01 XORLW 0x1 003a04 e00e BZ 0x3a22 003a06 0a0f XORLW 0xf 003a08 e00a BZ 0x3a1e 003a0a 0a03 XORLW 0x3 003a0c e001 BZ 0x3a10 003a0e d03e BRA 0x3a8c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case SET_ADR: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a10 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a12 0e01 MOVLW 0x1 003a14 6fce MOVWF 0xce,0x1 003a16 0101 MOVLB 0x1 usb_device_state = ADR_PENDING_STATE; // Update state only C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a18 0e04 MOVLW 0x4 003a1a 6fd5 MOVWF 0xd5,0x1 /* See USBCtrlTrfInHandler() in usbctrltrf.c for the next step */ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a1c d038 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case GET_DSC: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a1e d838 RCALL 0x3a90 USBStdGetDscHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a20 d036 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case SET_CFG: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a22 d893 RCALL 0x3b4a USBStdSetCfgHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a24 d034 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case GET_CFG: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a26 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a28 0e01 MOVLW 0x1 003a2a 6fce MOVWF 0xce,0x1 003a2c 0101 MOVLB 0x1 pSrc.bRam = (byte*)&usb_active_cfg; // Set Source C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a2e 0ed7 MOVLW 0xd7 003a30 6fcf MOVWF 0xcf,0x1 003a32 0e01 MOVLW 0x1 003a34 6fd0 MOVWF 0xd0,0x1 003a36 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a38 93d6 BCF 0xd6,0x1,0x1 003a3a 0101 MOVLB 0x1 LSB(wCount) = 1; // Set data count C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a3c 0e01 MOVLW 0x1 003a3e 6fd3 MOVWF 0xd3,0x1 003a40 d026 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case GET_STATUS: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a42 d8ab RCALL 0x3b9a USBStdGetStatusHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a44 d024 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case CLR_FEATURE: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case SET_FEATURE: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a46 d8f9 RCALL 0x3c3a USBStdFeatureReqHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a48 d022 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case GET_INTF: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a4a 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a4c 0e01 MOVLW 0x1 003a4e 6fce MOVWF 0xce,0x1 003a50 0104 MOVLB 0x4 pSrc.bRam = (byte*)&usb_alt_intf+SetupPkt.bIntfID; // Set source C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a52 5124 MOVF 0x24,0x0,0x1 003a54 0101 MOVLB 0x1 003a56 6fcf MOVWF 0xcf,0x1 003a58 6bd0 CLRF 0xd0,0x1 003a5a 0ed8 MOVLW 0xd8 003a5c 0101 MOVLB 0x1 003a5e 27cf ADDWF 0xcf,0x1,0x1 003a60 0e01 MOVLW 0x1 003a62 0101 MOVLB 0x1 003a64 23d0 ADDWFC 0xd0,0x1,0x1 003a66 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a68 93d6 BCF 0xd6,0x1,0x1 003a6a 0101 MOVLB 0x1 LSB(wCount) = 1; // Set data count C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a6c 0e01 MOVLW 0x1 003a6e 6fd3 MOVWF 0xd3,0x1 003a70 d00e BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case SET_INTF: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a72 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a74 0e01 MOVLW 0x1 003a76 6fce MOVWF 0xce,0x1 003a78 0104 MOVLB 0x4 usb_alt_intf[SetupPkt.bIntfID] = SetupPkt.bAltID; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a7a 5124 MOVF 0x24,0x0,0x1 003a7c 6aea CLRF 0xea,0x0 003a7e 0fd8 ADDLW 0xd8 003a80 6ee9 MOVWF 0xe9,0x0 003a82 0e01 MOVLW 0x1 003a84 22ea ADDWFC 0xea,0x1,0x0 003a86 c422 MOVFF 0x422,0xfef 003a88 ffef 003a8a d001 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case SET_DSC: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case SYNCH_FRAME: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c default: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a8c d000 BRA 0x3a8e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c }//end switch C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a8e 0012 RETURN 0x0 }//end USBCheckStdRequest C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Function: void USBStdGetDscHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Overview: This routine handles the standard GET_DESCRIPTOR request. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * It utilizes tables dynamically looks up descriptor size. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * This routine should never have to be modified if the tables C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * in usbdsc.c are declared correctly. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdGetDscHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a90 0e80 MOVLW 0x80 if(SetupPkt.bmRequestType == 0x80) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a92 0104 MOVLB 0x4 003a94 5d20 SUBWF 0x20,0x0,0x1 003a96 e158 BNZ 0x3b48 { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a98 0104 MOVLB 0x4 switch(SetupPkt.bDscType) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003a9a 5123 MOVF 0x23,0x0,0x1 003a9c 0a03 XORLW 0x3 003a9e e034 BZ 0x3b08 003aa0 0a01 XORLW 0x1 003aa2 e010 BZ 0x3ac4 003aa4 0a03 XORLW 0x3 003aa6 e001 BZ 0x3aaa 003aa8 d04d BRA 0x3b44 { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case DSC_DEV: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003aaa 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003aac 0e01 MOVLW 0x1 003aae 6fce MOVWF 0xce,0x1 003ab0 0101 MOVLB 0x1 pSrc.bRom = (rom byte*)&device_dsc; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ab2 0e9e MOVLW 0x9e 003ab4 6fcf MOVWF 0xcf,0x1 003ab6 0e40 MOVLW 0x40 003ab8 6fd0 MOVWF 0xd0,0x1 003aba 0e12 MOVLW 0x12 wCount._word = sizeof(device_dsc); // Set data count C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003abc 0101 MOVLB 0x1 003abe 6fd3 MOVWF 0xd3,0x1 003ac0 6bd4 CLRF 0xd4,0x1 003ac2 d040 BRA 0x3b44 break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case DSC_CFG: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ac4 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ac6 0e01 MOVLW 0x1 003ac8 6fce MOVWF 0xce,0x1 003aca 0104 MOVLB 0x4 pSrc.bRom = *(USB_CD_Ptr+SetupPkt.bDscIndex); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003acc 5122 MOVF 0x22,0x0,0x1 003ace 6ef6 MOVWF 0xf6,0x0 003ad0 6af7 CLRF 0xf7,0x0 003ad2 90d8 BCF 0xd8,0x0,0x0 003ad4 36f6 RLCF 0xf6,0x1,0x0 003ad6 36f7 RLCF 0xf7,0x1,0x0 003ad8 0e5f MOVLW 0x5f 003ada 26f6 ADDWF 0xf6,0x1,0x0 003adc 0e41 MOVLW 0x41 003ade 22f7 ADDWFC 0xf7,0x1,0x0 003ae0 0009 TBLRDPOSTINC 003ae2 cff5 MOVFF 0xff5,0x1cf 003ae4 f1cf 003ae6 000a TBLRDPOSTDEC 003ae8 cff5 MOVFF 0xff5,0x1d0 003aea f1d0 003aec 0e02 MOVLW 0x2 wCount._word = *(pSrc.wRom+1); // Set data count C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003aee 0101 MOVLB 0x1 003af0 6af7 CLRF 0xf7,0x0 003af2 25cf ADDWF 0xcf,0x0,0x1 003af4 6ef6 MOVWF 0xf6,0x0 003af6 51d0 MOVF 0xd0,0x0,0x1 003af8 22f7 ADDWFC 0xf7,0x1,0x0 003afa 0009 TBLRDPOSTINC 003afc cff5 MOVFF 0xff5,0x1d3 003afe f1d3 003b00 000a TBLRDPOSTDEC 003b02 cff5 MOVFF 0xff5,0x1d4 003b04 f1d4 003b06 d01e BRA 0x3b44 break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case DSC_STR: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b08 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b0a 0e01 MOVLW 0x1 003b0c 6fce MOVWF 0xce,0x1 003b0e 0104 MOVLB 0x4 pSrc.bRom = *(USB_SD_Ptr+SetupPkt.bDscIndex); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b10 5122 MOVF 0x22,0x0,0x1 003b12 6ef6 MOVWF 0xf6,0x0 003b14 6af7 CLRF 0xf7,0x0 003b16 90d8 BCF 0xd8,0x0,0x0 003b18 36f6 RLCF 0xf6,0x1,0x0 003b1a 36f7 RLCF 0xf7,0x1,0x0 003b1c 0e63 MOVLW 0x63 003b1e 26f6 ADDWF 0xf6,0x1,0x0 003b20 0e41 MOVLW 0x41 003b22 22f7 ADDWFC 0xf7,0x1,0x0 003b24 0009 TBLRDPOSTINC 003b26 cff5 MOVFF 0xff5,0x1cf 003b28 f1cf 003b2a 000a TBLRDPOSTDEC 003b2c cff5 MOVFF 0xff5,0x1d0 003b2e f1d0 003b30 c1cf MOVFF 0x1cf,0xff6 wCount._word = *pSrc.bRom; // Set data count C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b32 fff6 003b34 c1d0 MOVFF 0x1d0,0xff7 003b36 fff7 003b38 0008 TBLRD 003b3a 50f5 MOVF 0xf5,0x0,0x0 003b3c 0101 MOVLB 0x1 003b3e 6fd3 MOVWF 0xd3,0x1 003b40 6bd4 CLRF 0xd4,0x1 003b42 d000 BRA 0x3b44 break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c }//end switch C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b44 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _ROM; // Set memory type C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b46 83d6 BSF 0xd6,0x1,0x1 }//end if C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b48 0012 RETURN 0x0 }//end USBStdGetDscHandler C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Function: void USBStdSetCfgHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Overview: This routine first disables all endpoints by clearing C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * UEP registers. It then configures (initializes) endpoints C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * specified in the modifiable section. C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdSetCfgHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b4a 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b4c 0e01 MOVLW 0x1 003b4e 6fce MOVWF 0xce,0x1 003b50 0e0f MOVLW 0xf mDisableEP1to15(); // See usbdrv.h C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b52 6ee6 MOVWF 0xe6,0x0 003b54 0e71 MOVLW 0x71 003b56 6ee6 MOVWF 0xe6,0x0 003b58 0e0f MOVLW 0xf 003b5a 6ee6 MOVWF 0xe6,0x0 003b5c ec1f CALL 0x3e3e,0x0 003b5e f01f 003b60 52e5 MOVF 0xe5,0x1,0x0 003b62 52e5 MOVF 0xe5,0x1,0x0 003b64 52e5 MOVF 0xe5,0x1,0x0 003b66 0e01 MOVLW 0x1 ClearArray((byte*)&usb_alt_intf,MAX_NUM_INT); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b68 6ee6 MOVWF 0xe6,0x0 003b6a 0ed8 MOVLW 0xd8 003b6c 6ee6 MOVWF 0xe6,0x0 003b6e 0e01 MOVLW 0x1 003b70 6ee6 MOVWF 0xe6,0x0 003b72 ec1f CALL 0x3e3e,0x0 003b74 f01f 003b76 52e5 MOVF 0xe5,0x1,0x0 003b78 52e5 MOVF 0xe5,0x1,0x0 003b7a 52e5 MOVF 0xe5,0x1,0x0 003b7c c422 MOVFF 0x422,0x1d7 usb_active_cfg = SetupPkt.bCfgValue; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b7e f1d7 003b80 0104 MOVLB 0x4 if(SetupPkt.bCfgValue == 0) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b82 5122 MOVF 0x22,0x0,0x1 003b84 e104 BNZ 0x3b8e 003b86 0101 MOVLB 0x1 usb_device_state = ADDRESS_STATE; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b88 0e05 MOVLW 0x5 003b8a 6fd5 MOVWF 0xd5,0x1 003b8c d005 BRA 0x3b98 else C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b8e 0101 MOVLB 0x1 usb_device_state = CONFIGURED_STATE; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b90 0e06 MOVLW 0x6 003b92 6fd5 MOVWF 0xd5,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /* Modifiable Section */ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c #if defined(USB_USE_CDC) // See autofiles\usbcfg.h C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b94 ecc2 CALL 0x3384,0x0 CDCInitEP(); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b96 f019 #endif C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /* End modifiable section */ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c }//end if(SetupPkt.bcfgValue == 0) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b98 0012 RETURN 0x0 }//end USBStdSetCfgHandler C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Function: void USBStdGetStatusHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Overview: This routine handles the standard GET_STATUS request C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdGetStatusHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b9a 0104 MOVLB 0x4 CtrlTrfData._byte0 = 0; // Initialize content C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003b9c 6b28 CLRF 0x28,0x1 003b9e 0104 MOVLB 0x4 CtrlTrfData._byte1 = 0; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ba0 6b29 CLRF 0x29,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ba2 0104 MOVLB 0x4 switch(SetupPkt.Recipient) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ba4 5120 MOVF 0x20,0x0,0x1 003ba6 0b1f ANDLW 0x1f 003ba8 0a02 XORLW 0x2 003baa e014 BZ 0x3bd4 003bac 0a03 XORLW 0x3 003bae e00e BZ 0x3bcc 003bb0 0a01 XORLW 0x1 003bb2 e001 BZ 0x3bb6 003bb4 d034 BRA 0x3c1e { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case RCPT_DEV: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bb6 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bb8 0e01 MOVLW 0x1 003bba 6fce MOVWF 0xce,0x1 /* C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * _byte0: bit0: Self-Powered Status [0] Bus-Powered [1] Self-Powered C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * bit1: RemoteWakeup [0] Disabled [1] Enabled C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c */ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c if(self_power == 1) // self_power defined in io_cfg.h C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bbc 0104 MOVLB 0x4 CtrlTrfData._byte0|=0b000000001; // Set bit0 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bbe 8128 BSF 0x28,0x0,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bc0 0101 MOVLB 0x1 if(usb_stat.RemoteWakeup == 1) // usb_stat defined in usbmmap.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bc2 a1d6 BTFSS 0xd6,0x0,0x1 003bc4 d002 BRA 0x3bca 003bc6 0104 MOVLB 0x4 CtrlTrfData._byte0|=0b00000010; // Set bit1 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bc8 8328 BSF 0x28,0x1,0x1 003bca d029 BRA 0x3c1e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case RCPT_INTF: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bcc 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; // No data to update C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bce 0e01 MOVLW 0x1 003bd0 6fce MOVWF 0xce,0x1 003bd2 d025 BRA 0x3c1e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c case RCPT_EP: C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bd4 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bd6 0e01 MOVLW 0x1 003bd8 6fce MOVWF 0xce,0x1 /* C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * _byte0: bit0: Halt Status [0] Not Halted [1] Halted C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c */ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bda 0104 MOVLB 0x4 pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003bdc 5124 MOVF 0x24,0x0,0x1 003bde 0b0f ANDLW 0xf 003be0 0d08 MULLW 0x8 003be2 50f3 MOVF 0xf3,0x0,0x0 003be4 6a2b CLRF 0x2b,0x0 003be6 0f00 ADDLW 0x0 003be8 6e2a MOVWF 0x2a,0x0 003bea 0e04 MOVLW 0x4 003bec 222b ADDWFC 0x2b,0x1,0x0 003bee 0104 MOVLB 0x4 003bf0 5124 MOVF 0x24,0x0,0x1 003bf2 0b80 ANDLW 0x80 003bf4 e001 BZ 0x3bf8 003bf6 0e01 MOVLW 0x1 003bf8 0d04 MULLW 0x4 003bfa 50f3 MOVF 0xf3,0x0,0x0 003bfc 0101 MOVLB 0x1 003bfe 242a ADDWF 0x2a,0x0,0x0 003c00 6fd1 MOVWF 0xd1,0x1 003c02 0e00 MOVLW 0x0 003c04 202b ADDWFC 0x2b,0x0,0x0 003c06 6fd2 MOVWF 0xd2,0x1 003c08 c1d1 MOVFF 0x1d1,0xfe9 if(*pDst.bRam & _BSTALL) // Use _BSTALL as a bit mask C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c0a ffe9 003c0c c1d2 MOVFF 0x1d2,0xfea 003c0e ffea 003c10 50ef MOVF 0xef,0x0,0x0 003c12 0b04 ANDLW 0x4 003c14 e003 BZ 0x3c1c 003c16 0104 MOVLB 0x4 CtrlTrfData._byte0=0x01;// Set bit0 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c18 0e01 MOVLW 0x1 003c1a 6f28 MOVWF 0x28,0x1 003c1c d000 BRA 0x3c1e break; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c }//end switch C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c1e 0101 MOVLB 0x1 if(ctrl_trf_session_owner == MUID_USB9) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c20 05ce DECF 0xce,0x0,0x1 003c22 e10a BNZ 0x3c38 { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c24 0101 MOVLB 0x1 pSrc.bRam = (byte*)&CtrlTrfData; // Set Source C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c26 0e28 MOVLW 0x28 003c28 6fcf MOVWF 0xcf,0x1 003c2a 0e04 MOVLW 0x4 003c2c 6fd0 MOVWF 0xd0,0x1 003c2e 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c30 93d6 BCF 0xd6,0x1,0x1 003c32 0101 MOVLB 0x1 LSB(wCount) = 2; // Set data count C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c34 0e02 MOVLW 0x2 003c36 6fd3 MOVWF 0xd3,0x1 }//end if(...) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c38 0012 RETURN 0x0 }//end USBStdGetStatusHandler C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Function: void USBStdFeatureReqHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Overview: This routine handles the standard SET & CLEAR FEATURES C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * requests C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c void USBStdFeatureReqHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c3a 0104 MOVLB 0x4 if((SetupPkt.bFeature == DEVICE_REMOTE_WAKEUP)&& C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c3c 0522 DECF 0x22,0x0,0x1 003c3e e111 BNZ 0x3c62 (SetupPkt.Recipient == RCPT_DEV)) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c40 0104 MOVLB 0x4 003c42 5120 MOVF 0x20,0x0,0x1 003c44 0b1f ANDLW 0x1f 003c46 0900 IORLW 0x0 003c48 e10c BNZ 0x3c62 { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c4a 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c4c 0e01 MOVLW 0x1 003c4e 6fce MOVWF 0xce,0x1 003c50 0e03 MOVLW 0x3 if(SetupPkt.bRequest == SET_FEATURE) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c52 0104 MOVLB 0x4 003c54 5d21 SUBWF 0x21,0x0,0x1 003c56 e103 BNZ 0x3c5e 003c58 0101 MOVLB 0x1 usb_stat.RemoteWakeup = 1; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c5a 81d6 BSF 0xd6,0x0,0x1 003c5c d002 BRA 0x3c62 else C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c5e 0101 MOVLB 0x1 usb_stat.RemoteWakeup = 0; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c60 91d6 BCF 0xd6,0x0,0x1 }//end if C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c62 0104 MOVLB 0x4 if((SetupPkt.bFeature == ENDPOINT_HALT)&& C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c64 5122 MOVF 0x22,0x0,0x1 003c66 e13e BNZ 0x3ce4 (SetupPkt.Recipient == RCPT_EP)&& C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c68 0104 MOVLB 0x4 003c6a 5120 MOVF 0x20,0x0,0x1 003c6c 0b1f ANDLW 0x1f 003c6e 0802 SUBLW 0x2 003c70 e139 BNZ 0x3ce4 003c72 0104 MOVLB 0x4 (SetupPkt.EPNum != 0)) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c74 5124 MOVF 0x24,0x0,0x1 003c76 0b0f ANDLW 0xf 003c78 0900 IORLW 0x0 003c7a e034 BZ 0x3ce4 { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c7c 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c7e 0e01 MOVLW 0x1 003c80 6fce MOVWF 0xce,0x1 /* Must do address calculation here */ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c82 0104 MOVLB 0x4 pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003c84 5124 MOVF 0x24,0x0,0x1 003c86 0b0f ANDLW 0xf 003c88 0d08 MULLW 0x8 003c8a 50f3 MOVF 0xf3,0x0,0x0 003c8c 6a2b CLRF 0x2b,0x0 003c8e 0f00 ADDLW 0x0 003c90 6e2a MOVWF 0x2a,0x0 003c92 0e04 MOVLW 0x4 003c94 222b ADDWFC 0x2b,0x1,0x0 003c96 0104 MOVLB 0x4 003c98 5124 MOVF 0x24,0x0,0x1 003c9a 0b80 ANDLW 0x80 003c9c e001 BZ 0x3ca0 003c9e 0e01 MOVLW 0x1 003ca0 0d04 MULLW 0x4 003ca2 50f3 MOVF 0xf3,0x0,0x0 003ca4 0101 MOVLB 0x1 003ca6 242a ADDWF 0x2a,0x0,0x0 003ca8 6fd1 MOVWF 0xd1,0x1 003caa 0e00 MOVLW 0x0 003cac 202b ADDWFC 0x2b,0x0,0x0 003cae 6fd2 MOVWF 0xd2,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cb0 0e03 MOVLW 0x3 if(SetupPkt.bRequest == SET_FEATURE) C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cb2 0104 MOVLB 0x4 003cb4 5d21 SUBWF 0x21,0x0,0x1 003cb6 e107 BNZ 0x3cc6 003cb8 0e84 MOVLW 0x84 *pDst.bRam = _USIE|_BSTALL; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cba c1d1 MOVFF 0x1d1,0xfe9 003cbc ffe9 003cbe c1d2 MOVFF 0x1d2,0xfea 003cc0 ffea 003cc2 6eef MOVWF 0xef,0x0 003cc4 d00f BRA 0x3ce4 else C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cc6 0104 MOVLB 0x4 if(SetupPkt.EPDir == 1) // IN C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cc8 af24 BTFSS 0x24,0x7,0x1 003cca d006 BRA 0x3cd8 003ccc c1d1 MOVFF 0x1d1,0xfe9 *pDst.bRam = _UCPU; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cce ffe9 003cd0 c1d2 MOVFF 0x1d2,0xfea 003cd2 ffea 003cd4 6aef CLRF 0xef,0x0 003cd6 d006 BRA 0x3ce4 else C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cd8 0e88 MOVLW 0x88 *pDst.bRam = _USIE|_DAT0|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003cda c1d1 MOVFF 0x1d1,0xfe9 003cdc ffe9 003cde c1d2 MOVFF 0x1d2,0xfea 003ce0 ffea 003ce2 6eef MOVWF 0xef,0x0 }//end if C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c }//end if C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c 003ce4 0012 RETURN 0x0 }//end USBStdFeatureReqHandler C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /** EOF usb9.c ***************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usb9\usb9.c /********************************************************************* C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c ********************************************************************* C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * FileName: usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Software License Agreement C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * license. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /********************************************************************* C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * -usbdsc.c- C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * This file contains the USB descriptor information. It is used C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * in conjunction with the usbdsc.h file. When a descriptor is added C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * or removed from the main configuration descriptor, i.e. CFG01, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * the user must also change the descriptor structure defined in C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * the usbdsc.h file. The structure is used to calculate the C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * descriptor size, i.e. sizeof(CFG01). C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * A typical configuration descriptor consists of: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * At least one configuration descriptor (USB_CFG_DSC) C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * One or more interface descriptors (USB_INTF_DSC) C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * One or more endpoint descriptors (USB_EP_DSC) C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Naming Convention: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * To resolve ambiguity, the naming convention are as followed: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * - USB_CFG_DSC type should be named cdxx, where xx is the C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * configuration number. This number should match the actual C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * index value of this configuration. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * - USB_INTF_DSC type should be named ia, where yy is the C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * interface number and zz is the alternate interface number. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * - USB_EP_DSC type should be named ep<##>_ia, where C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * ## is the endpoint number and d is the direction of transfer. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The interface name should also be listed as a suffix to identify C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * which interface does the endpoint belong to. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Example: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * If a device has one configuration, two interfaces; interface 0 C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * has two endpoints (in and out), and interface 1 has one endpoint(in). C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Then the CFG01 structure in the usbdsc.h should be: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * #define CFG01 rom struct \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * { USB_CFG_DSC cd01; \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * USB_INTF_DSC i00a00; \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * USB_EP_DSC ep01o_i00a00; \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * USB_EP_DSC ep01i_i00a00; \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * USB_INTF_DSC i01a00; \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * USB_EP_DSC ep02i_i01a00; \ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * } cfg01 C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Note the hierarchy of the descriptors above, it follows the USB C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * specification requirement. All endpoints belonging to an interface C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * should be listed immediately after that interface. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Filling in the descriptor values in the usbdsc.c file: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Most items should be self-explanatory, however, a few will be C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * explained for clarification. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * [Configuration Descriptor(USB_CFG_DSC)] C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The configuration attribute must always have the _DEFAULT C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * definition at the minimum. Additional options can be ORed C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * to the _DEFAULT attribute. Available options are _SELF and _RWU. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * These definitions are defined in the usbdefs_std_dsc.h file. The C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * _SELF tells the USB host that this device is self-powered. The C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * _RWU tells the USB host that this device supports Remote Wakeup. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * [Endpoint Descriptor(USB_EP_DSC)] C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Assume the following example: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * sizeof(USB_EP_DSC),DSC_EP,_EP01_OUT,_BULK,64,0x00 C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The first two parameters are self-explanatory. They specify the C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * length of this endpoint descriptor (7) and the descriptor type. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The next parameter identifies the endpoint, the definitions are C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * defined in usbdefs_std_dsc.h and has the following naming C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * convention: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * _EP<##>_ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * where ## is the endpoint number and dir is the direction of C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * transfer. The dir has the value of either 'OUT' or 'IN'. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The next parameter identifies the type of the endpoint. Available C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * options are _BULK, _INT, _ISO, and _CTRL. The _CTRL is not C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * typically used because the default control transfer endpoint is C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * not defined in the USB descriptors. When _ISO option is used, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * addition options can be ORed to _ISO. Example: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * _ISO|_AD|_FE C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * This describes the endpoint as an isochronous pipe with adaptive C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * and feedback attributes. See usbdefs_std_dsc.h and the USB C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * specification for details. The next parameter defines the size of C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * the endpoint. The last parameter in the polling interval. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Adding a USB String C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * A string descriptor array should have the following format: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * rom struct{byte bLength;byte bDscType;word string[size];}sdxxx={ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * sizeof(sdxxx),DSC_STR,}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The above structure provides a means for the C compiler to C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * calculate the length of string descriptor sdxxx, where xxx is the C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * index number. The first two bytes of the descriptor are descriptor C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * length and type. The rest are string texts which must be C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * in the unicode format. The unicode format is achieved by declaring C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * each character as a word type. The whole text string is declared C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * as a word array with the number of characters equals to . C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * has to be manually counted and entered into the array C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * declaration. Let's study this through an example: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * if the string is "USB" , then the string descriptor should be: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * (Using index 02) C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * rom struct{byte bLength;byte bDscType;word string[3];}sd002={ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * sizeof(sd002),DSC_STR,'U','S','B'}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * A USB project may have multiple strings and the firmware supports C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * the management of multiple strings through a look-up table. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The look-up table is defined as: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The above declaration has 3 strings, sd000, sd001, and sd002. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Strings can be removed or added. sd000 is a specialized string C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * descriptor. It defines the language code, usually this is C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * US English (0x0409). The index of the string must match the index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * position of the USB_SD_Ptr array, &sd000 must be in position C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * USB_SD_Ptr[0], &sd001 must be in position USB_SD_Ptr[1] and so on. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The look-up table USB_SD_Ptr is used by the get string handler C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * function in usb9.c. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The look-up table scheme also applies to the configuration C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * descriptor. A USB device may have multiple configuration C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * descriptors, i.e. CFG01, CFG02, etc. To add a configuration C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * descriptor, user must implement a structure similar to CFG01. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * The next step is to add the configuration descriptor name, i.e. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * cfg01, cfg02,.., to the look-up table USB_CD_Ptr. USB_CD_Ptr[0] C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * is a dummy place holder since configuration 0 is the un-configured C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * state according to the definition in the USB specification. C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /********************************************************************* C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Descriptor specific type definitions are defined in: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * system\usb\usbdefs\usbdefs_std_dsc.h C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * Configuration information is defined in: C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c * autofiles\usbcfg.h C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /** I N C L U D E S *************************************************/ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c #include "system\typedefs.h" C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c #include "system\usb\usb.h" C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /** C O N S T A N T S ************************************************/ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c #pragma romdata C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Device Descriptor */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom USB_DEV_DSC device_dsc= C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c { C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_DEV_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c DSC_DEV, // DEVICE descriptor type C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x0200, // USB Spec Release Number in BCD format C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c CDC_DEVICE, // Class Code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x00, // Subclass code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x00, // Protocol code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c EP0_BUFF_SIZE, // Max packet size for EP0, see usbcfg.h C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x04D8, // Vendor ID C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x000A, // Product ID: CDC RS-232 Emulation Demo C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x0000, // Device release number in BCD format C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x01, // Manufacturer string index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x02, // Product string index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x00, // Device serial number string index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0x01 // Number of possible configurations C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c }; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Configuration 1 Descriptor */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c CFG01= C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c { C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Configuration Descriptor */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_CFG_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c DSC_CFG, // CONFIGURATION descriptor type C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(cfg01), // Total length of data for this cfg C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 2, // Number of interfaces in this cfg C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 1, // Index value of this configuration C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Configuration string index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c _DEFAULT, // Attributes, see usbdefs_std_dsc.h C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 50, // Max power consumption (2X mA) C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Interface Descriptor */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_INTF_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c DSC_INTF, // INTERFACE descriptor type C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Interface Number C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Alternate Setting Number C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 1, // Number of endpoints in this intf C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c COMM_INTF, // Class code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c ABSTRACT_CONTROL_MODEL, // Subclass code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c V25TER, // Protocol code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Interface string index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* CDC Class-Specific Descriptors */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_CDC_HEADER_FN_DSC),CS_INTERFACE,DSC_FN_HEADER,0x0110, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_CDC_ACM_FN_DSC),CS_INTERFACE,DSC_FN_ACM,0x02, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_CDC_UNION_FN_DSC),CS_INTERFACE,DSC_FN_UNION,CDC_COMM_INTF_ID,CDC_DATA_INTF_ID, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_CDC_CALL_MGT_FN_DSC),CS_INTERFACE,DSC_FN_CALL_MGT,0x00,CDC_DATA_INTF_ID, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Endpoint Descriptor */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP02_IN,_INT,CDC_INT_EP_SIZE,0x02, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Interface Descriptor */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_INTF_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c DSC_INTF, // INTERFACE descriptor type C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 1, // Interface Number C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Alternate Setting Number C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 2, // Number of endpoints in this intf C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c DATA_INTF, // Class code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Subclass code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c NO_PROTOCOL, // Protocol code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 0, // Interface string index C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /* Endpoint Descriptors */ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP03_OUT,_BULK,CDC_BULK_OUT_EP_SIZE,0x00, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP03_IN,_BULK,CDC_BULK_IN_EP_SIZE,0x00 C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c }; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[1];}sd000={ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(sd000),DSC_STR,0x0409}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[25];}sd001={ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(sd001),DSC_STR, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 'M','i','c','r','o','c','h','i','p',' ', C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[25];}sd002={ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c sizeof(sd002),DSC_STR, C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 'C','D','C',' ','R','S','-','2','3','2',' ', C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c 'E','m','u','l','a','t','i','o','n',' ','D','e','m','o'}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom const unsigned char *rom USB_CD_Ptr[]={&cfg01,&cfg01}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c rom pFunc ClassReqHandler[1]= C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c { C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c &USBCheckCDCRequest C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c }; C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c #pragma code C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /** EOF usbdsc.c ****************************************************/ C:\Projects\UBW\FW\2455\D\autofiles\usbdsc.c /********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c ********************************************************************* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * FileName: usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Software License Agreement C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * license. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Author Date Comment C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c #include C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c #include "system\typedefs.h" C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c #include "system\usb\usb.h" C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c #pragma udata C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c byte ctrl_trf_state; // Control Transfer State C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c byte ctrl_trf_session_owner; // Current transfer session owner C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c POINTER pSrc; // Data source pointer C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c POINTER pDst; // Data destination pointer C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c WORD wCount; // Data counter C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfSetupHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfOutHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfInHandler(void); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c #pragma code C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlEPService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: USTAT is loaded with a valid endpoint address. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: USBCtrlEPService checks for three transaction types that C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * it knows how to service and services them: C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 1. EP0 SETUP C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 2. EP0 OUT C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 3. EP0 IN C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * It ignores all other types (i.e. EP1, EP2, etc.) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlEPService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00368e 506c MOVF 0x6c,0x0,0x0 if(USTAT == EP00_OUT) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003690 e002 BZ 0x3696 003692 0e00 MOVLW 0x0 003694 d001 BRA 0x3698 003696 0e01 MOVLW 0x1 003698 0900 IORLW 0x0 00369a e00b BZ 0x36b2 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00369c 0104 MOVLB 0x4 if(ep0Bo.Stat.PID == SETUP_TOKEN) // EP0 SETUP C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00369e 5100 MOVF 0x0,0x0,0x1 0036a0 0b3c ANDLW 0x3c 0036a2 42e8 RRNCF 0xe8,0x1,0x0 0036a4 42e8 RRNCF 0xe8,0x1,0x0 0036a6 080d SUBLW 0xd 0036a8 e102 BNZ 0x36ae 0036aa d80c RCALL 0x36c4 USBCtrlTrfSetupHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036ac d001 BRA 0x36b0 else // EP0 OUT C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036ae d842 RCALL 0x3734 USBCtrlTrfOutHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c } C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036b0 d008 BRA 0x36c2 else if(USTAT == EP00_IN) // EP0 IN C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036b2 506c MOVF 0x6c,0x0,0x0 0036b4 e002 BZ 0x36ba 0036b6 0e00 MOVLW 0x0 0036b8 d001 BRA 0x36bc 0036ba 0e01 MOVLW 0x1 0036bc 0904 IORLW 0x4 0036be e001 BZ 0x36c2 0036c0 d84b RCALL 0x3758 USBCtrlTrfInHandler(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036c2 0012 RETURN 0x0 }//end USBCtrlEPService C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfSetupHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: SetupPkt buffer is loaded with valid USB Setup Data C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine is a task dispatcher and has 3 stages. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 1. It initializes the control transfer state machine. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 2. It calls on each of the module that may know how to C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * service the Setup Request from the host. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Module Example: USB9, HID, CDC, MSD, ... C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * As new classes are added, ClassReqHandler table in C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * usbdsc.c should be updated to call all available C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * class handlers. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 3. Once each of the modules has had a chance to check if C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * it is responsible for servicing the request, stage 3 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * then checks direction of the transfer to determine how C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * to prepare EP0 for the control transfer. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Refer to USBCtrlEPServiceComplete() for more details. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: Microchip USB Firmware has three different states for C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * the control transfer state machine: C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 1. WAIT_SETUP C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 2. CTRL_TRF_TX C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 3. CTRL_TRF_RX C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Refer to firmware manual to find out how one state C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * is transitioned to another. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * A Control Transfer is composed of many USB transactions. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * When transferring data over multiple transactions, C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * it is important to keep track of data source, data C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * destination, and data count. These three parameters are C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * stored in pSrc,pDst, and wCount. A flag is used to C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * note if the data source is from ROM or RAM. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036c4 cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfSetupHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036c6 ffe6 0036c8 cfe1 MOVFF 0xfe1,0xfd9 0036ca ffd9 0036cc 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c byte i; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* Stage 1 */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036ce 0101 MOVLB 0x1 ctrl_trf_state = WAIT_SETUP; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036d0 6bcd CLRF 0xcd,0x1 0036d2 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_NULL; // Set owner to NULL C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036d4 6bce CLRF 0xce,0x1 0036d6 0101 MOVLB 0x1 wCount._word = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036d8 6bd3 CLRF 0xd3,0x1 0036da 6bd4 CLRF 0xd4,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* Stage 2 */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036dc ece4 CALL 0x39c8,0x0 USBCheckStdRequest(); // See system\usb9\usb9.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036de f01c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036e0 6adf CLRF 0xdf,0x0 for(i=0;i < (sizeof(ClassReqHandler)/sizeof(pFunc));i++) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036e2 50df MOVF 0xdf,0x0,0x0 0036e4 6e2a MOVWF 0x2a,0x0 0036e6 6a2b CLRF 0x2b,0x0 0036e8 0e01 MOVLW 0x1 0036ea 5c2a SUBWF 0x2a,0x0,0x0 0036ec 0e00 MOVLW 0x0 0036ee 582b SUBWFB 0x2b,0x0,0x0 0036f0 e21b BC 0x3728 003724 2adf INCF 0xdf,0x1,0x0 003726 d7dd BRA 0x36e2 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036f2 0101 MOVLB 0x1 if(ctrl_trf_session_owner != MUID_NULL)break; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036f4 51ce MOVF 0xce,0x0,0x1 0036f6 e001 BZ 0x36fa 0036f8 d017 BRA 0x3728 0036fa 6af7 CLRF 0xf7,0x0 ClassReqHandler[i](); // See autofiles\usbdsc.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0036fc 34df RLCF 0xdf,0x0,0x0 0036fe 0bfe ANDLW 0xfe 003700 36f7 RLCF 0xf7,0x1,0x0 003702 6ef6 MOVWF 0xf6,0x0 003704 0e69 MOVLW 0x69 003706 26f6 ADDWF 0xf6,0x1,0x0 003708 0e41 MOVLW 0x41 00370a 22f7 ADDWFC 0xf7,0x1,0x0 00370c 0009 TBLRDPOSTINC 00370e cff5 MOVFF 0xff5,0x2a 003710 f02a 003712 0008 TBLRD 003714 cff5 MOVFF 0xff5,0x2b 003716 f02b 003718 d004 BRA 0x3722 00371a c02b MOVFF 0x2b,0xffa 00371c fffa 00371e 502a MOVF 0x2a,0x0,0x0 003720 6ef9 MOVWF 0xf9,0x0 003722 dffb RCALL 0x371a }//end while C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* Stage 3 */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003728 d8f0 RCALL 0x390a USBCtrlEPServiceComplete(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00372a 52e5 MOVF 0xe5,0x1,0x0 }//end USBCtrlTrfSetupHandler C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00372c 52e5 MOVF 0xe5,0x1,0x0 00372e cfe7 MOVFF 0xfe7,0xfd9 003730 ffd9 003732 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfOutHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine handles an OUT transaction according to C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * which control transfer state is currently active. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: Note that if the the control transfer was from C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * host to device, the session owner should be notified C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * at the end of each OUT transaction to service the C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * received data. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfOutHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003734 0e02 MOVLW 0x2 if(ctrl_trf_state == CTRL_TRF_RX) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003736 0101 MOVLB 0x1 003738 5dcd SUBWF 0xcd,0x0,0x1 00373a e10c BNZ 0x3754 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00373c d8a4 RCALL 0x3886 USBCtrlTrfRxService(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Don't have to worry about overwriting _KEEP bit C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * because if _KEEP was set, TRNIF would not have been C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * generated in the first place. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00373e 0104 MOVLB 0x4 if(ep0Bo.Stat.DTS == 0) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003740 bd00 BTFSC 0x0,0x6,0x1 003742 d004 BRA 0x374c 003744 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003746 0ec8 MOVLW 0xc8 003748 6f00 MOVWF 0x0,0x1 00374a d003 BRA 0x3752 else C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00374c 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT0|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00374e 0e88 MOVLW 0x88 003750 6f00 MOVWF 0x0,0x1 } C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003752 d001 BRA 0x3756 else // CTRL_TRF_TX C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003754 d929 RCALL 0x39a8 USBPrepareForNextSetupTrf(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003756 0012 RETURN 0x0 }//end USBCtrlTrfOutHandler C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfInHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine handles an IN transaction according to C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * which control transfer state is currently active. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: A Set Address Request must not change the acutal address C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * of the device until the completion of the control C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * transfer. The end of the control transfer for Set Address C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Request is an IN transaction. Therefore it is necessary C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * to service this unique situation when the condition is C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * right. Macro mUSBCheckAdrPendingState is defined in C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * usb9.h and its function is to specifically service this C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * event. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfInHandler(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003758 0e04 MOVLW 0x4 mUSBCheckAdrPendingState(); // Must check if in ADR_PENDING_STATE C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00375a 0101 MOVLB 0x1 00375c 5dd5 SUBWF 0xd5,0x0,0x1 00375e e10c BNZ 0x3778 003760 c422 MOVFF 0x422,0xf6e 003762 ff6e 003764 506e MOVF 0x6e,0x0,0x0 003766 0800 SUBLW 0x0 003768 e204 BC 0x3772 00376a 0101 MOVLB 0x1 00376c 0e05 MOVLW 0x5 00376e 6fd5 MOVWF 0xd5,0x1 003770 d003 BRA 0x3778 003772 0101 MOVLB 0x1 003774 0e03 MOVLW 0x3 003776 6fd5 MOVWF 0xd5,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003778 0101 MOVLB 0x1 if(ctrl_trf_state == CTRL_TRF_TX) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00377a 05cd DECF 0xcd,0x0,0x1 00377c e10c BNZ 0x3796 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00377e d80d RCALL 0x379a USBCtrlTrfTxService(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003780 0104 MOVLB 0x4 if(ep0Bi.Stat.DTS == 0) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003782 bd04 BTFSC 0x4,0x6,0x1 003784 d004 BRA 0x378e 003786 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003788 0ec8 MOVLW 0xc8 00378a 6f04 MOVWF 0x4,0x1 00378c d003 BRA 0x3794 else C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00378e 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT0|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003790 0e88 MOVLW 0x88 003792 6f04 MOVWF 0x4,0x1 } C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003794 d001 BRA 0x3798 else // CTRL_TRF_RX C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003796 d908 RCALL 0x39a8 USBPrepareForNextSetupTrf(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003798 0012 RETURN 0x0 }//end USBCtrlTrfInHandler C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfTxService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: pSrc, wCount, and usb_stat.ctrl_trf_mem are setup properly. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine should be called from only two places. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * One from USBCtrlEPServiceComplete() and one from C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * USBCtrlTrfInHandler(). It takes care of managing a C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * transfer over multiple USB transactions. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: This routine works with isochronous endpoint larger than C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 256 bytes and is shown here as an example of how to deal C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * with BC9 and BC8. In reality, a control endpoint can never C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * be larger than 64 bytes. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00379a cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfTxService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00379c ffe6 00379e cfe1 MOVFF 0xfe1,0xfd9 0037a0 ffd9 0037a2 0e02 MOVLW 0x2 0037a4 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c WORD byte_to_send; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * First, have to figure out how many byte of data to send. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037a6 0101 MOVLB 0x1 if(wCount._word < EP0_BUFF_SIZE) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037a8 0e08 MOVLW 0x8 0037aa 5dd3 SUBWF 0xd3,0x0,0x1 0037ac 0e00 MOVLW 0x0 0037ae 59d4 SUBWFB 0xd4,0x0,0x1 0037b0 e205 BC 0x37bc 0037b2 c1d3 MOVFF 0x1d3,0xfde byte_to_send._word = wCount._word; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037b4 ffde 0037b6 c1d4 MOVFF 0x1d4,0xfdd 0037b8 ffdd 0037ba d003 BRA 0x37c2 else C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037bc 0e08 MOVLW 0x8 byte_to_send._word = EP0_BUFF_SIZE; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037be 6ede MOVWF 0xde,0x0 0037c0 6add CLRF 0xdd,0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Next, load the number of bytes to send to BC9..0 in buffer descriptor C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037c2 0104 MOVLB 0x4 ep0Bi.Stat.BC9 = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037c4 9304 BCF 0x4,0x1,0x1 0037c6 0104 MOVLB 0x4 ep0Bi.Stat.BC8 = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037c8 9104 BCF 0x4,0x0,0x1 0037ca 0e01 MOVLW 0x1 ep0Bi.Stat._byte |= MSB(byte_to_send); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037cc 50db MOVF 0xdb,0x0,0x0 0037ce 0104 MOVLB 0x4 0037d0 1304 IORWF 0x4,0x1,0x1 0037d2 cfdf MOVFF 0xfdf,0x405 ep0Bi.Cnt = LSB(byte_to_send); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037d4 f405 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Subtract the number of bytes just about to be sent from the total. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037d6 0e00 MOVLW 0x0 wCount._word = wCount._word - byte_to_send._word; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037d8 50db MOVF 0xdb,0x0,0x0 0037da 0101 MOVLB 0x1 0037dc 5fd3 SUBWF 0xd3,0x1,0x1 0037de 0e01 MOVLW 0x1 0037e0 50db MOVF 0xdb,0x0,0x0 0037e2 0101 MOVLB 0x1 0037e4 5bd4 SUBWFB 0xd4,0x1,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037e6 0101 MOVLB 0x1 pDst.bRam = (byte*)&CtrlTrfData; // Set destination pointer C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037e8 0e28 MOVLW 0x28 0037ea 6fd1 MOVWF 0xd1,0x1 0037ec 0e04 MOVLW 0x4 0037ee 6fd2 MOVWF 0xd2,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037f0 0101 MOVLB 0x1 if(usb_stat.ctrl_trf_mem == _ROM) // Determine type of memory source C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037f2 a3d6 BTFSS 0xd6,0x1,0x1 0037f4 d020 BRA 0x3836 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037f6 cfd9 MOVFF 0xfd9,0xfe9 while(byte_to_send._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0037f8 ffe9 0037fa cfda MOVFF 0xfda,0xfea 0037fc ffea 0037fe 50ee MOVF 0xee,0x0,0x0 003800 10ed IORWF 0xed,0x0,0x0 003802 e018 BZ 0x3834 003832 d7e1 BRA 0x37f6 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003804 c1cf MOVFF 0x1cf,0xff6 *pDst.bRam = *pSrc.bRom; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003806 fff6 003808 c1d0 MOVFF 0x1d0,0xff7 00380a fff7 00380c 0008 TBLRD 00380e 50f5 MOVF 0xf5,0x0,0x0 003810 c1d1 MOVFF 0x1d1,0xfe9 003812 ffe9 003814 c1d2 MOVFF 0x1d2,0xfea 003816 ffea 003818 6eef MOVWF 0xef,0x0 00381a 0101 MOVLB 0x1 pDst.bRam++; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00381c 2bd1 INCF 0xd1,0x1,0x1 00381e 0e00 MOVLW 0x0 003820 23d2 ADDWFC 0xd2,0x1,0x1 003822 0101 MOVLB 0x1 pSrc.bRom++; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003824 2bcf INCF 0xcf,0x1,0x1 003826 0e00 MOVLW 0x0 003828 23d0 ADDWFC 0xd0,0x1,0x1 00382a 06df DECF 0xdf,0x1,0x0 byte_to_send._word--; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00382c 0e01 MOVLW 0x1 00382e e201 BC 0x3832 003830 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_send._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c } C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003834 d01e BRA 0x3872 else // RAM C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003836 cfd9 MOVFF 0xfd9,0xfe9 while(byte_to_send._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003838 ffe9 00383a cfda MOVFF 0xfda,0xfea 00383c ffea 00383e 50ee MOVF 0xee,0x0,0x0 003840 10ed IORWF 0xed,0x0,0x0 003842 e017 BZ 0x3872 003870 d7e2 BRA 0x3836 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003844 c1cf MOVFF 0x1cf,0xfe9 *pDst.bRam = *pSrc.bRam; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003846 ffe9 003848 c1d0 MOVFF 0x1d0,0xfea 00384a ffea 00384c 50ef MOVF 0xef,0x0,0x0 00384e c1d1 MOVFF 0x1d1,0xfe9 003850 ffe9 003852 c1d2 MOVFF 0x1d2,0xfea 003854 ffea 003856 6eef MOVWF 0xef,0x0 003858 0101 MOVLB 0x1 pDst.bRam++; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00385a 2bd1 INCF 0xd1,0x1,0x1 00385c 0e00 MOVLW 0x0 00385e 23d2 ADDWFC 0xd2,0x1,0x1 003860 0101 MOVLB 0x1 pSrc.bRam++; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003862 2bcf INCF 0xcf,0x1,0x1 003864 0e00 MOVLW 0x0 003866 23d0 ADDWFC 0xd0,0x1,0x1 003868 06df DECF 0xdf,0x1,0x0 byte_to_send._word--; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00386a 0e01 MOVLW 0x1 00386c e201 BC 0x3870 00386e 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_send._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c }//end if(usb_stat.ctrl_trf_mem == _ROM) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003872 0e02 MOVLW 0x2 }//end USBCtrlTrfTxService C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003874 5ce1 SUBWF 0xe1,0x0,0x0 003876 e202 BC 0x387c 003878 6ae1 CLRF 0xe1,0x0 00387a 52e5 MOVF 0xe5,0x1,0x0 00387c 6ee1 MOVWF 0xe1,0x0 00387e 52e5 MOVF 0xe5,0x1,0x0 003880 cfe7 MOVFF 0xfe7,0xfd9 003882 ffd9 003884 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfRxService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: pDst and wCount are setup properly. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * pSrc is always &CtrlTrfData C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * usb_stat.ctrl_trf_mem is always _RAM. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * wCount should be set to 0 at the start of each control C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * transfer. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: *** This routine is only partially complete. Check for C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * new version of the firmware. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003886 cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfRxService(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003888 ffe6 00388a cfe1 MOVFF 0xfe1,0xfd9 00388c ffd9 00388e 0e02 MOVLW 0x2 003890 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c WORD byte_to_read; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003892 0e03 MOVLW 0x3 MSB(byte_to_read) = 0x03 & ep0Bo.Stat._byte; // Filter out last 2 bits C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003894 0104 MOVLB 0x4 003896 1500 ANDWF 0x0,0x0,0x1 003898 6ee7 MOVWF 0xe7,0x0 00389a 0e01 MOVLW 0x1 00389c cfe7 MOVFF 0xfe7,0xfdb 00389e ffdb 0038a0 c401 MOVFF 0x401,0xfdf LSB(byte_to_read) = ep0Bo.Cnt; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038a2 ffdf C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Accumulate total number of bytes read C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038a4 50de MOVF 0xde,0x0,0x0 wCount._word = wCount._word + byte_to_read._word; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038a6 0101 MOVLB 0x1 0038a8 27d3 ADDWF 0xd3,0x1,0x1 0038aa 50dd MOVF 0xdd,0x0,0x0 0038ac 0101 MOVLB 0x1 0038ae 23d4 ADDWFC 0xd4,0x1,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038b0 0101 MOVLB 0x1 pSrc.bRam = (byte*)&CtrlTrfData; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038b2 0e28 MOVLW 0x28 0038b4 6fcf MOVWF 0xcf,0x1 0038b6 0e04 MOVLW 0x4 0038b8 6fd0 MOVWF 0xd0,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038ba cfd9 MOVFF 0xfd9,0xfe9 while(byte_to_read._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038bc ffe9 0038be cfda MOVFF 0xfda,0xfea 0038c0 ffea 0038c2 50ee MOVF 0xee,0x0,0x0 0038c4 10ed IORWF 0xed,0x0,0x0 0038c6 e017 BZ 0x38f6 0038f4 d7e2 BRA 0x38ba { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038c8 c1cf MOVFF 0x1cf,0xfe9 *pDst.bRam = *pSrc.bRam; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038ca ffe9 0038cc c1d0 MOVFF 0x1d0,0xfea 0038ce ffea 0038d0 50ef MOVF 0xef,0x0,0x0 0038d2 c1d1 MOVFF 0x1d1,0xfe9 0038d4 ffe9 0038d6 c1d2 MOVFF 0x1d2,0xfea 0038d8 ffea 0038da 6eef MOVWF 0xef,0x0 0038dc 0101 MOVLB 0x1 pDst.bRam++; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038de 2bd1 INCF 0xd1,0x1,0x1 0038e0 0e00 MOVLW 0x0 0038e2 23d2 ADDWFC 0xd2,0x1,0x1 0038e4 0101 MOVLB 0x1 pSrc.bRam++; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038e6 2bcf INCF 0xcf,0x1,0x1 0038e8 0e00 MOVLW 0x0 0038ea 23d0 ADDWFC 0xd0,0x1,0x1 0038ec 06df DECF 0xdf,0x1,0x0 byte_to_read._word--; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038ee 0e01 MOVLW 0x1 0038f0 e201 BC 0x38f4 0038f2 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_read._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038f6 0e02 MOVLW 0x2 }//end USBCtrlTrfRxService C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0038f8 5ce1 SUBWF 0xe1,0x0,0x0 0038fa e202 BC 0x3900 0038fc 6ae1 CLRF 0xe1,0x0 0038fe 52e5 MOVF 0xe5,0x1,0x0 003900 6ee1 MOVWF 0xe1,0x0 003902 52e5 MOVF 0xe5,0x1,0x0 003904 cfe7 MOVFF 0xfe7,0xfd9 003906 ffd9 003908 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlEPServiceComplete(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine wrap up the ramaining tasks in servicing C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * a Setup Request. Its main task is to set the endpoint C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * controls appropriately for a given situation. See code C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * below. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * There are three main scenarios: C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * a) There was no handler for the Request, in this case C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * a STALL should be sent out. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * b) The host has requested a read control transfer, C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * endpoints are required to be setup in a specific way. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * c) The host has requested a write control transfer, or C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * a control data stage is not required, endpoints are C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * required to be setup in a specific way. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Packet processing is resumed by clearing PKTDIS bit. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlEPServiceComplete(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PKTDIS bit is set when a Setup Transaction is received. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Clear to resume packet processing. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00390a 986d BCF 0x6d,0x4,0x0 UCONbits.PKTDIS = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00390c 0101 MOVLB 0x1 if(ctrl_trf_session_owner == MUID_NULL) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00390e 51ce MOVF 0xce,0x0,0x1 003910 e10f BNZ 0x3930 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * If no one knows how to service this request then stall. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Must also prepare EP0 to receive the next SETUP transaction. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003912 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003914 0e08 MOVLW 0x8 003916 6f01 MOVWF 0x1,0x1 003918 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&SetupPkt; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00391a 0e20 MOVLW 0x20 00391c 6f02 MOVWF 0x2,0x1 00391e 0e04 MOVLW 0x4 003920 6f03 MOVWF 0x3,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003922 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_BSTALL; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003924 0e84 MOVLW 0x84 003926 6f00 MOVWF 0x0,0x1 003928 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_BSTALL; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00392a 0e84 MOVLW 0x84 00392c 6f04 MOVWF 0x4,0x1 } C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00392e d03b BRA 0x39a6 else // A module has claimed ownership of the control transfer session. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003930 0104 MOVLB 0x4 if(SetupPkt.DataDir == DEV_TO_HOST) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003932 af20 BTFSS 0x20,0x7,0x1 003934 d025 BRA 0x3980 { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003936 0101 MOVLB 0x1 if(SetupPkt.wLength < wCount._word) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003938 51d3 MOVF 0xd3,0x0,0x1 00393a 0104 MOVLB 0x4 00393c 5d26 SUBWF 0x26,0x0,0x1 00393e 0101 MOVLB 0x1 003940 51d4 MOVF 0xd4,0x0,0x1 003942 0104 MOVLB 0x4 003944 5927 SUBWFB 0x27,0x0,0x1 003946 e204 BC 0x3950 003948 c426 MOVFF 0x426,0x1d3 wCount._word = SetupPkt.wLength; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00394a f1d3 00394c c427 MOVFF 0x427,0x1d4 00394e f1d4 003950 df24 RCALL 0x379a USBCtrlTrfTxService(); C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003952 0101 MOVLB 0x1 ctrl_trf_state = CTRL_TRF_TX; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003954 0e01 MOVLW 0x1 003956 6fcd MOVWF 0xcd,0x1 /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Control Read: C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * ... | C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 1. Prepare OUT EP to respond to early termination C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * NOTE: C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * If something went wrong during the control transfer, C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * the last status stage may not be sent by the host. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * When this happens, two different things could happen C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * depending on the host. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * a) The host could send out a RESET. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * b) The host could send out a new SETUP transaction C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * without sending a RESET first. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * To properly handle case (b), the OUT EP must be setup C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * to receive either a zero length OUT transaction, or a C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * new SETUP transaction. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Since the SETUP transaction requires the DTS bit to be C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * DAT0 while the zero length OUT status requires the DTS C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * bit to be DAT1, the DTS bit check by the hardware should C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * be disabled. This way the SIE could accept either of C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * the two transactions. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Furthermore, the Cnt byte should be set to prepare for C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * the SETUP data (8-byte or more), and the buffer address C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * should be pointed to SetupPkt. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003958 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00395a 0e08 MOVLW 0x8 00395c 6f01 MOVWF 0x1,0x1 00395e 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&SetupPkt; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003960 0e20 MOVLW 0x20 003962 6f02 MOVWF 0x2,0x1 003964 0e04 MOVLW 0x4 003966 6f03 MOVWF 0x3,0x1 003968 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE; // Note: DTSEN is 0! C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00396a 0e80 MOVLW 0x80 00396c 6f00 MOVWF 0x0,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 2. Prepare IN EP to transfer data, Cnt should have C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * been initialized by responsible request owner. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00396e 0104 MOVLB 0x4 ep0Bi.ADR = (byte*)&CtrlTrfData; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003970 0e28 MOVLW 0x28 003972 6f06 MOVWF 0x6,0x1 003974 0e04 MOVLW 0x4 003976 6f07 MOVWF 0x7,0x1 003978 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00397a 0ec8 MOVLW 0xc8 00397c 6f04 MOVWF 0x4,0x1 } C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00397e d013 BRA 0x39a6 else // (SetupPkt.DataDir == HOST_TO_DEV) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003980 0101 MOVLB 0x1 ctrl_trf_state = CTRL_TRF_RX; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003982 0e02 MOVLW 0x2 003984 6fcd MOVWF 0xcd,0x1 /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Control Write: C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * ... | C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 1. Prepare IN EP to respond to early termination C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * This is the same as a Zero Length Packet Response C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * for control transfer without a data stage C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003986 0104 MOVLB 0x4 ep0Bi.Cnt = 0; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003988 6b05 CLRF 0x5,0x1 00398a 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 00398c 0ec8 MOVLW 0xc8 00398e 6f04 MOVWF 0x4,0x1 C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * 2. Prepare OUT EP to receive data. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003990 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003992 0e08 MOVLW 0x8 003994 6f01 MOVWF 0x1,0x1 003996 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&CtrlTrfData; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 003998 0e28 MOVLW 0x28 00399a 6f02 MOVWF 0x2,0x1 00399c 0e04 MOVLW 0x4 00399e 6f03 MOVWF 0x3,0x1 0039a0 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039a2 0ec8 MOVLW 0xc8 0039a4 6f00 MOVWF 0x0,0x1 }//end if(SetupPkt.DataDir == DEV_TO_HOST) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c }//end if(ctrl_trf_session_owner == MUID_NULL) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039a6 0012 RETURN 0x0 }//end USBCtrlEPServiceComplete C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBPrepareForNextSetupTrf(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Overview: The routine forces EP0 OUT to be ready for a new Setup C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * transaction, and forces EP0 IN to be owned by CPU. C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c void USBPrepareForNextSetupTrf(void) C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039a8 0101 MOVLB 0x1 ctrl_trf_state = WAIT_SETUP; // See usbctrltrf.h C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039aa 6bcd CLRF 0xcd,0x1 0039ac 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; // Defined in usbcfg.h C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039ae 0e08 MOVLW 0x8 0039b0 6f01 MOVWF 0x1,0x1 0039b2 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&SetupPkt; C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039b4 0e20 MOVLW 0x20 0039b6 6f02 MOVWF 0x2,0x1 0039b8 0e04 MOVLW 0x4 0039ba 6f03 MOVWF 0x3,0x1 0039bc 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT0|_DTSEN; // EP0 buff dsc init, see usbmmap.h C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039be 0e88 MOVLW 0x88 0039c0 6f00 MOVWF 0x0,0x1 0039c2 0104 MOVLB 0x4 ep0Bi.Stat._byte = _UCPU; // EP0 IN buffer initialization C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c 0039c4 6b04 CLRF 0x4,0x1 0039c6 0012 RETURN 0x0 }//end USBPrepareForNextSetupTrf C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /** EOF usbctrltrf.c *********************************************************/ C:\Projects\UBW\FW\2455\D\system\usb\usbctrltrf\usbctrltrf.c /********************************************************************* C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c ********************************************************************* C:\Projects\UBW\FW\2455\D\user\user.c * FileName: user.c C:\Projects\UBW\FW\2455\D\user\user.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\2455\D\user\user.c * Processor: PIC18 C:\Projects\UBW\FW\2455\D\user\user.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\2455\D\user\user.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Software License Agreement C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\2455\D\user\user.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\2455\D\user\user.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\2455\D\user\user.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\2455\D\user\user.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\2455\D\user\user.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\2455\D\user\user.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\2455\D\user\user.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\2455\D\user\user.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\2455\D\user\user.c * license. C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\2455\D\user\user.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\2455\D\user\user.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\2455\D\user\user.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\2455\D\user\user.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\2455\D\user\user.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Author Date Comment C:\Projects\UBW\FW\2455\D\user\user.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\2455\D\user\user.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\2455\D\user\user.c * Brian Schmalz 03/15/06 Added user code to impliment C:\Projects\UBW\FW\2455\D\user\user.c * firmware version D v1.0 for UBW C:\Projects\UBW\FW\2455\D\user\user.c * project. See www.greta.dhs.org/UBW C:\Projects\UBW\FW\2455\D\user\user.c * Brian Schmalz 05/04/06 Starting version 1.1, which will C:\Projects\UBW\FW\2455\D\user\user.c * include several fixes. See website. C:\Projects\UBW\FW\2455\D\user\user.c * BPS 06/21/06 Starting v1.2 - C:\Projects\UBW\FW\2455\D\user\user.c * - Fixed problem with I packets (from T command) filling up TX buffer C:\Projects\UBW\FW\2455\D\user\user.c * and not letting any incoming commands be received. (strange) C:\Projects\UBW\FW\2455\D\user\user.c * - Adding several commands - Analog inputs being the biggest set. C:\Projects\UBW\FW\2455\D\user\user.c * - Also Byte read/Byte write (PEEK/POKE) anywhere in memory C:\Projects\UBW\FW\2455\D\user\user.c * - Individual pin I/O and direction C:\Projects\UBW\FW\2455\D\user\user.c * BPS 08/16/06 v1.3 - Fixed bug with USB startup C:\Projects\UBW\FW\2455\D\user\user.c * BPS 09/09/06 v1.4 - Starting 1.4 C:\Projects\UBW\FW\2455\D\user\user.c * - Fixed Microchip bug with early silicon - UCONbits.PKTDIS = 0; C:\Projects\UBW\FW\2455\D\user\user.c * - Adding BO and BC commands for parallel output to graphics pannels C:\Projects\UBW\FW\2455\D\user\user.c * BPS 12/06/06 v1.4 - More work on 1.4 C:\Projects\UBW\FW\2455\D\user\user.c * - Re-wrote all I/O buffering code for increased speed and functionality C:\Projects\UBW\FW\2455\D\user\user.c * - Re-wrote error handling code C:\Projects\UBW\FW\2455\D\user\user.c * - Added delays to BC/BO commands to help Corey C:\Projects\UBW\FW\2455\D\user\user.c * BPS 01/06 v1.4 - Added RC command for servos C:\Projects\UBW\FW\2455\D\user\user.c ********************************************************************/ C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\2455\D\user\user.c #include C:\Projects\UBW\FW\2455\D\user\user.c #include C:\Projects\UBW\FW\2455\D\user\user.c #include C:\Projects\UBW\FW\2455\D\user\user.c #include C:\Projects\UBW\FW\2455\D\user\user.c #include C:\Projects\UBW\FW\2455\D\user\user.c #include "system\typedefs.h" C:\Projects\UBW\FW\2455\D\user\user.c #include "system\usb\usb.h" C:\Projects\UBW\FW\2455\D\user\user.c #include "io_cfg.h" // I/O pin mapping C:\Projects\UBW\FW\2455\D\user\user.c #include "user\user.h" C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c /** D E F I N E S ********************************************************/ C:\Projects\UBW\FW\2455\D\user\user.c #define bitset(var,bitno) ((var) |= (1 << (bitno))) C:\Projects\UBW\FW\2455\D\user\user.c #define bitclr(var,bitno) ((var) &= ~(1 << (bitno))) C:\Projects\UBW\FW\2455\D\user\user.c #define bittst(var,bitno) (var& (1 << (bitno))) C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // For the RC command, we define a little data structure that holds the C:\Projects\UBW\FW\2455\D\user\user.c // values assoicated with a particular servo connection C:\Projects\UBW\FW\2455\D\user\user.c // It's port, pin, value (position) and state (INACTIVE, PRIMED or TIMING) C:\Projects\UBW\FW\2455\D\user\user.c // Later on we make an array of these (19 elements long - 19 pins) to track C:\Projects\UBW\FW\2455\D\user\user.c // the values of all of the servos. C:\Projects\UBW\FW\2455\D\user\user.c typedef enum { C:\Projects\UBW\FW\2455\D\user\user.c kOFF = 1 C:\Projects\UBW\FW\2455\D\user\user.c ,kWAITING C:\Projects\UBW\FW\2455\D\user\user.c ,kPRIMED C:\Projects\UBW\FW\2455\D\user\user.c ,kTIMING C:\Projects\UBW\FW\2455\D\user\user.c } tRC_state; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #define kRC_DATA_SIZE 24 // In structs, since there are 3 ports of 8 bits each C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #define kTX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\2455\D\user\user.c #define kRX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #define kUSART_TX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\2455\D\user\user.c #define kUSART_RX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Enum for extract_num() function parameter C:\Projects\UBW\FW\2455\D\user\user.c typedef enum { C:\Projects\UBW\FW\2455\D\user\user.c kCHAR C:\Projects\UBW\FW\2455\D\user\user.c ,kUCHAR C:\Projects\UBW\FW\2455\D\user\user.c ,kINT C:\Projects\UBW\FW\2455\D\user\user.c ,kUINT C:\Projects\UBW\FW\2455\D\user\user.c ,kASCII_CHAR C:\Projects\UBW\FW\2455\D\user\user.c ,kUCASE_ASCII_CHAR C:\Projects\UBW\FW\2455\D\user\user.c } tExtractType; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #define advance_RX_buf_out() \ C:\Projects\UBW\FW\2455\D\user\user.c { \ C:\Projects\UBW\FW\2455\D\user\user.c g_RX_buf_out++; \ C:\Projects\UBW\FW\2455\D\user\user.c if (kRX_BUF_SIZE == g_RX_buf_out) \ C:\Projects\UBW\FW\2455\D\user\user.c { \ C:\Projects\UBW\FW\2455\D\user\user.c g_RX_buf_out = 0; \ C:\Projects\UBW\FW\2455\D\user\user.c } \ C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #define kISR_FIFO_A_DEPTH 3 C:\Projects\UBW\FW\2455\D\user\user.c #define kISR_FIFO_D_DEPTH 3 C:\Projects\UBW\FW\2455\D\user\user.c #define kPR2_RELOAD 250 // For 1ms TMR2 tick C:\Projects\UBW\FW\2455\D\user\user.c #define kCR 0x0D C:\Projects\UBW\FW\2455\D\user\user.c #define kLF 0x0A C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // defines for the error_byte byte - each bit has a meaning C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_TX_BUF_OVERRUN 2 C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_RX_BUFFER_OVERRUN 3 C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_MISSING_PARAMETER 4 C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_PRINTED_ERROR 5 // We've already printed out an error C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT 6 C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_EXTRA_CHARACTERS 7 C:\Projects\UBW\FW\2455\D\user\user.c #define kERROR_BYTE_UNKNOWN_COMMAND 8 // Part of command parser, not error handler C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\2455\D\user\user.c #pragma udata access fast_vars C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Rate variable - how fast does interrupt fire to capture inputs? C:\Projects\UBW\FW\2455\D\user\user.c near unsigned int time_between_updates; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned int ISR_D_RepeatRate; // How many 1ms ticks between Digital updates C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char ISR_D_FIFO_in; // In pointer C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char ISR_D_FIFO_out; // Out pointer C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char ISR_D_FIFO_length; // Current FIFO depth C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned int ISR_A_RepeatRate; // How many 1ms ticks between Analog updates C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char ISR_A_FIFO_in; // In pointer C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char ISR_A_FIFO_out; // Out pointer C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char ISR_A_FIFO_length; // Current FIFO depth C:\Projects\UBW\FW\2455\D\user\user.c near volatile unsigned char AnalogEnable; // Maximum ADC channel to convert C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // This byte has each of its bits used as a seperate error flag C:\Projects\UBW\FW\2455\D\user\user.c near unsigned char error_byte; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // RC servo variables C:\Projects\UBW\FW\2455\D\user\user.c // First the main array of data for each servo C:\Projects\UBW\FW\2455\D\user\user.c near unsigned char g_RC_primed_ptr; C:\Projects\UBW\FW\2455\D\user\user.c near unsigned char g_RC_next_ptr; C:\Projects\UBW\FW\2455\D\user\user.c near unsigned char g_RC_timing_ptr; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Used only in LowISR C:\Projects\UBW\FW\2455\D\user\user.c near unsigned int D_tick_counter; C:\Projects\UBW\FW\2455\D\user\user.c near unsigned int A_tick_counter; C:\Projects\UBW\FW\2455\D\user\user.c near unsigned char A_cur_channel; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // ROM strings C:\Projects\UBW\FW\2455\D\user\user.c const rom char st_OK[] = {"OK\r\n"}; C:\Projects\UBW\FW\2455\D\user\user.c const rom char st_LFCR[] = {"\r\n"}; C:\Projects\UBW\FW\2455\D\user\user.c const rom char st_version[] = {"UBW FW D Version 1.4.0\r\n"}; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #pragma udata ISR_buf=0x100 C:\Projects\UBW\FW\2455\D\user\user.c volatile unsigned int ISR_A_FIFO[12][kISR_FIFO_A_DEPTH]; // Stores the most recent analog conversions C:\Projects\UBW\FW\2455\D\user\user.c volatile unsigned char ISR_D_FIFO[3][kISR_FIFO_D_DEPTH]; // FIFO of actual data C:\Projects\UBW\FW\2455\D\user\user.c volatile tRC_state g_RC_state[kRC_DATA_SIZE]; // Stores states for each pin for RC command C:\Projects\UBW\FW\2455\D\user\user.c volatile unsigned int g_RC_value[kRC_DATA_SIZE]; // Stores reload values for TMR0 C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #pragma udata com_buf=0x200 C:\Projects\UBW\FW\2455\D\user\user.c // USB Transmit buffer for packets (back to PC) C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_TX_buf[kTX_BUF_SIZE]; C:\Projects\UBW\FW\2455\D\user\user.c // USB Receiving buffer for commands as they come from PC C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_RX_buf[kRX_BUF_SIZE]; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // USART Receiving buffer for data coming from the USART C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_USART_RX_buf[kUSART_RX_BUF_SIZE]; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // USART Transmit buffer for data going to the USART C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_USART_TX_buf[kUSART_TX_BUF_SIZE]; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // These variables are in normal storage space C:\Projects\UBW\FW\2455\D\user\user.c #pragma udata C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // These are used for the Fast Parallel Output routines C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_BO_init; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_BO_strobe_mask; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_BO_wait_mask; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_BO_wait_delay; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_BO_strobe_delay; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Pointers to USB transmit (back to PC) buffer C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_TX_buf_in; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_TX_buf_out; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Pointers to USB receive (from PC) buffer C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_RX_buf_in; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_RX_buf_out; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // In and out pointers to our USART input buffer C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_USART_RX_buf_in; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_USART_RX_buf_out; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // In and out pointers to our USART output buffer C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_USART_TX_buf_in; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char g_USART_TX_buf_out; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Normally set to TRUE. Able to set FALSE to not send "OK" message after packet recepetion C:\Projects\UBW\FW\2455\D\user\user.c BOOL g_ack_enable; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\2455\D\user\user.c void BlinkUSBStatus (void); // Handles blinking the USB status LED C:\Projects\UBW\FW\2455\D\user\user.c BOOL SwitchIsPressed (void); // Check to see if the user (PRG) switch is pressed C:\Projects\UBW\FW\2455\D\user\user.c void parse_packet (void); // Take a full packet and dispatch it to the right function C:\Projects\UBW\FW\2455\D\user\user.c signed short long extract_number (tExtractType type); // Pull a number paramter out of the packet C:\Projects\UBW\FW\2455\D\user\user.c signed char extract_digit (signed short long * acc, unsigned char digits); // Pull a character out of the packet C:\Projects\UBW\FW\2455\D\user\user.c void parse_R_packet (void); // R for resetting UBW C:\Projects\UBW\FW\2455\D\user\user.c void parse_C_packet (void); // C for configuring I/O and analog pins C:\Projects\UBW\FW\2455\D\user\user.c void parse_CX_packet (void); // CX For configuring serial port C:\Projects\UBW\FW\2455\D\user\user.c void parse_O_packet (void); // O for output digital to pins C:\Projects\UBW\FW\2455\D\user\user.c void parse_I_packet (void); // I for input digital from pins C:\Projects\UBW\FW\2455\D\user\user.c void parse_V_packet (void); // V for printing version C:\Projects\UBW\FW\2455\D\user\user.c void parse_A_packet (void); // A for requesting analog inputs C:\Projects\UBW\FW\2455\D\user\user.c void parse_T_packet (void); // T for setting up timed I/O (digital or analog) C:\Projects\UBW\FW\2455\D\user\user.c void parse_PI_packet (void); // PI for reading a single pin C:\Projects\UBW\FW\2455\D\user\user.c void parse_PO_packet (void); // PO for setting a single pin state C:\Projects\UBW\FW\2455\D\user\user.c void parse_PD_packet (void); // PD for setting a pin's direction C:\Projects\UBW\FW\2455\D\user\user.c void parse_MR_packet (void); // MR for Memory Read C:\Projects\UBW\FW\2455\D\user\user.c void parse_MW_packet (void); // MW for Memory Write C:\Projects\UBW\FW\2455\D\user\user.c void parse_TX_packet (void); // TX for transmitting serial C:\Projects\UBW\FW\2455\D\user\user.c void parse_RX_packet (void); // RX for receiving serial C:\Projects\UBW\FW\2455\D\user\user.c void parse_RC_packet (void); // RC is for outputing RC servo pulses C:\Projects\UBW\FW\2455\D\user\user.c void parse_BO_packet (void); // BO sends data to fast parallel output C:\Projects\UBW\FW\2455\D\user\user.c void parse_BC_packet (void); // BC configures fast parallel outputs C:\Projects\UBW\FW\2455\D\user\user.c void parse_BS_packet (void); // BS sends binary data to fast parallel output C:\Projects\UBW\FW\2455\D\user\user.c void parse_CU_packet (void); // CU configures UBW (system wide parameters) C:\Projects\UBW\FW\2455\D\user\user.c void parse_SS_packet (void); // SS Send SPI C:\Projects\UBW\FW\2455\D\user\user.c void parse_RS_packet (void); // RS Receive SPI C:\Projects\UBW\FW\2455\D\user\user.c void parse_CS_packet (void); // CS Configure SPI C:\Projects\UBW\FW\2455\D\user\user.c void parse_SI_packet (void); // SI Send I2C C:\Projects\UBW\FW\2455\D\user\user.c void parse_RI_packet (void); // RI Receive I2C C:\Projects\UBW\FW\2455\D\user\user.c void parse_CI_packet (void); // CI Configure I2C C:\Projects\UBW\FW\2455\D\user\user.c void check_and_send_TX_data (void); // See if there is any data to send to PC, and if so, do it C:\Projects\UBW\FW\2455\D\user\user.c void print_ack (void); // Print "OK" after packet is parsed C:\Projects\UBW\FW\2455\D\user\user.c int _user_putc (char c); // Our UBS based stream character printer C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\2455\D\user\user.c #pragma code C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #pragma interruptlow low_ISR C:\Projects\UBW\FW\2455\D\user\user.c 000844 cfd8 MOVFF 0xfd8,0xfe4 void low_ISR(void) C:\Projects\UBW\FW\2455\D\user\user.c 000846 ffe4 000848 cfe0 MOVFF 0xfe0,0xfe4 00084a ffe4 00084c 6ee4 MOVWF 0xe4,0x0 00084e cfda MOVFF 0xfda,0xfe4 000850 ffe4 000852 cfe2 MOVFF 0xfe2,0xfda 000854 ffda 000856 cfe9 MOVFF 0xfe9,0xfe4 000858 ffe4 00085a cfea MOVFF 0xfea,0xfe4 00085c ffe4 00085e cff3 MOVFF 0xff3,0xfe4 000860 ffe4 000862 cff4 MOVFF 0xff4,0xfe4 000864 ffe4 000866 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c // Do we have a Timer2 interrupt? (1ms rate) C:\Projects\UBW\FW\2455\D\user\user.c 000868 a29e BTFSS 0x9e,0x1,0x0 if (PIR1bits.TMR2IF) C:\Projects\UBW\FW\2455\D\user\user.c 00086a d101 BRA 0xa6e { C:\Projects\UBW\FW\2455\D\user\user.c // Clear the interrupt C:\Projects\UBW\FW\2455\D\user\user.c 00086c 929e BCF 0x9e,0x1,0x0 PIR1bits.TMR2IF = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // The most time critical part of this interrupt service routine is the C:\Projects\UBW\FW\2455\D\user\user.c // handling of the RC command's servo output pulses. C:\Projects\UBW\FW\2455\D\user\user.c // Each time we get this interrupt, we look to see if the next pin on the C:\Projects\UBW\FW\2455\D\user\user.c // list has a value greater than zero. If so, we arm set it high and set C:\Projects\UBW\FW\2455\D\user\user.c // it's state to PRIMED. Then we advance the pointers to the next pair. C:\Projects\UBW\FW\2455\D\user\user.c 00086e 0e03 MOVLW 0x3 if (kPRIMED == g_RC_state[g_RC_primed_ptr]) C:\Projects\UBW\FW\2455\D\user\user.c 000870 6e38 MOVWF 0x38,0x0 000872 500e MOVF 0xe,0x0,0x0 000874 6aea CLRF 0xea,0x0 000876 0f51 ADDLW 0x51 000878 6ee9 MOVWF 0xe9,0x0 00087a 0e01 MOVLW 0x1 00087c 22ea ADDWFC 0xea,0x1,0x0 00087e 50ef MOVF 0xef,0x0,0x0 000880 5c38 SUBWF 0x38,0x0,0x0 000882 e130 BNZ 0x8e4 { C:\Projects\UBW\FW\2455\D\user\user.c // This is easy, throw the value into the timer C:\Projects\UBW\FW\2455\D\user\user.c 000884 500e MOVF 0xe,0x0,0x0 TMR0H = g_RC_value[g_RC_primed_ptr] >> 8; C:\Projects\UBW\FW\2455\D\user\user.c 000886 6ee9 MOVWF 0xe9,0x0 000888 6aea CLRF 0xea,0x0 00088a 90d8 BCF 0xd8,0x0,0x0 00088c 36e9 RLCF 0xe9,0x1,0x0 00088e 36ea RLCF 0xea,0x1,0x0 000890 0e69 MOVLW 0x69 000892 26e9 ADDWF 0xe9,0x1,0x0 000894 0e01 MOVLW 0x1 000896 22ea ADDWFC 0xea,0x1,0x0 000898 cfee MOVFF 0xfee,0x38 00089a f038 00089c cfef MOVFF 0xfef,0x39 00089e f039 0008a0 c039 MOVFF 0x39,0x38 0008a2 f038 0008a4 6a39 CLRF 0x39,0x0 0008a6 5038 MOVF 0x38,0x0,0x0 0008a8 6ed7 MOVWF 0xd7,0x0 0008aa 500e MOVF 0xe,0x0,0x0 TMR0L = g_RC_value[g_RC_primed_ptr] & 0xFF; C:\Projects\UBW\FW\2455\D\user\user.c 0008ac 6ee9 MOVWF 0xe9,0x0 0008ae 6aea CLRF 0xea,0x0 0008b0 90d8 BCF 0xd8,0x0,0x0 0008b2 36e9 RLCF 0xe9,0x1,0x0 0008b4 36ea RLCF 0xea,0x1,0x0 0008b6 0e69 MOVLW 0x69 0008b8 26e9 ADDWF 0xe9,0x1,0x0 0008ba 0e01 MOVLW 0x1 0008bc 22ea ADDWFC 0xea,0x1,0x0 0008be cfee MOVFF 0xfee,0x38 0008c0 f038 0008c2 cfef MOVFF 0xfef,0x39 0008c4 f039 0008c6 5038 MOVF 0x38,0x0,0x0 0008c8 6ed6 MOVWF 0xd6,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Then make sure the timer's interrupt enable is set C:\Projects\UBW\FW\2455\D\user\user.c 0008ca 8af2 BSF 0xf2,0x5,0x0 INTCONbits.TMR0IE = 1; C:\Projects\UBW\FW\2455\D\user\user.c // And be sure to clear the flag too C:\Projects\UBW\FW\2455\D\user\user.c 0008cc 94f2 BCF 0xf2,0x2,0x0 INTCONbits.TMR0IF = 0; C:\Projects\UBW\FW\2455\D\user\user.c // Turn on Timer0 C:\Projects\UBW\FW\2455\D\user\user.c 0008ce 8ed5 BSF 0xd5,0x7,0x0 T0CONbits.TMR0ON = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // And set this pin's state to timing C:\Projects\UBW\FW\2455\D\user\user.c 0008d0 500e MOVF 0xe,0x0,0x0 g_RC_state[g_RC_primed_ptr] = kTIMING; C:\Projects\UBW\FW\2455\D\user\user.c 0008d2 6aea CLRF 0xea,0x0 0008d4 0f51 ADDLW 0x51 0008d6 6ee9 MOVWF 0xe9,0x0 0008d8 0e01 MOVLW 0x1 0008da 22ea ADDWFC 0xea,0x1,0x0 0008dc 0e04 MOVLW 0x4 0008de 6eef MOVWF 0xef,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Remember which pin is now timing C:\Projects\UBW\FW\2455\D\user\user.c 0008e0 500e MOVF 0xe,0x0,0x0 g_RC_timing_ptr = g_RC_primed_ptr; C:\Projects\UBW\FW\2455\D\user\user.c 0008e2 6e10 MOVWF 0x10,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 0008e4 0e02 MOVLW 0x2 if (kWAITING == g_RC_state[g_RC_next_ptr]) C:\Projects\UBW\FW\2455\D\user\user.c 0008e6 6e38 MOVWF 0x38,0x0 0008e8 500f MOVF 0xf,0x0,0x0 0008ea 6aea CLRF 0xea,0x0 0008ec 0f51 ADDLW 0x51 0008ee 6ee9 MOVWF 0xe9,0x0 0008f0 0e01 MOVLW 0x1 0008f2 22ea ADDWFC 0xea,0x1,0x0 0008f4 50ef MOVF 0xef,0x0,0x0 0008f6 5c38 SUBWF 0x38,0x0,0x0 0008f8 e149 BNZ 0x98c { C:\Projects\UBW\FW\2455\D\user\user.c // If the value is zero, then shut this pin off C:\Projects\UBW\FW\2455\D\user\user.c // otherwise, prime it for sending a pulse C:\Projects\UBW\FW\2455\D\user\user.c 0008fa 500f MOVF 0xf,0x0,0x0 if (0 == g_RC_value[g_RC_next_ptr]) C:\Projects\UBW\FW\2455\D\user\user.c 0008fc 6ee9 MOVWF 0xe9,0x0 0008fe 6aea CLRF 0xea,0x0 000900 90d8 BCF 0xd8,0x0,0x0 000902 36e9 RLCF 0xe9,0x1,0x0 000904 36ea RLCF 0xea,0x1,0x0 000906 0e69 MOVLW 0x69 000908 26e9 ADDWF 0xe9,0x1,0x0 00090a 0e01 MOVLW 0x1 00090c 22ea ADDWFC 0xea,0x1,0x0 00090e 50ee MOVF 0xee,0x0,0x0 000910 10ed IORWF 0xed,0x0,0x0 000912 e109 BNZ 0x926 { C:\Projects\UBW\FW\2455\D\user\user.c 000914 500f MOVF 0xf,0x0,0x0 g_RC_state[g_RC_next_ptr] = kOFF; C:\Projects\UBW\FW\2455\D\user\user.c 000916 6aea CLRF 0xea,0x0 000918 0f51 ADDLW 0x51 00091a 6ee9 MOVWF 0xe9,0x0 00091c 0e01 MOVLW 0x1 00091e 22ea ADDWFC 0xea,0x1,0x0 000920 0e01 MOVLW 0x1 000922 6eef MOVWF 0xef,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000924 d033 BRA 0x98c else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Set the bit high C:\Projects\UBW\FW\2455\D\user\user.c 000926 0e08 MOVLW 0x8 if (g_RC_next_ptr < 8) C:\Projects\UBW\FW\2455\D\user\user.c 000928 5c0f SUBWF 0xf,0x0,0x0 00092a e20c BC 0x944 { C:\Projects\UBW\FW\2455\D\user\user.c 00092c 0e07 MOVLW 0x7 bitset (LATA, g_RC_next_ptr & 0x7); C:\Projects\UBW\FW\2455\D\user\user.c 00092e 140f ANDWF 0xf,0x0,0x0 000930 6e38 MOVWF 0x38,0x0 000932 0e01 MOVLW 0x1 000934 5238 MOVF 0x38,0x1,0x0 000936 e004 BZ 0x940 000938 46e8 RLNCF 0xe8,0x1,0x0 00093a 0bfe ANDLW 0xfe 00093c 0638 DECF 0x38,0x1,0x0 00093e e1fc BNZ 0x938 000940 1289 IORWF 0x89,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000942 d01a BRA 0x978 else if (g_RC_next_ptr < 16) C:\Projects\UBW\FW\2455\D\user\user.c 000944 0e10 MOVLW 0x10 000946 5c0f SUBWF 0xf,0x0,0x0 000948 e20c BC 0x962 { C:\Projects\UBW\FW\2455\D\user\user.c 00094a 0e07 MOVLW 0x7 bitset (LATB, g_RC_next_ptr & 0x7); C:\Projects\UBW\FW\2455\D\user\user.c 00094c 140f ANDWF 0xf,0x0,0x0 00094e 6e38 MOVWF 0x38,0x0 000950 0e01 MOVLW 0x1 000952 5238 MOVF 0x38,0x1,0x0 000954 e004 BZ 0x95e 000956 46e8 RLNCF 0xe8,0x1,0x0 000958 0bfe ANDLW 0xfe 00095a 0638 DECF 0x38,0x1,0x0 00095c e1fc BNZ 0x956 00095e 128a IORWF 0x8a,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000960 d00b BRA 0x978 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 000962 0e07 MOVLW 0x7 bitset (LATC, g_RC_next_ptr & 0x7); C:\Projects\UBW\FW\2455\D\user\user.c 000964 140f ANDWF 0xf,0x0,0x0 000966 6e38 MOVWF 0x38,0x0 000968 0e01 MOVLW 0x1 00096a 5238 MOVF 0x38,0x1,0x0 00096c e004 BZ 0x976 00096e 46e8 RLNCF 0xe8,0x1,0x0 000970 0bfe ANDLW 0xfe 000972 0638 DECF 0x38,0x1,0x0 000974 e1fc BNZ 0x96e 000976 128b IORWF 0x8b,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c // Set the state to primed so we know to do next C:\Projects\UBW\FW\2455\D\user\user.c 000978 500f MOVF 0xf,0x0,0x0 g_RC_state[g_RC_next_ptr] = kPRIMED; C:\Projects\UBW\FW\2455\D\user\user.c 00097a 6aea CLRF 0xea,0x0 00097c 0f51 ADDLW 0x51 00097e 6ee9 MOVWF 0xe9,0x0 000980 0e01 MOVLW 0x1 000982 22ea ADDWFC 0xea,0x1,0x0 000984 0e03 MOVLW 0x3 000986 6eef MOVWF 0xef,0x0 // And remember which pin is primed C:\Projects\UBW\FW\2455\D\user\user.c 000988 500f MOVF 0xf,0x0,0x0 g_RC_primed_ptr = g_RC_next_ptr; C:\Projects\UBW\FW\2455\D\user\user.c 00098a 6e0e MOVWF 0xe,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // And always advance the main pointer C:\Projects\UBW\FW\2455\D\user\user.c // NOTE: we need to skip RA6, RA7, and RC3, RC4, and RC5 C:\Projects\UBW\FW\2455\D\user\user.c // (Because UBW doesn't bring those pins out to headers) C:\Projects\UBW\FW\2455\D\user\user.c 00098c 2a0f INCF 0xf,0x1,0x0 g_RC_next_ptr++; C:\Projects\UBW\FW\2455\D\user\user.c 00098e 0e06 MOVLW 0x6 if (6 == g_RC_next_ptr) C:\Projects\UBW\FW\2455\D\user\user.c 000990 5c0f SUBWF 0xf,0x0,0x0 000992 e103 BNZ 0x99a { C:\Projects\UBW\FW\2455\D\user\user.c 000994 0e08 MOVLW 0x8 g_RC_next_ptr = 8; C:\Projects\UBW\FW\2455\D\user\user.c 000996 6e0f MOVWF 0xf,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000998 d00a BRA 0x9ae else if (19 == g_RC_next_ptr) C:\Projects\UBW\FW\2455\D\user\user.c 00099a 0e13 MOVLW 0x13 00099c 5c0f SUBWF 0xf,0x0,0x0 00099e e103 BNZ 0x9a6 { C:\Projects\UBW\FW\2455\D\user\user.c 0009a0 0e16 MOVLW 0x16 g_RC_next_ptr = 22; C:\Projects\UBW\FW\2455\D\user\user.c 0009a2 6e0f MOVWF 0xf,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 0009a4 d004 BRA 0x9ae else if (kRC_DATA_SIZE == g_RC_next_ptr) C:\Projects\UBW\FW\2455\D\user\user.c 0009a6 0e18 MOVLW 0x18 0009a8 5c0f SUBWF 0xf,0x0,0x0 0009aa e101 BNZ 0x9ae { C:\Projects\UBW\FW\2455\D\user\user.c 0009ac 6a0f CLRF 0xf,0x0 g_RC_next_ptr = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // See if it's time to fire off an I packet C:\Projects\UBW\FW\2455\D\user\user.c 0009ae 0e00 MOVLW 0x0 if (ISR_D_RepeatRate > 0) C:\Projects\UBW\FW\2455\D\user\user.c 0009b0 80d8 BSF 0xd8,0x0,0x0 0009b2 5402 SUBFWB 0x2,0x0,0x0 0009b4 0e00 MOVLW 0x0 0009b6 5403 SUBFWB 0x3,0x0,0x0 0009b8 e22e BC 0xa16 { C:\Projects\UBW\FW\2455\D\user\user.c 0009ba 2a11 INCF 0x11,0x1,0x0 D_tick_counter++; C:\Projects\UBW\FW\2455\D\user\user.c 0009bc 0e00 MOVLW 0x0 0009be 2212 ADDWFC 0x12,0x1,0x0 0009c0 5002 MOVF 0x2,0x0,0x0 if (D_tick_counter >= ISR_D_RepeatRate) C:\Projects\UBW\FW\2455\D\user\user.c 0009c2 5c11 SUBWF 0x11,0x0,0x0 0009c4 5003 MOVF 0x3,0x0,0x0 0009c6 5812 SUBWFB 0x12,0x0,0x0 0009c8 e326 BNC 0xa16 { C:\Projects\UBW\FW\2455\D\user\user.c 0009ca 6a11 CLRF 0x11,0x0 D_tick_counter = 0; C:\Projects\UBW\FW\2455\D\user\user.c 0009cc 6a12 CLRF 0x12,0x0 // Tell the main code to send an I packet C:\Projects\UBW\FW\2455\D\user\user.c 0009ce 0e03 MOVLW 0x3 if (ISR_D_FIFO_length < kISR_FIFO_D_DEPTH) C:\Projects\UBW\FW\2455\D\user\user.c 0009d0 5c06 SUBWF 0x6,0x0,0x0 0009d2 e21f BC 0xa12 { C:\Projects\UBW\FW\2455\D\user\user.c // And copy over our port values C:\Projects\UBW\FW\2455\D\user\user.c 0009d4 5004 MOVF 0x4,0x0,0x0 ISR_D_FIFO[0][ISR_D_FIFO_in] = PORTA; C:\Projects\UBW\FW\2455\D\user\user.c 0009d6 6aea CLRF 0xea,0x0 0009d8 0f48 ADDLW 0x48 0009da 6ee9 MOVWF 0xe9,0x0 0009dc 0e01 MOVLW 0x1 0009de 22ea ADDWFC 0xea,0x1,0x0 0009e0 cf80 MOVFF 0xf80,0xfef 0009e2 ffef 0009e4 5004 MOVF 0x4,0x0,0x0 ISR_D_FIFO[1][ISR_D_FIFO_in] = PORTB; C:\Projects\UBW\FW\2455\D\user\user.c 0009e6 6aea CLRF 0xea,0x0 0009e8 0f4b ADDLW 0x4b 0009ea 6ee9 MOVWF 0xe9,0x0 0009ec 0e01 MOVLW 0x1 0009ee 22ea ADDWFC 0xea,0x1,0x0 0009f0 cf81 MOVFF 0xf81,0xfef 0009f2 ffef 0009f4 5004 MOVF 0x4,0x0,0x0 ISR_D_FIFO[2][ISR_D_FIFO_in] = PORTC; C:\Projects\UBW\FW\2455\D\user\user.c 0009f6 6aea CLRF 0xea,0x0 0009f8 0f4e ADDLW 0x4e 0009fa 6ee9 MOVWF 0xe9,0x0 0009fc 0e01 MOVLW 0x1 0009fe 22ea ADDWFC 0xea,0x1,0x0 000a00 cf82 MOVFF 0xf82,0xfef 000a02 ffef 000a04 2a04 INCF 0x4,0x1,0x0 ISR_D_FIFO_in++; C:\Projects\UBW\FW\2455\D\user\user.c 000a06 0e03 MOVLW 0x3 if (ISR_D_FIFO_in >= kISR_FIFO_D_DEPTH) C:\Projects\UBW\FW\2455\D\user\user.c 000a08 5c04 SUBWF 0x4,0x0,0x0 000a0a e301 BNC 0xa0e { C:\Projects\UBW\FW\2455\D\user\user.c 000a0c 6a04 CLRF 0x4,0x0 ISR_D_FIFO_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000a0e 2a06 INCF 0x6,0x1,0x0 ISR_D_FIFO_length++; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000a10 d002 BRA 0xa16 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Stop the madness! Something is wrong, we're C:\Projects\UBW\FW\2455\D\user\user.c // not getting our packets out. So kill the C:\Projects\UBW\FW\2455\D\user\user.c // timer. C:\Projects\UBW\FW\2455\D\user\user.c 000a12 6a02 CLRF 0x2,0x0 ISR_D_RepeatRate = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000a14 6a03 CLRF 0x3,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // See if it's time to fire off an A packet C:\Projects\UBW\FW\2455\D\user\user.c 000a16 0e00 MOVLW 0x0 if ((ISR_A_RepeatRate > 0) && (AnalogEnable > 0)) C:\Projects\UBW\FW\2455\D\user\user.c 000a18 80d8 BSF 0xd8,0x0,0x0 000a1a 5407 SUBFWB 0x7,0x0,0x0 000a1c 0e00 MOVLW 0x0 000a1e 5408 SUBFWB 0x8,0x0,0x0 000a20 e219 BC 0xa54 000a22 500c MOVF 0xc,0x0,0x0 000a24 0800 SUBLW 0x0 000a26 e216 BC 0xa54 { C:\Projects\UBW\FW\2455\D\user\user.c 000a28 2a13 INCF 0x13,0x1,0x0 A_tick_counter++; C:\Projects\UBW\FW\2455\D\user\user.c 000a2a 0e00 MOVLW 0x0 000a2c 2214 ADDWFC 0x14,0x1,0x0 000a2e 5007 MOVF 0x7,0x0,0x0 if (A_tick_counter >= ISR_A_RepeatRate) C:\Projects\UBW\FW\2455\D\user\user.c 000a30 5c13 SUBWF 0x13,0x0,0x0 000a32 5008 MOVF 0x8,0x0,0x0 000a34 5814 SUBWFB 0x14,0x0,0x0 000a36 e30e BNC 0xa54 { C:\Projects\UBW\FW\2455\D\user\user.c 000a38 6a13 CLRF 0x13,0x0 A_tick_counter = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000a3a 6a14 CLRF 0x14,0x0 // Tell the main code to send an A packet C:\Projects\UBW\FW\2455\D\user\user.c 000a3c 0e03 MOVLW 0x3 if (ISR_A_FIFO_length < kISR_FIFO_A_DEPTH) C:\Projects\UBW\FW\2455\D\user\user.c 000a3e 5c0b SUBWF 0xb,0x0,0x0 000a40 e207 BC 0xa50 { C:\Projects\UBW\FW\2455\D\user\user.c 000a42 2a09 INCF 0x9,0x1,0x0 ISR_A_FIFO_in++; C:\Projects\UBW\FW\2455\D\user\user.c 000a44 0e03 MOVLW 0x3 if (ISR_A_FIFO_in >= kISR_FIFO_A_DEPTH) C:\Projects\UBW\FW\2455\D\user\user.c 000a46 5c09 SUBWF 0x9,0x0,0x0 000a48 e301 BNC 0xa4c { C:\Projects\UBW\FW\2455\D\user\user.c 000a4a 6a09 CLRF 0x9,0x0 ISR_A_FIFO_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000a4c 2a0b INCF 0xb,0x1,0x0 ISR_A_FIFO_length++; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000a4e d002 BRA 0xa54 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Stop the madness! Something is wrong, we're C:\Projects\UBW\FW\2455\D\user\user.c // not getting our packets out. So kill the A C:\Projects\UBW\FW\2455\D\user\user.c // packets. C:\Projects\UBW\FW\2455\D\user\user.c 000a50 6a07 CLRF 0x7,0x0 ISR_A_RepeatRate = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000a52 6a08 CLRF 0x8,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // See if it's time to start analog conversions C:\Projects\UBW\FW\2455\D\user\user.c 000a54 500c MOVF 0xc,0x0,0x0 if (AnalogEnable > 0) C:\Projects\UBW\FW\2455\D\user\user.c 000a56 0800 SUBLW 0x0 000a58 e20a BC 0xa6e { C:\Projects\UBW\FW\2455\D\user\user.c // Set the channel to zero to start off with C:\Projects\UBW\FW\2455\D\user\user.c 000a5a 6a15 CLRF 0x15,0x0 A_cur_channel = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000a5c 5015 MOVF 0x15,0x0,0x0 ADCON0 = (A_cur_channel << 2) + 1; C:\Projects\UBW\FW\2455\D\user\user.c 000a5e 0d04 MULLW 0x4 000a60 28f3 INCF 0xf3,0x0,0x0 000a62 6ec2 MOVWF 0xc2,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Clear the interrupt C:\Projects\UBW\FW\2455\D\user\user.c 000a64 9c9e BCF 0x9e,0x6,0x0 PIR1bits.ADIF = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // And make sure to always use low priority. C:\Projects\UBW\FW\2455\D\user\user.c 000a66 9c9f BCF 0x9f,0x6,0x0 IPR1bits.ADIP = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Set the interrupt enable C:\Projects\UBW\FW\2455\D\user\user.c 000a68 8c9d BSF 0x9d,0x6,0x0 PIE1bits.ADIE = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Make sure it's on! C:\Projects\UBW\FW\2455\D\user\user.c 000a6a 80c2 BSF 0xc2,0x0,0x0 ADCON0bits.ADON = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // And tell the A/D to GO! C:\Projects\UBW\FW\2455\D\user\user.c 000a6c 82c2 BSF 0xc2,0x1,0x0 ADCON0bits.GO_DONE = 1; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Do we have an analog interrupt? C:\Projects\UBW\FW\2455\D\user\user.c 000a6e ac9e BTFSS 0x9e,0x6,0x0 if (PIR1bits.ADIF) C:\Projects\UBW\FW\2455\D\user\user.c 000a70 d02d BRA 0xacc { C:\Projects\UBW\FW\2455\D\user\user.c // Clear the interrupt C:\Projects\UBW\FW\2455\D\user\user.c 000a72 9c9e BCF 0x9e,0x6,0x0 PIR1bits.ADIF = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Read out the value that we just converted, and store it. C:\Projects\UBW\FW\2455\D\user\user.c 000a8a 5015 MOVF 0x15,0x0,0x0 ISR_A_FIFO[A_cur_channel][ISR_A_FIFO_in] = C:\Projects\UBW\FW\2455\D\user\user.c 000a8c 0d06 MULLW 0x6 000a8e cff3 MOVFF 0xff3,0x38 000a90 f038 000a92 cff4 MOVFF 0xff4,0x39 000a94 f039 000a96 0e00 MOVLW 0x0 000a98 2638 ADDWF 0x38,0x1,0x0 000a9a 0e01 MOVLW 0x1 000a9c 2239 ADDWFC 0x39,0x1,0x0 000a9e 5009 MOVF 0x9,0x0,0x0 000aa0 0d02 MULLW 0x2 000aa2 5038 MOVF 0x38,0x0,0x0 000aa4 24f3 ADDWF 0xf3,0x0,0x0 000aa6 6ee9 MOVWF 0xe9,0x0 000aa8 5039 MOVF 0x39,0x0,0x0 000aaa 20f4 ADDWFC 0xf4,0x0,0x0 000aac 6eea MOVWF 0xea,0x0 000a7e 50c3 MOVF 0xc3,0x0,0x0 (unsigned int)ADRESL C:\Projects\UBW\FW\2455\D\user\user.c | C:\Projects\UBW\FW\2455\D\user\user.c 000a74 50c4 MOVF 0xc4,0x0,0x0 ((unsigned int)ADRESH << 8); C:\Projects\UBW\FW\2455\D\user\user.c 000a76 6e3c MOVWF 0x3c,0x0 000a78 c03c MOVFF 0x3c,0x3d 000a7a f03d 000a7c 6a3c CLRF 0x3c,0x0 000a80 0100 MOVLB 0x0 000a82 103c IORWF 0x3c,0x0,0x0 000a84 6e3a MOVWF 0x3a,0x0 000a86 c03d MOVFF 0x3d,0x3b 000a88 f03b 000aae c03a MOVFF 0x3a,0xfee 000ab0 ffee 000ab2 c03b MOVFF 0x3b,0xfed 000ab4 ffed C:\Projects\UBW\FW\2455\D\user\user.c // Incriment the channel and write the new one in C:\Projects\UBW\FW\2455\D\user\user.c 000ab6 2a15 INCF 0x15,0x1,0x0 A_cur_channel++; C:\Projects\UBW\FW\2455\D\user\user.c 000ab8 500c MOVF 0xc,0x0,0x0 if (A_cur_channel >= AnalogEnable) C:\Projects\UBW\FW\2455\D\user\user.c 000aba 5c15 SUBWF 0x15,0x0,0x0 000abc e302 BNC 0xac2 { C:\Projects\UBW\FW\2455\D\user\user.c // We're done, so just sit and wait C:\Projects\UBW\FW\2455\D\user\user.c // Turn off our interrupts though. C:\Projects\UBW\FW\2455\D\user\user.c 000abe 9c9d BCF 0x9d,0x6,0x0 PIE1bits.ADIE = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000ac0 d005 BRA 0xacc else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Update the channel number C:\Projects\UBW\FW\2455\D\user\user.c 000ac2 5015 MOVF 0x15,0x0,0x0 ADCON0 = (A_cur_channel << 2) + 1; C:\Projects\UBW\FW\2455\D\user\user.c 000ac4 0d04 MULLW 0x4 000ac6 28f3 INCF 0xf3,0x0,0x0 000ac8 6ec2 MOVWF 0xc2,0x0 // And start the next conversion C:\Projects\UBW\FW\2455\D\user\user.c 000aca 82c2 BSF 0xc2,0x1,0x0 ADCON0bits.GO_DONE = 1; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Do we have a TMR0 interrupt? (RC command) C:\Projects\UBW\FW\2455\D\user\user.c // TMR0 is in 16 bit mode, and counts up to FFFF and overflows, generating C:\Projects\UBW\FW\2455\D\user\user.c // this interrupt. C:\Projects\UBW\FW\2455\D\user\user.c 000acc a4f2 BTFSS 0xf2,0x2,0x0 if (INTCONbits.TMR0IF) C:\Projects\UBW\FW\2455\D\user\user.c 000ace d042 BRA 0xb54 { C:\Projects\UBW\FW\2455\D\user\user.c // Turn off Timer0 C:\Projects\UBW\FW\2455\D\user\user.c 000ad0 9ed5 BCF 0xd5,0x7,0x0 T0CONbits.TMR0ON = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Clear the interrupt C:\Projects\UBW\FW\2455\D\user\user.c 000ad2 94f2 BCF 0xf2,0x2,0x0 INTCONbits.TMR0IF = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // And disable it C:\Projects\UBW\FW\2455\D\user\user.c 000ad4 9af2 BCF 0xf2,0x5,0x0 INTCONbits.TMR0IE = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Only do our stuff if the pin is in the proper state C:\Projects\UBW\FW\2455\D\user\user.c 000ad6 0e04 MOVLW 0x4 if (kTIMING == g_RC_state[g_RC_timing_ptr]) C:\Projects\UBW\FW\2455\D\user\user.c 000ad8 6e38 MOVWF 0x38,0x0 000ada 5010 MOVF 0x10,0x0,0x0 000adc 6aea CLRF 0xea,0x0 000ade 0f51 ADDLW 0x51 000ae0 6ee9 MOVWF 0xe9,0x0 000ae2 0e01 MOVLW 0x1 000ae4 22ea ADDWFC 0xea,0x1,0x0 000ae6 50ef MOVF 0xef,0x0,0x0 000ae8 5c38 SUBWF 0x38,0x0,0x0 000aea e134 BNZ 0xb54 { C:\Projects\UBW\FW\2455\D\user\user.c // All we need to do is clear the pin and change its state to kWAITING C:\Projects\UBW\FW\2455\D\user\user.c 000aec 0e08 MOVLW 0x8 if (g_RC_timing_ptr < 8) C:\Projects\UBW\FW\2455\D\user\user.c 000aee 5c10 SUBWF 0x10,0x0,0x0 000af0 e20d BC 0xb0c { C:\Projects\UBW\FW\2455\D\user\user.c 000af2 0e07 MOVLW 0x7 bitclr (LATA, g_RC_timing_ptr & 0x7); C:\Projects\UBW\FW\2455\D\user\user.c 000af4 1410 ANDWF 0x10,0x0,0x0 000af6 6e38 MOVWF 0x38,0x0 000af8 0e01 MOVLW 0x1 000afa 5238 MOVF 0x38,0x1,0x0 000afc e004 BZ 0xb06 000afe 46e8 RLNCF 0xe8,0x1,0x0 000b00 0bfe ANDLW 0xfe 000b02 0638 DECF 0x38,0x1,0x0 000b04 e1fc BNZ 0xafe 000b06 1ce8 COMF 0xe8,0x0,0x0 000b08 1689 ANDWF 0x89,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000b0a d01c BRA 0xb44 else if (g_RC_timing_ptr < 16) C:\Projects\UBW\FW\2455\D\user\user.c 000b0c 0e10 MOVLW 0x10 000b0e 5c10 SUBWF 0x10,0x0,0x0 000b10 e20d BC 0xb2c { C:\Projects\UBW\FW\2455\D\user\user.c 000b12 0e07 MOVLW 0x7 bitclr (LATB, g_RC_timing_ptr & 0x7); C:\Projects\UBW\FW\2455\D\user\user.c 000b14 1410 ANDWF 0x10,0x0,0x0 000b16 6e38 MOVWF 0x38,0x0 000b18 0e01 MOVLW 0x1 000b1a 5238 MOVF 0x38,0x1,0x0 000b1c e004 BZ 0xb26 000b1e 46e8 RLNCF 0xe8,0x1,0x0 000b20 0bfe ANDLW 0xfe 000b22 0638 DECF 0x38,0x1,0x0 000b24 e1fc BNZ 0xb1e 000b26 1ce8 COMF 0xe8,0x0,0x0 000b28 168a ANDWF 0x8a,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000b2a d00c BRA 0xb44 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 000b2c 0e07 MOVLW 0x7 bitclr (LATC, g_RC_timing_ptr & 0x7); C:\Projects\UBW\FW\2455\D\user\user.c 000b2e 1410 ANDWF 0x10,0x0,0x0 000b30 6e38 MOVWF 0x38,0x0 000b32 0e01 MOVLW 0x1 000b34 5238 MOVF 0x38,0x1,0x0 000b36 e004 BZ 0xb40 000b38 46e8 RLNCF 0xe8,0x1,0x0 000b3a 0bfe ANDLW 0xfe 000b3c 0638 DECF 0x38,0x1,0x0 000b3e e1fc BNZ 0xb38 000b40 1ce8 COMF 0xe8,0x0,0x0 000b42 168b ANDWF 0x8b,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000b44 5010 MOVF 0x10,0x0,0x0 g_RC_state[g_RC_timing_ptr] = kWAITING; C:\Projects\UBW\FW\2455\D\user\user.c 000b46 6aea CLRF 0xea,0x0 000b48 0f51 ADDLW 0x51 000b4a 6ee9 MOVWF 0xe9,0x0 000b4c 0e01 MOVLW 0x1 000b4e 22ea ADDWFC 0xea,0x1,0x0 000b50 0e02 MOVLW 0x2 000b52 6eef MOVWF 0xef,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000b54 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000b56 cfe5 MOVFF 0xfe5,0xff4 000b58 fff4 000b5a cfe5 MOVFF 0xfe5,0xff3 000b5c fff3 000b5e cfe5 MOVFF 0xfe5,0xfea 000b60 ffea 000b62 cfe5 MOVFF 0xfe5,0xfe9 000b64 ffe9 000b66 cfe5 MOVFF 0xfe5,0xfda 000b68 ffda 000b6a 50e5 MOVF 0xe5,0x0,0x0 000b6c cfe5 MOVFF 0xfe5,0xfe0 000b6e ffe0 000b70 cfe5 MOVFF 0xfe5,0xfd8 000b72 ffd8 000b74 0010 RETFIE 0x0 C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c #pragma interrupt high_ISR C:\Projects\UBW\FW\2455\D\user\user.c 000b76 cfda MOVFF 0xfda,0xfe4 void high_ISR(void) C:\Projects\UBW\FW\2455\D\user\user.c 000b78 ffe4 000b7a cfe2 MOVFF 0xfe2,0xfda 000b7c ffda 000b7e 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c 000b80 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000b82 cfe5 MOVFF 0xfe5,0xfda 000b84 ffda 000b86 0011 RETFIE 0x1 C:\Projects\UBW\FW\2455\D\user\user.c 000b88 cfd9 MOVFF 0xfd9,0xfe6 void UserInit(void) C:\Projects\UBW\FW\2455\D\user\user.c 000b8a ffe6 000b8c cfe1 MOVFF 0xfe1,0xfd9 000b8e ffd9 000b90 0e02 MOVLW 0x2 000b92 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c char i, j; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Make all of 3 digital inputs C:\Projects\UBW\FW\2455\D\user\user.c 000b94 6a89 CLRF 0x89,0x0 LATA = 0x00; C:\Projects\UBW\FW\2455\D\user\user.c 000b96 6892 SETF 0x92,0x0 TRISA = 0xFF; C:\Projects\UBW\FW\2455\D\user\user.c // Turn all analog inputs into digital inputs C:\Projects\UBW\FW\2455\D\user\user.c 000b98 0e0f MOVLW 0xf ADCON1 = 0x0F; C:\Projects\UBW\FW\2455\D\user\user.c 000b9a 6ec1 MOVWF 0xc1,0x0 // Turn off the ADC C:\Projects\UBW\FW\2455\D\user\user.c 000b9c 90c2 BCF 0xc2,0x0,0x0 ADCON0bits.ADON = 0; C:\Projects\UBW\FW\2455\D\user\user.c // Turn off our own idea of how many analog channels to convert C:\Projects\UBW\FW\2455\D\user\user.c 000b9e 6a0c CLRF 0xc,0x0 AnalogEnable = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000ba0 0e07 MOVLW 0x7 CMCON = 0x07; // Comparators as digital inputs C:\Projects\UBW\FW\2455\D\user\user.c 000ba2 6eb4 MOVWF 0xb4,0x0 // Make all of PORTB inputs C:\Projects\UBW\FW\2455\D\user\user.c 000ba4 6a8a CLRF 0x8a,0x0 LATB = 0x00; C:\Projects\UBW\FW\2455\D\user\user.c 000ba6 6893 SETF 0x93,0x0 TRISB = 0xFF; C:\Projects\UBW\FW\2455\D\user\user.c // Make all of PORTC inputs C:\Projects\UBW\FW\2455\D\user\user.c 000ba8 6a8b CLRF 0x8b,0x0 LATC = 0x00; C:\Projects\UBW\FW\2455\D\user\user.c 000baa 6894 SETF 0x94,0x0 TRISC = 0xFF; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Initalize LED I/Os to outputs C:\Projects\UBW\FW\2455\D\user\user.c 000bac 0efc MOVLW 0xfc mInitAllLEDs(); C:\Projects\UBW\FW\2455\D\user\user.c 000bae 168b ANDWF 0x8b,0x1,0x0 000bb0 0efc MOVLW 0xfc 000bb2 1694 ANDWF 0x94,0x1,0x0 // Initalize switch as an input C:\Projects\UBW\FW\2455\D\user\user.c 000bb4 8494 BSF 0x94,0x2,0x0 mInitSwitch(); C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Start off always using "OK" acknoledge. C:\Projects\UBW\FW\2455\D\user\user.c 000bb6 0101 MOVLB 0x1 g_ack_enable = TRUE; C:\Projects\UBW\FW\2455\D\user\user.c 000bb8 0e01 MOVLW 0x1 000bba 6fc1 MOVWF 0xc1,0x1 C:\Projects\UBW\FW\2455\D\user\user.c // Use our own special output function for STDOUT C:\Projects\UBW\FW\2455\D\user\user.c 000bbc 0101 MOVLB 0x1 stdout = _H_USER; C:\Projects\UBW\FW\2455\D\user\user.c 000bbe 69de SETF 0xde,0x1 000bc0 69df SETF 0xdf,0x1 C:\Projects\UBW\FW\2455\D\user\user.c // Initalize all of the ISR FIFOs C:\Projects\UBW\FW\2455\D\user\user.c 000bc2 6a0a CLRF 0xa,0x0 ISR_A_FIFO_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bc4 6a09 CLRF 0x9,0x0 ISR_A_FIFO_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bc6 6a0b CLRF 0xb,0x0 ISR_A_FIFO_length = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bc8 6a05 CLRF 0x5,0x0 ISR_D_FIFO_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bca 6a04 CLRF 0x4,0x0 ISR_D_FIFO_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bcc 6a06 CLRF 0x6,0x0 ISR_D_FIFO_length = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Make sure that our timer stuff starts out disabled C:\Projects\UBW\FW\2455\D\user\user.c 000bce 6a02 CLRF 0x2,0x0 ISR_D_RepeatRate = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bd0 6a03 CLRF 0x3,0x0 000bd2 6a07 CLRF 0x7,0x0 ISR_A_RepeatRate = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bd4 6a08 CLRF 0x8,0x0 000bd6 6a11 CLRF 0x11,0x0 D_tick_counter = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bd8 6a12 CLRF 0x12,0x0 000bda 6a13 CLRF 0x13,0x0 A_tick_counter = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000bdc 6a14 CLRF 0x14,0x0 000bde 6a15 CLRF 0x15,0x0 A_cur_channel = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Now init our registers C:\Projects\UBW\FW\2455\D\user\user.c // The prescaler will be at 16 C:\Projects\UBW\FW\2455\D\user\user.c 000be0 82ca BSF 0xca,0x1,0x0 T2CONbits.T2CKPS1 = 1; C:\Projects\UBW\FW\2455\D\user\user.c 000be2 80ca BSF 0xca,0x0,0x0 T2CONbits.T2CKPS0 = 1; C:\Projects\UBW\FW\2455\D\user\user.c // We want the TMR2 post scaler to be a 3 C:\Projects\UBW\FW\2455\D\user\user.c 000be4 9cca BCF 0xca,0x6,0x0 T2CONbits.T2OUTPS3 = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000be6 9aca BCF 0xca,0x5,0x0 T2CONbits.T2OUTPS2 = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000be8 88ca BSF 0xca,0x4,0x0 T2CONbits.T2OUTPS1 = 1; C:\Projects\UBW\FW\2455\D\user\user.c 000bea 96ca BCF 0xca,0x3,0x0 T2CONbits.T2OUTPS0 = 0; C:\Projects\UBW\FW\2455\D\user\user.c // Set our reload value C:\Projects\UBW\FW\2455\D\user\user.c 000bec 0efa MOVLW 0xfa PR2 = kPR2_RELOAD; C:\Projects\UBW\FW\2455\D\user\user.c 000bee 6ecb MOVWF 0xcb,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Set up the Analog to Digital converter C:\Projects\UBW\FW\2455\D\user\user.c // Clear out the FIFO data C:\Projects\UBW\FW\2455\D\user\user.c 000bf0 6adf CLRF 0xdf,0x0 for (i = 0; i < 12; i++) C:\Projects\UBW\FW\2455\D\user\user.c 000bf2 cfdf MOVFF 0xfdf,0x2a 000bf4 f02a 000bf6 0e0c MOVLW 0xc 000bf8 6ee7 MOVWF 0xe7,0x0 000bfa 182a XORWF 0x2a,0x0,0x0 000bfc aee8 BTFSS 0xe8,0x7,0x0 000bfe d002 BRA 0xc04 000c00 34e7 RLCF 0xe7,0x0,0x0 000c02 d002 BRA 0xc08 000c04 50e7 MOVF 0xe7,0x0,0x0 000c06 5c2a SUBWF 0x2a,0x0,0x0 000c08 e238 BC 0xc7a 000c76 2adf INCF 0xdf,0x1,0x0 000c78 d7bc BRA 0xbf2 { C:\Projects\UBW\FW\2455\D\user\user.c 000c0a 0e01 MOVLW 0x1 for (j = 0; j < kISR_FIFO_A_DEPTH; j++) C:\Projects\UBW\FW\2455\D\user\user.c 000c0c 6adb CLRF 0xdb,0x0 000c0e 0e01 MOVLW 0x1 000c10 cfdb MOVFF 0xfdb,0x2a 000c12 f02a 000c14 0e03 MOVLW 0x3 000c16 6ee7 MOVWF 0xe7,0x0 000c18 182a XORWF 0x2a,0x0,0x0 000c1a aee8 BTFSS 0xe8,0x7,0x0 000c1c d002 BRA 0xc22 000c1e 34e7 RLCF 0xe7,0x0,0x0 000c20 d002 BRA 0xc26 000c22 50e7 MOVF 0xe7,0x0,0x0 000c24 5c2a SUBWF 0x2a,0x0,0x0 000c26 e227 BC 0xc76 000c70 0e01 MOVLW 0x1 000c72 2adb INCF 0xdb,0x1,0x0 000c74 d7cc BRA 0xc0e { C:\Projects\UBW\FW\2455\D\user\user.c 000c28 cfdf MOVFF 0xfdf,0x2a ISR_A_FIFO[i][j] = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c2a f02a 000c2c 6a2b CLRF 0x2b,0x0 000c2e be2a BTFSC 0x2a,0x7,0x0 000c30 682b SETF 0x2b,0x0 000c32 0e06 MOVLW 0x6 000c34 022b MULWF 0x2b,0x0 000c36 cff3 MOVFF 0xff3,0x2b 000c38 f02b 000c3a 0e06 MOVLW 0x6 000c3c 022a MULWF 0x2a,0x0 000c3e cff3 MOVFF 0xff3,0x2a 000c40 f02a 000c42 50f4 MOVF 0xf4,0x0,0x0 000c44 262b ADDWF 0x2b,0x1,0x0 000c46 0e00 MOVLW 0x0 000c48 262a ADDWF 0x2a,0x1,0x0 000c4a 0e01 MOVLW 0x1 000c4c 222b ADDWFC 0x2b,0x1,0x0 000c4e 0e01 MOVLW 0x1 000c50 cfdb MOVFF 0xfdb,0x2c 000c52 f02c 000c54 6a2d CLRF 0x2d,0x0 000c56 be2c BTFSC 0x2c,0x7,0x0 000c58 682d SETF 0x2d,0x0 000c5a 90d8 BCF 0xd8,0x0,0x0 000c5c 362c RLCF 0x2c,0x1,0x0 000c5e 362d RLCF 0x2d,0x1,0x0 000c60 502a MOVF 0x2a,0x0,0x0 000c62 242c ADDWF 0x2c,0x0,0x0 000c64 6ee9 MOVWF 0xe9,0x0 000c66 502b MOVF 0x2b,0x0,0x0 000c68 202d ADDWFC 0x2d,0x0,0x0 000c6a 6eea MOVWF 0xea,0x0 000c6c 6aee CLRF 0xee,0x0 000c6e 6aed CLRF 0xed,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Inialize USB TX and RX buffer management C:\Projects\UBW\FW\2455\D\user\user.c 000c7a 0101 MOVLB 0x1 g_RX_buf_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c7c 6bbb CLRF 0xbb,0x1 000c7e 0101 MOVLB 0x1 g_RX_buf_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c80 6bbc CLRF 0xbc,0x1 000c82 0101 MOVLB 0x1 g_TX_buf_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c84 6bb9 CLRF 0xb9,0x1 000c86 0101 MOVLB 0x1 g_TX_buf_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c88 6bba CLRF 0xba,0x1 C:\Projects\UBW\FW\2455\D\user\user.c // And the USART TX and RX buffer management C:\Projects\UBW\FW\2455\D\user\user.c 000c8a 0101 MOVLB 0x1 g_USART_RX_buf_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c8c 6bbd CLRF 0xbd,0x1 000c8e 0101 MOVLB 0x1 g_USART_RX_buf_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c90 6bbe CLRF 0xbe,0x1 000c92 0101 MOVLB 0x1 g_USART_TX_buf_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c94 6bbf CLRF 0xbf,0x1 000c96 0101 MOVLB 0x1 g_USART_TX_buf_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c98 6bc0 CLRF 0xc0,0x1 C:\Projects\UBW\FW\2455\D\user\user.c // Clear out the RC servo output pointer values C:\Projects\UBW\FW\2455\D\user\user.c 000c9a 6a0e CLRF 0xe,0x0 g_RC_primed_ptr = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c9c 6a0f CLRF 0xf,0x0 g_RC_next_ptr = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000c9e 6a10 CLRF 0x10,0x0 g_RC_timing_ptr = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Clear the RC data structure C:\Projects\UBW\FW\2455\D\user\user.c 000ca0 6adf CLRF 0xdf,0x0 for (i = 0; i < kRC_DATA_SIZE; i++) C:\Projects\UBW\FW\2455\D\user\user.c 000ca2 cfdf MOVFF 0xfdf,0x2a 000ca4 f02a 000ca6 0e18 MOVLW 0x18 000ca8 6ee7 MOVWF 0xe7,0x0 000caa 182a XORWF 0x2a,0x0,0x0 000cac aee8 BTFSS 0xe8,0x7,0x0 000cae d002 BRA 0xcb4 000cb0 34e7 RLCF 0xe7,0x0,0x0 000cb2 d002 BRA 0xcb8 000cb4 50e7 MOVF 0xe7,0x0,0x0 000cb6 5c2a SUBWF 0x2a,0x0,0x0 000cb8 e21b BC 0xcf0 000cec 2adf INCF 0xdf,0x1,0x0 000cee d7d9 BRA 0xca2 { C:\Projects\UBW\FW\2455\D\user\user.c 000cba cfdf MOVFF 0xfdf,0xfe9 g_RC_value[i] = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000cbc ffe9 000cbe 6aea CLRF 0xea,0x0 000cc0 bee9 BTFSC 0xe9,0x7,0x0 000cc2 68ea SETF 0xea,0x0 000cc4 90d8 BCF 0xd8,0x0,0x0 000cc6 36e9 RLCF 0xe9,0x1,0x0 000cc8 36ea RLCF 0xea,0x1,0x0 000cca 0e69 MOVLW 0x69 000ccc 26e9 ADDWF 0xe9,0x1,0x0 000cce 0e01 MOVLW 0x1 000cd0 22ea ADDWFC 0xea,0x1,0x0 000cd2 6aee CLRF 0xee,0x0 000cd4 6aed CLRF 0xed,0x0 000cd6 cfdf MOVFF 0xfdf,0xfe9 g_RC_state[i] = kOFF; C:\Projects\UBW\FW\2455\D\user\user.c 000cd8 ffe9 000cda 6aea CLRF 0xea,0x0 000cdc bee9 BTFSC 0xe9,0x7,0x0 000cde 68ea SETF 0xea,0x0 000ce0 0e51 MOVLW 0x51 000ce2 26e9 ADDWF 0xe9,0x1,0x0 000ce4 0e01 MOVLW 0x1 000ce6 22ea ADDWFC 0xea,0x1,0x0 000ce8 0e01 MOVLW 0x1 000cea 6eef MOVWF 0xef,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Enable TMR0 for our RC timing operation C:\Projects\UBW\FW\2455\D\user\user.c 000cf0 86d5 BSF 0xd5,0x3,0x0 T0CONbits.PSA = 1; // Do NOT use the prescaler C:\Projects\UBW\FW\2455\D\user\user.c 000cf2 9ad5 BCF 0xd5,0x5,0x0 T0CONbits.T0CS = 0; // Use internal clock C:\Projects\UBW\FW\2455\D\user\user.c 000cf4 9cd5 BCF 0xd5,0x6,0x0 T0CONbits.T08BIT = 0; // 16 bit timer C:\Projects\UBW\FW\2455\D\user\user.c 000cf6 94f2 BCF 0xf2,0x2,0x0 INTCONbits.TMR0IF = 0; // Clear the interrupt flag C:\Projects\UBW\FW\2455\D\user\user.c 000cf8 9af2 BCF 0xf2,0x5,0x0 INTCONbits.TMR0IE = 0; // And clear the interrupt enable C:\Projects\UBW\FW\2455\D\user\user.c 000cfa 94f1 BCF 0xf1,0x2,0x0 INTCON2bits.TMR0IP = 0; // Low priority C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Enable interrupt priorities C:\Projects\UBW\FW\2455\D\user\user.c 000cfc 8ed0 BSF 0xd0,0x7,0x0 RCONbits.IPEN = 1; C:\Projects\UBW\FW\2455\D\user\user.c 000cfe 94ca BCF 0xca,0x2,0x0 T2CONbits.TMR2ON = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 000d00 829d BSF 0x9d,0x1,0x0 PIE1bits.TMR2IE = 1; C:\Projects\UBW\FW\2455\D\user\user.c 000d02 929f BCF 0x9f,0x1,0x0 IPR1bits.TMR2IP = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 000d04 8ef2 BSF 0xf2,0x7,0x0 INTCONbits.GIEH = 1; // Turn high priority interrupts on C:\Projects\UBW\FW\2455\D\user\user.c 000d06 8cf2 BSF 0xf2,0x6,0x0 INTCONbits.GIEL = 1; // Turn low priority interrupts on C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Turn on the Timer2 C:\Projects\UBW\FW\2455\D\user\user.c 000d08 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 000d0a 0e02 MOVLW 0x2 }//end UserInit C:\Projects\UBW\FW\2455\D\user\user.c 000d0c 5ce1 SUBWF 0xe1,0x0,0x0 000d0e e202 BC 0xd14 000d10 6ae1 CLRF 0xe1,0x0 000d12 52e5 MOVF 0xe5,0x1,0x0 000d14 6ee1 MOVWF 0xe1,0x0 000d16 52e5 MOVF 0xe5,0x1,0x0 000d18 cfe7 MOVFF 0xfe7,0xfd9 000d1a ffd9 000d1c 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c /****************************************************************************** C:\Projects\UBW\FW\2455\D\user\user.c * Function: void ProcessIO(void) C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * PreCondition: None C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Input: None C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Output: None C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Side Effects: None C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Overview: In this function, we check for a new packet that just C:\Projects\UBW\FW\2455\D\user\user.c * arrived via USB. We do a few checks on the packet to see C:\Projects\UBW\FW\2455\D\user\user.c * if it is worthy of us trying to interpret it. If it is, C:\Projects\UBW\FW\2455\D\user\user.c * we go and call the proper function based upon the first C:\Projects\UBW\FW\2455\D\user\user.c * character of the packet. C:\Projects\UBW\FW\2455\D\user\user.c * NOTE: We need to see everything in one packet (i.e. we C:\Projects\UBW\FW\2455\D\user\user.c * won't treat the USB data as a stream and try to find our C:\Projects\UBW\FW\2455\D\user\user.c * start and end of packets within the stream. We just look C:\Projects\UBW\FW\2455\D\user\user.c * at the first character of each packet for a command and C:\Projects\UBW\FW\2455\D\user\user.c * check that there's a CR as the last character of the C:\Projects\UBW\FW\2455\D\user\user.c * packet. C:\Projects\UBW\FW\2455\D\user\user.c * C:\Projects\UBW\FW\2455\D\user\user.c * Note: None C:\Projects\UBW\FW\2455\D\user\user.c *****************************************************************************/ C:\Projects\UBW\FW\2455\D\user\user.c 000d1e cfd9 MOVFF 0xfd9,0xfe6 void ProcessIO(void) C:\Projects\UBW\FW\2455\D\user\user.c 000d20 ffe6 000d22 cfe1 MOVFF 0xfe1,0xfd9 000d24 ffd9 000d26 0e02 MOVLW 0x2 000d28 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c static BOOL in_cr = FALSE; C:\Projects\UBW\FW\2455\D\user\user.c static byte last_fifo_size; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char tst_char; C:\Projects\UBW\FW\2455\D\user\user.c 000d2a 0e01 MOVLW 0x1 BOOL got_full_packet = FALSE; C:\Projects\UBW\FW\2455\D\user\user.c 000d2c 6adb CLRF 0xdb,0x0 000d2e 0101 MOVLB 0x1 cdc_rx_len = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000d30 6b99 CLRF 0x99,0x1 C:\Projects\UBW\FW\2455\D\user\user.c 000d32 ec0d CALL 0x261a,0x0 BlinkUSBStatus(); C:\Projects\UBW\FW\2455\D\user\user.c 000d34 f013 C:\Projects\UBW\FW\2455\D\user\user.c // User Application USB tasks C:\Projects\UBW\FW\2455\D\user\user.c 000d36 0e06 MOVLW 0x6 if((usb_device_state < CONFIGURED_STATE) || (UCONbits.SUSPND == 1)) C:\Projects\UBW\FW\2455\D\user\user.c 000d38 0101 MOVLB 0x1 000d3a 5dd5 SUBWF 0xd5,0x0,0x1 000d3c e303 BNC 0xd44 000d3e 506d MOVF 0x6d,0x0,0x0 000d40 0b02 ANDLW 0x2 000d42 e001 BZ 0xd46 { C:\Projects\UBW\FW\2455\D\user\user.c 000d44 d105 BRA 0xf50 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Check for any new I packets (from T command) ready to go out C:\Projects\UBW\FW\2455\D\user\user.c 000d46 5006 MOVF 0x6,0x0,0x0 while (ISR_D_FIFO_length > 0) C:\Projects\UBW\FW\2455\D\user\user.c 000d48 0800 SUBLW 0x0 000d4a e209 BC 0xd5e 000d5c d7f4 BRA 0xd46 { C:\Projects\UBW\FW\2455\D\user\user.c // Spit out an I packet first C:\Projects\UBW\FW\2455\D\user\user.c 000d4c ec02 CALL 0x1604,0x0 parse_I_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 000d4e f00b C:\Projects\UBW\FW\2455\D\user\user.c // Then upate our I packet fifo stuff C:\Projects\UBW\FW\2455\D\user\user.c 000d50 2a05 INCF 0x5,0x1,0x0 ISR_D_FIFO_out++; C:\Projects\UBW\FW\2455\D\user\user.c 000d52 0e03 MOVLW 0x3 if (ISR_D_FIFO_out == kISR_FIFO_D_DEPTH) C:\Projects\UBW\FW\2455\D\user\user.c 000d54 5c05 SUBWF 0x5,0x0,0x0 000d56 e101 BNZ 0xd5a { C:\Projects\UBW\FW\2455\D\user\user.c 000d58 6a05 CLRF 0x5,0x0 ISR_D_FIFO_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000d5a 0606 DECF 0x6,0x1,0x0 ISR_D_FIFO_length--; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Check for a new A packet (from T command) ready to go out C:\Projects\UBW\FW\2455\D\user\user.c 000d5e 500b MOVF 0xb,0x0,0x0 while (ISR_A_FIFO_length > 0) C:\Projects\UBW\FW\2455\D\user\user.c 000d60 0800 SUBLW 0x0 000d62 e209 BC 0xd76 000d74 d7f4 BRA 0xd5e { C:\Projects\UBW\FW\2455\D\user\user.c // Spit out an A packet first C:\Projects\UBW\FW\2455\D\user\user.c 000d64 ec2e CALL 0x165c,0x0 parse_A_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 000d66 f00b C:\Projects\UBW\FW\2455\D\user\user.c // Then update our A packet fifo stuff C:\Projects\UBW\FW\2455\D\user\user.c 000d68 2a0a INCF 0xa,0x1,0x0 ISR_A_FIFO_out++; C:\Projects\UBW\FW\2455\D\user\user.c 000d6a 0e03 MOVLW 0x3 if (ISR_A_FIFO_out == kISR_FIFO_A_DEPTH) C:\Projects\UBW\FW\2455\D\user\user.c 000d6c 5c0a SUBWF 0xa,0x0,0x0 000d6e e101 BNZ 0xd72 { C:\Projects\UBW\FW\2455\D\user\user.c 000d70 6a0a CLRF 0xa,0x0 ISR_A_FIFO_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000d72 060b DECF 0xb,0x1,0x0 ISR_A_FIFO_length--; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Pull in some new data if there is new data to pull in C:\Projects\UBW\FW\2455\D\user\user.c 000d76 0104 MOVLB 0x4 if(!mCDCUsartRxIsBusy()) C:\Projects\UBW\FW\2455\D\user\user.c 000d78 bf18 BTFSC 0x18,0x7,0x1 000d7a d065 BRA 0xe46 { C:\Projects\UBW\FW\2455\D\user\user.c // Copy data from dual-ram buffer to user's buffer C:\Projects\UBW\FW\2455\D\user\user.c 000d7c 0101 MOVLB 0x1 for(cdc_rx_len = 0; cdc_rx_len < CDC_BULK_BD_OUT.Cnt; cdc_rx_len++) C:\Projects\UBW\FW\2455\D\user\user.c 000d7e 6b99 CLRF 0x99,0x1 000d80 0104 MOVLB 0x4 000d82 5119 MOVF 0x19,0x0,0x1 000d84 0101 MOVLB 0x1 000d86 5d99 SUBWF 0x99,0x0,0x1 000d88 e253 BC 0xe30 000e2a 0101 MOVLB 0x1 000e2c 2b99 INCF 0x99,0x1,0x1 000e2e d7a8 BRA 0xd80 { C:\Projects\UBW\FW\2455\D\user\user.c // Check to see if we are in a CR/LF situation C:\Projects\UBW\FW\2455\D\user\user.c 000d8a 0101 MOVLB 0x1 tst_char = cdc_data_rx[cdc_rx_len]; C:\Projects\UBW\FW\2455\D\user\user.c 000d8c 5199 MOVF 0x99,0x0,0x1 000d8e 6aea CLRF 0xea,0x0 000d90 0f08 ADDLW 0x8 000d92 6ee9 MOVWF 0xe9,0x0 000d94 0e05 MOVLW 0x5 000d96 22ea ADDWFC 0xea,0x1,0x0 000d98 cfef MOVFF 0xfef,0xfdf 000d9a ffdf if ( C:\Projects\UBW\FW\2455\D\user\user.c 000d9c 0101 MOVLB 0x1 !in_cr C:\Projects\UBW\FW\2455\D\user\user.c 000d9e 51d9 MOVF 0xd9,0x0,0x1 && C:\Projects\UBW\FW\2455\D\user\user.c ( C:\Projects\UBW\FW\2455\D\user\user.c 000da2 0e0d MOVLW 0xd kCR == tst_char C:\Projects\UBW\FW\2455\D\user\user.c 000da4 6e2a MOVWF 0x2a,0x0 000da6 50df MOVF 0xdf,0x0,0x0 000da8 5c2a SUBWF 0x2a,0x0,0x0 || C:\Projects\UBW\FW\2455\D\user\user.c 000dac 0e0a MOVLW 0xa kLF == tst_char C:\Projects\UBW\FW\2455\D\user\user.c 000dae 6e2b MOVWF 0x2b,0x0 000db0 50df MOVF 0xdf,0x0,0x0 000daa e005 BZ 0xdb6 ) C:\Projects\UBW\FW\2455\D\user\user.c 000db2 5c2b SUBWF 0x2b,0x0,0x0 000db4 e112 BNZ 0xdda 000da0 e11c BNZ 0xdda ) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 000db6 0101 MOVLB 0x1 in_cr = TRUE; C:\Projects\UBW\FW\2455\D\user\user.c 000db8 0e01 MOVLW 0x1 000dba 6fd9 MOVWF 0xd9,0x1 000dbc 0101 MOVLB 0x1 g_RX_buf[g_RX_buf_in] = kCR; C:\Projects\UBW\FW\2455\D\user\user.c 000dbe 51bb MOVF 0xbb,0x0,0x1 000dc0 6aea CLRF 0xea,0x0 000dc2 0f40 ADDLW 0x40 000dc4 6ee9 MOVWF 0xe9,0x0 000dc6 0e02 MOVLW 0x2 000dc8 22ea ADDWFC 0xea,0x1,0x0 000dca 0e0d MOVLW 0xd 000dcc 6eef MOVWF 0xef,0x0 000dce 0101 MOVLB 0x1 g_RX_buf_in++; C:\Projects\UBW\FW\2455\D\user\user.c 000dd0 2bbb INCF 0xbb,0x1,0x1 C:\Projects\UBW\FW\2455\D\user\user.c // At this point, we know we have a full packet C:\Projects\UBW\FW\2455\D\user\user.c // of information from the PC to parse C:\Projects\UBW\FW\2455\D\user\user.c 000dd2 52de MOVF 0xde,0x1,0x0 got_full_packet = TRUE; C:\Projects\UBW\FW\2455\D\user\user.c 000dd4 0e01 MOVLW 0x1 000dd6 6edd MOVWF 0xdd,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000dd8 d015 BRA 0xe04 else if ( C:\Projects\UBW\FW\2455\D\user\user.c 000dda 0e0d MOVLW 0xd tst_char != kCR C:\Projects\UBW\FW\2455\D\user\user.c 000ddc 5cdf SUBWF 0xdf,0x0,0x0 && C:\Projects\UBW\FW\2455\D\user\user.c 000de0 0e0a MOVLW 0xa tst_char != kLF C:\Projects\UBW\FW\2455\D\user\user.c 000dde e011 BZ 0xe02 ) C:\Projects\UBW\FW\2455\D\user\user.c 000de2 5cdf SUBWF 0xdf,0x0,0x0 000de4 e00e BZ 0xe02 { C:\Projects\UBW\FW\2455\D\user\user.c // Only add a byte if it is not a CR or LF C:\Projects\UBW\FW\2455\D\user\user.c 000de6 0101 MOVLB 0x1 g_RX_buf[g_RX_buf_in] = tst_char; C:\Projects\UBW\FW\2455\D\user\user.c 000de8 51bb MOVF 0xbb,0x0,0x1 000dea 6aea CLRF 0xea,0x0 000dec 0f40 ADDLW 0x40 000dee 6ee9 MOVWF 0xe9,0x0 000df0 0e02 MOVLW 0x2 000df2 22ea ADDWFC 0xea,0x1,0x0 000df4 cfdf MOVFF 0xfdf,0xfef 000df6 ffef 000df8 0101 MOVLB 0x1 in_cr = FALSE; C:\Projects\UBW\FW\2455\D\user\user.c 000dfa 6bd9 CLRF 0xd9,0x1 000dfc 0101 MOVLB 0x1 g_RX_buf_in++; C:\Projects\UBW\FW\2455\D\user\user.c 000dfe 2bbb INCF 0xbb,0x1,0x1 } C:\Projects\UBW\FW\2455\D\user\user.c 000e00 d001 BRA 0xe04 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 000e02 d013 BRA 0xe2a continue; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c // Check for buffer wraparound C:\Projects\UBW\FW\2455\D\user\user.c 000e04 0e40 MOVLW 0x40 if (kRX_BUF_SIZE == g_RX_buf_in) C:\Projects\UBW\FW\2455\D\user\user.c 000e06 0101 MOVLB 0x1 000e08 5dbb SUBWF 0xbb,0x0,0x1 000e0a e102 BNZ 0xe10 { C:\Projects\UBW\FW\2455\D\user\user.c 000e0c 0101 MOVLB 0x1 g_RX_buf_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000e0e 6bbb CLRF 0xbb,0x1 } C:\Projects\UBW\FW\2455\D\user\user.c // If we hit the out pointer, then this is bad. C:\Projects\UBW\FW\2455\D\user\user.c 000e10 0101 MOVLB 0x1 if (g_RX_buf_in == g_RX_buf_out) C:\Projects\UBW\FW\2455\D\user\user.c 000e12 51bc MOVF 0xbc,0x0,0x1 000e14 0101 MOVLB 0x1 000e16 5dbb SUBWF 0xbb,0x0,0x1 000e18 e102 BNZ 0xe1e { C:\Projects\UBW\FW\2455\D\user\user.c 000e1a 860d BSF 0xd,0x3,0x0 bitset (error_byte, kERROR_BYTE_RX_BUFFER_OVERRUN); C:\Projects\UBW\FW\2455\D\user\user.c 000e1c d009 BRA 0xe30 break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c // Now, if we've gotten a full command (user send ) then C:\Projects\UBW\FW\2455\D\user\user.c // go call the code that deals with that command, and then C:\Projects\UBW\FW\2455\D\user\user.c // keep parsing. (This allows multiple small commands per packet) C:\Projects\UBW\FW\2455\D\user\user.c 000e1e 0e01 MOVLW 0x1 if (got_full_packet) C:\Projects\UBW\FW\2455\D\user\user.c 000e20 50db MOVF 0xdb,0x0,0x0 000e22 e003 BZ 0xe2a { C:\Projects\UBW\FW\2455\D\user\user.c 000e24 d915 RCALL 0x1050 parse_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 000e26 0e01 MOVLW 0x1 got_full_packet = FALSE; C:\Projects\UBW\FW\2455\D\user\user.c 000e28 6adb CLRF 0xdb,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Prepare dual-ram buffer for next OUT transaction C:\Projects\UBW\FW\2455\D\user\user.c 000e30 0104 MOVLB 0x4 CDC_BULK_BD_OUT.Cnt = sizeof(cdc_data_rx); C:\Projects\UBW\FW\2455\D\user\user.c 000e32 0e40 MOVLW 0x40 000e34 6f19 MOVWF 0x19,0x1 000e36 0e40 MOVLW 0x40 mUSBBufferReady(CDC_BULK_BD_OUT); C:\Projects\UBW\FW\2455\D\user\user.c 000e38 0104 MOVLB 0x4 000e3a 1718 ANDWF 0x18,0x1,0x1 000e3c 0104 MOVLB 0x4 000e3e 7d18 BTG 0x18,0x6,0x1 000e40 0e88 MOVLW 0x88 000e42 0104 MOVLB 0x4 000e44 1318 IORWF 0x18,0x1,0x1 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Check for any errors logged in error_byte that need to be sent out C:\Projects\UBW\FW\2455\D\user\user.c 000e46 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 000e48 e101 BNZ 0xe4c 000e4a d081 BRA 0xf4e { C:\Projects\UBW\FW\2455\D\user\user.c 000e4c a00d BTFSS 0xd,0x0,0x0 if (bittst (error_byte, 0)) C:\Projects\UBW\FW\2455\D\user\user.c 000e4e d010 BRA 0xe70 { C:\Projects\UBW\FW\2455\D\user\user.c // Unused as of yet C:\Projects\UBW\FW\2455\D\user\user.c 000e50 0eab MOVLW 0xab printf ((rom char *)"!0 \r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000e52 6e2a MOVWF 0x2a,0x0 000e54 0e3f MOVLW 0x3f 000e56 6e2b MOVWF 0x2b,0x0 000e58 6a2c CLRF 0x2c,0x0 000e5a c02a MOVFF 0x2a,0xfe6 000e5c ffe6 000e5e c02b MOVFF 0x2b,0xfe6 000e60 ffe6 000e62 c02c MOVFF 0x2c,0xfe6 000e64 ffe6 000e66 ec05 CALL 0x420a,0x0 000e68 f021 000e6a 52e5 MOVF 0xe5,0x1,0x0 000e6c 52e5 MOVF 0xe5,0x1,0x0 000e6e 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000e70 a20d BTFSS 0xd,0x1,0x0 if (bittst (error_byte, 1)) C:\Projects\UBW\FW\2455\D\user\user.c 000e72 d010 BRA 0xe94 { C:\Projects\UBW\FW\2455\D\user\user.c // Unused as of yet C:\Projects\UBW\FW\2455\D\user\user.c 000e74 0ea5 MOVLW 0xa5 printf ((rom char *)"!1 \r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000e76 6e2a MOVWF 0x2a,0x0 000e78 0e3f MOVLW 0x3f 000e7a 6e2b MOVWF 0x2b,0x0 000e7c 6a2c CLRF 0x2c,0x0 000e7e c02a MOVFF 0x2a,0xfe6 000e80 ffe6 000e82 c02b MOVFF 0x2b,0xfe6 000e84 ffe6 000e86 c02c MOVFF 0x2c,0xfe6 000e88 ffe6 000e8a ec05 CALL 0x420a,0x0 000e8c f021 000e8e 52e5 MOVF 0xe5,0x1,0x0 000e90 52e5 MOVF 0xe5,0x1,0x0 000e92 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000e94 a40d BTFSS 0xd,0x2,0x0 if (bittst (error_byte, kERROR_BYTE_TX_BUF_OVERRUN)) C:\Projects\UBW\FW\2455\D\user\user.c 000e96 d010 BRA 0xeb8 { C:\Projects\UBW\FW\2455\D\user\user.c 000e98 0e89 MOVLW 0x89 printf ((rom char *)"!2 Err: TX Buffer overrun\r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000e9a 6e2a MOVWF 0x2a,0x0 000e9c 0e3f MOVLW 0x3f 000e9e 6e2b MOVWF 0x2b,0x0 000ea0 6a2c CLRF 0x2c,0x0 000ea2 c02a MOVFF 0x2a,0xfe6 000ea4 ffe6 000ea6 c02b MOVFF 0x2b,0xfe6 000ea8 ffe6 000eaa c02c MOVFF 0x2c,0xfe6 000eac ffe6 000eae ec05 CALL 0x420a,0x0 000eb0 f021 000eb2 52e5 MOVF 0xe5,0x1,0x0 000eb4 52e5 MOVF 0xe5,0x1,0x0 000eb6 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000eb8 a60d BTFSS 0xd,0x3,0x0 if (bittst (error_byte, kERROR_BYTE_RX_BUFFER_OVERRUN)) C:\Projects\UBW\FW\2455\D\user\user.c 000eba d010 BRA 0xedc { C:\Projects\UBW\FW\2455\D\user\user.c 000ebc 0e6d MOVLW 0x6d printf ((rom char *)"!3 Err: RX Buffer overrun\r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000ebe 6e2a MOVWF 0x2a,0x0 000ec0 0e3f MOVLW 0x3f 000ec2 6e2b MOVWF 0x2b,0x0 000ec4 6a2c CLRF 0x2c,0x0 000ec6 c02a MOVFF 0x2a,0xfe6 000ec8 ffe6 000eca c02b MOVFF 0x2b,0xfe6 000ecc ffe6 000ece c02c MOVFF 0x2c,0xfe6 000ed0 ffe6 000ed2 ec05 CALL 0x420a,0x0 000ed4 f021 000ed6 52e5 MOVF 0xe5,0x1,0x0 000ed8 52e5 MOVF 0xe5,0x1,0x0 000eda 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000edc a80d BTFSS 0xd,0x4,0x0 if (bittst (error_byte, kERROR_BYTE_MISSING_PARAMETER)) C:\Projects\UBW\FW\2455\D\user\user.c 000ede d010 BRA 0xf00 { C:\Projects\UBW\FW\2455\D\user\user.c 000ee0 0e4e MOVLW 0x4e printf ((rom char *)"!4 Err: Missing parameter(s)\r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000ee2 6e2a MOVWF 0x2a,0x0 000ee4 0e3f MOVLW 0x3f 000ee6 6e2b MOVWF 0x2b,0x0 000ee8 6a2c CLRF 0x2c,0x0 000eea c02a MOVFF 0x2a,0xfe6 000eec ffe6 000eee c02b MOVFF 0x2b,0xfe6 000ef0 ffe6 000ef2 c02c MOVFF 0x2c,0xfe6 000ef4 ffe6 000ef6 ec05 CALL 0x420a,0x0 000ef8 f021 000efa 52e5 MOVF 0xe5,0x1,0x0 000efc 52e5 MOVF 0xe5,0x1,0x0 000efe 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000f00 aa0d BTFSS 0xd,0x5,0x0 if (bittst (error_byte, kERROR_BYTE_PRINTED_ERROR)) C:\Projects\UBW\FW\2455\D\user\user.c 000f02 d000 BRA 0xf04 { C:\Projects\UBW\FW\2455\D\user\user.c // We don't need to do anything since something has already been printed out C:\Projects\UBW\FW\2455\D\user\user.c //printf ((rom char *)"!5\r\n"); C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000f04 ac0d BTFSS 0xd,0x6,0x0 if (bittst (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT)) C:\Projects\UBW\FW\2455\D\user\user.c 000f06 d010 BRA 0xf28 { C:\Projects\UBW\FW\2455\D\user\user.c 000f08 0e2d MOVLW 0x2d printf ((rom char *)"!6 Err: Invalid paramter value\r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000f0a 6e2a MOVWF 0x2a,0x0 000f0c 0e3f MOVLW 0x3f 000f0e 6e2b MOVWF 0x2b,0x0 000f10 6a2c CLRF 0x2c,0x0 000f12 c02a MOVFF 0x2a,0xfe6 000f14 ffe6 000f16 c02b MOVFF 0x2b,0xfe6 000f18 ffe6 000f1a c02c MOVFF 0x2c,0xfe6 000f1c ffe6 000f1e ec05 CALL 0x420a,0x0 000f20 f021 000f22 52e5 MOVF 0xe5,0x1,0x0 000f24 52e5 MOVF 0xe5,0x1,0x0 000f26 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000f28 ae0d BTFSS 0xd,0x7,0x0 if (bittst (error_byte, kERROR_BYTE_EXTRA_CHARACTERS)) C:\Projects\UBW\FW\2455\D\user\user.c 000f2a d010 BRA 0xf4c { C:\Projects\UBW\FW\2455\D\user\user.c 000f2c 0e14 MOVLW 0x14 printf ((rom char *)"!7 Err: Extra parmater\r\n"); C:\Projects\UBW\FW\2455\D\user\user.c 000f2e 6e2a MOVWF 0x2a,0x0 000f30 0e3f MOVLW 0x3f 000f32 6e2b MOVWF 0x2b,0x0 000f34 6a2c CLRF 0x2c,0x0 000f36 c02a MOVFF 0x2a,0xfe6 000f38 ffe6 000f3a c02b MOVFF 0x2b,0xfe6 000f3c ffe6 000f3e c02c MOVFF 0x2c,0xfe6 000f40 ffe6 000f42 ec05 CALL 0x420a,0x0 000f44 f021 000f46 52e5 MOVF 0xe5,0x1,0x0 000f48 52e5 MOVF 0xe5,0x1,0x0 000f4a 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000f4c 6a0d CLRF 0xd,0x0 error_byte = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Go send any data that needs sending to PC C:\Projects\UBW\FW\2455\D\user\user.c 000f4e d835 RCALL 0xfba check_and_send_TX_data (); C:\Projects\UBW\FW\2455\D\user\user.c 000f50 0e02 MOVLW 0x2 } C:\Projects\UBW\FW\2455\D\user\user.c 000f52 5ce1 SUBWF 0xe1,0x0,0x0 000f54 e202 BC 0xf5a 000f56 6ae1 CLRF 0xe1,0x0 000f58 52e5 MOVF 0xe5,0x1,0x0 000f5a 6ee1 MOVWF 0xe1,0x0 000f5c 52e5 MOVF 0xe5,0x1,0x0 000f5e cfe7 MOVFF 0xfe7,0xfd9 000f60 ffd9 000f62 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // This is our replacement for the standard putc routine C:\Projects\UBW\FW\2455\D\user\user.c // This enables printf() and all related functions to print to C:\Projects\UBW\FW\2455\D\user\user.c // the UBS output (i.e. to the PC) buffer C:\Projects\UBW\FW\2455\D\user\user.c 000f64 cfd9 MOVFF 0xfd9,0xfe6 int _user_putc (char c) C:\Projects\UBW\FW\2455\D\user\user.c 000f66 ffe6 000f68 cfe1 MOVFF 0xfe1,0xfd9 000f6a ffd9 { C:\Projects\UBW\FW\2455\D\user\user.c // Copy the character into the output buffer C:\Projects\UBW\FW\2455\D\user\user.c 000f6c 0101 MOVLB 0x1 g_TX_buf[g_TX_buf_in] = c; C:\Projects\UBW\FW\2455\D\user\user.c 000f6e 51b9 MOVF 0xb9,0x0,0x1 000f70 6aea CLRF 0xea,0x0 000f72 0f00 ADDLW 0x0 000f74 6ee9 MOVWF 0xe9,0x0 000f76 0e02 MOVLW 0x2 000f78 22ea ADDWFC 0xea,0x1,0x0 000f7a 0efe MOVLW 0xfe 000f7c cfdb MOVFF 0xfdb,0xfef 000f7e ffef 000f80 0101 MOVLB 0x1 g_TX_buf_in++; C:\Projects\UBW\FW\2455\D\user\user.c 000f82 2bb9 INCF 0xb9,0x1,0x1 C:\Projects\UBW\FW\2455\D\user\user.c // Check for wrap around C:\Projects\UBW\FW\2455\D\user\user.c 000f84 0e40 MOVLW 0x40 if (kTX_BUF_SIZE == g_TX_buf_in) C:\Projects\UBW\FW\2455\D\user\user.c 000f86 0101 MOVLB 0x1 000f88 5db9 SUBWF 0xb9,0x0,0x1 000f8a e102 BNZ 0xf90 { C:\Projects\UBW\FW\2455\D\user\user.c 000f8c 0101 MOVLB 0x1 g_TX_buf_in = 0; C:\Projects\UBW\FW\2455\D\user\user.c 000f8e 6bb9 CLRF 0xb9,0x1 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Also check to see if we bumpted up against our output pointer C:\Projects\UBW\FW\2455\D\user\user.c 000f90 0101 MOVLB 0x1 if (g_TX_buf_in == g_TX_buf_out) C:\Projects\UBW\FW\2455\D\user\user.c 000f92 51ba MOVF 0xba,0x0,0x1 000f94 0101 MOVLB 0x1 000f96 5db9 SUBWF 0xb9,0x0,0x1 000f98 e101 BNZ 0xf9c { C:\Projects\UBW\FW\2455\D\user\user.c 000f9a 840d BSF 0xd,0x2,0x0 bitset (error_byte, kERROR_BYTE_TX_BUF_OVERRUN); C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 000f9c 0efe MOVLW 0xfe return (c); C:\Projects\UBW\FW\2455\D\user\user.c 000f9e cfdb MOVFF 0xfdb,0x2a 000fa0 f02a 000fa2 6a2b CLRF 0x2b,0x0 000fa4 be2a BTFSC 0x2a,0x7,0x0 000fa6 682b SETF 0x2b,0x0 000fa8 c02a MOVFF 0x2a,0xff3 000faa fff3 000fac c02b MOVFF 0x2b,0xff4 000fae fff4 000fb0 d000 BRA 0xfb2 000fb2 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 000fb4 cfe7 MOVFF 0xfe7,0xfd9 000fb6 ffd9 000fb8 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // In this function, we check to see it is OK to transmit. If so C:\Projects\UBW\FW\2455\D\user\user.c // we see if there is any data to transmit to PC. If so, we schedule C:\Projects\UBW\FW\2455\D\user\user.c // it for sending. C:\Projects\UBW\FW\2455\D\user\user.c 000fba cfd9 MOVFF 0xfd9,0xfe6 void check_and_send_TX_data (void) C:\Projects\UBW\FW\2455\D\user\user.c 000fbc ffe6 000fbe cfe1 MOVFF 0xfe1,0xfd9 000fc0 ffd9 000fc2 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c char temp; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Only send if we're not already sending something C:\Projects\UBW\FW\2455\D\user\user.c 000fc4 0101 MOVLB 0x1 if (mUSBUSARTIsTxTrfReady ()) C:\Projects\UBW\FW\2455\D\user\user.c 000fc6 519a MOVF 0x9a,0x0,0x1 000fc8 e13e BNZ 0x1046 { C:\Projects\UBW\FW\2455\D\user\user.c // And only send if there's something there to send C:\Projects\UBW\FW\2455\D\user\user.c 000fca 0101 MOVLB 0x1 if (g_TX_buf_out != g_TX_buf_in) C:\Projects\UBW\FW\2455\D\user\user.c 000fcc 51b9 MOVF 0xb9,0x0,0x1 000fce 0101 MOVLB 0x1 000fd0 5dba SUBWF 0xba,0x0,0x1 000fd2 e039 BZ 0x1046 { C:\Projects\UBW\FW\2455\D\user\user.c // Now decide if we need to break it up into two parts or not C:\Projects\UBW\FW\2455\D\user\user.c 000fd4 0101 MOVLB 0x1 if (g_TX_buf_in > g_TX_buf_out) C:\Projects\UBW\FW\2455\D\user\user.c 000fd6 51ba MOVF 0xba,0x0,0x1 000fd8 0101 MOVLB 0x1 000fda 80d8 BSF 0xd8,0x0,0x0 000fdc 55b9 SUBFWB 0xb9,0x0,0x1 000fde e21a BC 0x1014 { C:\Projects\UBW\FW\2455\D\user\user.c // Since IN is beyond OUT, only need one chunk C:\Projects\UBW\FW\2455\D\user\user.c 000fe0 0101 MOVLB 0x1 temp = g_TX_buf_in - g_TX_buf_out; C:\Projects\UBW\FW\2455\D\user\user.c 000fe2 51ba MOVF 0xba,0x0,0x1 000fe4 0101 MOVLB 0x1 000fe6 5db9 SUBWF 0xb9,0x0,0x1 000fe8 6edf MOVWF 0xdf,0x0 000fea 0101 MOVLB 0x1 mUSBUSARTTxRam (&g_TX_buf[g_TX_buf_out], temp); C:\Projects\UBW\FW\2455\D\user\user.c 000fec 51ba MOVF 0xba,0x0,0x1 000fee 0101 MOVLB 0x1 000ff0 6f9b MOVWF 0x9b,0x1 000ff2 6b9c CLRF 0x9c,0x1 000ff4 0e00 MOVLW 0x0 000ff6 0101 MOVLB 0x1 000ff8 279b ADDWF 0x9b,0x1,0x1 000ffa 0e02 MOVLW 0x2 000ffc 0101 MOVLB 0x1 000ffe 239c ADDWFC 0x9c,0x1,0x1 001000 cfdf MOVFF 0xfdf,0x19f 001002 f19f 001004 0101 MOVLB 0x1 001006 6ba0 CLRF 0xa0,0x1 001008 0101 MOVLB 0x1 00100a 0e01 MOVLW 0x1 00100c 6f9a MOVWF 0x9a,0x1 // Now that we've scheduled the data for sending, C:\Projects\UBW\FW\2455\D\user\user.c // update the pointer C:\Projects\UBW\FW\2455\D\user\user.c 00100e c1b9 MOVFF 0x1b9,0x1ba g_TX_buf_out = g_TX_buf_in; C:\Projects\UBW\FW\2455\D\user\user.c 001010 f1ba } C:\Projects\UBW\FW\2455\D\user\user.c 001012 d019 BRA 0x1046 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Since IN is before OUT, we need to send from OUT to the end C:\Projects\UBW\FW\2455\D\user\user.c // of the buffer, then the next time around we'll catch C:\Projects\UBW\FW\2455\D\user\user.c // from the beginning to IN. C:\Projects\UBW\FW\2455\D\user\user.c 001014 0e40 MOVLW 0x40 temp = kTX_BUF_SIZE - g_TX_buf_out; C:\Projects\UBW\FW\2455\D\user\user.c 001016 0101 MOVLB 0x1 001018 80d8 BSF 0xd8,0x0,0x0 00101a 55ba SUBFWB 0xba,0x0,0x1 00101c 6edf MOVWF 0xdf,0x0 00101e 0101 MOVLB 0x1 mUSBUSARTTxRam (&g_TX_buf[g_TX_buf_out], temp); C:\Projects\UBW\FW\2455\D\user\user.c 001020 51ba MOVF 0xba,0x0,0x1 001022 0101 MOVLB 0x1 001024 6f9b MOVWF 0x9b,0x1 001026 6b9c CLRF 0x9c,0x1 001028 0e00 MOVLW 0x0 00102a 0101 MOVLB 0x1 00102c 279b ADDWF 0x9b,0x1,0x1 00102e 0e02 MOVLW 0x2 001030 0101 MOVLB 0x1 001032 239c ADDWFC 0x9c,0x1,0x1 001034 cfdf MOVFF 0xfdf,0x19f 001036 f19f 001038 0101 MOVLB 0x1 00103a 6ba0 CLRF 0xa0,0x1 00103c 0101 MOVLB 0x1 00103e 0e01 MOVLW 0x1 001040 6f9a MOVWF 0x9a,0x1 // Now that we've scheduled the data for sending, C:\Projects\UBW\FW\2455\D\user\user.c // update the pointer C:\Projects\UBW\FW\2455\D\user\user.c 001042 0101 MOVLB 0x1 g_TX_buf_out = 0; C:\Projects\UBW\FW\2455\D\user\user.c 001044 6bba CLRF 0xba,0x1 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001046 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001048 52e5 MOVF 0xe5,0x1,0x0 00104a cfe7 MOVFF 0xfe7,0xfd9 00104c ffd9 00104e 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Look at the new packet, see what command it is, and C:\Projects\UBW\FW\2455\D\user\user.c // route it appropriately. We come in knowing that C:\Projects\UBW\FW\2455\D\user\user.c // our packet is in g_RX_buf[], and that the beginning C:\Projects\UBW\FW\2455\D\user\user.c // of the packet is at g_RX_buf_out, and the end (CR) is at C:\Projects\UBW\FW\2455\D\user\user.c // g_RX_buf_in. Note that because of buffer wrapping, C:\Projects\UBW\FW\2455\D\user\user.c // g_RX_buf_in may be less than g_RX_buf_out. C:\Projects\UBW\FW\2455\D\user\user.c 001050 cfd9 MOVFF 0xfd9,0xfe6 void parse_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 001052 ffe6 001054 cfe1 MOVFF 0xfe1,0xfd9 001056 ffd9 001058 0e04 MOVLW 0x4 00105a 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c 00105c 6ade CLRF 0xde,0x0 unsigned int command = 0; C:\Projects\UBW\FW\2455\D\user\user.c 00105e 6add CLRF 0xdd,0x0 001060 0e02 MOVLW 0x2 unsigned char cmd1 = 0; C:\Projects\UBW\FW\2455\D\user\user.c 001062 6adb CLRF 0xdb,0x0 001064 0e03 MOVLW 0x3 unsigned char cmd2 = 0; C:\Projects\UBW\FW\2455\D\user\user.c 001066 6adb CLRF 0xdb,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Always grab the first character (which is the first byte of the command) C:\Projects\UBW\FW\2455\D\user\user.c 001068 0101 MOVLB 0x1 cmd1 = toupper (g_RX_buf[g_RX_buf_out]); C:\Projects\UBW\FW\2455\D\user\user.c 00106a 51bc MOVF 0xbc,0x0,0x1 00106c 6aea CLRF 0xea,0x0 00106e 0f40 ADDLW 0x40 001070 6ee9 MOVWF 0xe9,0x0 001072 0e02 MOVLW 0x2 001074 22ea ADDWFC 0xea,0x1,0x0 001076 50ef MOVF 0xef,0x0,0x0 001078 6ee6 MOVWF 0xe6,0x0 00107a 6ae6 CLRF 0xe6,0x0 00107c ecfe CALL 0x43fc,0x0 00107e f021 001080 52e5 MOVF 0xe5,0x1,0x0 001082 52e5 MOVF 0xe5,0x1,0x0 001084 0e02 MOVLW 0x2 001086 cff3 MOVFF 0xff3,0xfdb 001088 ffdb 00108a 0101 MOVLB 0x1 advance_RX_buf_out(); C:\Projects\UBW\FW\2455\D\user\user.c 00108c 2bbc INCF 0xbc,0x1,0x1 00108e 0e40 MOVLW 0x40 001090 0101 MOVLB 0x1 001092 5dbc SUBWF 0xbc,0x0,0x1 001094 e102 BNZ 0x109a 001096 0101 MOVLB 0x1 001098 6bbc CLRF 0xbc,0x1 00109a 0e02 MOVLW 0x2 command = cmd1; C:\Projects\UBW\FW\2455\D\user\user.c 00109c 50db MOVF 0xdb,0x0,0x0 00109e 6ede MOVWF 0xde,0x0 0010a0 6add CLRF 0xdd,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Only grab second one if it is not a comma C:\Projects\UBW\FW\2455\D\user\user.c 0010a2 0101 MOVLB 0x1 if (g_RX_buf[g_RX_buf_out] != ',' && g_RX_buf[g_RX_buf_out] != kCR) C:\Projects\UBW\FW\2455\D\user\user.c 0010a4 51bc MOVF 0xbc,0x0,0x1 0010a6 6aea CLRF 0xea,0x0 0010a8 0f40 ADDLW 0x40 0010aa 6ee9 MOVWF 0xe9,0x0 0010ac 0e02 MOVLW 0x2 0010ae 22ea ADDWFC 0xea,0x1,0x0 0010b0 50ef MOVF 0xef,0x0,0x0 0010b2 082c SUBLW 0x2c 0010b4 e035 BZ 0x1120 0010b6 0101 MOVLB 0x1 0010b8 51bc MOVF 0xbc,0x0,0x1 0010ba 6aea CLRF 0xea,0x0 0010bc 0f40 ADDLW 0x40 0010be 6ee9 MOVWF 0xe9,0x0 0010c0 0e02 MOVLW 0x2 0010c2 22ea ADDWFC 0xea,0x1,0x0 0010c4 50ef MOVF 0xef,0x0,0x0 0010c6 080d SUBLW 0xd 0010c8 e02b BZ 0x1120 { C:\Projects\UBW\FW\2455\D\user\user.c 0010ca 0101 MOVLB 0x1 cmd2 = toupper (g_RX_buf[g_RX_buf_out]); C:\Projects\UBW\FW\2455\D\user\user.c 0010cc 51bc MOVF 0xbc,0x0,0x1 0010ce 6aea CLRF 0xea,0x0 0010d0 0f40 ADDLW 0x40 0010d2 6ee9 MOVWF 0xe9,0x0 0010d4 0e02 MOVLW 0x2 0010d6 22ea ADDWFC 0xea,0x1,0x0 0010d8 50ef MOVF 0xef,0x0,0x0 0010da 6ee6 MOVWF 0xe6,0x0 0010dc 6ae6 CLRF 0xe6,0x0 0010de ecfe CALL 0x43fc,0x0 0010e0 f021 0010e2 52e5 MOVF 0xe5,0x1,0x0 0010e4 52e5 MOVF 0xe5,0x1,0x0 0010e6 0e03 MOVLW 0x3 0010e8 cff3 MOVFF 0xff3,0xfdb 0010ea ffdb 0010ec 0101 MOVLB 0x1 advance_RX_buf_out(); C:\Projects\UBW\FW\2455\D\user\user.c 0010ee 2bbc INCF 0xbc,0x1,0x1 0010f0 0e40 MOVLW 0x40 0010f2 0101 MOVLB 0x1 0010f4 5dbc SUBWF 0xbc,0x0,0x1 0010f6 e102 BNZ 0x10fc 0010f8 0101 MOVLB 0x1 0010fa 6bbc CLRF 0xbc,0x1 0010fc 0e02 MOVLW 0x2 command = ((unsigned int)(cmd1) << 8) + cmd2; C:\Projects\UBW\FW\2455\D\user\user.c 0010fe cfdb MOVFF 0xfdb,0x2c 001100 f02c 001102 c02c MOVFF 0x2c,0x2d 001104 f02d 001106 6a2c CLRF 0x2c,0x0 001108 0e03 MOVLW 0x3 00110a 50db MOVF 0xdb,0x0,0x0 00110c 0100 MOVLB 0x0 00110e 242c ADDWF 0x2c,0x0,0x0 001110 6e2a MOVWF 0x2a,0x0 001112 0e00 MOVLW 0x0 001114 202d ADDWFC 0x2d,0x0,0x0 001116 6e2b MOVWF 0x2b,0x0 001118 c02a MOVFF 0x2a,0xfde 00111a ffde 00111c c02b MOVFF 0x2b,0xfdd 00111e ffdd } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Now 'command' is equal to one or two bytes of our command C:\Projects\UBW\FW\2455\D\user\user.c 001120 0e00 MOVLW 0x0 switch (command) C:\Projects\UBW\FW\2455\D\user\user.c 001122 cfdb MOVFF 0xfdb,0x1e 001124 f01e 001126 0e01 MOVLW 0x1 001128 cfdb MOVFF 0xfdb,0x1f 00112a f01f 00112c 0e49 MOVLW 0x49 00112e 181e XORWF 0x1e,0x0,0x0 001130 e102 BNZ 0x1136 001132 0e43 MOVLW 0x43 001134 181f XORWF 0x1f,0x0,0x0 001136 e101 BNZ 0x113a 001138 d0d7 BRA 0x12e8 00113a 0e49 MOVLW 0x49 00113c 181e XORWF 0x1e,0x0,0x0 00113e e102 BNZ 0x1144 001140 0e52 MOVLW 0x52 001142 181f XORWF 0x1f,0x0,0x0 001144 e101 BNZ 0x1148 001146 d0cd BRA 0x12e2 001148 0e49 MOVLW 0x49 00114a 181e XORWF 0x1e,0x0,0x0 00114c e102 BNZ 0x1152 00114e 0e53 MOVLW 0x53 001150 181f XORWF 0x1f,0x0,0x0 001152 e101 BNZ 0x1156 001154 d0c3 BRA 0x12dc 001156 0e53 MOVLW 0x53 001158 181e XORWF 0x1e,0x0,0x0 00115a e102 BNZ 0x1160 00115c 0e43 MOVLW 0x43 00115e 181f XORWF 0x1f,0x0,0x0 001160 e101 BNZ 0x1164 001162 d0b9 BRA 0x12d6 001164 0e53 MOVLW 0x53 001166 181e XORWF 0x1e,0x0,0x0 001168 e102 BNZ 0x116e 00116a 0e52 MOVLW 0x52 00116c 181f XORWF 0x1f,0x0,0x0 00116e e101 BNZ 0x1172 001170 d0af BRA 0x12d0 001172 0e53 MOVLW 0x53 001174 181e XORWF 0x1e,0x0,0x0 001176 e102 BNZ 0x117c 001178 0e53 MOVLW 0x53 00117a 181f XORWF 0x1f,0x0,0x0 00117c e101 BNZ 0x1180 00117e d0a5 BRA 0x12ca 001180 0e53 MOVLW 0x53 001182 181e XORWF 0x1e,0x0,0x0 001184 e102 BNZ 0x118a 001186 0e42 MOVLW 0x42 001188 181f XORWF 0x1f,0x0,0x0 00118a e101 BNZ 0x118e 00118c d09b BRA 0x12c4 00118e 0e43 MOVLW 0x43 001190 181e XORWF 0x1e,0x0,0x0 001192 e102 BNZ 0x1198 001194 0e42 MOVLW 0x42 001196 181f XORWF 0x1f,0x0,0x0 001198 e101 BNZ 0x119c 00119a d091 BRA 0x12be 00119c 0e43 MOVLW 0x43 00119e 181e XORWF 0x1e,0x0,0x0 0011a0 e102 BNZ 0x11a6 0011a2 0e52 MOVLW 0x52 0011a4 181f XORWF 0x1f,0x0,0x0 0011a6 e101 BNZ 0x11aa 0011a8 d087 BRA 0x12b8 0011aa 0e4f MOVLW 0x4f 0011ac 181e XORWF 0x1e,0x0,0x0 0011ae e102 BNZ 0x11b4 0011b0 0e42 MOVLW 0x42 0011b2 181f XORWF 0x1f,0x0,0x0 0011b4 e101 BNZ 0x11b8 0011b6 d07d BRA 0x12b2 0011b8 0e57 MOVLW 0x57 0011ba 181e XORWF 0x1e,0x0,0x0 0011bc e102 BNZ 0x11c2 0011be 0e4d MOVLW 0x4d 0011c0 181f XORWF 0x1f,0x0,0x0 0011c2 e075 BZ 0x12ae 0011c4 0e52 MOVLW 0x52 0011c6 181e XORWF 0x1e,0x0,0x0 0011c8 e102 BNZ 0x11ce 0011ca 0e4d MOVLW 0x4d 0011cc 181f XORWF 0x1f,0x0,0x0 0011ce e06d BZ 0x12aa 0011d0 0e44 MOVLW 0x44 0011d2 181e XORWF 0x1e,0x0,0x0 0011d4 e102 BNZ 0x11da 0011d6 0e50 MOVLW 0x50 0011d8 181f XORWF 0x1f,0x0,0x0 0011da e065 BZ 0x12a6 0011dc 0e4f MOVLW 0x4f 0011de 181e XORWF 0x1e,0x0,0x0 0011e0 e102 BNZ 0x11e6 0011e2 0e50 MOVLW 0x50 0011e4 181f XORWF 0x1f,0x0,0x0 0011e6 e05d BZ 0x12a2 0011e8 0e49 MOVLW 0x49 0011ea 181e XORWF 0x1e,0x0,0x0 0011ec e102 BNZ 0x11f2 0011ee 0e50 MOVLW 0x50 0011f0 181f XORWF 0x1f,0x0,0x0 0011f2 e055 BZ 0x129e 0011f4 0e58 MOVLW 0x58 0011f6 181e XORWF 0x1e,0x0,0x0 0011f8 e102 BNZ 0x11fe 0011fa 0e54 MOVLW 0x54 0011fc 181f XORWF 0x1f,0x0,0x0 0011fe e04c BZ 0x1298 001200 0e54 MOVLW 0x54 001202 181e XORWF 0x1e,0x0,0x0 001204 e101 BNZ 0x1208 001206 501f MOVF 0x1f,0x0,0x0 001208 e045 BZ 0x1294 00120a 0e41 MOVLW 0x41 00120c 181e XORWF 0x1e,0x0,0x0 00120e e101 BNZ 0x1212 001210 501f MOVF 0x1f,0x0,0x0 001212 e03e BZ 0x1290 001214 0e56 MOVLW 0x56 001216 181e XORWF 0x1e,0x0,0x0 001218 e101 BNZ 0x121c 00121a 501f MOVF 0x1f,0x0,0x0 00121c e037 BZ 0x128c 00121e 0e49 MOVLW 0x49 001220 181e XORWF 0x1e,0x0,0x0 001222 e101 BNZ 0x1226 001224 501f MOVF 0x1f,0x0,0x0 001226 e030 BZ 0x1288 001228 0e4f MOVLW 0x4f 00122a 181e XORWF 0x1e,0x0,0x0 00122c e101 BNZ 0x1230 00122e 501f MOVF 0x1f,0x0,0x0 001230 e029 BZ 0x1284 001232 0e55 MOVLW 0x55 001234 181e XORWF 0x1e,0x0,0x0 001236 e102 BNZ 0x123c 001238 0e43 MOVLW 0x43 00123a 181f XORWF 0x1f,0x0,0x0 00123c e021 BZ 0x1280 00123e 0e58 MOVLW 0x58 001240 181e XORWF 0x1e,0x0,0x0 001242 e102 BNZ 0x1248 001244 0e43 MOVLW 0x43 001246 181f XORWF 0x1f,0x0,0x0 001248 e018 BZ 0x127a 00124a 0e43 MOVLW 0x43 00124c 181e XORWF 0x1e,0x0,0x0 00124e e101 BNZ 0x1252 001250 501f MOVF 0x1f,0x0,0x0 001252 e011 BZ 0x1276 001254 0e52 MOVLW 0x52 001256 181e XORWF 0x1e,0x0,0x0 001258 e101 BNZ 0x125c 00125a 501f MOVF 0x1f,0x0,0x0 00125c e00a BZ 0x1272 00125e 0e58 MOVLW 0x58 001260 181e XORWF 0x1e,0x0,0x0 001262 e102 BNZ 0x1268 001264 0e52 MOVLW 0x52 001266 181f XORWF 0x1f,0x0,0x0 001268 e001 BZ 0x126c 00126a d041 BRA 0x12ee { C:\Projects\UBW\FW\2455\D\user\user.c case ('R' * 256) + 'X': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // For receiving serial C:\Projects\UBW\FW\2455\D\user\user.c 00126c ecbc CALL 0x1b78,0x0 parse_RX_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 00126e f00d 001270 d07d BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'R': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Reset command (resets everything to power-on state) C:\Projects\UBW\FW\2455\D\user\user.c 001272 d8b3 RCALL 0x13da parse_R_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 001274 d07b BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'C': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Configure command (configure ports for Input or Ouptut) C:\Projects\UBW\FW\2455\D\user\user.c 001276 d936 RCALL 0x14e4 parse_C_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 001278 d079 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('C' * 256) + 'X': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // For configuring serial port C:\Projects\UBW\FW\2455\D\user\user.c 00127a ecbe CALL 0x1b7c,0x0 parse_CX_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 00127c f00d 00127e d076 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('C' * 256) + 'U': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // For configuring UBW C:\Projects\UBW\FW\2455\D\user\user.c 001280 d8b0 RCALL 0x13e2 parse_CU_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 001282 d074 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'O': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Output command (tell the ports to output something) C:\Projects\UBW\FW\2455\D\user\user.c 001284 d98c RCALL 0x159e parse_O_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 001286 d072 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'I': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Input command (return the current status of the ports) C:\Projects\UBW\FW\2455\D\user\user.c 001288 d9bd RCALL 0x1604 parse_I_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 00128a d070 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'V': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Version command C:\Projects\UBW\FW\2455\D\user\user.c 00128c d9d6 RCALL 0x163a parse_V_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 00128e d06e BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'A': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Analog command C:\Projects\UBW\FW\2455\D\user\user.c 001290 d9e5 RCALL 0x165c parse_A_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 001292 d06c BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case 'T': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // For timed I/O C:\Projects\UBW\FW\2455\D\user\user.c 001294 d8e6 RCALL 0x1462 parse_T_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 001296 d06a BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('T' * 256) + 'X': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // For transmitting serial C:\Projects\UBW\FW\2455\D\user\user.c 001298 ecba CALL 0x1b74,0x0 parse_TX_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 00129a f00d 00129c d067 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('P' * 256) + 'I': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // PI for reading a single pin C:\Projects\UBW\FW\2455\D\user\user.c 00129e db51 RCALL 0x1942 parse_PI_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012a0 d065 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('P' * 256) + 'O': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // PO for setting a single pin C:\Projects\UBW\FW\2455\D\user\user.c 0012a2 dbcf RCALL 0x1a42 parse_PO_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012a4 d063 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c case ('P' * 256) + 'D': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // PD for setting a pin's direction C:\Projects\UBW\FW\2455\D\user\user.c 0012a6 dab1 RCALL 0x180a parse_PD_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012a8 d061 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('M' * 256) + 'R': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // MR for Memory Read C:\Projects\UBW\FW\2455\D\user\user.c 0012aa da6e RCALL 0x1788 parse_MR_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012ac d05f BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('M' * 256) + 'W': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // MW for Memory Write C:\Projects\UBW\FW\2455\D\user\user.c 0012ae da37 RCALL 0x171e parse_MW_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012b0 d05d BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('B' * 256) + 'O': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // MR for Fast Parallel Output C:\Projects\UBW\FW\2455\D\user\user.c 0012b2 ecb0 CALL 0x1d60,0x0 parse_BO_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012b4 f00e 0012b6 d05a BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('R' * 256) + 'C': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // RC for RC servo output C:\Projects\UBW\FW\2455\D\user\user.c 0012b8 ecc0 CALL 0x1b80,0x0 parse_RC_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012ba f00d 0012bc d057 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('B' * 256) + 'C': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // BC for Fast Parallel Configure C:\Projects\UBW\FW\2455\D\user\user.c 0012be ec69 CALL 0x1cd2,0x0 parse_BC_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012c0 f00e 0012c2 d054 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('B' * 256) + 'S': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // BS for Fast Binary Stream output C:\Projects\UBW\FW\2455\D\user\user.c 0012c4 ecf7 CALL 0x1fee,0x0 parse_BS_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012c6 f00f 0012c8 d051 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('S' * 256) + 'S': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // SS for Send SPI C:\Projects\UBW\FW\2455\D\user\user.c 0012ca ecb3 CALL 0x2166,0x0 parse_SS_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012cc f010 0012ce d04e BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('R' * 256) + 'S': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // RS for Receive SPI C:\Projects\UBW\FW\2455\D\user\user.c 0012d0 ecb6 CALL 0x216c,0x0 parse_RS_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012d2 f010 0012d4 d04b BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('C' * 256) + 'S': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // CS for Configure SPI C:\Projects\UBW\FW\2455\D\user\user.c 0012d6 ecb9 CALL 0x2172,0x0 parse_CS_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012d8 f010 0012da d048 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('S' * 256) + 'I': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // SI for Send I2C C:\Projects\UBW\FW\2455\D\user\user.c 0012dc ecbc CALL 0x2178,0x0 parse_SI_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012de f010 0012e0 d045 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('R' * 256) + 'I': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // RI for Receive I2C C:\Projects\UBW\FW\2455\D\user\user.c 0012e2 ecbf CALL 0x217e,0x0 parse_RI_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012e4 f010 0012e6 d042 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c case ('C' * 256) + 'I': C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // CI for Configure I2C C:\Projects\UBW\FW\2455\D\user\user.c 0012e8 ecc2 CALL 0x2184,0x0 parse_CI_packet (); C:\Projects\UBW\FW\2455\D\user\user.c 0012ea f010 0012ec d03f BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c default: C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0012ee 0e03 MOVLW 0x3 if (0 == cmd2) C:\Projects\UBW\FW\2455\D\user\user.c 0012f0 50db MOVF 0xdb,0x0,0x0 0012f2 e11a BNZ 0x1328 { C:\Projects\UBW\FW\2455\D\user\user.c // Send back 'unknown command' error C:\Projects\UBW\FW\2455\D\user\user.c printf ( C:\Projects\UBW\FW\2455\D\user\user.c (rom char *)"!8 Err: Unknown command '%c:%2X'\r\n" C:\Projects\UBW\FW\2455\D\user\user.c 001304 0ef1 MOVLW 0xf1 ,cmd1 C:\Projects\UBW\FW\2455\D\user\user.c 001306 6e2a MOVWF 0x2a,0x0 001308 0e3e MOVLW 0x3e 00130a 6e2b MOVWF 0x2b,0x0 00130c 6a2c CLRF 0x2c,0x0 00130e c02a MOVFF 0x2a,0xfe6 001310 ffe6 001312 c02b MOVFF 0x2b,0xfe6 001314 ffe6 001316 c02c MOVFF 0x2c,0xfe6 001318 ffe6 0012fc 0e02 MOVLW 0x2 ,cmd1 C:\Projects\UBW\FW\2455\D\user\user.c 0012fe cfdb MOVFF 0xfdb,0xfe6 001300 ffe6 001302 6ae6 CLRF 0xe6,0x0 0012f4 0e02 MOVLW 0x2 ); C:\Projects\UBW\FW\2455\D\user\user.c 0012f6 cfdb MOVFF 0xfdb,0xfe6 0012f8 ffe6 0012fa 6ae6 CLRF 0xe6,0x0 00131a ec05 CALL 0x420a,0x0 00131c f021 00131e 6e2d MOVWF 0x2d,0x0 001320 0e07 MOVLW 0x7 001322 5ee1 SUBWF 0xe1,0x1,0x0 001324 502d MOVF 0x2d,0x0,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001326 d021 BRA 0x136a else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Send back 'unknown command' error C:\Projects\UBW\FW\2455\D\user\user.c printf ( C:\Projects\UBW\FW\2455\D\user\user.c (rom char *)"!8 Err: Unknown command '%c%c:%2X%2X'\r\n" C:\Projects\UBW\FW\2455\D\user\user.c 001348 0ec9 MOVLW 0xc9 ,cmd1 C:\Projects\UBW\FW\2455\D\user\user.c 00134a 6e2a MOVWF 0x2a,0x0 00134c 0e3e MOVLW 0x3e 00134e 6e2b MOVWF 0x2b,0x0 001350 6a2c CLRF 0x2c,0x0 001352 c02a MOVFF 0x2a,0xfe6 001354 ffe6 001356 c02b MOVFF 0x2b,0xfe6 001358 ffe6 00135a c02c MOVFF 0x2c,0xfe6 00135c ffe6 001340 0e02 MOVLW 0x2 ,cmd2 C:\Projects\UBW\FW\2455\D\user\user.c 001342 cfdb MOVFF 0xfdb,0xfe6 001344 ffe6 001346 6ae6 CLRF 0xe6,0x0 001338 0e03 MOVLW 0x3 ,cmd1 C:\Projects\UBW\FW\2455\D\user\user.c 00133a cfdb MOVFF 0xfdb,0xfe6 00133c ffe6 00133e 6ae6 CLRF 0xe6,0x0 001330 0e02 MOVLW 0x2 ,cmd2 C:\Projects\UBW\FW\2455\D\user\user.c 001332 cfdb MOVFF 0xfdb,0xfe6 001334 ffe6 001336 6ae6 CLRF 0xe6,0x0 001328 0e03 MOVLW 0x3 ); C:\Projects\UBW\FW\2455\D\user\user.c 00132a cfdb MOVFF 0xfdb,0xfe6 00132c ffe6 00132e 6ae6 CLRF 0xe6,0x0 00135e ec05 CALL 0x420a,0x0 001360 f021 001362 6e2d MOVWF 0x2d,0x0 001364 0e0b MOVLW 0xb 001366 5ee1 SUBWF 0xe1,0x1,0x0 001368 502d MOVF 0x2d,0x0,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 00136a d000 BRA 0x136c break; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Double check that our output pointer is now at the ending C:\Projects\UBW\FW\2455\D\user\user.c // If it is not, this indicates that there were extra characters that C:\Projects\UBW\FW\2455\D\user\user.c // the command parsing routine didn't eat. This would be an error and needs C:\Projects\UBW\FW\2455\D\user\user.c // to be reported. (Ignore for Reset command because FIFO pointers get cleared.) C:\Projects\UBW\FW\2455\D\user\user.c if ( C:\Projects\UBW\FW\2455\D\user\user.c 00136c 0101 MOVLB 0x1 (g_RX_buf[g_RX_buf_out] != kCR && 0 == error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 00136e 51bc MOVF 0xbc,0x0,0x1 001370 6aea CLRF 0xea,0x0 001372 0f40 ADDLW 0x40 001374 6ee9 MOVWF 0xe9,0x0 001376 0e02 MOVLW 0x2 001378 22ea ADDWFC 0xea,0x1,0x0 00137a 50ef MOVF 0xef,0x0,0x0 00137c 080d SUBLW 0xd 00137e e00d BZ 0x139a 001380 500d MOVF 0xd,0x0,0x0 001382 e10b BNZ 0x139a && C:\Projects\UBW\FW\2455\D\user\user.c 001384 0e52 MOVLW 0x52 ('R' != command) C:\Projects\UBW\FW\2455\D\user\user.c 001386 6e2a MOVWF 0x2a,0x0 001388 6a2b CLRF 0x2b,0x0 00138a 50df MOVF 0xdf,0x0,0x0 00138c 182a XORWF 0x2a,0x0,0x0 00138e e103 BNZ 0x1396 001390 52de MOVF 0xde,0x1,0x0 001392 50dd MOVF 0xdd,0x0,0x0 001394 182b XORWF 0x2b,0x0,0x0 001396 e001 BZ 0x139a ) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001398 8e0d BSF 0xd,0x7,0x0 bitset (error_byte, kERROR_BYTE_EXTRA_CHARACTERS); C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Clean up by skipping over any bytes we haven't eaten C:\Projects\UBW\FW\2455\D\user\user.c // This is safe since we parse each packet as we get a C:\Projects\UBW\FW\2455\D\user\user.c // (i.e. g_RX_buf_in doesn't move while we are in this routine) C:\Projects\UBW\FW\2455\D\user\user.c 00139a c1bb MOVFF 0x1bb,0x1bc g_RX_buf_out = g_RX_buf_in; C:\Projects\UBW\FW\2455\D\user\user.c 00139c f1bc 00139e 0e04 MOVLW 0x4 } C:\Projects\UBW\FW\2455\D\user\user.c 0013a0 5ce1 SUBWF 0xe1,0x0,0x0 0013a2 e202 BC 0x13a8 0013a4 6ae1 CLRF 0xe1,0x0 0013a6 52e5 MOVF 0xe5,0x1,0x0 0013a8 6ee1 MOVWF 0xe1,0x0 0013aa 52e5 MOVF 0xe5,0x1,0x0 0013ac cfe7 MOVFF 0xfe7,0xfd9 0013ae ffd9 0013b0 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Print out the positive acknoledgement that the packet was received C:\Projects\UBW\FW\2455\D\user\user.c // if we have acks turned on. C:\Projects\UBW\FW\2455\D\user\user.c void print_ack(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0013b2 0101 MOVLB 0x1 if (g_ack_enable) C:\Projects\UBW\FW\2455\D\user\user.c 0013b4 51c1 MOVF 0xc1,0x0,0x1 0013b6 e010 BZ 0x13d8 { C:\Projects\UBW\FW\2455\D\user\user.c 0013b8 0ec8 MOVLW 0xc8 printf ((rom char *)st_OK); C:\Projects\UBW\FW\2455\D\user\user.c 0013ba 6e2a MOVWF 0x2a,0x0 0013bc 0e44 MOVLW 0x44 0013be 6e2b MOVWF 0x2b,0x0 0013c0 6a2c CLRF 0x2c,0x0 0013c2 c02a MOVFF 0x2a,0xfe6 0013c4 ffe6 0013c6 c02b MOVFF 0x2b,0xfe6 0013c8 ffe6 0013ca c02c MOVFF 0x2c,0xfe6 0013cc ffe6 0013ce ec05 CALL 0x420a,0x0 0013d0 f021 0013d2 52e5 MOVF 0xe5,0x1,0x0 0013d4 52e5 MOVF 0xe5,0x1,0x0 0013d6 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 0013d8 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Return all I/Os to their default power-on values C:\Projects\UBW\FW\2455\D\user\user.c void parse_R_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0013da ecc4 CALL 0xb88,0x0 UserInit (); C:\Projects\UBW\FW\2455\D\user\user.c 0013dc f005 0013de dfe9 RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 0013e0 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // CU is "Configure UBW" and controls system-wide configruation values C:\Projects\UBW\FW\2455\D\user\user.c // "CU,," C:\Projects\UBW\FW\2455\D\user\user.c // C:\Projects\UBW\FW\2455\D\user\user.c // 1 {1|0} turns on or off the 'ack' ("OK" at end of packets) C:\Projects\UBW\FW\2455\D\user\user.c 0013e2 cfd9 MOVFF 0xfd9,0xfe6 void parse_CU_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 0013e4 ffe6 0013e6 cfe1 MOVFF 0xfe1,0xfd9 0013e8 ffd9 0013ea 0e03 MOVLW 0x3 0013ec 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char parameter_number; C:\Projects\UBW\FW\2455\D\user\user.c signed int paramater_value; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 0013ee 0e01 MOVLW 0x1 parameter_number = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 0013f0 6ee6 MOVWF 0xe6,0x0 0013f2 ecc5 CALL 0x218a,0x0 0013f4 f010 0013f6 52e5 MOVF 0xe5,0x1,0x0 0013f8 501d MOVF 0x1d,0x0,0x0 0013fa 6edf MOVWF 0xdf,0x0 0013fc 0e02 MOVLW 0x2 paramater_value = extract_number (kINT); C:\Projects\UBW\FW\2455\D\user\user.c 0013fe 6ee6 MOVWF 0xe6,0x0 001400 ecc5 CALL 0x218a,0x0 001402 f010 001404 52e5 MOVF 0xe5,0x1,0x0 001406 52de MOVF 0xde,0x1,0x0 001408 c01d MOVFF 0x1d,0xfde 00140a ffde 00140c c01e MOVFF 0x1e,0xfdd 00140e ffdd 001410 52dd MOVF 0xdd,0x1,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 001412 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001414 e001 BZ 0x1418 { C:\Projects\UBW\FW\2455\D\user\user.c 001416 d01b BRA 0x144e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001418 04df DECF 0xdf,0x0,0x0 if (1 == parameter_number) C:\Projects\UBW\FW\2455\D\user\user.c 00141a e118 BNZ 0x144c { C:\Projects\UBW\FW\2455\D\user\user.c 00141c 50d9 MOVF 0xd9,0x0,0x0 if (0 == paramater_value || 1 == paramater_value) C:\Projects\UBW\FW\2455\D\user\user.c 00141e 0f01 ADDLW 0x1 001420 6ee9 MOVWF 0xe9,0x0 001422 cfda MOVFF 0xfda,0xfea 001424 ffea 001426 50ee MOVF 0xee,0x0,0x0 001428 10ed IORWF 0xed,0x0,0x0 00142a e00b BZ 0x1442 00142c 0e01 MOVLW 0x1 00142e 6e2a MOVWF 0x2a,0x0 001430 6a2b CLRF 0x2b,0x0 001432 0e01 MOVLW 0x1 001434 50db MOVF 0xdb,0x0,0x0 001436 182a XORWF 0x2a,0x0,0x0 001438 e103 BNZ 0x1440 00143a 0e02 MOVLW 0x2 00143c 50db MOVF 0xdb,0x0,0x0 00143e 182b XORWF 0x2b,0x0,0x0 001440 e104 BNZ 0x144a { C:\Projects\UBW\FW\2455\D\user\user.c 001442 0e01 MOVLW 0x1 g_ack_enable = paramater_value; C:\Projects\UBW\FW\2455\D\user\user.c 001444 cfdb MOVFF 0xfdb,0x1c1 001446 f1c1 } C:\Projects\UBW\FW\2455\D\user\user.c 001448 d001 BRA 0x144c else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 00144a 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 00144c dfb2 RCALL 0x13b2 print_ack(); C:\Projects\UBW\FW\2455\D\user\user.c 00144e 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 001450 5ce1 SUBWF 0xe1,0x0,0x0 001452 e202 BC 0x1458 001454 6ae1 CLRF 0xe1,0x0 001456 52e5 MOVF 0xe5,0x1,0x0 001458 6ee1 MOVWF 0xe1,0x0 00145a 52e5 MOVF 0xe5,0x1,0x0 00145c cfe7 MOVFF 0xfe7,0xfd9 00145e ffd9 001460 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // "T" Packet C:\Projects\UBW\FW\2455\D\user\user.c // Causes PIC to sample digital or analog inputs at a regular interval and send C:\Projects\UBW\FW\2455\D\user\user.c // I (or A) packets back at that interval. C:\Projects\UBW\FW\2455\D\user\user.c // Send T,0,0 to stop I (or A) packets C:\Projects\UBW\FW\2455\D\user\user.c // FORMAT: T,, C:\Projects\UBW\FW\2455\D\user\user.c // is 0 for digital (I packets) and 1 for analog (A packets) C:\Projects\UBW\FW\2455\D\user\user.c // EXAMPLE: "T,4000,0" to send an I packet back every 4 seconds. C:\Projects\UBW\FW\2455\D\user\user.c // EXAMPLE: "T,2000,1" to send an A packet back every 2 seconds. C:\Projects\UBW\FW\2455\D\user\user.c 001462 cfd9 MOVFF 0xfd9,0xfe6 void parse_T_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 001464 ffe6 001466 cfe1 MOVFF 0xfe1,0xfd9 001468 ffd9 00146a 0e03 MOVLW 0x3 00146c 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned int value; C:\Projects\UBW\FW\2455\D\user\user.c 00146e 0e02 MOVLW 0x2 unsigned char mode = 0; C:\Projects\UBW\FW\2455\D\user\user.c 001470 6adb CLRF 0xdb,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Extract the value C:\Projects\UBW\FW\2455\D\user\user.c 001472 0e03 MOVLW 0x3 time_between_updates = extract_number (kUINT); C:\Projects\UBW\FW\2455\D\user\user.c 001474 6ee6 MOVWF 0xe6,0x0 001476 ecc5 CALL 0x218a,0x0 001478 f010 00147a 52e5 MOVF 0xe5,0x1,0x0 00147c c01d MOVFF 0x1d,0x0 00147e f000 001480 c01e MOVFF 0x1e,0x1 001482 f001 // Extract the value C:\Projects\UBW\FW\2455\D\user\user.c 001484 0e01 MOVLW 0x1 mode = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001486 6ee6 MOVWF 0xe6,0x0 001488 ecc5 CALL 0x218a,0x0 00148a f010 00148c 52e5 MOVF 0xe5,0x1,0x0 00148e 0e02 MOVLW 0x2 001490 c01d MOVFF 0x1d,0xfdb 001492 ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 001494 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001496 e001 BZ 0x149a { C:\Projects\UBW\FW\2455\D\user\user.c 001498 d01b BRA 0x14d0 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Now start up the timer at the right rate or shut C:\Projects\UBW\FW\2455\D\user\user.c // it down. C:\Projects\UBW\FW\2455\D\user\user.c 00149a 0e02 MOVLW 0x2 if (0 == mode) C:\Projects\UBW\FW\2455\D\user\user.c 00149c 50db MOVF 0xdb,0x0,0x0 00149e e10c BNZ 0x14b8 { C:\Projects\UBW\FW\2455\D\user\user.c 0014a0 5000 MOVF 0x0,0x0,0x0 if (0 == time_between_updates) C:\Projects\UBW\FW\2455\D\user\user.c 0014a2 1001 IORWF 0x1,0x0,0x0 0014a4 e103 BNZ 0x14ac { C:\Projects\UBW\FW\2455\D\user\user.c // Turn off sending of I packets. C:\Projects\UBW\FW\2455\D\user\user.c 0014a6 6a02 CLRF 0x2,0x0 ISR_D_RepeatRate = 0; C:\Projects\UBW\FW\2455\D\user\user.c 0014a8 6a03 CLRF 0x3,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 0014aa d005 BRA 0x14b6 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0014ac 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Eventually gaurd this section from interrupts C:\Projects\UBW\FW\2455\D\user\user.c 0014ae c000 MOVFF 0x0,0x2 ISR_D_RepeatRate = time_between_updates; C:\Projects\UBW\FW\2455\D\user\user.c 0014b0 f002 0014b2 c001 MOVFF 0x1,0x3 0014b4 f003 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 0014b6 d00b BRA 0x14ce else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0014b8 5000 MOVF 0x0,0x0,0x0 if (0 == time_between_updates) C:\Projects\UBW\FW\2455\D\user\user.c 0014ba 1001 IORWF 0x1,0x0,0x0 0014bc e103 BNZ 0x14c4 { C:\Projects\UBW\FW\2455\D\user\user.c // Turn off sending of A packets. C:\Projects\UBW\FW\2455\D\user\user.c 0014be 6a07 CLRF 0x7,0x0 ISR_A_RepeatRate = 0; C:\Projects\UBW\FW\2455\D\user\user.c 0014c0 6a08 CLRF 0x8,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 0014c2 d005 BRA 0x14ce else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0014c4 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Eventually gaurd this section from interrupts C:\Projects\UBW\FW\2455\D\user\user.c 0014c6 c000 MOVFF 0x0,0x7 ISR_A_RepeatRate = time_between_updates; C:\Projects\UBW\FW\2455\D\user\user.c 0014c8 f007 0014ca c001 MOVFF 0x1,0x8 0014cc f008 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 0014ce df71 RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 0014d0 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 0014d2 5ce1 SUBWF 0xe1,0x0,0x0 0014d4 e202 BC 0x14da 0014d6 6ae1 CLRF 0xe1,0x0 0014d8 52e5 MOVF 0xe5,0x1,0x0 0014da 6ee1 MOVWF 0xe1,0x0 0014dc 52e5 MOVF 0xe5,0x1,0x0 0014de cfe7 MOVFF 0xfe7,0xfd9 0014e0 ffd9 0014e2 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // FORMAT: C,,,, C:\Projects\UBW\FW\2455\D\user\user.c // EXAMPLE: "C,255,0,4,0" C:\Projects\UBW\FW\2455\D\user\user.c // is the byte sent to the Data Direction (DDR) regsiter for C:\Projects\UBW\FW\2455\D\user\user.c // each port. A 1 in a bit location means input, a 0 means output. C:\Projects\UBW\FW\2455\D\user\user.c // is a value between 0 and 12. It tells the UBW C:\Projects\UBW\FW\2455\D\user\user.c // how many analog inputs to enable. If a zero is sent for this C:\Projects\UBW\FW\2455\D\user\user.c // parameter, all analog inputs are disabled. C:\Projects\UBW\FW\2455\D\user\user.c // For the other values, see the following chart to know what pins are C:\Projects\UBW\FW\2455\D\user\user.c // used for what: C:\Projects\UBW\FW\2455\D\user\user.c // C:\Projects\UBW\FW\2455\D\user\user.c // Note that in the following chart, PortE is references. This port C:\Projects\UBW\FW\2455\D\user\user.c // only exists on the 40 and 44 pin versions of the UBW. For the C:\Projects\UBW\FW\2455\D\user\user.c // 28 pin versions of the UBW, all PortE based analog pins will return C:\Projects\UBW\FW\2455\D\user\user.c // zero. C:\Projects\UBW\FW\2455\D\user\user.c // C:\Projects\UBW\FW\2455\D\user\user.c // Analog Inputs Enabled Pins Used For Analog Inputs C:\Projects\UBW\FW\2455\D\user\user.c // --------------- --------------------- ------------------------------- C:\Projects\UBW\FW\2455\D\user\user.c // 0 C:\Projects\UBW\FW\2455\D\user\user.c // 1 AN0 A0 C:\Projects\UBW\FW\2455\D\user\user.c // 2 AN0,AN1 A0,A1 C:\Projects\UBW\FW\2455\D\user\user.c // 3 AN0,AN1,AN2 A0,A1,A2 C:\Projects\UBW\FW\2455\D\user\user.c // 4 AN0,AN1,AN2,AN3 A0,A1,A2,A3 C:\Projects\UBW\FW\2455\D\user\user.c // 5 AN0,AN1,AN2,AN3,AN4 A0,A1,A2,A3,A5 C:\Projects\UBW\FW\2455\D\user\user.c // 6 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0 C:\Projects\UBW\FW\2455\D\user\user.c // AN5 C:\Projects\UBW\FW\2455\D\user\user.c // 7 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1 C:\Projects\UBW\FW\2455\D\user\user.c // AN5,AN6 C:\Projects\UBW\FW\2455\D\user\user.c // 8 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2 C:\Projects\UBW\FW\2455\D\user\user.c // AN5,AN6,AN7 C:\Projects\UBW\FW\2455\D\user\user.c // 9 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2 C:\Projects\UBW\FW\2455\D\user\user.c // AN5,AN6,AN7,AN8 C:\Projects\UBW\FW\2455\D\user\user.c // 10 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2,B3 C:\Projects\UBW\FW\2455\D\user\user.c // AN5,AN6,AN7,AN8, C:\Projects\UBW\FW\2455\D\user\user.c // AN9 C:\Projects\UBW\FW\2455\D\user\user.c // 11 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2,B3,B1 C:\Projects\UBW\FW\2455\D\user\user.c // AN5,AN6,AN7,AN8, C:\Projects\UBW\FW\2455\D\user\user.c // AB9,AN10 C:\Projects\UBW\FW\2455\D\user\user.c // 12 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2,B3,B1,B4 C:\Projects\UBW\FW\2455\D\user\user.c // AN5,AN6,AN7,AN8, C:\Projects\UBW\FW\2455\D\user\user.c // AN9,AN10,AN11 C:\Projects\UBW\FW\2455\D\user\user.c // NOTE: it is up to the user to tell the proper port direction bits to be C:\Projects\UBW\FW\2455\D\user\user.c // inputs for the analog channels they wish to use. C:\Projects\UBW\FW\2455\D\user\user.c 0014e4 cfd9 MOVFF 0xfd9,0xfe6 void parse_C_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 0014e6 ffe6 0014e8 cfe1 MOVFF 0xfe1,0xfd9 0014ea ffd9 0014ec 0e04 MOVLW 0x4 0014ee 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char PA, PB, PC, AA; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Extract each of the four values. C:\Projects\UBW\FW\2455\D\user\user.c 0014f0 0e01 MOVLW 0x1 PA = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 0014f2 6ee6 MOVWF 0xe6,0x0 0014f4 ecc5 CALL 0x218a,0x0 0014f6 f010 0014f8 52e5 MOVF 0xe5,0x1,0x0 0014fa 501d MOVF 0x1d,0x0,0x0 0014fc 6edf MOVWF 0xdf,0x0 0014fe 0e01 MOVLW 0x1 PB = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001500 6ee6 MOVWF 0xe6,0x0 001502 ecc5 CALL 0x218a,0x0 001504 f010 001506 52e5 MOVF 0xe5,0x1,0x0 001508 0e01 MOVLW 0x1 00150a c01d MOVFF 0x1d,0xfdb 00150c ffdb 00150e 0e01 MOVLW 0x1 PC = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001510 6ee6 MOVWF 0xe6,0x0 001512 ecc5 CALL 0x218a,0x0 001514 f010 001516 52e5 MOVF 0xe5,0x1,0x0 001518 0e02 MOVLW 0x2 00151a c01d MOVFF 0x1d,0xfdb 00151c ffdb 00151e 0e01 MOVLW 0x1 AA = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001520 6ee6 MOVWF 0xe6,0x0 001522 ecc5 CALL 0x218a,0x0 001524 f010 001526 52e5 MOVF 0xe5,0x1,0x0 001528 0e03 MOVLW 0x3 00152a c01d MOVFF 0x1d,0xfdb 00152c ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 00152e 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001530 e001 BZ 0x1534 { C:\Projects\UBW\FW\2455\D\user\user.c 001532 d02b BRA 0x158a return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Now write those values to the data direction registers. C:\Projects\UBW\FW\2455\D\user\user.c 001534 50df MOVF 0xdf,0x0,0x0 TRISA = PA; C:\Projects\UBW\FW\2455\D\user\user.c 001536 6e92 MOVWF 0x92,0x0 001538 0e01 MOVLW 0x1 TRISB = PB; C:\Projects\UBW\FW\2455\D\user\user.c 00153a 50db MOVF 0xdb,0x0,0x0 00153c 6e93 MOVWF 0x93,0x0 00153e 0e02 MOVLW 0x2 TRISC = PC; C:\Projects\UBW\FW\2455\D\user\user.c 001540 50db MOVF 0xdb,0x0,0x0 001542 6e94 MOVWF 0x94,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Handle the analog value. C:\Projects\UBW\FW\2455\D\user\user.c // Maximum value of 12. C:\Projects\UBW\FW\2455\D\user\user.c 001544 0e03 MOVLW 0x3 if (AA > 12) C:\Projects\UBW\FW\2455\D\user\user.c 001546 50db MOVF 0xdb,0x0,0x0 001548 080c SUBLW 0xc 00154a e205 BC 0x1556 { C:\Projects\UBW\FW\2455\D\user\user.c 00154c 0e0c MOVLW 0xc AA = 12; C:\Projects\UBW\FW\2455\D\user\user.c 00154e 6ef3 MOVWF 0xf3,0x0 001550 0e03 MOVLW 0x3 001552 cff3 MOVFF 0xff3,0xfdb 001554 ffdb } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // If we are turning off Analog inputs C:\Projects\UBW\FW\2455\D\user\user.c 001556 0e03 MOVLW 0x3 if (0 == AA) C:\Projects\UBW\FW\2455\D\user\user.c 001558 50db MOVF 0xdb,0x0,0x0 00155a e105 BNZ 0x1566 { C:\Projects\UBW\FW\2455\D\user\user.c // Turn all analog inputs into digital inputs C:\Projects\UBW\FW\2455\D\user\user.c 00155c 0e0f MOVLW 0xf ADCON1 = 0x0F; C:\Projects\UBW\FW\2455\D\user\user.c 00155e 6ec1 MOVWF 0xc1,0x0 // Turn off the ADC C:\Projects\UBW\FW\2455\D\user\user.c 001560 90c2 BCF 0xc2,0x0,0x0 ADCON0bits.ADON = 0; C:\Projects\UBW\FW\2455\D\user\user.c // Turn off our own idea of how many analog channels to convert C:\Projects\UBW\FW\2455\D\user\user.c 001562 6a0c CLRF 0xc,0x0 AnalogEnable = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001564 d011 BRA 0x1588 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c // Some protection from ISR C:\Projects\UBW\FW\2455\D\user\user.c 001566 6a0c CLRF 0xc,0x0 AnalogEnable = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // We're turning some on. C:\Projects\UBW\FW\2455\D\user\user.c // Start by selecting channel zero C:\Projects\UBW\FW\2455\D\user\user.c 001568 6ac2 CLRF 0xc2,0x0 ADCON0 = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Then enabling the proper number of channels C:\Projects\UBW\FW\2455\D\user\user.c 00156a 0e03 MOVLW 0x3 ADCON1 = 15 - AA; C:\Projects\UBW\FW\2455\D\user\user.c 00156c cfdb MOVFF 0xfdb,0xfe6 00156e ffe6 001570 0e0f MOVLW 0xf 001572 52e5 MOVF 0xe5,0x1,0x0 001574 80d8 BSF 0xd8,0x0,0x0 001576 54e7 SUBFWB 0xe7,0x0,0x0 001578 6ec1 MOVWF 0xc1,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Set up ADCON2 options C:\Projects\UBW\FW\2455\D\user\user.c // A/D Result right justified C:\Projects\UBW\FW\2455\D\user\user.c // Acq time = 20 Tad (?) C:\Projects\UBW\FW\2455\D\user\user.c // Tad = Fosc/64 C:\Projects\UBW\FW\2455\D\user\user.c 00157a 0ebe MOVLW 0xbe ADCON2 = 0b10111110; C:\Projects\UBW\FW\2455\D\user\user.c 00157c 6ec0 MOVWF 0xc0,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Turn on the ADC C:\Projects\UBW\FW\2455\D\user\user.c 00157e 80c2 BSF 0xc2,0x0,0x0 ADCON0bits.ADON = 1; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Tell ourselves how many channels to convert, and turn on ISR conversions C:\Projects\UBW\FW\2455\D\user\user.c 001580 0e03 MOVLW 0x3 AnalogEnable = AA; C:\Projects\UBW\FW\2455\D\user\user.c 001582 50db MOVF 0xdb,0x0,0x0 001584 6e0c MOVWF 0xc,0x0 C:\Projects\UBW\FW\2455\D\user\user.c 001586 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001588 df14 RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 00158a 0e04 MOVLW 0x4 } C:\Projects\UBW\FW\2455\D\user\user.c 00158c 5ce1 SUBWF 0xe1,0x0,0x0 00158e e202 BC 0x1594 001590 6ae1 CLRF 0xe1,0x0 001592 52e5 MOVF 0xe5,0x1,0x0 001594 6ee1 MOVWF 0xe1,0x0 001596 52e5 MOVF 0xe5,0x1,0x0 001598 cfe7 MOVFF 0xfe7,0xfd9 00159a ffd9 00159c 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Outputs values to the ports pins that are set up as outputs. C:\Projects\UBW\FW\2455\D\user\user.c // Example "O,121,224,002" C:\Projects\UBW\FW\2455\D\user\user.c 00159e cfd9 MOVFF 0xfd9,0xfe6 void parse_O_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 0015a0 ffe6 0015a2 cfe1 MOVFF 0xfe1,0xfd9 0015a4 ffd9 0015a6 0e03 MOVLW 0x3 0015a8 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char PA, PB, PC; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Extract each of the four values. C:\Projects\UBW\FW\2455\D\user\user.c 0015aa 0e01 MOVLW 0x1 PA = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 0015ac 6ee6 MOVWF 0xe6,0x0 0015ae ecc5 CALL 0x218a,0x0 0015b0 f010 0015b2 52e5 MOVF 0xe5,0x1,0x0 0015b4 501d MOVF 0x1d,0x0,0x0 0015b6 6edf MOVWF 0xdf,0x0 0015b8 0e01 MOVLW 0x1 PB = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 0015ba 6ee6 MOVWF 0xe6,0x0 0015bc ecc5 CALL 0x218a,0x0 0015be f010 0015c0 52e5 MOVF 0xe5,0x1,0x0 0015c2 0e01 MOVLW 0x1 0015c4 c01d MOVFF 0x1d,0xfdb 0015c6 ffdb 0015c8 0e01 MOVLW 0x1 PC = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 0015ca 6ee6 MOVWF 0xe6,0x0 0015cc ecc5 CALL 0x218a,0x0 0015ce f010 0015d0 52e5 MOVF 0xe5,0x1,0x0 0015d2 0e02 MOVLW 0x2 0015d4 c01d MOVFF 0x1d,0xfdb 0015d6 ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 0015d8 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 0015da e001 BZ 0x15de { C:\Projects\UBW\FW\2455\D\user\user.c 0015dc d009 BRA 0x15f0 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c // Now write those values to the data port registers. C:\Projects\UBW\FW\2455\D\user\user.c 0015de 50df MOVF 0xdf,0x0,0x0 LATA = PA; C:\Projects\UBW\FW\2455\D\user\user.c 0015e0 6e89 MOVWF 0x89,0x0 0015e2 0e01 MOVLW 0x1 LATB = PB; C:\Projects\UBW\FW\2455\D\user\user.c 0015e4 50db MOVF 0xdb,0x0,0x0 0015e6 6e8a MOVWF 0x8a,0x0 0015e8 0e02 MOVLW 0x2 LATC = PC; C:\Projects\UBW\FW\2455\D\user\user.c 0015ea 50db MOVF 0xdb,0x0,0x0 0015ec 6e8b MOVWF 0x8b,0x0 C:\Projects\UBW\FW\2455\D\user\user.c 0015ee dee1 RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 0015f0 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 0015f2 5ce1 SUBWF 0xe1,0x0,0x0 0015f4 e202 BC 0x15fa 0015f6 6ae1 CLRF 0xe1,0x0 0015f8 52e5 MOVF 0xe5,0x1,0x0 0015fa 6ee1 MOVWF 0xe1,0x0 0015fc 52e5 MOVF 0xe5,0x1,0x0 0015fe cfe7 MOVFF 0xfe7,0xfd9 001600 ffd9 001602 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Read in the three I/O ports (A,B,C) and create C:\Projects\UBW\FW\2455\D\user\user.c // a packet to send back with all of values. C:\Projects\UBW\FW\2455\D\user\user.c // Example: "I,143,221,010" C:\Projects\UBW\FW\2455\D\user\user.c // Remember that on UBW 28 pin boards, we only have C:\Projects\UBW\FW\2455\D\user\user.c // Port A bits 0 through 5 C:\Projects\UBW\FW\2455\D\user\user.c // Port B bits 0 through 7 C:\Projects\UBW\FW\2455\D\user\user.c // Port C bits 0,1,2 and 7,8 C:\Projects\UBW\FW\2455\D\user\user.c // And that Port C bits 0,1,2 are used for C:\Projects\UBW\FW\2455\D\user\user.c // User1 LED, User2 LED and Program switch respectively. C:\Projects\UBW\FW\2455\D\user\user.c // The rest will be read in as zeros. C:\Projects\UBW\FW\2455\D\user\user.c void parse_I_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c printf ( C:\Projects\UBW\FW\2455\D\user\user.c 001616 0eb6 MOVLW 0xb6 (rom char*)"I,%03i,%03i,%03i\r\n", C:\Projects\UBW\FW\2455\D\user\user.c 001618 6e2a MOVWF 0x2a,0x0 00161a 0e3e MOVLW 0x3e 00161c 6e2b MOVWF 0x2b,0x0 00161e 6a2c CLRF 0x2c,0x0 001620 c02a MOVFF 0x2a,0xfe6 001622 ffe6 001624 c02b MOVFF 0x2b,0xfe6 001626 ffe6 001628 c02c MOVFF 0x2c,0xfe6 00162a ffe6 001610 5080 MOVF 0x80,0x0,0x0 PORTA, C:\Projects\UBW\FW\2455\D\user\user.c 001612 6ee6 MOVWF 0xe6,0x0 001614 6ae6 CLRF 0xe6,0x0 00160a 5081 MOVF 0x81,0x0,0x0 PORTB, C:\Projects\UBW\FW\2455\D\user\user.c 00160c 6ee6 MOVWF 0xe6,0x0 00160e 6ae6 CLRF 0xe6,0x0 001604 5082 MOVF 0x82,0x0,0x0 PORTC C:\Projects\UBW\FW\2455\D\user\user.c 001606 6ee6 MOVWF 0xe6,0x0 ); C:\Projects\UBW\FW\2455\D\user\user.c 001608 6ae6 CLRF 0xe6,0x0 00162c ec05 CALL 0x420a,0x0 00162e f021 001630 6e2d MOVWF 0x2d,0x0 001632 0e09 MOVLW 0x9 001634 5ee1 SUBWF 0xe1,0x1,0x0 001636 502d MOVF 0x2d,0x0,0x0 001638 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // All we do here is just print out our version number C:\Projects\UBW\FW\2455\D\user\user.c void parse_V_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 00163a 0ed0 MOVLW 0xd0 printf ((rom char *)st_version); C:\Projects\UBW\FW\2455\D\user\user.c 00163c 6e2a MOVWF 0x2a,0x0 00163e 0e44 MOVLW 0x44 001640 6e2b MOVWF 0x2b,0x0 001642 6a2c CLRF 0x2c,0x0 001644 c02a MOVFF 0x2a,0xfe6 001646 ffe6 001648 c02b MOVFF 0x2b,0xfe6 00164a ffe6 00164c c02c MOVFF 0x2c,0xfe6 00164e ffe6 001650 ec05 CALL 0x420a,0x0 001652 f021 001654 52e5 MOVF 0xe5,0x1,0x0 001656 52e5 MOVF 0xe5,0x1,0x0 001658 52e5 MOVF 0xe5,0x1,0x0 00165a 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // A is for read Analog inputs C:\Projects\UBW\FW\2455\D\user\user.c // Just print out the last analog values for each of the C:\Projects\UBW\FW\2455\D\user\user.c // enabled channels. The number of value returned in the C:\Projects\UBW\FW\2455\D\user\user.c // A packet depend upon the number of analog inputs enabled. C:\Projects\UBW\FW\2455\D\user\user.c // The user can enabled any number of analog inputs between C:\Projects\UBW\FW\2455\D\user\user.c // 0 and 12. (none enabled, through all 12 analog inputs enabled). C:\Projects\UBW\FW\2455\D\user\user.c // Returned packet will look like "A,0,0,0,0,0,0" if C:\Projects\UBW\FW\2455\D\user\user.c // six analog inputs are enabled but they are all C:\Projects\UBW\FW\2455\D\user\user.c // grounded. Note that each one is a 10 bit C:\Projects\UBW\FW\2455\D\user\user.c // value, where 0 means the intput was at ground, and C:\Projects\UBW\FW\2455\D\user\user.c // 1024 means it was at +5 V. (Or whatever the USB +5 C:\Projects\UBW\FW\2455\D\user\user.c // pin is at.) C:\Projects\UBW\FW\2455\D\user\user.c 00165c cfd9 MOVFF 0xfd9,0xfe6 void parse_A_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 00165e ffe6 001660 cfe1 MOVFF 0xfe1,0xfd9 001662 ffd9 001664 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c 001666 6adf CLRF 0xdf,0x0 char channel = 0; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Put the beginning of the packet in place C:\Projects\UBW\FW\2455\D\user\user.c 001668 0eb4 MOVLW 0xb4 printf ((rom char *)"A"); C:\Projects\UBW\FW\2455\D\user\user.c 00166a 6e2a MOVWF 0x2a,0x0 00166c 0e3e MOVLW 0x3e 00166e 6e2b MOVWF 0x2b,0x0 001670 6a2c CLRF 0x2c,0x0 001672 c02a MOVFF 0x2a,0xfe6 001674 ffe6 001676 c02b MOVFF 0x2b,0xfe6 001678 ffe6 00167a c02c MOVFF 0x2c,0xfe6 00167c ffe6 00167e ec05 CALL 0x420a,0x0 001680 f021 001682 52e5 MOVF 0xe5,0x1,0x0 001684 52e5 MOVF 0xe5,0x1,0x0 001686 52e5 MOVF 0xe5,0x1,0x0 C:\Projects\UBW\FW\2455\D\user\user.c // Now add each analog value C:\Projects\UBW\FW\2455\D\user\user.c 001688 6adf CLRF 0xdf,0x0 for (channel = 0; channel < AnalogEnable; channel++) C:\Projects\UBW\FW\2455\D\user\user.c 00168a 500c MOVF 0xc,0x0,0x0 00168c 5cdf SUBWF 0xdf,0x0,0x0 00168e e232 BC 0x16f4 0016f0 2adf INCF 0xdf,0x1,0x0 0016f2 d7cb BRA 0x168a { C:\Projects\UBW\FW\2455\D\user\user.c printf( C:\Projects\UBW\FW\2455\D\user\user.c (rom char *)",%04u" C:\Projects\UBW\FW\2455\D\user\user.c 001690 cfdf MOVFF 0xfdf,0x2a ,ISR_A_FIFO[channel][ISR_A_FIFO_out] C:\Projects\UBW\FW\2455\D\user\user.c 001692 f02a 001694 6a2b CLRF 0x2b,0x0 001696 be2a BTFSC 0x2a,0x7,0x0 001698 682b SETF 0x2b,0x0 00169a 0e06 MOVLW 0x6 00169c 022b MULWF 0x2b,0x0 00169e cff3 MOVFF 0xff3,0x2b 0016a0 f02b 0016a2 0e06 MOVLW 0x6 0016a4 022a MULWF 0x2a,0x0 0016a6 cff3 MOVFF 0xff3,0x2a 0016a8 f02a 0016aa 50f4 MOVF 0xf4,0x0,0x0 0016ac 262b ADDWF 0x2b,0x1,0x0 0016ae 0e00 MOVLW 0x0 0016b0 262a ADDWF 0x2a,0x1,0x0 0016b2 0e01 MOVLW 0x1 0016b4 222b ADDWFC 0x2b,0x1,0x0 0016b6 500a MOVF 0xa,0x0,0x0 0016b8 0d02 MULLW 0x2 0016ba 502a MOVF 0x2a,0x0,0x0 0016bc 24f3 ADDWF 0xf3,0x0,0x0 0016be 6ee9 MOVWF 0xe9,0x0 0016c0 502b MOVF 0x2b,0x0,0x0 0016c2 20f4 ADDWFC 0xf4,0x0,0x0 0016c4 6eea MOVWF 0xea,0x0 0016ce 0eae MOVLW 0xae 0016d0 6e2c MOVWF 0x2c,0x0 0016d2 0e3e MOVLW 0x3e 0016d4 6e2d MOVWF 0x2d,0x0 0016d6 6a2e CLRF 0x2e,0x0 0016d8 c02c MOVFF 0x2c,0xfe6 0016da ffe6 0016dc c02d MOVFF 0x2d,0xfe6 0016de ffe6 0016e0 c02e MOVFF 0x2e,0xfe6 0016e2 ffe6 0016c6 cfee MOVFF 0xfee,0xfe6 ); C:\Projects\UBW\FW\2455\D\user\user.c 0016c8 ffe6 0016ca cfef MOVFF 0xfef,0xfe6 0016cc ffe6 0016e4 ec05 CALL 0x420a,0x0 0016e6 f021 0016e8 6e2f MOVWF 0x2f,0x0 0016ea 0e05 MOVLW 0x5 0016ec 5ee1 SUBWF 0xe1,0x1,0x0 0016ee 502f MOVF 0x2f,0x0,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Add \r\n and terminating zero. C:\Projects\UBW\FW\2455\D\user\user.c 0016f4 0ecd MOVLW 0xcd printf ((rom char *)st_LFCR); C:\Projects\UBW\FW\2455\D\user\user.c 0016f6 6e2a MOVWF 0x2a,0x0 0016f8 0e44 MOVLW 0x44 0016fa 6e2b MOVWF 0x2b,0x0 0016fc 6a2c CLRF 0x2c,0x0 0016fe c02a MOVFF 0x2a,0xfe6 001700 ffe6 001702 c02b MOVFF 0x2b,0xfe6 001704 ffe6 001706 c02c MOVFF 0x2c,0xfe6 001708 ffe6 00170a ec05 CALL 0x420a,0x0 00170c f021 00170e 52e5 MOVF 0xe5,0x1,0x0 001710 52e5 MOVF 0xe5,0x1,0x0 001712 52e5 MOVF 0xe5,0x1,0x0 001714 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001716 52e5 MOVF 0xe5,0x1,0x0 001718 cfe7 MOVFF 0xfe7,0xfd9 00171a ffd9 00171c 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // MW is for Memory Write C:\Projects\UBW\FW\2455\D\user\user.c // "MW,," C:\Projects\UBW\FW\2455\D\user\user.c // is a decimal value between 0 and 4096 indicating the RAM address to write to C:\Projects\UBW\FW\2455\D\user\user.c // is a decimal value between 0 and 255 that is the value to write C:\Projects\UBW\FW\2455\D\user\user.c 00171e cfd9 MOVFF 0xfd9,0xfe6 void parse_MW_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 001720 ffe6 001722 cfe1 MOVFF 0xfe1,0xfd9 001724 ffd9 001726 0e03 MOVLW 0x3 001728 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned int location; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char value; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 00172a 0e03 MOVLW 0x3 location = extract_number (kUINT); C:\Projects\UBW\FW\2455\D\user\user.c 00172c 6ee6 MOVWF 0xe6,0x0 00172e ecc5 CALL 0x218a,0x0 001730 f010 001732 52e5 MOVF 0xe5,0x1,0x0 001734 c01d MOVFF 0x1d,0xfde 001736 ffde 001738 c01e MOVFF 0x1e,0xfdd 00173a ffdd 00173c 0e01 MOVLW 0x1 value = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 00173e 6ee6 MOVWF 0xe6,0x0 001740 ecc5 CALL 0x218a,0x0 001742 f010 001744 52e5 MOVF 0xe5,0x1,0x0 001746 0e02 MOVLW 0x2 001748 c01d MOVFF 0x1d,0xfdb 00174a ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 00174c 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 00174e e001 BZ 0x1752 { C:\Projects\UBW\FW\2455\D\user\user.c 001750 d011 BRA 0x1774 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c // Limit check the address and write the byte in C:\Projects\UBW\FW\2455\D\user\user.c 001752 cfde MOVFF 0xfde,0x2a if (location < 4096) C:\Projects\UBW\FW\2455\D\user\user.c 001754 f02a 001756 cfdd MOVFF 0xfdd,0x2b 001758 f02b 00175a 0e00 MOVLW 0x0 00175c 5c2a SUBWF 0x2a,0x0,0x0 00175e 0e10 MOVLW 0x10 001760 582b SUBWFB 0x2b,0x0,0x0 001762 e207 BC 0x1772 { C:\Projects\UBW\FW\2455\D\user\user.c 001764 cfde MOVFF 0xfde,0xfe9 *((unsigned char *)location) = value; C:\Projects\UBW\FW\2455\D\user\user.c 001766 ffe9 001768 cfdd MOVFF 0xfdd,0xfea 00176a ffea 00176c 0e02 MOVLW 0x2 00176e cfdb MOVFF 0xfdb,0xfef 001770 ffef } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001772 de1f RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 001774 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 001776 5ce1 SUBWF 0xe1,0x0,0x0 001778 e202 BC 0x177e 00177a 6ae1 CLRF 0xe1,0x0 00177c 52e5 MOVF 0xe5,0x1,0x0 00177e 6ee1 MOVWF 0xe1,0x0 001780 52e5 MOVF 0xe5,0x1,0x0 001782 cfe7 MOVFF 0xfe7,0xfd9 001784 ffd9 001786 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // MR is for Memory Read C:\Projects\UBW\FW\2455\D\user\user.c // "MW," C:\Projects\UBW\FW\2455\D\user\user.c // is a decimal value between 0 and 4096 indicating the RAM address to read from C:\Projects\UBW\FW\2455\D\user\user.c // The UBW will then send a "MR," packet back to the PC C:\Projects\UBW\FW\2455\D\user\user.c // where is the byte value read from the address C:\Projects\UBW\FW\2455\D\user\user.c 001788 cfd9 MOVFF 0xfd9,0xfe6 void parse_MR_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 00178a ffe6 00178c cfe1 MOVFF 0xfe1,0xfd9 00178e ffd9 001790 0e03 MOVLW 0x3 001792 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned int location; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char value; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001794 0e03 MOVLW 0x3 location = extract_number (kUINT); C:\Projects\UBW\FW\2455\D\user\user.c 001796 6ee6 MOVWF 0xe6,0x0 001798 ecc5 CALL 0x218a,0x0 00179a f010 00179c 52e5 MOVF 0xe5,0x1,0x0 00179e c01d MOVFF 0x1d,0xfde 0017a0 ffde 0017a2 c01e MOVFF 0x1e,0xfdd 0017a4 ffdd C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 0017a6 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 0017a8 e001 BZ 0x17ac { C:\Projects\UBW\FW\2455\D\user\user.c 0017aa d025 BRA 0x17f6 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Limit check the address and write the byte in C:\Projects\UBW\FW\2455\D\user\user.c 0017ac cfde MOVFF 0xfde,0x2a if (location < 4096) C:\Projects\UBW\FW\2455\D\user\user.c 0017ae f02a 0017b0 cfdd MOVFF 0xfdd,0x2b 0017b2 f02b 0017b4 0e00 MOVLW 0x0 0017b6 5c2a SUBWF 0x2a,0x0,0x0 0017b8 0e10 MOVLW 0x10 0017ba 582b SUBWFB 0x2b,0x0,0x0 0017bc e207 BC 0x17cc { C:\Projects\UBW\FW\2455\D\user\user.c 0017be cfde MOVFF 0xfde,0xfe9 value = *((unsigned char *)location); C:\Projects\UBW\FW\2455\D\user\user.c 0017c0 ffe9 0017c2 cfdd MOVFF 0xfdd,0xfea 0017c4 ffea 0017c6 0e02 MOVLW 0x2 0017c8 cfef MOVFF 0xfef,0xfdb 0017ca ffdb } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Now send back the MR packet C:\Projects\UBW\FW\2455\D\user\user.c printf ( C:\Projects\UBW\FW\2455\D\user\user.c (rom char *)"MR,%03u\r\n" C:\Projects\UBW\FW\2455\D\user\user.c 0017d4 0ea4 MOVLW 0xa4 ,value C:\Projects\UBW\FW\2455\D\user\user.c 0017d6 6e2a MOVWF 0x2a,0x0 0017d8 0e3e MOVLW 0x3e 0017da 6e2b MOVWF 0x2b,0x0 0017dc 6a2c CLRF 0x2c,0x0 0017de c02a MOVFF 0x2a,0xfe6 0017e0 ffe6 0017e2 c02b MOVFF 0x2b,0xfe6 0017e4 ffe6 0017e6 c02c MOVFF 0x2c,0xfe6 0017e8 ffe6 0017cc 0e02 MOVLW 0x2 ); C:\Projects\UBW\FW\2455\D\user\user.c 0017ce cfdb MOVFF 0xfdb,0xfe6 0017d0 ffe6 0017d2 6ae6 CLRF 0xe6,0x0 0017ea ec05 CALL 0x420a,0x0 0017ec f021 0017ee 6e2d MOVWF 0x2d,0x0 0017f0 0e05 MOVLW 0x5 0017f2 5ee1 SUBWF 0xe1,0x1,0x0 0017f4 502d MOVF 0x2d,0x0,0x0 0017f6 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 0017f8 5ce1 SUBWF 0xe1,0x0,0x0 0017fa e202 BC 0x1800 0017fc 6ae1 CLRF 0xe1,0x0 0017fe 52e5 MOVF 0xe5,0x1,0x0 001800 6ee1 MOVWF 0xe1,0x0 001802 52e5 MOVF 0xe5,0x1,0x0 001804 cfe7 MOVFF 0xfe7,0xfd9 001806 ffd9 001808 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // PD is for Pin Direction C:\Projects\UBW\FW\2455\D\user\user.c // "PD,,," C:\Projects\UBW\FW\2455\D\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\2455\D\user\user.c // is a number between 0 and 7 and indicates which pin to change direction on C:\Projects\UBW\FW\2455\D\user\user.c // is "1" for input, "0" for output C:\Projects\UBW\FW\2455\D\user\user.c 00180a cfd9 MOVFF 0xfd9,0xfe6 void parse_PD_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 00180c ffe6 00180e cfe1 MOVFF 0xfe1,0xfd9 001810 ffd9 001812 0e03 MOVLW 0x3 001814 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char port; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char pin; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char direction; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001816 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001818 6ee6 MOVWF 0xe6,0x0 00181a ecc5 CALL 0x218a,0x0 00181c f010 00181e 52e5 MOVF 0xe5,0x1,0x0 001820 501d MOVF 0x1d,0x0,0x0 001822 6edf MOVWF 0xdf,0x0 001824 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001826 6ee6 MOVWF 0xe6,0x0 001828 ecc5 CALL 0x218a,0x0 00182a f010 00182c 52e5 MOVF 0xe5,0x1,0x0 00182e 0e01 MOVLW 0x1 001830 c01d MOVFF 0x1d,0xfdb 001832 ffdb 001834 0e01 MOVLW 0x1 direction = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001836 6ee6 MOVWF 0xe6,0x0 001838 ecc5 CALL 0x218a,0x0 00183a f010 00183c 52e5 MOVF 0xe5,0x1,0x0 00183e 0e02 MOVLW 0x2 001840 c01d MOVFF 0x1d,0xfdb 001842 ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 001844 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001846 e001 BZ 0x184a { C:\Projects\UBW\FW\2455\D\user\user.c 001848 d072 BRA 0x192e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Limit check the parameters C:\Projects\UBW\FW\2455\D\user\user.c 00184a 0e02 MOVLW 0x2 if (direction > 1) C:\Projects\UBW\FW\2455\D\user\user.c 00184c 50db MOVF 0xdb,0x0,0x0 00184e 0801 SUBLW 0x1 001850 e202 BC 0x1856 { C:\Projects\UBW\FW\2455\D\user\user.c 001852 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001854 d06c BRA 0x192e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001856 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\2455\D\user\user.c 001858 50db MOVF 0xdb,0x0,0x0 00185a 0807 SUBLW 0x7 00185c e202 BC 0x1862 { C:\Projects\UBW\FW\2455\D\user\user.c 00185e 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001860 d066 BRA 0x192e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001862 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001864 6e2a MOVWF 0x2a,0x0 001866 50df MOVF 0xdf,0x0,0x0 001868 5c2a SUBWF 0x2a,0x0,0x0 00186a e11c BNZ 0x18a4 { C:\Projects\UBW\FW\2455\D\user\user.c 00186c 0e02 MOVLW 0x2 if (0 == direction) C:\Projects\UBW\FW\2455\D\user\user.c 00186e 50db MOVF 0xdb,0x0,0x0 001870 e10d BNZ 0x188c { C:\Projects\UBW\FW\2455\D\user\user.c 001872 0e01 MOVLW 0x1 bitclr (DDRA, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001874 6ef3 MOVWF 0xf3,0x0 001876 0e01 MOVLW 0x1 001878 50db MOVF 0xdb,0x0,0x0 00187a e004 BZ 0x1884 00187c 90d8 BCF 0xd8,0x0,0x0 00187e 36f3 RLCF 0xf3,0x1,0x0 001880 06e8 DECF 0xe8,0x1,0x0 001882 e1fc BNZ 0x187c 001884 50f3 MOVF 0xf3,0x0,0x0 001886 1ce8 COMF 0xe8,0x0,0x0 001888 1692 ANDWF 0x92,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 00188a d00b BRA 0x18a2 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 00188c 0e01 MOVLW 0x1 bitset (DDRA, pin); C:\Projects\UBW\FW\2455\D\user\user.c 00188e 6ef3 MOVWF 0xf3,0x0 001890 0e01 MOVLW 0x1 001892 50db MOVF 0xdb,0x0,0x0 001894 e004 BZ 0x189e 001896 90d8 BCF 0xd8,0x0,0x0 001898 36f3 RLCF 0xf3,0x1,0x0 00189a 06e8 DECF 0xe8,0x1,0x0 00189c e1fc BNZ 0x1896 00189e 50f3 MOVF 0xf3,0x0,0x0 0018a0 1292 IORWF 0x92,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 0018a2 d044 BRA 0x192c else if ('B' == port) C:\Projects\UBW\FW\2455\D\user\user.c 0018a4 0e42 MOVLW 0x42 0018a6 6e2a MOVWF 0x2a,0x0 0018a8 50df MOVF 0xdf,0x0,0x0 0018aa 5c2a SUBWF 0x2a,0x0,0x0 0018ac e11c BNZ 0x18e6 { C:\Projects\UBW\FW\2455\D\user\user.c 0018ae 0e02 MOVLW 0x2 if (0 == direction) C:\Projects\UBW\FW\2455\D\user\user.c 0018b0 50db MOVF 0xdb,0x0,0x0 0018b2 e10d BNZ 0x18ce { C:\Projects\UBW\FW\2455\D\user\user.c 0018b4 0e01 MOVLW 0x1 bitclr (DDRB, pin); C:\Projects\UBW\FW\2455\D\user\user.c 0018b6 6ef3 MOVWF 0xf3,0x0 0018b8 0e01 MOVLW 0x1 0018ba 50db MOVF 0xdb,0x0,0x0 0018bc e004 BZ 0x18c6 0018be 90d8 BCF 0xd8,0x0,0x0 0018c0 36f3 RLCF 0xf3,0x1,0x0 0018c2 06e8 DECF 0xe8,0x1,0x0 0018c4 e1fc BNZ 0x18be 0018c6 50f3 MOVF 0xf3,0x0,0x0 0018c8 1ce8 COMF 0xe8,0x0,0x0 0018ca 1693 ANDWF 0x93,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 0018cc d00b BRA 0x18e4 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 0018ce 0e01 MOVLW 0x1 bitset (DDRB, pin); C:\Projects\UBW\FW\2455\D\user\user.c 0018d0 6ef3 MOVWF 0xf3,0x0 0018d2 0e01 MOVLW 0x1 0018d4 50db MOVF 0xdb,0x0,0x0 0018d6 e004 BZ 0x18e0 0018d8 90d8 BCF 0xd8,0x0,0x0 0018da 36f3 RLCF 0xf3,0x1,0x0 0018dc 06e8 DECF 0xe8,0x1,0x0 0018de e1fc BNZ 0x18d8 0018e0 50f3 MOVF 0xf3,0x0,0x0 0018e2 1293 IORWF 0x93,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 0018e4 d023 BRA 0x192c else if ('C' == port) C:\Projects\UBW\FW\2455\D\user\user.c 0018e6 0e43 MOVLW 0x43 0018e8 6e2a MOVWF 0x2a,0x0 0018ea 50df MOVF 0xdf,0x0,0x0 0018ec 5c2a SUBWF 0x2a,0x0,0x0 0018ee e11c BNZ 0x1928 { C:\Projects\UBW\FW\2455\D\user\user.c 0018f0 0e02 MOVLW 0x2 if (0 == direction) C:\Projects\UBW\FW\2455\D\user\user.c 0018f2 50db MOVF 0xdb,0x0,0x0 0018f4 e10d BNZ 0x1910 { C:\Projects\UBW\FW\2455\D\user\user.c 0018f6 0e01 MOVLW 0x1 bitclr (DDRC, pin); C:\Projects\UBW\FW\2455\D\user\user.c 0018f8 6ef3 MOVWF 0xf3,0x0 0018fa 0e01 MOVLW 0x1 0018fc 50db MOVF 0xdb,0x0,0x0 0018fe e004 BZ 0x1908 001900 90d8 BCF 0xd8,0x0,0x0 001902 36f3 RLCF 0xf3,0x1,0x0 001904 06e8 DECF 0xe8,0x1,0x0 001906 e1fc BNZ 0x1900 001908 50f3 MOVF 0xf3,0x0,0x0 00190a 1ce8 COMF 0xe8,0x0,0x0 00190c 1694 ANDWF 0x94,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 00190e d00b BRA 0x1926 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001910 0e01 MOVLW 0x1 bitset (DDRC, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001912 6ef3 MOVWF 0xf3,0x0 001914 0e01 MOVLW 0x1 001916 50db MOVF 0xdb,0x0,0x0 001918 e004 BZ 0x1922 00191a 90d8 BCF 0xd8,0x0,0x0 00191c 36f3 RLCF 0xf3,0x1,0x0 00191e 06e8 DECF 0xe8,0x1,0x0 001920 e1fc BNZ 0x191a 001922 50f3 MOVF 0xf3,0x0,0x0 001924 1294 IORWF 0x94,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001926 d002 BRA 0x192c else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001928 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 00192a d001 BRA 0x192e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 00192c dd42 RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 00192e 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 001930 5ce1 SUBWF 0xe1,0x0,0x0 001932 e202 BC 0x1938 001934 6ae1 CLRF 0xe1,0x0 001936 52e5 MOVF 0xe5,0x1,0x0 001938 6ee1 MOVWF 0xe1,0x0 00193a 52e5 MOVF 0xe5,0x1,0x0 00193c cfe7 MOVFF 0xfe7,0xfd9 00193e ffd9 001940 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // PI is for Pin Input C:\Projects\UBW\FW\2455\D\user\user.c // "PI,," C:\Projects\UBW\FW\2455\D\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\2455\D\user\user.c // is a number between 0 and 7 and indicates which pin to read C:\Projects\UBW\FW\2455\D\user\user.c // The command returns a "PI," packet, C:\Projects\UBW\FW\2455\D\user\user.c // where is the value (0 or 1 for digital, 0 to 1024 for Analog) C:\Projects\UBW\FW\2455\D\user\user.c // value for that pin. C:\Projects\UBW\FW\2455\D\user\user.c 001942 cfd9 MOVFF 0xfd9,0xfe6 void parse_PI_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 001944 ffe6 001946 cfe1 MOVFF 0xfe1,0xfd9 001948 ffd9 00194a 0e03 MOVLW 0x3 00194c 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char port; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char pin; C:\Projects\UBW\FW\2455\D\user\user.c 00194e 0e02 MOVLW 0x2 unsigned char value = 0; C:\Projects\UBW\FW\2455\D\user\user.c 001950 6adb CLRF 0xdb,0x0 C:\Projects\UBW\FW\2455\D\user\user.c 001952 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001954 6ee6 MOVWF 0xe6,0x0 001956 ecc5 CALL 0x218a,0x0 001958 f010 00195a 52e5 MOVF 0xe5,0x1,0x0 00195c 501d MOVF 0x1d,0x0,0x0 00195e 6edf MOVWF 0xdf,0x0 001960 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001962 6ee6 MOVWF 0xe6,0x0 001964 ecc5 CALL 0x218a,0x0 001966 f010 001968 52e5 MOVF 0xe5,0x1,0x0 00196a 0e01 MOVLW 0x1 00196c c01d MOVFF 0x1d,0xfdb 00196e ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 001970 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001972 e001 BZ 0x1976 { C:\Projects\UBW\FW\2455\D\user\user.c 001974 d05c BRA 0x1a2e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Limit check the parameters C:\Projects\UBW\FW\2455\D\user\user.c 001976 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\2455\D\user\user.c 001978 50db MOVF 0xdb,0x0,0x0 00197a 0807 SUBLW 0x7 00197c e202 BC 0x1982 { C:\Projects\UBW\FW\2455\D\user\user.c 00197e 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001980 d056 BRA 0x1a2e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Then test the bit in question based upon port C:\Projects\UBW\FW\2455\D\user\user.c 001982 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001984 6e2a MOVWF 0x2a,0x0 001986 50df MOVF 0xdf,0x0,0x0 001988 5c2a SUBWF 0x2a,0x0,0x0 00198a e110 BNZ 0x19ac { C:\Projects\UBW\FW\2455\D\user\user.c 00198c 0e01 MOVLW 0x1 value = bittst (PORTA, pin); C:\Projects\UBW\FW\2455\D\user\user.c 00198e 6ef3 MOVWF 0xf3,0x0 001990 0e01 MOVLW 0x1 001992 50db MOVF 0xdb,0x0,0x0 001994 e004 BZ 0x199e 001996 90d8 BCF 0xd8,0x0,0x0 001998 36f3 RLCF 0xf3,0x1,0x0 00199a 06e8 DECF 0xe8,0x1,0x0 00199c e1fc BNZ 0x1996 00199e 50f3 MOVF 0xf3,0x0,0x0 0019a0 1480 ANDWF 0x80,0x0,0x0 0019a2 6ee7 MOVWF 0xe7,0x0 0019a4 0e02 MOVLW 0x2 0019a6 cfe7 MOVFF 0xfe7,0xfdb 0019a8 ffdb } C:\Projects\UBW\FW\2455\D\user\user.c 0019aa d02c BRA 0x1a04 else if ('B' == port) C:\Projects\UBW\FW\2455\D\user\user.c 0019ac 0e42 MOVLW 0x42 0019ae 6e2a MOVWF 0x2a,0x0 0019b0 50df MOVF 0xdf,0x0,0x0 0019b2 5c2a SUBWF 0x2a,0x0,0x0 0019b4 e110 BNZ 0x19d6 { C:\Projects\UBW\FW\2455\D\user\user.c 0019b6 0e01 MOVLW 0x1 value = bittst (PORTB, pin); C:\Projects\UBW\FW\2455\D\user\user.c 0019b8 6ef3 MOVWF 0xf3,0x0 0019ba 0e01 MOVLW 0x1 0019bc 50db MOVF 0xdb,0x0,0x0 0019be e004 BZ 0x19c8 0019c0 90d8 BCF 0xd8,0x0,0x0 0019c2 36f3 RLCF 0xf3,0x1,0x0 0019c4 06e8 DECF 0xe8,0x1,0x0 0019c6 e1fc BNZ 0x19c0 0019c8 50f3 MOVF 0xf3,0x0,0x0 0019ca 1481 ANDWF 0x81,0x0,0x0 0019cc 6ee7 MOVWF 0xe7,0x0 0019ce 0e02 MOVLW 0x2 0019d0 cfe7 MOVFF 0xfe7,0xfdb 0019d2 ffdb } C:\Projects\UBW\FW\2455\D\user\user.c 0019d4 d017 BRA 0x1a04 else if ('C' == port) C:\Projects\UBW\FW\2455\D\user\user.c 0019d6 0e43 MOVLW 0x43 0019d8 6e2a MOVWF 0x2a,0x0 0019da 50df MOVF 0xdf,0x0,0x0 0019dc 5c2a SUBWF 0x2a,0x0,0x0 0019de e110 BNZ 0x1a00 { C:\Projects\UBW\FW\2455\D\user\user.c 0019e0 0e01 MOVLW 0x1 value = bittst (PORTC, pin); C:\Projects\UBW\FW\2455\D\user\user.c 0019e2 6ef3 MOVWF 0xf3,0x0 0019e4 0e01 MOVLW 0x1 0019e6 50db MOVF 0xdb,0x0,0x0 0019e8 e004 BZ 0x19f2 0019ea 90d8 BCF 0xd8,0x0,0x0 0019ec 36f3 RLCF 0xf3,0x1,0x0 0019ee 06e8 DECF 0xe8,0x1,0x0 0019f0 e1fc BNZ 0x19ea 0019f2 50f3 MOVF 0xf3,0x0,0x0 0019f4 1482 ANDWF 0x82,0x0,0x0 0019f6 6ee7 MOVWF 0xe7,0x0 0019f8 0e02 MOVLW 0x2 0019fa cfe7 MOVFF 0xfe7,0xfdb 0019fc ffdb } C:\Projects\UBW\FW\2455\D\user\user.c 0019fe d002 BRA 0x1a04 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001a00 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001a02 d015 BRA 0x1a2e return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Now send back our response C:\Projects\UBW\FW\2455\D\user\user.c printf( C:\Projects\UBW\FW\2455\D\user\user.c (rom char *)"PI,%1u\r\n" C:\Projects\UBW\FW\2455\D\user\user.c 001a0c 0e9b MOVLW 0x9b ,value C:\Projects\UBW\FW\2455\D\user\user.c 001a0e 6e2a MOVWF 0x2a,0x0 001a10 0e3e MOVLW 0x3e 001a12 6e2b MOVWF 0x2b,0x0 001a14 6a2c CLRF 0x2c,0x0 001a16 c02a MOVFF 0x2a,0xfe6 001a18 ffe6 001a1a c02b MOVFF 0x2b,0xfe6 001a1c ffe6 001a1e c02c MOVFF 0x2c,0xfe6 001a20 ffe6 001a04 0e02 MOVLW 0x2 ); C:\Projects\UBW\FW\2455\D\user\user.c 001a06 cfdb MOVFF 0xfdb,0xfe6 001a08 ffe6 001a0a 6ae6 CLRF 0xe6,0x0 001a22 ec05 CALL 0x420a,0x0 001a24 f021 001a26 6e2d MOVWF 0x2d,0x0 001a28 0e05 MOVLW 0x5 001a2a 5ee1 SUBWF 0xe1,0x1,0x0 001a2c 502d MOVF 0x2d,0x0,0x0 001a2e 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 001a30 5ce1 SUBWF 0xe1,0x0,0x0 001a32 e202 BC 0x1a38 001a34 6ae1 CLRF 0xe1,0x0 001a36 52e5 MOVF 0xe5,0x1,0x0 001a38 6ee1 MOVWF 0xe1,0x0 001a3a 52e5 MOVF 0xe5,0x1,0x0 001a3c cfe7 MOVFF 0xfe7,0xfd9 001a3e ffd9 001a40 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // PO is for Pin Output C:\Projects\UBW\FW\2455\D\user\user.c // "PO,,," C:\Projects\UBW\FW\2455\D\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\2455\D\user\user.c // is a number between 0 and 7 and indicates which pin to write out the value to C:\Projects\UBW\FW\2455\D\user\user.c // is "1" or "0" and indicates the state to change the pin to C:\Projects\UBW\FW\2455\D\user\user.c 001a42 cfd9 MOVFF 0xfd9,0xfe6 void parse_PO_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 001a44 ffe6 001a46 cfe1 MOVFF 0xfe1,0xfd9 001a48 ffd9 001a4a 0e03 MOVLW 0x3 001a4c 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char port; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char pin; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char value; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001a4e 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001a50 6ee6 MOVWF 0xe6,0x0 001a52 db9b RCALL 0x218a 001a54 52e5 MOVF 0xe5,0x1,0x0 001a56 501d MOVF 0x1d,0x0,0x0 001a58 6edf MOVWF 0xdf,0x0 001a5a 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001a5c 6ee6 MOVWF 0xe6,0x0 001a5e db95 RCALL 0x218a 001a60 52e5 MOVF 0xe5,0x1,0x0 001a62 0e01 MOVLW 0x1 001a64 c01d MOVFF 0x1d,0xfdb 001a66 ffdb 001a68 0e01 MOVLW 0x1 value = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001a6a 6ee6 MOVWF 0xe6,0x0 001a6c db8e RCALL 0x218a 001a6e 52e5 MOVF 0xe5,0x1,0x0 001a70 0e02 MOVLW 0x2 001a72 c01d MOVFF 0x1d,0xfdb 001a74 ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 001a76 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001a78 e001 BZ 0x1a7c { C:\Projects\UBW\FW\2455\D\user\user.c 001a7a d072 BRA 0x1b60 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Limit check the parameters C:\Projects\UBW\FW\2455\D\user\user.c 001a7c 0e02 MOVLW 0x2 if (value > 1) C:\Projects\UBW\FW\2455\D\user\user.c 001a7e 50db MOVF 0xdb,0x0,0x0 001a80 0801 SUBLW 0x1 001a82 e202 BC 0x1a88 { C:\Projects\UBW\FW\2455\D\user\user.c 001a84 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001a86 d06c BRA 0x1b60 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001a88 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\2455\D\user\user.c 001a8a 50db MOVF 0xdb,0x0,0x0 001a8c 0807 SUBLW 0x7 001a8e e202 BC 0x1a94 { C:\Projects\UBW\FW\2455\D\user\user.c 001a90 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001a92 d066 BRA 0x1b60 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001a94 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001a96 6e2a MOVWF 0x2a,0x0 001a98 50df MOVF 0xdf,0x0,0x0 001a9a 5c2a SUBWF 0x2a,0x0,0x0 001a9c e11c BNZ 0x1ad6 { C:\Projects\UBW\FW\2455\D\user\user.c 001a9e 0e02 MOVLW 0x2 if (0 == value) C:\Projects\UBW\FW\2455\D\user\user.c 001aa0 50db MOVF 0xdb,0x0,0x0 001aa2 e10d BNZ 0x1abe { C:\Projects\UBW\FW\2455\D\user\user.c 001aa4 0e01 MOVLW 0x1 bitclr (LATA, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001aa6 6ef3 MOVWF 0xf3,0x0 001aa8 0e01 MOVLW 0x1 001aaa 50db MOVF 0xdb,0x0,0x0 001aac e004 BZ 0x1ab6 001aae 90d8 BCF 0xd8,0x0,0x0 001ab0 36f3 RLCF 0xf3,0x1,0x0 001ab2 06e8 DECF 0xe8,0x1,0x0 001ab4 e1fc BNZ 0x1aae 001ab6 50f3 MOVF 0xf3,0x0,0x0 001ab8 1ce8 COMF 0xe8,0x0,0x0 001aba 1689 ANDWF 0x89,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001abc d00b BRA 0x1ad4 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001abe 0e01 MOVLW 0x1 bitset (LATA, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001ac0 6ef3 MOVWF 0xf3,0x0 001ac2 0e01 MOVLW 0x1 001ac4 50db MOVF 0xdb,0x0,0x0 001ac6 e004 BZ 0x1ad0 001ac8 90d8 BCF 0xd8,0x0,0x0 001aca 36f3 RLCF 0xf3,0x1,0x0 001acc 06e8 DECF 0xe8,0x1,0x0 001ace e1fc BNZ 0x1ac8 001ad0 50f3 MOVF 0xf3,0x0,0x0 001ad2 1289 IORWF 0x89,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001ad4 d044 BRA 0x1b5e else if ('B' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001ad6 0e42 MOVLW 0x42 001ad8 6e2a MOVWF 0x2a,0x0 001ada 50df MOVF 0xdf,0x0,0x0 001adc 5c2a SUBWF 0x2a,0x0,0x0 001ade e11c BNZ 0x1b18 { C:\Projects\UBW\FW\2455\D\user\user.c 001ae0 0e02 MOVLW 0x2 if (0 == value) C:\Projects\UBW\FW\2455\D\user\user.c 001ae2 50db MOVF 0xdb,0x0,0x0 001ae4 e10d BNZ 0x1b00 { C:\Projects\UBW\FW\2455\D\user\user.c 001ae6 0e01 MOVLW 0x1 bitclr (LATB, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001ae8 6ef3 MOVWF 0xf3,0x0 001aea 0e01 MOVLW 0x1 001aec 50db MOVF 0xdb,0x0,0x0 001aee e004 BZ 0x1af8 001af0 90d8 BCF 0xd8,0x0,0x0 001af2 36f3 RLCF 0xf3,0x1,0x0 001af4 06e8 DECF 0xe8,0x1,0x0 001af6 e1fc BNZ 0x1af0 001af8 50f3 MOVF 0xf3,0x0,0x0 001afa 1ce8 COMF 0xe8,0x0,0x0 001afc 168a ANDWF 0x8a,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001afe d00b BRA 0x1b16 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001b00 0e01 MOVLW 0x1 bitset (LATB, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001b02 6ef3 MOVWF 0xf3,0x0 001b04 0e01 MOVLW 0x1 001b06 50db MOVF 0xdb,0x0,0x0 001b08 e004 BZ 0x1b12 001b0a 90d8 BCF 0xd8,0x0,0x0 001b0c 36f3 RLCF 0xf3,0x1,0x0 001b0e 06e8 DECF 0xe8,0x1,0x0 001b10 e1fc BNZ 0x1b0a 001b12 50f3 MOVF 0xf3,0x0,0x0 001b14 128a IORWF 0x8a,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001b16 d023 BRA 0x1b5e else if ('C' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001b18 0e43 MOVLW 0x43 001b1a 6e2a MOVWF 0x2a,0x0 001b1c 50df MOVF 0xdf,0x0,0x0 001b1e 5c2a SUBWF 0x2a,0x0,0x0 001b20 e11c BNZ 0x1b5a { C:\Projects\UBW\FW\2455\D\user\user.c 001b22 0e02 MOVLW 0x2 if (0 == value) C:\Projects\UBW\FW\2455\D\user\user.c 001b24 50db MOVF 0xdb,0x0,0x0 001b26 e10d BNZ 0x1b42 { C:\Projects\UBW\FW\2455\D\user\user.c 001b28 0e01 MOVLW 0x1 bitclr (LATC, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001b2a 6ef3 MOVWF 0xf3,0x0 001b2c 0e01 MOVLW 0x1 001b2e 50db MOVF 0xdb,0x0,0x0 001b30 e004 BZ 0x1b3a 001b32 90d8 BCF 0xd8,0x0,0x0 001b34 36f3 RLCF 0xf3,0x1,0x0 001b36 06e8 DECF 0xe8,0x1,0x0 001b38 e1fc BNZ 0x1b32 001b3a 50f3 MOVF 0xf3,0x0,0x0 001b3c 1ce8 COMF 0xe8,0x0,0x0 001b3e 168b ANDWF 0x8b,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001b40 d00b BRA 0x1b58 else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001b42 0e01 MOVLW 0x1 bitset (LATC, pin); C:\Projects\UBW\FW\2455\D\user\user.c 001b44 6ef3 MOVWF 0xf3,0x0 001b46 0e01 MOVLW 0x1 001b48 50db MOVF 0xdb,0x0,0x0 001b4a e004 BZ 0x1b54 001b4c 90d8 BCF 0xd8,0x0,0x0 001b4e 36f3 RLCF 0xf3,0x1,0x0 001b50 06e8 DECF 0xe8,0x1,0x0 001b52 e1fc BNZ 0x1b4c 001b54 50f3 MOVF 0xf3,0x0,0x0 001b56 128b IORWF 0x8b,0x1,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001b58 d002 BRA 0x1b5e else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001b5a 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001b5c d001 BRA 0x1b60 return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001b5e dc29 RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 001b60 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\2455\D\user\user.c 001b62 5ce1 SUBWF 0xe1,0x0,0x0 001b64 e202 BC 0x1b6a 001b66 6ae1 CLRF 0xe1,0x0 001b68 52e5 MOVF 0xe5,0x1,0x0 001b6a 6ee1 MOVWF 0xe1,0x0 001b6c 52e5 MOVF 0xe5,0x1,0x0 001b6e cfe7 MOVFF 0xfe7,0xfd9 001b70 ffd9 001b72 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // TX is for Serial Transmit C:\Projects\UBW\FW\2455\D\user\user.c // "TX,," C:\Projects\UBW\FW\2455\D\user\user.c // is a count of the number of bytes in the field. C:\Projects\UBW\FW\2455\D\user\user.c // It must never be larger than the number of bytes that are currently free in the C:\Projects\UBW\FW\2455\D\user\user.c // software TX buffer or some data will get lost. C:\Projects\UBW\FW\2455\D\user\user.c // are the bytes that you want the UBW to send. It will store them C:\Projects\UBW\FW\2455\D\user\user.c // in its software TX buffer until there is time to send them out the TX pin. C:\Projects\UBW\FW\2455\D\user\user.c // If you send in "0" for a C:\Projects\UBW\FW\2455\D\user\user.c // then the UBW will send back a "TX," packet, C:\Projects\UBW\FW\2455\D\user\user.c // where is the number of bytes currently available in the C:\Projects\UBW\FW\2455\D\user\user.c // software TX buffer. C:\Projects\UBW\FW\2455\D\user\user.c void parse_TX_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001b74 dc1e RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 001b76 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // RX is for Serial Receive C:\Projects\UBW\FW\2455\D\user\user.c // "RX," C:\Projects\UBW\FW\2455\D\user\user.c // is the maximum number of characters that you want the UBW to send C:\Projects\UBW\FW\2455\D\user\user.c // back to you in the RX packet. If you use "0" for then the UBW C:\Projects\UBW\FW\2455\D\user\user.c // will just send you the current number of bytes in it's RX buffer, and if C:\Projects\UBW\FW\2455\D\user\user.c // there have been any buffer overruns since the last time a of C:\Projects\UBW\FW\2455\D\user\user.c // "0" was received by the UBW. C:\Projects\UBW\FW\2455\D\user\user.c // This command will send back a "RX,," C:\Projects\UBW\FW\2455\D\user\user.c // or "RX,," packet depending upon if you send C:\Projects\UBW\FW\2455\D\user\user.c // "0" or something else for C:\Projects\UBW\FW\2455\D\user\user.c // in the returning RX packet is a count of the number of bytes C:\Projects\UBW\FW\2455\D\user\user.c // in the field. It will never be more than the C:\Projects\UBW\FW\2455\D\user\user.c // you sent in. C:\Projects\UBW\FW\2455\D\user\user.c // is the data (in raw form - byte for byte what was received - C:\Projects\UBW\FW\2455\D\user\user.c // i.e. not translated in any way, into ASCII values or anything else) that the UBW C:\Projects\UBW\FW\2455\D\user\user.c // received. This may include s and NULLs among any other bytes, so make sure C:\Projects\UBW\FW\2455\D\user\user.c // your PC application treates the RX packet coming back from the UBW in a speical way C:\Projects\UBW\FW\2455\D\user\user.c // so as not to screw up normal packet processing if any special caracters are received. C:\Projects\UBW\FW\2455\D\user\user.c // is a valule between 0 and MAX_SERIAL_RX_BUFFER_SIZE that records C:\Projects\UBW\FW\2455\D\user\user.c // the total number of bytes, at that point in time, that the UBW is holding, waiting C:\Projects\UBW\FW\2455\D\user\user.c // to pass on to the PC. C:\Projects\UBW\FW\2455\D\user\user.c // has several bits. C:\Projects\UBW\FW\2455\D\user\user.c // Bit 0 = Software RX Buffer Overrun (1 means software RX buffer (on RX pin) C:\Projects\UBW\FW\2455\D\user\user.c // has been overrun and data has been lost) This will happen if you don't C:\Projects\UBW\FW\2455\D\user\user.c // read the data out of the UWB often enough and the data is coming in too fast. C:\Projects\UBW\FW\2455\D\user\user.c // Bit 1 = Software TX Buffer Overrun (1 means software TX buffer (on TX pin) C:\Projects\UBW\FW\2455\D\user\user.c // as been overrun and data hs been lost. This will happen if you send too much C:\Projects\UBW\FW\2455\D\user\user.c // data to the UBW and you have the serial port set to a low baud rate. C:\Projects\UBW\FW\2455\D\user\user.c void parse_RX_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001b78 dc1c RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 001b7a 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // CX is for setting up serial port parameters C:\Projects\UBW\FW\2455\D\user\user.c // TBD C:\Projects\UBW\FW\2455\D\user\user.c void parse_CX_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001b7c dc1a RCALL 0x13b2 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 001b7e 0012 RETURN 0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // RC is for outputting RC servo pulses on a pin C:\Projects\UBW\FW\2455\D\user\user.c // "RC,,," C:\Projects\UBW\FW\2455\D\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\2455\D\user\user.c // is a number between 0 and 7 and indicates which pin to output the new value on C:\Projects\UBW\FW\2455\D\user\user.c // is an unsigned 16 bit number between 0 and 11890. C:\Projects\UBW\FW\2455\D\user\user.c // If is "0" then the RC output on that pin is disabled. C:\Projects\UBW\FW\2455\D\user\user.c // Otherwise = 1 means 1ms pulse, = 11890 means 2ms pulse, C:\Projects\UBW\FW\2455\D\user\user.c // any value inbetween means proportional pulse values between those two C:\Projects\UBW\FW\2455\D\user\user.c // Note: The pin used for RC output must be set as an output, or not much will happen. C:\Projects\UBW\FW\2455\D\user\user.c // The RC command will continue to send out pulses at the last set value on C:\Projects\UBW\FW\2455\D\user\user.c // each pin that has RC output with a repition rate of 1 pulse about every 19ms. C:\Projects\UBW\FW\2455\D\user\user.c // If you have RC output enabled on a pin, outputting a digital value to that pin C:\Projects\UBW\FW\2455\D\user\user.c // will be overwritten the next time the RC pulses. Make sure to turn off the RC C:\Projects\UBW\FW\2455\D\user\user.c // output if you want to use the pin for something else. C:\Projects\UBW\FW\2455\D\user\user.c 001b80 cfd9 MOVFF 0xfd9,0xfe6 void parse_RC_packet(void) C:\Projects\UBW\FW\2455\D\user\user.c 001b82 ffe6 001b84 cfe1 MOVFF 0xfe1,0xfd9 001b86 ffd9 001b88 0e06 MOVLW 0x6 001b8a 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\2455\D\user\user.c unsigned char port; C:\Projects\UBW\FW\2455\D\user\user.c unsigned char pin; C:\Projects\UBW\FW\2455\D\user\user.c unsigned int value; C:\Projects\UBW\FW\2455\D\user\user.c unsigned int orig_value; C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001b8c 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001b8e 6ee6 MOVWF 0xe6,0x0 001b90 dafc RCALL 0x218a 001b92 52e5 MOVF 0xe5,0x1,0x0 001b94 501d MOVF 0x1d,0x0,0x0 001b96 6edf MOVWF 0xdf,0x0 001b98 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\2455\D\user\user.c 001b9a 6ee6 MOVWF 0xe6,0x0 001b9c daf6 RCALL 0x218a 001b9e 52e5 MOVF 0xe5,0x1,0x0 001ba0 0e01 MOVLW 0x1 001ba2 c01d MOVFF 0x1d,0xfdb 001ba4 ffdb 001ba6 0e03 MOVLW 0x3 value = extract_number (kUINT); C:\Projects\UBW\FW\2455\D\user\user.c 001ba8 6ee6 MOVWF 0xe6,0x0 001baa daef RCALL 0x218a 001bac 52e5 MOVF 0xe5,0x1,0x0 001bae 0e02 MOVLW 0x2 001bb0 c01d MOVFF 0x1d,0xfdb 001bb2 ffdb 001bb4 0e03 MOVLW 0x3 001bb6 c01e MOVFF 0x1e,0xfdb 001bb8 ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\2455\D\user\user.c 001bba 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\2455\D\user\user.c 001bbc e001 BZ 0x1bc0 { C:\Projects\UBW\FW\2455\D\user\user.c 001bbe d07f BRA 0x1cbe return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Max value user can input. (min is zero) C:\Projects\UBW\FW\2455\D\user\user.c 001bc0 50d9 MOVF 0xd9,0x0,0x0 if (value > 11890) C:\Projects\UBW\FW\2455\D\user\user.c 001bc2 0f02 ADDLW 0x2 001bc4 6ee9 MOVWF 0xe9,0x0 001bc6 cfda MOVFF 0xfda,0xfea 001bc8 ffea 001bca 0e72 MOVLW 0x72 001bcc 80d8 BSF 0xd8,0x0,0x0 001bce 54ee SUBFWB 0xee,0x0,0x0 001bd0 0e2e MOVLW 0x2e 001bd2 54ed SUBFWB 0xed,0x0,0x0 001bd4 e202 BC 0x1bda { C:\Projects\UBW\FW\2455\D\user\user.c 001bd6 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001bd8 d072 BRA 0x1cbe return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001bda 0e02 MOVLW 0x2 orig_value = value; C:\Projects\UBW\FW\2455\D\user\user.c 001bdc cfdb MOVFF 0xfdb,0x1e 001bde f01e 001be0 0e03 MOVLW 0x3 001be2 cfdb MOVFF 0xfdb,0x1f 001be4 f01f 001be6 0e04 MOVLW 0x4 001be8 c01e MOVFF 0x1e,0xfdb 001bea ffdb 001bec 0e05 MOVLW 0x5 001bee c01f MOVFF 0x1f,0xfdb 001bf0 ffdb C:\Projects\UBW\FW\2455\D\user\user.c // Now get Value in the form that TMR0 needs it C:\Projects\UBW\FW\2455\D\user\user.c // TMR0 needs to get filled with values from 65490 (1ms) to 53600 (2ms) C:\Projects\UBW\FW\2455\D\user\user.c 001bf2 682d SETF 0x2d,0x0 value = (65535 - (value + 45)); C:\Projects\UBW\FW\2455\D\user\user.c 001bf4 682e SETF 0x2e,0x0 001bf6 6a2f CLRF 0x2f,0x0 001bf8 0e2d MOVLW 0x2d 001bfa 6ee7 MOVWF 0xe7,0x0 001bfc 0e02 MOVLW 0x2 001bfe cfdb MOVFF 0xfdb,0x30 001c00 f030 001c02 0e03 MOVLW 0x3 001c04 cfdb MOVFF 0xfdb,0x31 001c06 f031 001c08 50e7 MOVF 0xe7,0x0,0x0 001c0a 2630 ADDWF 0x30,0x1,0x0 001c0c 0e00 MOVLW 0x0 001c0e 2231 ADDWFC 0x31,0x1,0x0 001c10 6a32 CLRF 0x32,0x0 001c12 5030 MOVF 0x30,0x0,0x0 001c14 5c2d SUBWF 0x2d,0x0,0x0 001c16 6e2a MOVWF 0x2a,0x0 001c18 5031 MOVF 0x31,0x0,0x0 001c1a 582e SUBWFB 0x2e,0x0,0x0 001c1c 6e2b MOVWF 0x2b,0x0 001c1e 5032 MOVF 0x32,0x0,0x0 001c20 582f SUBWFB 0x2f,0x0,0x0 001c22 6e2c MOVWF 0x2c,0x0 001c24 0e02 MOVLW 0x2 001c26 c02a MOVFF 0x2a,0xfdb 001c28 ffdb 001c2a 0e03 MOVLW 0x3 001c2c c02b MOVFF 0x2b,0xfdb 001c2e ffdb C:\Projects\UBW\FW\2455\D\user\user.c 001c30 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\2455\D\user\user.c 001c32 50db MOVF 0xdb,0x0,0x0 001c34 0807 SUBLW 0x7 001c36 e202 BC 0x1c3c { C:\Projects\UBW\FW\2455\D\user\user.c 001c38 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001c3a d041 BRA 0x1cbe return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001c3c 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001c3e 6e2a MOVWF 0x2a,0x0 001c40 50df MOVF 0xdf,0x0,0x0 001c42 5c2a SUBWF 0x2a,0x0,0x0 001c44 e102 BNZ 0x1c4a { C:\Projects\UBW\FW\2455\D\user\user.c 001c46 6adf CLRF 0xdf,0x0 port = 0; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c 001c48 d012 BRA 0x1c6e else if ('B' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001c4a 0e42 MOVLW 0x42 001c4c 6e2a MOVWF 0x2a,0x0 001c4e 50df MOVF 0xdf,0x0,0x0 001c50 5c2a SUBWF 0x2a,0x0,0x0 001c52 e103 BNZ 0x1c5a { C:\Projects\UBW\FW\2455\D\user\user.c 001c54 0e08 MOVLW 0x8 port = 8; C:\Projects\UBW\FW\2455\D\user\user.c 001c56 6edf MOVWF 0xdf,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001c58 d00a BRA 0x1c6e else if ('C' == port) C:\Projects\UBW\FW\2455\D\user\user.c 001c5a 0e43 MOVLW 0x43 001c5c 6e2a MOVWF 0x2a,0x0 001c5e 50df MOVF 0xdf,0x0,0x0 001c60 5c2a SUBWF 0x2a,0x0,0x0 001c62 e103 BNZ 0x1c6a { C:\Projects\UBW\FW\2455\D\user\user.c 001c64 0e10 MOVLW 0x10 port = 16; C:\Projects\UBW\FW\2455\D\user\user.c 001c66 6edf MOVWF 0xdf,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c 001c68 d002 BRA 0x1c6e else C:\Projects\UBW\FW\2455\D\user\user.c { C:\Projects\UBW\FW\2455\D\user\user.c 001c6a 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\2455\D\user\user.c 001c6c d028 BRA 0x1cbe return; C:\Projects\UBW\FW\2455\D\user\user.c } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c // Store the new RC time value C:\Projects\UBW\FW\2455\D\user\user.c 001c6e 0e01 MOVLW 0x1 g_RC_value[pin + port] = value; C:\Projects\UBW\FW\2455\D\user\user.c 001c70 50db MOVF 0xdb,0x0,0x0 001c72 24df ADDWF 0xdf,0x0,0x0 001c74 6ee9 MOVWF 0xe9,0x0 001c76 6aea CLRF 0xea,0x0 001c78 90d8 BCF 0xd8,0x0,0x0 001c7a 36e9 RLCF 0xe9,0x1,0x0 001c7c 36ea RLCF 0xea,0x1,0x0 001c7e 0e69 MOVLW 0x69 001c80 26e9 ADDWF 0xe9,0x1,0x0 001c82 0e01 MOVLW 0x1 001c84 22ea ADDWFC 0xea,0x1,0x0 001c86 0e02 MOVLW 0x2 001c88 cfdb MOVFF 0xfdb,0xfee 001c8a ffee 001c8c 0e03 MOVLW 0x3 001c8e cfdb MOVFF 0xfdb,0xfed 001c90 ffed // Only set this state if we are off - if we are already running on C:\Projects\UBW\FW\2455\D\user\user.c // this pin, then the new value will be picked up next time around (19ms) C:\Projects\UBW\FW\2455\D\user\user.c 001c92 0e01 MOVLW 0x1 if (kOFF == g_RC_state[pin + port]) C:\Projects\UBW\FW\2455\D\user\user.c 001c94 50db MOVF 0xdb,0x0,0x0 001c96 24df ADDWF 0xdf,0x0,0x0 001c98 6aea CLRF 0xea,0x0 001c9a 0f51 ADDLW 0x51 001c9c 6ee9 MOVWF 0xe9,0x0 001c9e 0e01 MOVLW 0x1 001ca0 22ea ADDWFC 0xea,0x1,0x0 001ca2 04ef DECF 0xef,0x0,0x0 001ca4 e10a BNZ 0x1cba { C:\Projects\UBW\FW\2455\D\user\user.c 001ca6 0e01 MOVLW 0x1 g_RC_state[pin + port] = kWAITING; C:\Projects\UBW\FW\2455\D\user\user.c 001ca8 50db MOVF 0xdb,0x0,0x0 001caa 24df ADDWF 0xdf,0x0,0x0 001cac 6aea CLRF 0xea,0x0 001cae 0f51 ADDLW 0x51 001cb0 6ee9 MOVWF 0xe9,0x0 001cb2 0e01 MOVLW 0x1 001cb4 22ea ADDWFC 0xea,0x1,0x0 001cb6 0e02 MOVLW 0x2 001cb8 6eef MOVWF 0xef,0x0 } C:\Projects\UBW\FW\2455\D\user\user.c C:\Projects\UBW\FW\2455\D\user\user.c 001cba ecd9 CALL 0x13b2,0x0 print_ack (); C:\Projects\UBW\FW\2455\D\user\user.c 001cbc f009 001cbe 0e06 MOVLW 0x6 } C:\Projects\UBW\FW\2455\D\user\user.c 001cc0 5ce1 SUBWF 0xe1,0x0,0x0 001cc2 e202 BC 0x1cc8 001cc4 6ae1 CLRF 0xe1,0x0 001cc6 52e5 MOVF 0xe5,0x1,0x0 001cc8 6ee1 MOVWF 0xe1,0x0 001cca 52e5 MOVF 0xe5,0x1,0x0 001ccc cfe7 MOVFF 0xfe7,0xfd9 001cce ffd9 001cd0 0012 RETURN 0x0 C:\Projects\UBW\FW\2455\D\user\user.c // BC is for Bulk Configure C:\Projects\UBW\FW\2455\D\user\user.c // BC,,,,, C:\Projects\UBW\FW\2455\D\user\user.c // This command sets up the mask and strobe bits