MP2COD 4.12, COFF to COD File Converter Copyright (c) 2007 Microchip Technology Inc. Listing File Generated: Tue Aug 28 22:40:25 2007 Address Value Disassembly Source File ------- ------- ----------------------- ------------------------------------------------------------------------------- ----- /********************************************************************* C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c ********************************************************************* C:\Projects\UBW\FW\D_143\main.c * FileName: main.c C:\Projects\UBW\FW\D_143\main.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\main.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\main.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\main.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Software License Agreement C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\main.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\main.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\main.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\main.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\main.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\main.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\main.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\main.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\main.c * license. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\main.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\main.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\main.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\main.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\main.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Author Date Comment C:\Projects\UBW\FW\D_143\main.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\D_143\main.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\D_143\main.c ********************************************************************/ C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\D_143\main.c #include C:\Projects\UBW\FW\D_143\main.c #include "system\typedefs.h" // Required C:\Projects\UBW\FW\D_143\main.c #include "system\usb\usb.h" // Required C:\Projects\UBW\FW\D_143\main.c #include "io_cfg.h" // Required C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c #include "system\usb\usb_compile_time_validation.h" // Optional C:\Projects\UBW\FW\D_143\main.c #include "user\user.h" // Modifiable C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\D_143\main.c #pragma udata C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\D_143\main.c static void InitializeSystem(void); C:\Projects\UBW\FW\D_143\main.c void USBTasks(void); C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c #pragma code high_vector_section = 0x000808 C:\Projects\UBW\FW\D_143\main.c void high_vector (void) C:\Projects\UBW\FW\D_143\main.c { C:\Projects\UBW\FW\D_143\main.c 000808 efbb GOTO 0xb76 _asm goto high_ISR _endasm C:\Projects\UBW\FW\D_143\main.c 00080a f005 00080c 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\main.c #pragma code low_vector_section = 0x000818 C:\Projects\UBW\FW\D_143\main.c void low_vector (void) C:\Projects\UBW\FW\D_143\main.c { C:\Projects\UBW\FW\D_143\main.c 000818 ef22 GOTO 0x844 _asm goto low_ISR _endasm C:\Projects\UBW\FW\D_143\main.c 00081a f004 00081c 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\main.c #pragma code C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\D_143\main.c #pragma code C:\Projects\UBW\FW\D_143\main.c /****************************************************************************** C:\Projects\UBW\FW\D_143\main.c * Function: void main(void) C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * PreCondition: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Input: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Output: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Side Effects: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Overview: Main program entry point. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Note: None C:\Projects\UBW\FW\D_143\main.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\main.c void main(void) C:\Projects\UBW\FW\D_143\main.c { C:\Projects\UBW\FW\D_143\main.c 004544 d805 RCALL 0x4550 InitializeSystem(); C:\Projects\UBW\FW\D_143\main.c 00454c d7fc BRA 0x4546 while(1) C:\Projects\UBW\FW\D_143\main.c { C:\Projects\UBW\FW\D_143\main.c 004546 d811 RCALL 0x456a USBTasks(); // USB Tasks C:\Projects\UBW\FW\D_143\main.c 004548 ec8f CALL 0xd1e,0x0 ProcessIO(); // See user\user.c & .h C:\Projects\UBW\FW\D_143\main.c 00454a f006 }//end while C:\Projects\UBW\FW\D_143\main.c 00454e 0012 RETURN 0x0 }//end main C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /****************************************************************************** C:\Projects\UBW\FW\D_143\main.c * Function: static void InitializeSystem(void) C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * PreCondition: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Input: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Output: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Side Effects: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Overview: InitializeSystem is a centralize initialization routine. C:\Projects\UBW\FW\D_143\main.c * All required USB initialization routines are called from C:\Projects\UBW\FW\D_143\main.c * here. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * User application initialization routine should also be C:\Projects\UBW\FW\D_143\main.c * called from here. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Note: None C:\Projects\UBW\FW\D_143\main.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\main.c static void InitializeSystem(void) C:\Projects\UBW\FW\D_143\main.c { C:\Projects\UBW\FW\D_143\main.c 004550 0e0f MOVLW 0xf ADCON1 |= 0x0F; // Default all pins to digital C:\Projects\UBW\FW\D_143\main.c 004552 12c1 IORWF 0xc1,0x1,0x0 C:\Projects\UBW\FW\D_143\main.c 004554 0e14 MOVLW 0x14 mInitializeUSBDriver(); // See usbdrv.h C:\Projects\UBW\FW\D_143\main.c 004556 6e6f MOVWF 0x6f,0x0 004558 0101 MOVLB 0x1 00455a 6bd2 CLRF 0xd2,0x1 00455c 0101 MOVLB 0x1 00455e 6bd3 CLRF 0xd3,0x1 004560 0101 MOVLB 0x1 004562 6bd4 CLRF 0xd4,0x1 C:\Projects\UBW\FW\D_143\main.c 004564 ecc4 CALL 0xb88,0x0 UserInit(); // See user.c & .h C:\Projects\UBW\FW\D_143\main.c 004566 f005 C:\Projects\UBW\FW\D_143\main.c 004568 0012 RETURN 0x0 }//end InitializeSystem C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /****************************************************************************** C:\Projects\UBW\FW\D_143\main.c * Function: void USBTasks(void) C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * PreCondition: InitializeSystem has been called. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Input: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Output: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Side Effects: None C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Overview: Service loop for USB tasks. C:\Projects\UBW\FW\D_143\main.c * C:\Projects\UBW\FW\D_143\main.c * Note: None C:\Projects\UBW\FW\D_143\main.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\main.c void USBTasks(void) C:\Projects\UBW\FW\D_143\main.c { C:\Projects\UBW\FW\D_143\main.c /* C:\Projects\UBW\FW\D_143\main.c * Servicing Hardware C:\Projects\UBW\FW\D_143\main.c */ C:\Projects\UBW\FW\D_143\main.c 00456a eccd CALL 0x3d9a,0x0 USBCheckBusStatus(); // Must use polling method C:\Projects\UBW\FW\D_143\main.c 00456c f01e 00456e be6f BTFSC 0x6f,0x7,0x0 if(UCFGbits.UTEYE!=1) C:\Projects\UBW\FW\D_143\main.c 004570 d002 BRA 0x4576 004572 eced CALL 0x3dda,0x0 USBDriverService(); // Interrupt or polling method C:\Projects\UBW\FW\D_143\main.c 004574 f01e C:\Projects\UBW\FW\D_143\main.c #if defined(USB_USE_CDC) C:\Projects\UBW\FW\D_143\main.c 004576 ec17 CALL 0x362e,0x0 CDCTxService(); C:\Projects\UBW\FW\D_143\main.c 004578 f01b #endif C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c 00457a 0012 RETURN 0x0 }// end USBTasks C:\Projects\UBW\FW\D_143\main.c C:\Projects\UBW\FW\D_143\main.c /** EOF main.c ***************************************************************/ C:\Projects\UBW\FW\D_143\main.c /********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c ********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * FileName: usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Software License Agreement C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * license. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Author Date Comment C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c ********************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * -usbmmap.c- C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * USB Memory Map C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * This file is the USB memory manager; it serves as a compile-time memory C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * allocator for the USB endpoints. It uses the compile time options passed C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * from usbcfg.h to instantiate endpoints and endpoint buffer. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Each endpoint requires to have a set of Buffer Descriptor registers(BDT). C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * A BDT is 4-byte long and has a specific RAM location for each endpoint. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The BDT for endpoint 0 out is located at address 0x400 to 0x403. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The BDT for endpoint 0 in is located at address 0x404 to 0x407. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The BDT for endpoint 1 out is located at address 0x408 to 0x40B. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * and so on... The above allocation assumes the Ping-Pong Buffer Mode 0 is C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * used. These locations are already hard-wired in the silicon. The point C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * of doing instantiation, i.e. volatile far BDT ep0Bo;, is to provide the C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C compiler a way to address each variable directly. This is very important C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * because when a register can be accessed directly, it saves execution time C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * and reduces program size. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Endpoints are defined using the endpoint number and the direction C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * of transfer. For simplicity, usbmmap.c only uses the endpoint number C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * in the BDT register allocation scheme. This means if the usbcfg.h states C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * that the MAX_EP_NUMBER is number 1, then four BDTs will be C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * instantiated: one each for endpoint0 in and endpoint0 out, which must C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * always be instantiated for control transfer by default, and one each sets C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * for endpoint1 in and endpoint1 out. The naming convention for instantiating C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * BDT is C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * ep<#>B C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * where # is the endpoint number, and d is the direction of C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * transfer, which could be either or . C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The USB memory manager uses MAX_EP_NUMBER, as defined in usbcfg.h, to define C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * the endpoints to be instantiated. This represents the highest endpoint C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * number to be allocated, not how many endpoints are used. Since the BDTs for C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * endpoints have hardware-assigned addresses in Bank 4, setting this value too C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * high may lead to inefficient use of data RAM. For example, if an application C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * uses only endpoints EP0 and EP4, then the MAX_EP_NUMBER is 4, and not 2. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The in-between endpoint BDTs in this example (EP1, EP2, and EP3) go unused, C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * and the 24 bytes of memory associated with them are wasted. It does not make C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * much sense to skip endpoints, but the final decision lies with the user. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The next step is to assign the instantiated BDTs to different C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * USB functions. The firmware framework fundamentally assumes that every USB C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * function should know which endpoint it is using, i.e., the default control C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * transfer should know that it is using endpoint 0 in and endpoint 0 out. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * A HID class can choose which endpoint it wants to use, but once chosen, it C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * should always know the number of the endpoint. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The assignment of endpoints to USB functions is managed centrally C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * in usbcfg.h. This helps prevent the mistake of having more C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * than one USB function using the same endpoint. The "Endpoint Allocation" C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * section in usbcfg.h provides examples for how to map USB endpoints to USB C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * functions. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Quite a few things can be mapped in that section. There is no C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * one correct way to do the mapping and the user has the choice to C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * choose a method that is most suitable to the application. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Typically, however, a user will want to map the following for a given C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * USB interface function: C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * 1. The USB interface ID C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * 2. The endpoint control registers (UEPn) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * 3. The BDT registers (ep<#>B) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * 4. The endpoint size C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Example: Assume a USB device class "foo", which uses one out endpoint C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * of size 64-byte and one in endpoint of size 64-byte, then: C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * #define FOO_INTF_ID 0x00 C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * #define FOO_UEP UEP1 C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * #define FOO_BD_OUT ep1Bo C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * #define FOO_BD_IN ep1Bi C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * #define FOO_EP_SIZE 64 C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The mapping above has chosen class "foo" to use endpoint 1. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The names are arbitrary and can be anything other than FOO_??????. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * For abstraction, the code for class "foo" should use the abstract C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * definitions of FOO_BD_OUT,FOO_BD_IN, and not ep1Bo or ep1Bi. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Note that the endpoint size defined in the usbcfg.h file is again C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * used in the usbmmap.c file. This shows that the relationship between C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * the two files are tightly related. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The endpoint buffer for each USB function must be located in the C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * dual-port RAM area and has to come after all the BDTs have been C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * instantiated. An example declaration is: C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * volatile far unsigned char[FOO_EP_SIZE] data; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * The 'volatile' keyword tells the compiler not to perform any code C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * optimization on this variable because its content could be modified C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * by the hardware. The 'far' keyword tells the compiler that this variable C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * is not located in the Access RAM area (0x000 - 0x05F). C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * For the variable to be globally accessible by other files, it should be C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * declared in the header file usbmmap.h as an extern definition, such as C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * extern volatile far unsigned char[FOO_EP_SIZE] data; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Conclusion: C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * In a short summary, the dependencies between usbcfg and usbmmap can C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * be shown as: C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * usbcfg[MAX_EP_NUMBER] -> usbmmap C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * usbmmap[ep<#>B] -> usbcfg C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * usbcfg[EP size] -> usbmmap C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * usbcfg[abstract ep definitions] -> usb9/hid/cdc/etc class code C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * usbmmap[endpoint buffer variable] -> usb9/hid/cdc/etc class code C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Data mapping provides a means for direct addressing of BDT and endpoint C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * buffer. This means less usage of pointers, which equates to a faster and C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * smaller program code. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #include "system\typedefs.h" C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #include "system\usb\usb.h" C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\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\D_143\system\usb\usbmmap.c #pragma udata C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c byte usb_device_state; // Device States: DETACHED, ATTACHED, ... C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c USB_DEVICE_STATUS usb_stat; // Global USB flags C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c byte usb_active_cfg; // Value of current configuration C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c byte usb_alt_intf[MAX_NUM_INT]; // Array to keep track of the current alternate C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c // setting for each interface ID C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\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\D_143\system\usb\usbmmap.c #pragma udata usbram4=0x400 //See Linker Script,usb4:0x400-0x4FF(256-byte) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Section A: Buffer Descriptor Table C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - 0x400 - 0x4FF(max) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - MAX_EP_NUMBER is defined in autofiles\usbcfg.h C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - BDT data type is defined in system\usb\usbmmap.h C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(0 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep0Bo; //Endpoint #0 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep0Bi; //Endpoint #0 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(1 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep1Bo; //Endpoint #1 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep1Bi; //Endpoint #1 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(2 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep2Bo; //Endpoint #2 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep2Bi; //Endpoint #2 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(3 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep3Bo; //Endpoint #3 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep3Bi; //Endpoint #3 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(4 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep4Bo; //Endpoint #4 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep4Bi; //Endpoint #4 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(5 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep5Bo; //Endpoint #5 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep5Bi; //Endpoint #5 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(6 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep6Bo; //Endpoint #6 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep6Bi; //Endpoint #6 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(7 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep7Bo; //Endpoint #7 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep7Bi; //Endpoint #7 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(8 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep8Bo; //Endpoint #8 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep8Bi; //Endpoint #8 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(9 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep9Bo; //Endpoint #9 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep9Bi; //Endpoint #9 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(10 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep10Bo; //Endpoint #10 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep10Bi; //Endpoint #10 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(11 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep11Bo; //Endpoint #11 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep11Bi; //Endpoint #11 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(12 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep12Bo; //Endpoint #12 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep12Bi; //Endpoint #12 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(13 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep13Bo; //Endpoint #13 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep13Bi; //Endpoint #13 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(14 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep14Bo; //Endpoint #14 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep14Bi; //Endpoint #14 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if(15 <= MAX_EP_NUMBER) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep15Bo; //Endpoint #15 BD Out C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far BDT ep15Bi; //Endpoint #15 BD In C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Section B: EP0 Buffer Space C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c ****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - Two buffer areas are defined: C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * A. CTRL_TRF_SETUP C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - Size = EP0_BUFF_SIZE as defined in autofiles\usbcfg.h C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - Detailed data structure allows direct adddressing of bits and bytes. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * B. CTRL_TRF_DATA C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - Size = EP0_BUFF_SIZE as defined in autofiles\usbcfg.h C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - Data structure allows direct adddressing of the first 8 bytes. C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * - Both data types are defined in system\usb\usbdefs\usbdefs_ep0_buff.h C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far CTRL_TRF_SETUP SetupPkt; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far CTRL_TRF_DATA CtrlTrfData; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * Section C: CDC Buffer C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c ****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c * C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #pragma udata usbram5a=0x500 //See Linker Script,usb5:0x500-... C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #if defined(USB_USE_CDC) C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far unsigned char cdc_notice[CDC_INT_EP_SIZE]; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far unsigned char cdc_data_rx[CDC_BULK_OUT_EP_SIZE]; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c volatile far unsigned char cdc_data_tx[CDC_BULK_IN_EP_SIZE]; C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #endif C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c #pragma udata C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /** EOF usbmmap.c ************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbmmap.c /********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c ********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * FileName: usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Software License Agreement C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * license. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Author Date Comment C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c ********************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #include C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #include "system\typedefs.h" C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #include "system\usb\usb.h" C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #include "io_cfg.h" // Required for USBCheckBusStatus() C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #pragma udata C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\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\D_143\system\usb\usbdrv\usbdrv.c void USBModuleEnable(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBModuleDisable(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBSuspend(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBWakeFromSuspend(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBProtocolResetHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USB_SOF_Handler(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBStallHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBErrorHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #pragma code C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBCheckBusStatus(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: This routine enables/disables the USB module by monitoring C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the USB power signal. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBCheckBusStatus(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Bus Attachment & Detachment Detection C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * usb_bus_sense is an i/o pin defined in io_cfg.h C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #define USB_BUS_ATTACHED 1 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c #define USB_BUS_DETACHED 0 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c if(usb_bus_sense == USB_BUS_ATTACHED) // Is USB bus attached? C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003d9a a66d BTFSS 0x6d,0x3,0x0 if(UCONbits.USBEN == 0) // Is the module off? C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003d9c d810 RCALL 0x3dbe USBModuleEnable(); // Is off, enable it C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c } C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003d9e d002 BRA 0x3da4 else C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003da0 b66d BTFSC 0x6d,0x3,0x0 if(UCONbits.USBEN == 1) // Is the module on? C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003da2 d814 RCALL 0x3dcc USBModuleDisable(); // Is on, disable it C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c }//end if(usb_bus_sense...) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * After enabling the USB module, it takes some time for the voltage C:\Projects\UBW\FW\D_143\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\D_143\system\usb\usbdrv\usbdrv.c * The USB Reset interrupt should not be unmasked until the SE0 condition is C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * cleared. This helps preventing the firmware from misinterpreting this C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * unique event as a USB bus reset from the USB host. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003da4 0101 MOVLB 0x1 if(usb_device_state == ATTACHED_STATE) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003da6 05d2 DECF 0xd2,0x0,0x1 003da8 e109 BNZ 0x3dbc { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003daa ba6d BTFSC 0x6d,0x5,0x0 if(!UCONbits.SE0) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dac d007 BRA 0x3dbc { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dae 6a68 CLRF 0x68,0x0 UIR = 0; // Clear all USB interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003db0 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003db2 8069 BSF 0x69,0x0,0x0 UIEbits.URSTIE = 1; // Unmask RESET interrupt C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003db4 8869 BSF 0x69,0x4,0x0 UIEbits.IDLEIE = 1; // Unmask IDLE interrupt C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003db6 0101 MOVLB 0x1 usb_device_state = POWERED_STATE; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003db8 0e02 MOVLW 0x2 003dba 6fd2 MOVWF 0xd2,0x1 }//end if // else wait until SE0 is cleared C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c }//end if(usb_device_state == ATTACHED_STATE) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dbc 0012 RETURN 0x0 }//end USBCheckBusStatus C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBModuleEnable(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: This routine enables the USB module. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * An end designer should never have to call this routine C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * manually. This routine should only be called from C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * USBCheckBusStatus(). C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: See USBCheckBusStatus() for more information. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBModuleEnable(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dbe 6a6d CLRF 0x6d,0x0 UCON = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dc0 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dc2 866d BSF 0x6d,0x3,0x0 UCONbits.USBEN = 1; // Enable module & attach to bus C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dc4 0101 MOVLB 0x1 usb_device_state = ATTACHED_STATE; // Defined in usbmmap.c & .h C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dc6 0e01 MOVLW 0x1 003dc8 6fd2 MOVWF 0xd2,0x1 003dca 0012 RETURN 0x0 }//end USBModuleEnable C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBModuleDisable(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: This routine disables the USB module. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * An end designer should never have to call this routine C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * manually. This routine should only be called from C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * USBCheckBusStatus(). C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: See USBCheckBusStatus() for more information. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBModuleDisable(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dcc 6a6d CLRF 0x6d,0x0 UCON = 0; // Disable module & detach from bus C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dce 6a69 CLRF 0x69,0x0 UIE = 0; // Mask all USB interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dd0 0101 MOVLB 0x1 usb_device_state = DETACHED_STATE; // Defined in usbmmap.c & .h C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dd2 6bd2 CLRF 0xd2,0x1 003dd4 0012 RETURN 0x0 }//end USBModuleDisable C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBSoftDetach(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: The device will have to be re-enumerated to function again. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: USBSoftDetach electrically disconnects the device from C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the bus. This is done by stop supplying Vusb voltage to C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * pull-up resistor. The pull-down resistors on the host C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * side will pull both differential signal lines low and C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the host registers the event as a disconnect. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Since the USB cable is not physically disconnected, the C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * power supply through the cable can still be sensed by C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the device. The next time USBCheckBusStatus() function C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * is called, it will reconnect the device back to the bus. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBSoftDetach(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dd6 dffa RCALL 0x3dcc USBModuleDisable(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dd8 0012 RETURN 0x0 }//end USBSoftDetach C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBDriverService(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: This routine is the heart of this firmware. It manages C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * all USB interrupts. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: Device state transitions through the following stages: C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * DETACHED -> ATTACHED -> POWERED -> DEFAULT -> C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ADDRESS_PENDING -> ADDRESSED -> CONFIGURED -> READY C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBDriverService(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if USB cable is not even attached. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003dda 0101 MOVLB 0x1 if(usb_device_state == DETACHED_STATE) return; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ddc 51d2 MOVF 0xd2,0x0,0x1 003dde e101 BNZ 0x3de2 003de0 d03a BRA 0x3e56 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Task A: Service USB Activity Interrupt C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003de2 5068 MOVF 0x68,0x0,0x0 if(UIRbits.ACTVIF && UIEbits.ACTVIE) USBWakeFromSuspend(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003de4 0b04 ANDLW 0x4 003de6 e004 BZ 0x3df0 003de8 5069 MOVF 0x69,0x0,0x0 003dea 0b04 ANDLW 0x4 003dec e001 BZ 0x3df0 003dee d83c RCALL 0x3e68 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if the device is in suspend mode. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003df0 b26d BTFSC 0x6d,0x1,0x0 if(UCONbits.SUSPND==1) return; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003df2 d031 BRA 0x3e56 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Task B: Service USB Bus Reset Interrupt. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * When bus reset is received during suspend, ACTVIF will be set first, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * once the UCONbits.SUSPND is clear, then the URSTIF bit will be asserted. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * This is why URSTIF is checked after ACTVIF. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003df4 5068 MOVF 0x68,0x0,0x0 if(UIRbits.URSTIF && UIEbits.URSTIE) USBProtocolResetHandler(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003df6 0b01 ANDLW 0x1 003df8 e004 BZ 0x3e02 003dfa 5069 MOVF 0x69,0x0,0x0 003dfc 0b01 ANDLW 0x1 003dfe e001 BZ 0x3e02 003e00 d856 RCALL 0x3eae C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Task C: Service other USB interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e02 5068 MOVF 0x68,0x0,0x0 if(UIRbits.IDLEIF && UIEbits.IDLEIE) USBSuspend(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e04 0b10 ANDLW 0x10 003e06 e004 BZ 0x3e10 003e08 5069 MOVF 0x69,0x0,0x0 003e0a 0b10 ANDLW 0x10 003e0c e001 BZ 0x3e10 003e0e d824 RCALL 0x3e58 003e10 5068 MOVF 0x68,0x0,0x0 if(UIRbits.SOFIF && UIEbits.SOFIE) USB_SOF_Handler(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e12 0b40 ANDLW 0x40 003e14 e004 BZ 0x3e1e 003e16 5069 MOVF 0x69,0x0,0x0 003e18 0b40 ANDLW 0x40 003e1a e001 BZ 0x3e1e 003e1c d83d RCALL 0x3e98 003e1e 5068 MOVF 0x68,0x0,0x0 if(UIRbits.STALLIF && UIEbits.STALLIE) USBStallHandler(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e20 0b20 ANDLW 0x20 003e22 e004 BZ 0x3e2c 003e24 5069 MOVF 0x69,0x0,0x0 003e26 0b20 ANDLW 0x20 003e28 e001 BZ 0x3e2c 003e2a d838 RCALL 0x3e9c 003e2c 5068 MOVF 0x68,0x0,0x0 if(UIRbits.UERRIF && UIEbits.UERRIE) USBErrorHandler(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e2e 0b02 ANDLW 0x2 003e30 e004 BZ 0x3e3a 003e32 5069 MOVF 0x69,0x0,0x0 003e34 0b02 ANDLW 0x2 003e36 e001 BZ 0x3e3a 003e38 d838 RCALL 0x3eaa C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Pointless to continue servicing if the host has not sent a bus reset. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Once bus reset is received, the device transitions into the DEFAULT C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * state and is ready for communication. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e3a 0e03 MOVLW 0x3 if(usb_device_state < DEFAULT_STATE) return; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e3c 0101 MOVLB 0x1 003e3e 5dd2 SUBWF 0xd2,0x0,0x1 003e40 e201 BC 0x3e44 003e42 d009 BRA 0x3e56 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Task D: Servicing USB Transaction Complete Interrupt C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e44 5068 MOVF 0x68,0x0,0x0 if(UIRbits.TRNIF && UIEbits.TRNIE) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e46 0b08 ANDLW 0x8 003e48 e006 BZ 0x3e56 003e4a 5069 MOVF 0x69,0x0,0x0 003e4c 0b08 ANDLW 0x8 003e4e e003 BZ 0x3e56 { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * USBCtrlEPService only services transactions over EP0. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * It ignores all other EP transactions. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e50 eca1 CALL 0x3742,0x0 USBCtrlEPService(); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e52 f01b C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Other EP can be serviced later by responsible device class firmware. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Each device driver knows when an OUT or IN transaction is ready by C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * checking the buffer ownership bit. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * An OUT EP should always be owned by SIE until the data is ready. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * An IN EP should always be owned by CPU until the data is ready. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Because of this logic, it is not necessary to save the USTAT value C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * of non-EP0 transactions. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e54 9668 BCF 0x68,0x3,0x0 UIRbits.TRNIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c }//end if(UIRbits.TRNIF && UIEbits.TRNIE) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e56 0012 RETURN 0x0 }//end USBDriverService C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBSuspend(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBSuspend(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * NOTE: Do not clear UIRbits.ACTVIF here! C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Reason: C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ACTVIF is only generated once an IDLEIF has been generated. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * This is a 1:1 ratio interrupt generation. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * For every IDLEIF, there will be only one ACTVIF regardless of C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the number of subsequent bus transitions. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * If the ACTIF is cleared here, a problem could occur when: C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * [ IDLE ][bus activity -> C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * <--- 3 ms -----> ^ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ^ ACTVIF=1 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * IDLEIF=1 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * # # # # (#=Program polling flags) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ^ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * This polling loop will see both C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * IDLEIF=1 and ACTVIF=1. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * However, the program services IDLEIF first C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * because ACTIVIE=0. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * If this routine clears the only ACTIVIF, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * then it can never get out of the suspend C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * mode. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e58 8469 BSF 0x69,0x2,0x0 UIEbits.ACTVIE = 1; // Enable bus activity interrupt C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e5a 9868 BCF 0x68,0x4,0x0 UIRbits.IDLEIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e5c 826d BSF 0x6d,0x1,0x0 UCONbits.SUSPND = 1; // Put USB module in power conserve C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c // mode, SIE clock inactive C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * At this point the PIC can go into sleep,idle, or C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * switch to a slower clock, etc. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* Modifiable Section */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e5e 9aa1 BCF 0xa1,0x5,0x0 PIR2bits.USBIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e60 8aa0 BSF 0xa0,0x5,0x0 PIE2bits.USBIE = 1; // Set USB wakeup source C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e62 0003 SLEEP Sleep(); // Goto sleep C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e64 9aa0 BCF 0xa0,0x5,0x0 PIE2bits.USBIE = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* End Modifiable Section */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e66 0012 RETURN 0x0 }//end USBSuspend C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBWakeFromSuspend(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBWakeFromSuspend(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * If using clock switching, this is the place to restore the C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * original clock frequency. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e68 926d BCF 0x6d,0x1,0x0 UCONbits.SUSPND = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e6a 9469 BCF 0x69,0x2,0x0 UIEbits.ACTVIE = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e6c 9468 BCF 0x68,0x2,0x0 UIRbits.ACTVIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e6e 0012 RETURN 0x0 }//end USBWakeFromSuspend C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBRemoteWakeup(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: This function should be called by user when the device C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * is waken up by an external stimulus other than ACTIVIF. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Please read the note below to understand the limitations. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: The modifiable section in this routine should be changed C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * to meet the application needs. Current implementation C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * temporary blocks other functions from executing for a C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * period of 1-13 ms depending on the core frequency. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * According to USB 2.0 specification section 7.1.7.7, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * "The remote wakeup device must hold the resume signaling C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * for at lest 1 ms but for no more than 15 ms." C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * The idea here is to use a delay counter loop, using a C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * common value that would work over a wide range of core C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * frequencies. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * That value selected is 1800. See table below: C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ========================================================== C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Core Freq(MHz) MIP RESUME Signal Period (ms) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ========================================================== C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * 48 12 1.05 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * 4 1 12.6 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * ========================================================== C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * * These timing could be incorrect when using code C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * optimization or extended instruction mode, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * or when having other interrupts enabled. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Make sure to verify using the MPLAB SIM's Stopwatch C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBRemoteWakeup(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c static word delay_count; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e70 0101 MOVLB 0x1 if(usb_stat.RemoteWakeup == 1) // Check if RemoteWakeup function C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e72 a1d3 BTFSS 0xd3,0x0,0x1 003e74 d010 BRA 0x3e96 { // has been enabled by the host. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e76 dff8 RCALL 0x3e68 USBWakeFromSuspend(); // Unsuspend USB modue C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e78 846d BSF 0x6d,0x2,0x0 UCONbits.RESUME = 1; // Start RESUME signaling C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* Modifiable Section */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e7a 0101 MOVLB 0x1 delay_count = 1800U; // Set RESUME line for 1-13 ms C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e7c 0e08 MOVLW 0x8 003e7e 6fda MOVWF 0xda,0x1 003e80 0e07 MOVLW 0x7 003e82 6fdb MOVWF 0xdb,0x1 do C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e84 0101 MOVLB 0x1 delay_count--; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e86 07da DECF 0xda,0x1,0x1 003e88 0e00 MOVLW 0x0 003e8a 5bdb SUBWFB 0xdb,0x1,0x1 003e8c 0101 MOVLB 0x1 }while(delay_count); C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e8e 51da MOVF 0xda,0x0,0x1 003e90 11db IORWF 0xdb,0x0,0x1 003e92 e1f8 BNZ 0x3e84 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* End Modifiable Section */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e94 946d BCF 0x6d,0x2,0x0 UCONbits.RESUME = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c }//endif C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e96 0012 RETURN 0x0 }//end USBRemoteWakeup C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USB_SOF_Handler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: The USB host sends out a SOF packet to full-speed devices C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * every 1 ms. This interrupt may be useful for isochronous C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * pipes. End designers should implement callback routine C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * as necessary. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USB_SOF_Handler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* Callback routine here */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e98 9c68 BCF 0x68,0x6,0x0 UIRbits.SOFIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e9a 0012 RETURN 0x0 }//end USB_SOF_Handler C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBStallHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: A STALL packet is sent to the host by the SIE. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: The STALLIF is set anytime the SIE sends out a STALL C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * packet regardless of which endpoint causes it. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * A Setup transaction overrides the STALL function. A stalled C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * endpoint stops stalling once it receives a setup packet. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * In this case, the SIE will accepts the Setup packet and C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * set the TRNIF flag to notify the firmware. STALL function C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * for that particular endpoint pipe will be automatically C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * disabled (direction specific). C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * There are a few reasons for an endpoint to be stalled. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * 1. When a non-supported USB request is received. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Example: GET_DESCRIPTOR(DEVICE_QUALIFIER) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * 2. When an endpoint is currently halted. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * 3. When the device class specifies that an endpoint must C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * stall in response to a specific event. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Example: Mass Storage Device Class C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * If the CBW is not valid, the device shall C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * STALL the Bulk-In pipe. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * See USB Mass Storage Class Bulk-only Transport C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Specification for more details. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: UEPn.EPSTALL can be scanned to see which endpoint causes C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the stall event. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * If C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBStallHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Does not really have to do anything here, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * even for the control endpoint. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * All BDs of Endpoint 0 are owned by SIE right now, C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * but once a Setup Transaction is received, the ownership C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * for EP0_OUT will be returned to CPU. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * When the Setup Transaction is serviced, the ownership C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * for EP0_IN will then be forced back to CPU by firmware. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e9c a070 BTFSS 0x70,0x0,0x0 if(UEP0bits.EPSTALL == 1) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003e9e d003 BRA 0x3ea6 { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ea0 ec2e CALL 0x3a5c,0x0 USBPrepareForNextSetupTrf(); // Firmware work-around C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ea2 f01d 003ea4 9070 BCF 0x70,0x0,0x0 UEP0bits.EPSTALL = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c } C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ea6 9a68 BCF 0x68,0x5,0x0 UIRbits.STALLIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ea8 0012 RETURN 0x0 }//end USBStallHandler C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBErrorHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: The purpose of this interrupt is mainly for debugging C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * during development. Check UEIR to see which error causes C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * the interrupt. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBErrorHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eaa 9268 BCF 0x68,0x1,0x0 UIRbits.UERRIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eac 0012 RETURN 0x0 }//end USBErrorHandler C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Function: void USBProtocolResetHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * PreCondition: A USB bus reset is received from the host. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Side Effects: Currently, this routine flushes any pending USB C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * transactions. It empties out the USTAT FIFO. This action C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * might not be desirable in some applications. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Overview: Once a USB bus reset is received from the host, this C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * routine should be called. It resets the device address to C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * zero, disables all non-EP0 endpoints, initializes EP0 to C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * be ready for default communication, clears all USB C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * interrupt flags, unmasks applicable USB interrupts, and C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * reinitializes internal state-machine variables. C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c void USBProtocolResetHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eae 6a6a CLRF 0x6a,0x0 UEIR = 0; // Clear all USB error flags C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eb0 6a68 CLRF 0x68,0x0 UIR = 0; // Clears all USB interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eb2 0e9f MOVLW 0x9f UEIE = 0b10011111; // Unmask all USB error interrupts C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eb4 6e6b MOVWF 0x6b,0x0 003eb6 0e7b MOVLW 0x7b UIE = 0b01111011; // Enable all interrupts except ACTVIE C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eb8 6e69 MOVWF 0x69,0x0 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eba 6a6e CLRF 0x6e,0x0 UADDR = 0x00; // Reset to default address C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ebc 0e0f MOVLW 0xf mDisableEP1to15(); // Reset all non-EP0 UEPn registers C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ebe 6ee6 MOVWF 0xe6,0x0 003ec0 0e71 MOVLW 0x71 003ec2 6ee6 MOVWF 0xe6,0x0 003ec4 0e0f MOVLW 0xf 003ec6 6ee6 MOVWF 0xe6,0x0 003ec8 d814 RCALL 0x3ef2 003eca 52e5 MOVF 0xe5,0x1,0x0 003ecc 52e5 MOVF 0xe5,0x1,0x0 003ece 52e5 MOVF 0xe5,0x1,0x0 003ed0 0e16 MOVLW 0x16 UEP0 = EP_CTRL|HSHK_EN; // Init EP0 as a Ctrl EP, see usbdrv.h C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ed2 6e70 MOVWF 0x70,0x0 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ed4 a668 BTFSS 0x68,0x3,0x0 while(UIRbits.TRNIF == 1) // Flush any pending transactions C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ed6 d002 BRA 0x3edc 003eda d7fc BRA 0x3ed4 003ed8 9668 BCF 0x68,0x3,0x0 UIRbits.TRNIF = 0; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003edc 986d BCF 0x6d,0x4,0x0 UCONbits.PKTDIS = 0; // Make sure packet processing is enabled C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ede ec2e CALL 0x3a5c,0x0 USBPrepareForNextSetupTrf(); // Declared in usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ee0 f01d C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ee2 0101 MOVLB 0x1 usb_stat.RemoteWakeup = 0; // Default status flag to disable C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ee4 91d3 BCF 0xd3,0x0,0x1 003ee6 0101 MOVLB 0x1 usb_active_cfg = 0; // Clear active configuration C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ee8 6bd4 CLRF 0xd4,0x1 003eea 0101 MOVLB 0x1 usb_device_state = DEFAULT_STATE; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003eec 0e03 MOVLW 0x3 003eee 6fd2 MOVWF 0xd2,0x1 003ef0 0012 RETURN 0x0 }//end USBProtocolResetHandler C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /* Auxiliary Function */ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ef2 cfd9 MOVFF 0xfd9,0xfe6 void ClearArray(byte* startAdr,byte count) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003ef4 ffe6 003ef6 cfe1 MOVFF 0xfe1,0xfd9 003ef8 ffd9 { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003efa 0efd MOVLW 0xfd *startAdr; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003efc cfdb MOVFF 0xfdb,0xfe9 003efe ffe9 003f00 0efe MOVLW 0xfe 003f02 cfdb MOVFF 0xfdb,0xfea 003f04 ffea 003f06 0efc MOVLW 0xfc while(count) C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003f08 50db MOVF 0xdb,0x0,0x0 003f0a e004 BZ 0x3f14 003f12 d7f9 BRA 0x3f06 { C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c _asm C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003f0c 6aee CLRF 0xee,0x0 clrf POSTINC0,0 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c _endasm C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003f0e 0efc MOVLW 0xfc count--; C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003f10 06db DECF 0xdb,0x1,0x0 }//end while C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003f14 52e5 MOVF 0xe5,0x1,0x0 }//end ClearArray C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c 003f16 cfe7 MOVFF 0xfe7,0xfd9 003f18 ffd9 003f1a 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /** EOF usbdrv.c *************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbdrv\usbdrv.c /********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c ********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * FileName: usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Software License Agreement C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * license. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Author Date Comment C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c ********************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #include C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #include "system\typedefs.h" C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #include "system\usb\usb.h" C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #include "io_cfg.h" // Required for self_power status C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #pragma udata C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\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\D_143\system\usb\usb9\usb9.c void USBStdGetDscHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdSetCfgHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdGetStatusHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdFeatureReqHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #pragma code C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Function: void USBCheckStdRequest(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Overview: This routine checks the setup data packet to see if it C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * knows how to handle it C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBCheckStdRequest(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003a7c 0104 MOVLB 0x4 if(SetupPkt.RequestType != STANDARD) return; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003a7e 5120 MOVF 0x20,0x0,0x1 003a80 0b60 ANDLW 0x60 003a82 42e8 RRNCF 0xe8,0x1,0x0 003a84 42e8 RRNCF 0xe8,0x1,0x0 003a86 42e8 RRNCF 0xe8,0x1,0x0 003a88 42e8 RRNCF 0xe8,0x1,0x0 003a8a 42e8 RRNCF 0xe8,0x1,0x0 003a8c 0900 IORLW 0x0 003a8e e001 BZ 0x3a92 003a90 d058 BRA 0x3b42 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003a92 0104 MOVLB 0x4 switch(SetupPkt.bRequest) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003a94 5121 MOVF 0x21,0x0,0x1 003a96 0a07 XORLW 0x7 003a98 e053 BZ 0x3b40 003a9a 0a0b XORLW 0xb 003a9c e051 BZ 0x3b40 003a9e 0a07 XORLW 0x7 003aa0 e042 BZ 0x3b26 003aa2 0a01 XORLW 0x1 003aa4 e02c BZ 0x3afe 003aa6 0a0b XORLW 0xb 003aa8 e028 BZ 0x3afa 003aaa 0a02 XORLW 0x2 003aac e026 BZ 0x3afa 003aae 0a03 XORLW 0x3 003ab0 e022 BZ 0x3af6 003ab2 0a08 XORLW 0x8 003ab4 e012 BZ 0x3ada 003ab6 0a01 XORLW 0x1 003ab8 e00e BZ 0x3ad6 003aba 0a0f XORLW 0xf 003abc e00a BZ 0x3ad2 003abe 0a03 XORLW 0x3 003ac0 e001 BZ 0x3ac4 003ac2 d03e BRA 0x3b40 { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case SET_ADR: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ac4 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ac6 0e01 MOVLW 0x1 003ac8 6fcb MOVWF 0xcb,0x1 003aca 0101 MOVLB 0x1 usb_device_state = ADR_PENDING_STATE; // Update state only C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003acc 0e04 MOVLW 0x4 003ace 6fd2 MOVWF 0xd2,0x1 /* See USBCtrlTrfInHandler() in usbctrltrf.c for the next step */ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ad0 d038 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case GET_DSC: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ad2 d838 RCALL 0x3b44 USBStdGetDscHandler(); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ad4 d036 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case SET_CFG: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ad6 d893 RCALL 0x3bfe USBStdSetCfgHandler(); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ad8 d034 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case GET_CFG: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ada 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003adc 0e01 MOVLW 0x1 003ade 6fcb MOVWF 0xcb,0x1 003ae0 0101 MOVLB 0x1 pSrc.bRam = (byte*)&usb_active_cfg; // Set Source C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ae2 0ed4 MOVLW 0xd4 003ae4 6fcc MOVWF 0xcc,0x1 003ae6 0e01 MOVLW 0x1 003ae8 6fcd MOVWF 0xcd,0x1 003aea 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003aec 93d3 BCF 0xd3,0x1,0x1 003aee 0101 MOVLB 0x1 LSB(wCount) = 1; // Set data count C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003af0 0e01 MOVLW 0x1 003af2 6fd0 MOVWF 0xd0,0x1 003af4 d026 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case GET_STATUS: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003af6 d8ab RCALL 0x3c4e USBStdGetStatusHandler(); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003af8 d024 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case CLR_FEATURE: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case SET_FEATURE: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003afa d8f9 RCALL 0x3cee USBStdFeatureReqHandler(); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003afc d022 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case GET_INTF: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003afe 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b00 0e01 MOVLW 0x1 003b02 6fcb MOVWF 0xcb,0x1 003b04 0104 MOVLB 0x4 pSrc.bRam = (byte*)&usb_alt_intf+SetupPkt.bIntfID; // Set source C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b06 5124 MOVF 0x24,0x0,0x1 003b08 0101 MOVLB 0x1 003b0a 6fcc MOVWF 0xcc,0x1 003b0c 6bcd CLRF 0xcd,0x1 003b0e 0ed5 MOVLW 0xd5 003b10 0101 MOVLB 0x1 003b12 27cc ADDWF 0xcc,0x1,0x1 003b14 0e01 MOVLW 0x1 003b16 0101 MOVLB 0x1 003b18 23cd ADDWFC 0xcd,0x1,0x1 003b1a 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b1c 93d3 BCF 0xd3,0x1,0x1 003b1e 0101 MOVLB 0x1 LSB(wCount) = 1; // Set data count C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b20 0e01 MOVLW 0x1 003b22 6fd0 MOVWF 0xd0,0x1 003b24 d00e BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case SET_INTF: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b26 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b28 0e01 MOVLW 0x1 003b2a 6fcb MOVWF 0xcb,0x1 003b2c 0104 MOVLB 0x4 usb_alt_intf[SetupPkt.bIntfID] = SetupPkt.bAltID; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b2e 5124 MOVF 0x24,0x0,0x1 003b30 6aea CLRF 0xea,0x0 003b32 0fd5 ADDLW 0xd5 003b34 6ee9 MOVWF 0xe9,0x0 003b36 0e01 MOVLW 0x1 003b38 22ea ADDWFC 0xea,0x1,0x0 003b3a c422 MOVFF 0x422,0xfef 003b3c ffef 003b3e d001 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case SET_DSC: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case SYNCH_FRAME: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c default: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b40 d000 BRA 0x3b42 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c }//end switch C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b42 0012 RETURN 0x0 }//end USBCheckStdRequest C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Function: void USBStdGetDscHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Overview: This routine handles the standard GET_DESCRIPTOR request. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * It utilizes tables dynamically looks up descriptor size. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * This routine should never have to be modified if the tables C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * in usbdsc.c are declared correctly. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdGetDscHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b44 0e80 MOVLW 0x80 if(SetupPkt.bmRequestType == 0x80) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b46 0104 MOVLB 0x4 003b48 5d20 SUBWF 0x20,0x0,0x1 003b4a e158 BNZ 0x3bfc { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b4c 0104 MOVLB 0x4 switch(SetupPkt.bDscType) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b4e 5123 MOVF 0x23,0x0,0x1 003b50 0a03 XORLW 0x3 003b52 e034 BZ 0x3bbc 003b54 0a01 XORLW 0x1 003b56 e010 BZ 0x3b78 003b58 0a03 XORLW 0x3 003b5a e001 BZ 0x3b5e 003b5c d04d BRA 0x3bf8 { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case DSC_DEV: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b5e 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b60 0e01 MOVLW 0x1 003b62 6fcb MOVWF 0xcb,0x1 003b64 0101 MOVLB 0x1 pSrc.bRom = (rom byte*)&device_dsc; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b66 0e52 MOVLW 0x52 003b68 6fcc MOVWF 0xcc,0x1 003b6a 0e41 MOVLW 0x41 003b6c 6fcd MOVWF 0xcd,0x1 003b6e 0e12 MOVLW 0x12 wCount._word = sizeof(device_dsc); // Set data count C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b70 0101 MOVLB 0x1 003b72 6fd0 MOVWF 0xd0,0x1 003b74 6bd1 CLRF 0xd1,0x1 003b76 d040 BRA 0x3bf8 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case DSC_CFG: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b78 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b7a 0e01 MOVLW 0x1 003b7c 6fcb MOVWF 0xcb,0x1 003b7e 0104 MOVLB 0x4 pSrc.bRom = *(USB_CD_Ptr+SetupPkt.bDscIndex); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003b80 5122 MOVF 0x22,0x0,0x1 003b82 6ef6 MOVWF 0xf6,0x0 003b84 6af7 CLRF 0xf7,0x0 003b86 90d8 BCF 0xd8,0x0,0x0 003b88 36f6 RLCF 0xf6,0x1,0x0 003b8a 36f7 RLCF 0xf7,0x1,0x0 003b8c 0e13 MOVLW 0x13 003b8e 26f6 ADDWF 0xf6,0x1,0x0 003b90 0e42 MOVLW 0x42 003b92 22f7 ADDWFC 0xf7,0x1,0x0 003b94 0009 TBLRDPOSTINC 003b96 cff5 MOVFF 0xff5,0x1cc 003b98 f1cc 003b9a 000a TBLRDPOSTDEC 003b9c cff5 MOVFF 0xff5,0x1cd 003b9e f1cd 003ba0 0e02 MOVLW 0x2 wCount._word = *(pSrc.wRom+1); // Set data count C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ba2 0101 MOVLB 0x1 003ba4 6af7 CLRF 0xf7,0x0 003ba6 25cc ADDWF 0xcc,0x0,0x1 003ba8 6ef6 MOVWF 0xf6,0x0 003baa 51cd MOVF 0xcd,0x0,0x1 003bac 22f7 ADDWFC 0xf7,0x1,0x0 003bae 0009 TBLRDPOSTINC 003bb0 cff5 MOVFF 0xff5,0x1d0 003bb2 f1d0 003bb4 000a TBLRDPOSTDEC 003bb6 cff5 MOVFF 0xff5,0x1d1 003bb8 f1d1 003bba d01e BRA 0x3bf8 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case DSC_STR: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bbc 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bbe 0e01 MOVLW 0x1 003bc0 6fcb MOVWF 0xcb,0x1 003bc2 0104 MOVLB 0x4 pSrc.bRom = *(USB_SD_Ptr+SetupPkt.bDscIndex); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bc4 5122 MOVF 0x22,0x0,0x1 003bc6 6ef6 MOVWF 0xf6,0x0 003bc8 6af7 CLRF 0xf7,0x0 003bca 90d8 BCF 0xd8,0x0,0x0 003bcc 36f6 RLCF 0xf6,0x1,0x0 003bce 36f7 RLCF 0xf7,0x1,0x0 003bd0 0e17 MOVLW 0x17 003bd2 26f6 ADDWF 0xf6,0x1,0x0 003bd4 0e42 MOVLW 0x42 003bd6 22f7 ADDWFC 0xf7,0x1,0x0 003bd8 0009 TBLRDPOSTINC 003bda cff5 MOVFF 0xff5,0x1cc 003bdc f1cc 003bde 000a TBLRDPOSTDEC 003be0 cff5 MOVFF 0xff5,0x1cd 003be2 f1cd 003be4 c1cc MOVFF 0x1cc,0xff6 wCount._word = *pSrc.bRom; // Set data count C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003be6 fff6 003be8 c1cd MOVFF 0x1cd,0xff7 003bea fff7 003bec 0008 TBLRD 003bee 50f5 MOVF 0xf5,0x0,0x0 003bf0 0101 MOVLB 0x1 003bf2 6fd0 MOVWF 0xd0,0x1 003bf4 6bd1 CLRF 0xd1,0x1 003bf6 d000 BRA 0x3bf8 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c }//end switch C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bf8 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _ROM; // Set memory type C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bfa 83d3 BSF 0xd3,0x1,0x1 }//end if C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bfc 0012 RETURN 0x0 }//end USBStdGetDscHandler C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Function: void USBStdSetCfgHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Overview: This routine first disables all endpoints by clearing C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * UEP registers. It then configures (initializes) endpoints C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * specified in the modifiable section. C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdSetCfgHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003bfe 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c00 0e01 MOVLW 0x1 003c02 6fcb MOVWF 0xcb,0x1 003c04 0e0f MOVLW 0xf mDisableEP1to15(); // See usbdrv.h C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c06 6ee6 MOVWF 0xe6,0x0 003c08 0e71 MOVLW 0x71 003c0a 6ee6 MOVWF 0xe6,0x0 003c0c 0e0f MOVLW 0xf 003c0e 6ee6 MOVWF 0xe6,0x0 003c10 ec79 CALL 0x3ef2,0x0 003c12 f01f 003c14 52e5 MOVF 0xe5,0x1,0x0 003c16 52e5 MOVF 0xe5,0x1,0x0 003c18 52e5 MOVF 0xe5,0x1,0x0 003c1a 0e01 MOVLW 0x1 ClearArray((byte*)&usb_alt_intf,MAX_NUM_INT); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c1c 6ee6 MOVWF 0xe6,0x0 003c1e 0ed5 MOVLW 0xd5 003c20 6ee6 MOVWF 0xe6,0x0 003c22 0e01 MOVLW 0x1 003c24 6ee6 MOVWF 0xe6,0x0 003c26 ec79 CALL 0x3ef2,0x0 003c28 f01f 003c2a 52e5 MOVF 0xe5,0x1,0x0 003c2c 52e5 MOVF 0xe5,0x1,0x0 003c2e 52e5 MOVF 0xe5,0x1,0x0 003c30 c422 MOVFF 0x422,0x1d4 usb_active_cfg = SetupPkt.bCfgValue; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c32 f1d4 003c34 0104 MOVLB 0x4 if(SetupPkt.bCfgValue == 0) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c36 5122 MOVF 0x22,0x0,0x1 003c38 e104 BNZ 0x3c42 003c3a 0101 MOVLB 0x1 usb_device_state = ADDRESS_STATE; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c3c 0e05 MOVLW 0x5 003c3e 6fd2 MOVWF 0xd2,0x1 003c40 d005 BRA 0x3c4c else C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c42 0101 MOVLB 0x1 usb_device_state = CONFIGURED_STATE; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c44 0e06 MOVLW 0x6 003c46 6fd2 MOVWF 0xd2,0x1 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /* Modifiable Section */ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c #if defined(USB_USE_CDC) // See autofiles\usbcfg.h C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c48 ec1c CALL 0x3438,0x0 CDCInitEP(); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c4a f01a #endif C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /* End modifiable section */ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c }//end if(SetupPkt.bcfgValue == 0) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c4c 0012 RETURN 0x0 }//end USBStdSetCfgHandler C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Function: void USBStdGetStatusHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Overview: This routine handles the standard GET_STATUS request C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdGetStatusHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c4e 0104 MOVLB 0x4 CtrlTrfData._byte0 = 0; // Initialize content C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c50 6b28 CLRF 0x28,0x1 003c52 0104 MOVLB 0x4 CtrlTrfData._byte1 = 0; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c54 6b29 CLRF 0x29,0x1 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c56 0104 MOVLB 0x4 switch(SetupPkt.Recipient) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c58 5120 MOVF 0x20,0x0,0x1 003c5a 0b1f ANDLW 0x1f 003c5c 0a02 XORLW 0x2 003c5e e014 BZ 0x3c88 003c60 0a03 XORLW 0x3 003c62 e00e BZ 0x3c80 003c64 0a01 XORLW 0x1 003c66 e001 BZ 0x3c6a 003c68 d034 BRA 0x3cd2 { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case RCPT_DEV: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c6a 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c6c 0e01 MOVLW 0x1 003c6e 6fcb MOVWF 0xcb,0x1 /* C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * _byte0: bit0: Self-Powered Status [0] Bus-Powered [1] Self-Powered C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * bit1: RemoteWakeup [0] Disabled [1] Enabled C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c */ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c if(self_power == 1) // self_power defined in io_cfg.h C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c70 0104 MOVLB 0x4 CtrlTrfData._byte0|=0b000000001; // Set bit0 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c72 8128 BSF 0x28,0x0,0x1 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c74 0101 MOVLB 0x1 if(usb_stat.RemoteWakeup == 1) // usb_stat defined in usbmmap.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c76 a1d3 BTFSS 0xd3,0x0,0x1 003c78 d002 BRA 0x3c7e 003c7a 0104 MOVLB 0x4 CtrlTrfData._byte0|=0b00000010; // Set bit1 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c7c 8328 BSF 0x28,0x1,0x1 003c7e d029 BRA 0x3cd2 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case RCPT_INTF: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c80 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; // No data to update C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c82 0e01 MOVLW 0x1 003c84 6fcb MOVWF 0xcb,0x1 003c86 d025 BRA 0x3cd2 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c case RCPT_EP: C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c88 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c8a 0e01 MOVLW 0x1 003c8c 6fcb MOVWF 0xcb,0x1 /* C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * _byte0: bit0: Halt Status [0] Not Halted [1] Halted C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c */ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c8e 0104 MOVLB 0x4 pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003c90 5124 MOVF 0x24,0x0,0x1 003c92 0b0f ANDLW 0xf 003c94 0d08 MULLW 0x8 003c96 50f3 MOVF 0xf3,0x0,0x0 003c98 6a2b CLRF 0x2b,0x0 003c9a 0f00 ADDLW 0x0 003c9c 6e2a MOVWF 0x2a,0x0 003c9e 0e04 MOVLW 0x4 003ca0 222b ADDWFC 0x2b,0x1,0x0 003ca2 0104 MOVLB 0x4 003ca4 5124 MOVF 0x24,0x0,0x1 003ca6 0b80 ANDLW 0x80 003ca8 e001 BZ 0x3cac 003caa 0e01 MOVLW 0x1 003cac 0d04 MULLW 0x4 003cae 50f3 MOVF 0xf3,0x0,0x0 003cb0 0101 MOVLB 0x1 003cb2 242a ADDWF 0x2a,0x0,0x0 003cb4 6fce MOVWF 0xce,0x1 003cb6 0e00 MOVLW 0x0 003cb8 202b ADDWFC 0x2b,0x0,0x0 003cba 6fcf MOVWF 0xcf,0x1 003cbc c1ce MOVFF 0x1ce,0xfe9 if(*pDst.bRam & _BSTALL) // Use _BSTALL as a bit mask C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cbe ffe9 003cc0 c1cf MOVFF 0x1cf,0xfea 003cc2 ffea 003cc4 50ef MOVF 0xef,0x0,0x0 003cc6 0b04 ANDLW 0x4 003cc8 e003 BZ 0x3cd0 003cca 0104 MOVLB 0x4 CtrlTrfData._byte0=0x01;// Set bit0 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ccc 0e01 MOVLW 0x1 003cce 6f28 MOVWF 0x28,0x1 003cd0 d000 BRA 0x3cd2 break; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c }//end switch C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cd2 0101 MOVLB 0x1 if(ctrl_trf_session_owner == MUID_USB9) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cd4 05cb DECF 0xcb,0x0,0x1 003cd6 e10a BNZ 0x3cec { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cd8 0101 MOVLB 0x1 pSrc.bRam = (byte*)&CtrlTrfData; // Set Source C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cda 0e28 MOVLW 0x28 003cdc 6fcc MOVWF 0xcc,0x1 003cde 0e04 MOVLW 0x4 003ce0 6fcd MOVWF 0xcd,0x1 003ce2 0101 MOVLB 0x1 usb_stat.ctrl_trf_mem = _RAM; // Set memory type C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ce4 93d3 BCF 0xd3,0x1,0x1 003ce6 0101 MOVLB 0x1 LSB(wCount) = 2; // Set data count C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003ce8 0e02 MOVLW 0x2 003cea 6fd0 MOVWF 0xd0,0x1 }//end if(...) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cec 0012 RETURN 0x0 }//end USBStdGetStatusHandler C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Function: void USBStdFeatureReqHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Overview: This routine handles the standard SET & CLEAR FEATURES C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * requests C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c void USBStdFeatureReqHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cee 0104 MOVLB 0x4 if((SetupPkt.bFeature == DEVICE_REMOTE_WAKEUP)&& C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cf0 0522 DECF 0x22,0x0,0x1 003cf2 e111 BNZ 0x3d16 (SetupPkt.Recipient == RCPT_DEV)) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cf4 0104 MOVLB 0x4 003cf6 5120 MOVF 0x20,0x0,0x1 003cf8 0b1f ANDLW 0x1f 003cfa 0900 IORLW 0x0 003cfc e10c BNZ 0x3d16 { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003cfe 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d00 0e01 MOVLW 0x1 003d02 6fcb MOVWF 0xcb,0x1 003d04 0e03 MOVLW 0x3 if(SetupPkt.bRequest == SET_FEATURE) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d06 0104 MOVLB 0x4 003d08 5d21 SUBWF 0x21,0x0,0x1 003d0a e103 BNZ 0x3d12 003d0c 0101 MOVLB 0x1 usb_stat.RemoteWakeup = 1; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d0e 81d3 BSF 0xd3,0x0,0x1 003d10 d002 BRA 0x3d16 else C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d12 0101 MOVLB 0x1 usb_stat.RemoteWakeup = 0; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d14 91d3 BCF 0xd3,0x0,0x1 }//end if C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d16 0104 MOVLB 0x4 if((SetupPkt.bFeature == ENDPOINT_HALT)&& C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d18 5122 MOVF 0x22,0x0,0x1 003d1a e13e BNZ 0x3d98 (SetupPkt.Recipient == RCPT_EP)&& C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d1c 0104 MOVLB 0x4 003d1e 5120 MOVF 0x20,0x0,0x1 003d20 0b1f ANDLW 0x1f 003d22 0802 SUBLW 0x2 003d24 e139 BNZ 0x3d98 003d26 0104 MOVLB 0x4 (SetupPkt.EPNum != 0)) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d28 5124 MOVF 0x24,0x0,0x1 003d2a 0b0f ANDLW 0xf 003d2c 0900 IORLW 0x0 003d2e e034 BZ 0x3d98 { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d30 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_USB9; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d32 0e01 MOVLW 0x1 003d34 6fcb MOVWF 0xcb,0x1 /* Must do address calculation here */ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d36 0104 MOVLB 0x4 pDst.bRam = (byte*)&ep0Bo+(SetupPkt.EPNum*8)+(SetupPkt.EPDir*4); C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d38 5124 MOVF 0x24,0x0,0x1 003d3a 0b0f ANDLW 0xf 003d3c 0d08 MULLW 0x8 003d3e 50f3 MOVF 0xf3,0x0,0x0 003d40 6a2b CLRF 0x2b,0x0 003d42 0f00 ADDLW 0x0 003d44 6e2a MOVWF 0x2a,0x0 003d46 0e04 MOVLW 0x4 003d48 222b ADDWFC 0x2b,0x1,0x0 003d4a 0104 MOVLB 0x4 003d4c 5124 MOVF 0x24,0x0,0x1 003d4e 0b80 ANDLW 0x80 003d50 e001 BZ 0x3d54 003d52 0e01 MOVLW 0x1 003d54 0d04 MULLW 0x4 003d56 50f3 MOVF 0xf3,0x0,0x0 003d58 0101 MOVLB 0x1 003d5a 242a ADDWF 0x2a,0x0,0x0 003d5c 6fce MOVWF 0xce,0x1 003d5e 0e00 MOVLW 0x0 003d60 202b ADDWFC 0x2b,0x0,0x0 003d62 6fcf MOVWF 0xcf,0x1 C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d64 0e03 MOVLW 0x3 if(SetupPkt.bRequest == SET_FEATURE) C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d66 0104 MOVLB 0x4 003d68 5d21 SUBWF 0x21,0x0,0x1 003d6a e107 BNZ 0x3d7a 003d6c 0e84 MOVLW 0x84 *pDst.bRam = _USIE|_BSTALL; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d6e c1ce MOVFF 0x1ce,0xfe9 003d70 ffe9 003d72 c1cf MOVFF 0x1cf,0xfea 003d74 ffea 003d76 6eef MOVWF 0xef,0x0 003d78 d00f BRA 0x3d98 else C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c { C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d7a 0104 MOVLB 0x4 if(SetupPkt.EPDir == 1) // IN C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d7c af24 BTFSS 0x24,0x7,0x1 003d7e d006 BRA 0x3d8c 003d80 c1ce MOVFF 0x1ce,0xfe9 *pDst.bRam = _UCPU; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d82 ffe9 003d84 c1cf MOVFF 0x1cf,0xfea 003d86 ffea 003d88 6aef CLRF 0xef,0x0 003d8a d006 BRA 0x3d98 else C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d8c 0e88 MOVLW 0x88 *pDst.bRam = _USIE|_DAT0|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d8e c1ce MOVFF 0x1ce,0xfe9 003d90 ffe9 003d92 c1cf MOVFF 0x1cf,0xfea 003d94 ffea 003d96 6eef MOVWF 0xef,0x0 }//end if C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c }//end if C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c 003d98 0012 RETURN 0x0 }//end USBStdFeatureReqHandler C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /** EOF usb9.c ***************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usb9\usb9.c /********************************************************************* C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c ********************************************************************* C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * FileName: usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Software License Agreement C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * license. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c ********************************************************************/ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /********************************************************************* C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * -usbdsc.c- C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * This file contains the USB descriptor information. It is used C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * in conjunction with the usbdsc.h file. When a descriptor is added C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * or removed from the main configuration descriptor, i.e. CFG01, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * the user must also change the descriptor structure defined in C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * the usbdsc.h file. The structure is used to calculate the C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * descriptor size, i.e. sizeof(CFG01). C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * A typical configuration descriptor consists of: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * At least one configuration descriptor (USB_CFG_DSC) C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * One or more interface descriptors (USB_INTF_DSC) C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * One or more endpoint descriptors (USB_EP_DSC) C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Naming Convention: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * To resolve ambiguity, the naming convention are as followed: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * - USB_CFG_DSC type should be named cdxx, where xx is the C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * configuration number. This number should match the actual C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * index value of this configuration. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * - USB_INTF_DSC type should be named ia, where yy is the C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * interface number and zz is the alternate interface number. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * - USB_EP_DSC type should be named ep<##>_ia, where C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * ## is the endpoint number and d is the direction of transfer. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The interface name should also be listed as a suffix to identify C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * which interface does the endpoint belong to. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Example: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * If a device has one configuration, two interfaces; interface 0 C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * has two endpoints (in and out), and interface 1 has one endpoint(in). C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Then the CFG01 structure in the usbdsc.h should be: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * #define CFG01 rom struct \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * { USB_CFG_DSC cd01; \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * USB_INTF_DSC i00a00; \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * USB_EP_DSC ep01o_i00a00; \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * USB_EP_DSC ep01i_i00a00; \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * USB_INTF_DSC i01a00; \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * USB_EP_DSC ep02i_i01a00; \ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * } cfg01 C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Note the hierarchy of the descriptors above, it follows the USB C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * specification requirement. All endpoints belonging to an interface C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * should be listed immediately after that interface. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Filling in the descriptor values in the usbdsc.c file: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Most items should be self-explanatory, however, a few will be C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * explained for clarification. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * [Configuration Descriptor(USB_CFG_DSC)] C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The configuration attribute must always have the _DEFAULT C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * definition at the minimum. Additional options can be ORed C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * to the _DEFAULT attribute. Available options are _SELF and _RWU. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * These definitions are defined in the usbdefs_std_dsc.h file. The C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * _SELF tells the USB host that this device is self-powered. The C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * _RWU tells the USB host that this device supports Remote Wakeup. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * [Endpoint Descriptor(USB_EP_DSC)] C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Assume the following example: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * sizeof(USB_EP_DSC),DSC_EP,_EP01_OUT,_BULK,64,0x00 C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The first two parameters are self-explanatory. They specify the C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * length of this endpoint descriptor (7) and the descriptor type. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The next parameter identifies the endpoint, the definitions are C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * defined in usbdefs_std_dsc.h and has the following naming C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * convention: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * _EP<##>_ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * where ## is the endpoint number and dir is the direction of C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * transfer. The dir has the value of either 'OUT' or 'IN'. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The next parameter identifies the type of the endpoint. Available C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * options are _BULK, _INT, _ISO, and _CTRL. The _CTRL is not C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * typically used because the default control transfer endpoint is C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * not defined in the USB descriptors. When _ISO option is used, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * addition options can be ORed to _ISO. Example: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * _ISO|_AD|_FE C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * This describes the endpoint as an isochronous pipe with adaptive C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * and feedback attributes. See usbdefs_std_dsc.h and the USB C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * specification for details. The next parameter defines the size of C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * the endpoint. The last parameter in the polling interval. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Adding a USB String C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * A string descriptor array should have the following format: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * rom struct{byte bLength;byte bDscType;word string[size];}sdxxx={ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * sizeof(sdxxx),DSC_STR,}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The above structure provides a means for the C compiler to C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * calculate the length of string descriptor sdxxx, where xxx is the C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * index number. The first two bytes of the descriptor are descriptor C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * length and type. The rest are string texts which must be C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * in the unicode format. The unicode format is achieved by declaring C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * each character as a word type. The whole text string is declared C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * as a word array with the number of characters equals to . C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * has to be manually counted and entered into the array C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * declaration. Let's study this through an example: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * if the string is "USB" , then the string descriptor should be: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * (Using index 02) C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * rom struct{byte bLength;byte bDscType;word string[3];}sd002={ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * sizeof(sd002),DSC_STR,'U','S','B'}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * A USB project may have multiple strings and the firmware supports C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * the management of multiple strings through a look-up table. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The look-up table is defined as: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The above declaration has 3 strings, sd000, sd001, and sd002. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Strings can be removed or added. sd000 is a specialized string C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * descriptor. It defines the language code, usually this is C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * US English (0x0409). The index of the string must match the index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * position of the USB_SD_Ptr array, &sd000 must be in position C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * USB_SD_Ptr[0], &sd001 must be in position USB_SD_Ptr[1] and so on. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The look-up table USB_SD_Ptr is used by the get string handler C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * function in usb9.c. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * ------------------------------------------------------------------- C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The look-up table scheme also applies to the configuration C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * descriptor. A USB device may have multiple configuration C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * descriptors, i.e. CFG01, CFG02, etc. To add a configuration C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * descriptor, user must implement a structure similar to CFG01. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * The next step is to add the configuration descriptor name, i.e. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * cfg01, cfg02,.., to the look-up table USB_CD_Ptr. USB_CD_Ptr[0] C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * is a dummy place holder since configuration 0 is the un-configured C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * state according to the definition in the USB specification. C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c ********************************************************************/ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /********************************************************************* C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Descriptor specific type definitions are defined in: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * system\usb\usbdefs\usbdefs_std_dsc.h C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * Configuration information is defined in: C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c * autofiles\usbcfg.h C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c ********************************************************************/ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /** I N C L U D E S *************************************************/ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c #include "system\typedefs.h" C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c #include "system\usb\usb.h" C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /** C O N S T A N T S ************************************************/ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c #pragma romdata C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Device Descriptor */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom USB_DEV_DSC device_dsc= C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c { C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_DEV_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c DSC_DEV, // DEVICE descriptor type C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x0200, // USB Spec Release Number in BCD format C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c CDC_DEVICE, // Class Code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x00, // Subclass code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x00, // Protocol code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c EP0_BUFF_SIZE, // Max packet size for EP0, see usbcfg.h C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x04D8, // Vendor ID C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x000A, // Product ID: CDC RS-232 Emulation Demo C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x0000, // Device release number in BCD format C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x01, // Manufacturer string index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x02, // Product string index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x00, // Device serial number string index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0x01 // Number of possible configurations C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c }; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Configuration 1 Descriptor */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c CFG01= C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c { C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Configuration Descriptor */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_CFG_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c DSC_CFG, // CONFIGURATION descriptor type C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(cfg01), // Total length of data for this cfg C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 2, // Number of interfaces in this cfg C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 1, // Index value of this configuration C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Configuration string index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c _DEFAULT, // Attributes, see usbdefs_std_dsc.h C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 50, // Max power consumption (2X mA) C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Interface Descriptor */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_INTF_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c DSC_INTF, // INTERFACE descriptor type C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Interface Number C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Alternate Setting Number C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 1, // Number of endpoints in this intf C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c COMM_INTF, // Class code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c ABSTRACT_CONTROL_MODEL, // Subclass code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c V25TER, // Protocol code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Interface string index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* CDC Class-Specific Descriptors */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_CDC_HEADER_FN_DSC),CS_INTERFACE,DSC_FN_HEADER,0x0110, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_CDC_ACM_FN_DSC),CS_INTERFACE,DSC_FN_ACM,0x02, C:\Projects\UBW\FW\D_143\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\D_143\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\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Endpoint Descriptor */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP02_IN,_INT,CDC_INT_EP_SIZE,0x02, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Interface Descriptor */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_INTF_DSC), // Size of this descriptor in bytes C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c DSC_INTF, // INTERFACE descriptor type C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 1, // Interface Number C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Alternate Setting Number C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 2, // Number of endpoints in this intf C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c DATA_INTF, // Class code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Subclass code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c NO_PROTOCOL, // Protocol code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 0, // Interface string index C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /* Endpoint Descriptors */ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP03_OUT,_BULK,CDC_BULK_OUT_EP_SIZE,0x00, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(USB_EP_DSC),DSC_EP,_EP03_IN,_BULK,CDC_BULK_IN_EP_SIZE,0x00 C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c }; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[1];}sd000={ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(sd000),DSC_STR,0x0409}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[25];}sd001={ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(sd001),DSC_STR, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 'M','i','c','r','o','c','h','i','p',' ', C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom struct{byte bLength;byte bDscType;word string[25];}sd002={ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c sizeof(sd002),DSC_STR, C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 'C','D','C',' ','R','S','-','2','3','2',' ', C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c 'E','m','u','l','a','t','i','o','n',' ','D','e','m','o'}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom const unsigned char *rom USB_CD_Ptr[]={&cfg01,&cfg01}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002}; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c rom pFunc ClassReqHandler[1]= C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c { C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c &USBCheckCDCRequest C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c }; C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c #pragma code C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /** EOF usbdsc.c ****************************************************/ C:\Projects\UBW\FW\D_143\autofiles\usbdsc.c /********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c ********************************************************************* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * FileName: usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Software License Agreement C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * license. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Author Date Comment C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c ********************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c #include C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c #include "system\typedefs.h" C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c #include "system\usb\usb.h" C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c #pragma udata C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c byte ctrl_trf_state; // Control Transfer State C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c byte ctrl_trf_session_owner; // Current transfer session owner C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c POINTER pSrc; // Data source pointer C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c POINTER pDst; // Data destination pointer C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c WORD wCount; // Data counter C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\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\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfSetupHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfOutHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfInHandler(void); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c #pragma code C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlEPService(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: USTAT is loaded with a valid endpoint address. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: USBCtrlEPService checks for three transaction types that C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * it knows how to service and services them: C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 1. EP0 SETUP C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 2. EP0 OUT C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 3. EP0 IN C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * It ignores all other types (i.e. EP1, EP2, etc.) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlEPService(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003742 506c MOVF 0x6c,0x0,0x0 if(USTAT == EP00_OUT) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003744 e002 BZ 0x374a 003746 0e00 MOVLW 0x0 003748 d001 BRA 0x374c 00374a 0e01 MOVLW 0x1 00374c 0900 IORLW 0x0 00374e e00b BZ 0x3766 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003750 0104 MOVLB 0x4 if(ep0Bo.Stat.PID == SETUP_TOKEN) // EP0 SETUP C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003752 5100 MOVF 0x0,0x0,0x1 003754 0b3c ANDLW 0x3c 003756 42e8 RRNCF 0xe8,0x1,0x0 003758 42e8 RRNCF 0xe8,0x1,0x0 00375a 080d SUBLW 0xd 00375c e102 BNZ 0x3762 00375e d80c RCALL 0x3778 USBCtrlTrfSetupHandler(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003760 d001 BRA 0x3764 else // EP0 OUT C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003762 d842 RCALL 0x37e8 USBCtrlTrfOutHandler(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c } C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003764 d008 BRA 0x3776 else if(USTAT == EP00_IN) // EP0 IN C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003766 506c MOVF 0x6c,0x0,0x0 003768 e002 BZ 0x376e 00376a 0e00 MOVLW 0x0 00376c d001 BRA 0x3770 00376e 0e01 MOVLW 0x1 003770 0904 IORLW 0x4 003772 e001 BZ 0x3776 003774 d84b RCALL 0x380c USBCtrlTrfInHandler(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003776 0012 RETURN 0x0 }//end USBCtrlEPService C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfSetupHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: SetupPkt buffer is loaded with valid USB Setup Data C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine is a task dispatcher and has 3 stages. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 1. It initializes the control transfer state machine. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 2. It calls on each of the module that may know how to C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * service the Setup Request from the host. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Module Example: USB9, HID, CDC, MSD, ... C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * As new classes are added, ClassReqHandler table in C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * usbdsc.c should be updated to call all available C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * class handlers. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 3. Once each of the modules has had a chance to check if C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * it is responsible for servicing the request, stage 3 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * then checks direction of the transfer to determine how C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * to prepare EP0 for the control transfer. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Refer to USBCtrlEPServiceComplete() for more details. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: Microchip USB Firmware has three different states for C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * the control transfer state machine: C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 1. WAIT_SETUP C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 2. CTRL_TRF_TX C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 3. CTRL_TRF_RX C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Refer to firmware manual to find out how one state C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * is transitioned to another. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * A Control Transfer is composed of many USB transactions. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * When transferring data over multiple transactions, C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * it is important to keep track of data source, data C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * destination, and data count. These three parameters are C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * stored in pSrc,pDst, and wCount. A flag is used to C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * note if the data source is from ROM or RAM. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003778 cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfSetupHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00377a ffe6 00377c cfe1 MOVFF 0xfe1,0xfd9 00377e ffd9 003780 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c byte i; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* Stage 1 */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003782 0101 MOVLB 0x1 ctrl_trf_state = WAIT_SETUP; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003784 6bca CLRF 0xca,0x1 003786 0101 MOVLB 0x1 ctrl_trf_session_owner = MUID_NULL; // Set owner to NULL C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003788 6bcb CLRF 0xcb,0x1 00378a 0101 MOVLB 0x1 wCount._word = 0; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00378c 6bd0 CLRF 0xd0,0x1 00378e 6bd1 CLRF 0xd1,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* Stage 2 */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003790 ec3e CALL 0x3a7c,0x0 USBCheckStdRequest(); // See system\usb9\usb9.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003792 f01d C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003794 6adf CLRF 0xdf,0x0 for(i=0;i < (sizeof(ClassReqHandler)/sizeof(pFunc));i++) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003796 50df MOVF 0xdf,0x0,0x0 003798 6e2a MOVWF 0x2a,0x0 00379a 6a2b CLRF 0x2b,0x0 00379c 0e01 MOVLW 0x1 00379e 5c2a SUBWF 0x2a,0x0,0x0 0037a0 0e00 MOVLW 0x0 0037a2 582b SUBWFB 0x2b,0x0,0x0 0037a4 e21b BC 0x37dc 0037d8 2adf INCF 0xdf,0x1,0x0 0037da d7dd BRA 0x3796 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037a6 0101 MOVLB 0x1 if(ctrl_trf_session_owner != MUID_NULL)break; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037a8 51cb MOVF 0xcb,0x0,0x1 0037aa e001 BZ 0x37ae 0037ac d017 BRA 0x37dc 0037ae 6af7 CLRF 0xf7,0x0 ClassReqHandler[i](); // See autofiles\usbdsc.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037b0 34df RLCF 0xdf,0x0,0x0 0037b2 0bfe ANDLW 0xfe 0037b4 36f7 RLCF 0xf7,0x1,0x0 0037b6 6ef6 MOVWF 0xf6,0x0 0037b8 0e1d MOVLW 0x1d 0037ba 26f6 ADDWF 0xf6,0x1,0x0 0037bc 0e42 MOVLW 0x42 0037be 22f7 ADDWFC 0xf7,0x1,0x0 0037c0 0009 TBLRDPOSTINC 0037c2 cff5 MOVFF 0xff5,0x2a 0037c4 f02a 0037c6 0008 TBLRD 0037c8 cff5 MOVFF 0xff5,0x2b 0037ca f02b 0037cc d004 BRA 0x37d6 0037ce c02b MOVFF 0x2b,0xffa 0037d0 fffa 0037d2 502a MOVF 0x2a,0x0,0x0 0037d4 6ef9 MOVWF 0xf9,0x0 0037d6 dffb RCALL 0x37ce }//end while C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* Stage 3 */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037dc d8f0 RCALL 0x39be USBCtrlEPServiceComplete(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037de 52e5 MOVF 0xe5,0x1,0x0 }//end USBCtrlTrfSetupHandler C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037e0 52e5 MOVF 0xe5,0x1,0x0 0037e2 cfe7 MOVFF 0xfe7,0xfd9 0037e4 ffd9 0037e6 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfOutHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine handles an OUT transaction according to C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * which control transfer state is currently active. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: Note that if the the control transfer was from C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * host to device, the session owner should be notified C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * at the end of each OUT transaction to service the C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * received data. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfOutHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037e8 0e02 MOVLW 0x2 if(ctrl_trf_state == CTRL_TRF_RX) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037ea 0101 MOVLB 0x1 0037ec 5dca SUBWF 0xca,0x0,0x1 0037ee e10c BNZ 0x3808 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037f0 d8a4 RCALL 0x393a USBCtrlTrfRxService(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Don't have to worry about overwriting _KEEP bit C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * because if _KEEP was set, TRNIF would not have been C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * generated in the first place. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037f2 0104 MOVLB 0x4 if(ep0Bo.Stat.DTS == 0) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037f4 bd00 BTFSC 0x0,0x6,0x1 0037f6 d004 BRA 0x3800 0037f8 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0037fa 0ec8 MOVLW 0xc8 0037fc 6f00 MOVWF 0x0,0x1 0037fe d003 BRA 0x3806 else C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003800 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT0|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003802 0e88 MOVLW 0x88 003804 6f00 MOVWF 0x0,0x1 } C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003806 d001 BRA 0x380a else // CTRL_TRF_TX C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003808 d929 RCALL 0x3a5c USBPrepareForNextSetupTrf(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00380a 0012 RETURN 0x0 }//end USBCtrlTrfOutHandler C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfInHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine handles an IN transaction according to C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * which control transfer state is currently active. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: A Set Address Request must not change the acutal address C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * of the device until the completion of the control C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * transfer. The end of the control transfer for Set Address C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Request is an IN transaction. Therefore it is necessary C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * to service this unique situation when the condition is C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * right. Macro mUSBCheckAdrPendingState is defined in C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * usb9.h and its function is to specifically service this C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * event. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlTrfInHandler(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00380c 0e04 MOVLW 0x4 mUSBCheckAdrPendingState(); // Must check if in ADR_PENDING_STATE C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00380e 0101 MOVLB 0x1 003810 5dd2 SUBWF 0xd2,0x0,0x1 003812 e10c BNZ 0x382c 003814 c422 MOVFF 0x422,0xf6e 003816 ff6e 003818 506e MOVF 0x6e,0x0,0x0 00381a 0800 SUBLW 0x0 00381c e204 BC 0x3826 00381e 0101 MOVLB 0x1 003820 0e05 MOVLW 0x5 003822 6fd2 MOVWF 0xd2,0x1 003824 d003 BRA 0x382c 003826 0101 MOVLB 0x1 003828 0e03 MOVLW 0x3 00382a 6fd2 MOVWF 0xd2,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00382c 0101 MOVLB 0x1 if(ctrl_trf_state == CTRL_TRF_TX) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00382e 05ca DECF 0xca,0x0,0x1 003830 e10c BNZ 0x384a { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003832 d80d RCALL 0x384e USBCtrlTrfTxService(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003834 0104 MOVLB 0x4 if(ep0Bi.Stat.DTS == 0) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003836 bd04 BTFSC 0x4,0x6,0x1 003838 d004 BRA 0x3842 00383a 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00383c 0ec8 MOVLW 0xc8 00383e 6f04 MOVWF 0x4,0x1 003840 d003 BRA 0x3848 else C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003842 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT0|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003844 0e88 MOVLW 0x88 003846 6f04 MOVWF 0x4,0x1 } C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003848 d001 BRA 0x384c else // CTRL_TRF_RX C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00384a d908 RCALL 0x3a5c USBPrepareForNextSetupTrf(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00384c 0012 RETURN 0x0 }//end USBCtrlTrfInHandler C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfTxService(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: pSrc, wCount, and usb_stat.ctrl_trf_mem are setup properly. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine should be called from only two places. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * One from USBCtrlEPServiceComplete() and one from C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * USBCtrlTrfInHandler(). It takes care of managing a C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * transfer over multiple USB transactions. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: This routine works with isochronous endpoint larger than C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 256 bytes and is shown here as an example of how to deal C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * with BC9 and BC8. In reality, a control endpoint can never C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * be larger than 64 bytes. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00384e cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfTxService(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003850 ffe6 003852 cfe1 MOVFF 0xfe1,0xfd9 003854 ffd9 003856 0e02 MOVLW 0x2 003858 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c WORD byte_to_send; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * First, have to figure out how many byte of data to send. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00385a 0101 MOVLB 0x1 if(wCount._word < EP0_BUFF_SIZE) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00385c 0e08 MOVLW 0x8 00385e 5dd0 SUBWF 0xd0,0x0,0x1 003860 0e00 MOVLW 0x0 003862 59d1 SUBWFB 0xd1,0x0,0x1 003864 e205 BC 0x3870 003866 c1d0 MOVFF 0x1d0,0xfde byte_to_send._word = wCount._word; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003868 ffde 00386a c1d1 MOVFF 0x1d1,0xfdd 00386c ffdd 00386e d003 BRA 0x3876 else C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003870 0e08 MOVLW 0x8 byte_to_send._word = EP0_BUFF_SIZE; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003872 6ede MOVWF 0xde,0x0 003874 6add CLRF 0xdd,0x0 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Next, load the number of bytes to send to BC9..0 in buffer descriptor C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003876 0104 MOVLB 0x4 ep0Bi.Stat.BC9 = 0; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003878 9304 BCF 0x4,0x1,0x1 00387a 0104 MOVLB 0x4 ep0Bi.Stat.BC8 = 0; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00387c 9104 BCF 0x4,0x0,0x1 00387e 0e01 MOVLW 0x1 ep0Bi.Stat._byte |= MSB(byte_to_send); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003880 50db MOVF 0xdb,0x0,0x0 003882 0104 MOVLB 0x4 003884 1304 IORWF 0x4,0x1,0x1 003886 cfdf MOVFF 0xfdf,0x405 ep0Bi.Cnt = LSB(byte_to_send); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003888 f405 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Subtract the number of bytes just about to be sent from the total. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00388a 0e00 MOVLW 0x0 wCount._word = wCount._word - byte_to_send._word; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00388c 50db MOVF 0xdb,0x0,0x0 00388e 0101 MOVLB 0x1 003890 5fd0 SUBWF 0xd0,0x1,0x1 003892 0e01 MOVLW 0x1 003894 50db MOVF 0xdb,0x0,0x0 003896 0101 MOVLB 0x1 003898 5bd1 SUBWFB 0xd1,0x1,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00389a 0101 MOVLB 0x1 pDst.bRam = (byte*)&CtrlTrfData; // Set destination pointer C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00389c 0e28 MOVLW 0x28 00389e 6fce MOVWF 0xce,0x1 0038a0 0e04 MOVLW 0x4 0038a2 6fcf MOVWF 0xcf,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038a4 0101 MOVLB 0x1 if(usb_stat.ctrl_trf_mem == _ROM) // Determine type of memory source C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038a6 a3d3 BTFSS 0xd3,0x1,0x1 0038a8 d020 BRA 0x38ea { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038aa cfd9 MOVFF 0xfd9,0xfe9 while(byte_to_send._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038ac ffe9 0038ae cfda MOVFF 0xfda,0xfea 0038b0 ffea 0038b2 50ee MOVF 0xee,0x0,0x0 0038b4 10ed IORWF 0xed,0x0,0x0 0038b6 e018 BZ 0x38e8 0038e6 d7e1 BRA 0x38aa { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038b8 c1cc MOVFF 0x1cc,0xff6 *pDst.bRam = *pSrc.bRom; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038ba fff6 0038bc c1cd MOVFF 0x1cd,0xff7 0038be fff7 0038c0 0008 TBLRD 0038c2 50f5 MOVF 0xf5,0x0,0x0 0038c4 c1ce MOVFF 0x1ce,0xfe9 0038c6 ffe9 0038c8 c1cf MOVFF 0x1cf,0xfea 0038ca ffea 0038cc 6eef MOVWF 0xef,0x0 0038ce 0101 MOVLB 0x1 pDst.bRam++; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038d0 2bce INCF 0xce,0x1,0x1 0038d2 0e00 MOVLW 0x0 0038d4 23cf ADDWFC 0xcf,0x1,0x1 0038d6 0101 MOVLB 0x1 pSrc.bRom++; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038d8 2bcc INCF 0xcc,0x1,0x1 0038da 0e00 MOVLW 0x0 0038dc 23cd ADDWFC 0xcd,0x1,0x1 0038de 06df DECF 0xdf,0x1,0x0 byte_to_send._word--; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038e0 0e01 MOVLW 0x1 0038e2 e201 BC 0x38e6 0038e4 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_send._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c } C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038e8 d01e BRA 0x3926 else // RAM C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038ea cfd9 MOVFF 0xfd9,0xfe9 while(byte_to_send._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038ec ffe9 0038ee cfda MOVFF 0xfda,0xfea 0038f0 ffea 0038f2 50ee MOVF 0xee,0x0,0x0 0038f4 10ed IORWF 0xed,0x0,0x0 0038f6 e017 BZ 0x3926 003924 d7e2 BRA 0x38ea { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038f8 c1cc MOVFF 0x1cc,0xfe9 *pDst.bRam = *pSrc.bRam; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0038fa ffe9 0038fc c1cd MOVFF 0x1cd,0xfea 0038fe ffea 003900 50ef MOVF 0xef,0x0,0x0 003902 c1ce MOVFF 0x1ce,0xfe9 003904 ffe9 003906 c1cf MOVFF 0x1cf,0xfea 003908 ffea 00390a 6eef MOVWF 0xef,0x0 00390c 0101 MOVLB 0x1 pDst.bRam++; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00390e 2bce INCF 0xce,0x1,0x1 003910 0e00 MOVLW 0x0 003912 23cf ADDWFC 0xcf,0x1,0x1 003914 0101 MOVLB 0x1 pSrc.bRam++; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003916 2bcc INCF 0xcc,0x1,0x1 003918 0e00 MOVLW 0x0 00391a 23cd ADDWFC 0xcd,0x1,0x1 00391c 06df DECF 0xdf,0x1,0x0 byte_to_send._word--; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00391e 0e01 MOVLW 0x1 003920 e201 BC 0x3924 003922 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_send._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c }//end if(usb_stat.ctrl_trf_mem == _ROM) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003926 0e02 MOVLW 0x2 }//end USBCtrlTrfTxService C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003928 5ce1 SUBWF 0xe1,0x0,0x0 00392a e202 BC 0x3930 00392c 6ae1 CLRF 0xe1,0x0 00392e 52e5 MOVF 0xe5,0x1,0x0 003930 6ee1 MOVWF 0xe1,0x0 003932 52e5 MOVF 0xe5,0x1,0x0 003934 cfe7 MOVFF 0xfe7,0xfd9 003936 ffd9 003938 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlTrfRxService(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: pDst and wCount are setup properly. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * pSrc is always &CtrlTrfData C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * usb_stat.ctrl_trf_mem is always _RAM. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * wCount should be set to 0 at the start of each control C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * transfer. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: *** This routine is only partially complete. Check for C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * new version of the firmware. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00393a cfd9 MOVFF 0xfd9,0xfe6 void USBCtrlTrfRxService(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00393c ffe6 00393e cfe1 MOVFF 0xfe1,0xfd9 003940 ffd9 003942 0e02 MOVLW 0x2 003944 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c WORD byte_to_read; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003946 0e03 MOVLW 0x3 MSB(byte_to_read) = 0x03 & ep0Bo.Stat._byte; // Filter out last 2 bits C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003948 0104 MOVLB 0x4 00394a 1500 ANDWF 0x0,0x0,0x1 00394c 6ee7 MOVWF 0xe7,0x0 00394e 0e01 MOVLW 0x1 003950 cfe7 MOVFF 0xfe7,0xfdb 003952 ffdb 003954 c401 MOVFF 0x401,0xfdf LSB(byte_to_read) = ep0Bo.Cnt; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003956 ffdf C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Accumulate total number of bytes read C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003958 50de MOVF 0xde,0x0,0x0 wCount._word = wCount._word + byte_to_read._word; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00395a 0101 MOVLB 0x1 00395c 27d0 ADDWF 0xd0,0x1,0x1 00395e 50dd MOVF 0xdd,0x0,0x0 003960 0101 MOVLB 0x1 003962 23d1 ADDWFC 0xd1,0x1,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003964 0101 MOVLB 0x1 pSrc.bRam = (byte*)&CtrlTrfData; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003966 0e28 MOVLW 0x28 003968 6fcc MOVWF 0xcc,0x1 00396a 0e04 MOVLW 0x4 00396c 6fcd MOVWF 0xcd,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00396e cfd9 MOVFF 0xfd9,0xfe9 while(byte_to_read._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003970 ffe9 003972 cfda MOVFF 0xfda,0xfea 003974 ffea 003976 50ee MOVF 0xee,0x0,0x0 003978 10ed IORWF 0xed,0x0,0x0 00397a e017 BZ 0x39aa 0039a8 d7e2 BRA 0x396e { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00397c c1cc MOVFF 0x1cc,0xfe9 *pDst.bRam = *pSrc.bRam; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00397e ffe9 003980 c1cd MOVFF 0x1cd,0xfea 003982 ffea 003984 50ef MOVF 0xef,0x0,0x0 003986 c1ce MOVFF 0x1ce,0xfe9 003988 ffe9 00398a c1cf MOVFF 0x1cf,0xfea 00398c ffea 00398e 6eef MOVWF 0xef,0x0 003990 0101 MOVLB 0x1 pDst.bRam++; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003992 2bce INCF 0xce,0x1,0x1 003994 0e00 MOVLW 0x0 003996 23cf ADDWFC 0xcf,0x1,0x1 003998 0101 MOVLB 0x1 pSrc.bRam++; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 00399a 2bcc INCF 0xcc,0x1,0x1 00399c 0e00 MOVLW 0x0 00399e 23cd ADDWFC 0xcd,0x1,0x1 0039a0 06df DECF 0xdf,0x1,0x0 byte_to_read._word--; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039a2 0e01 MOVLW 0x1 0039a4 e201 BC 0x39a8 0039a6 06db DECF 0xdb,0x1,0x0 }//end while(byte_to_read._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039aa 0e02 MOVLW 0x2 }//end USBCtrlTrfRxService C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039ac 5ce1 SUBWF 0xe1,0x0,0x0 0039ae e202 BC 0x39b4 0039b0 6ae1 CLRF 0xe1,0x0 0039b2 52e5 MOVF 0xe5,0x1,0x0 0039b4 6ee1 MOVWF 0xe1,0x0 0039b6 52e5 MOVF 0xe5,0x1,0x0 0039b8 cfe7 MOVFF 0xfe7,0xfd9 0039ba ffd9 0039bc 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBCtrlEPServiceComplete(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: This routine wrap up the ramaining tasks in servicing C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * a Setup Request. Its main task is to set the endpoint C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * controls appropriately for a given situation. See code C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * below. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * There are three main scenarios: C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * a) There was no handler for the Request, in this case C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * a STALL should be sent out. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * b) The host has requested a read control transfer, C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * endpoints are required to be setup in a specific way. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * c) The host has requested a write control transfer, or C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * a control data stage is not required, endpoints are C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * required to be setup in a specific way. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Packet processing is resumed by clearing PKTDIS bit. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBCtrlEPServiceComplete(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PKTDIS bit is set when a Setup Transaction is received. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Clear to resume packet processing. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039be 986d BCF 0x6d,0x4,0x0 UCONbits.PKTDIS = 0; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039c0 0101 MOVLB 0x1 if(ctrl_trf_session_owner == MUID_NULL) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039c2 51cb MOVF 0xcb,0x0,0x1 0039c4 e10f BNZ 0x39e4 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * If no one knows how to service this request then stall. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Must also prepare EP0 to receive the next SETUP transaction. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039c6 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039c8 0e08 MOVLW 0x8 0039ca 6f01 MOVWF 0x1,0x1 0039cc 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&SetupPkt; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039ce 0e20 MOVLW 0x20 0039d0 6f02 MOVWF 0x2,0x1 0039d2 0e04 MOVLW 0x4 0039d4 6f03 MOVWF 0x3,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039d6 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_BSTALL; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039d8 0e84 MOVLW 0x84 0039da 6f00 MOVWF 0x0,0x1 0039dc 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_BSTALL; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039de 0e84 MOVLW 0x84 0039e0 6f04 MOVWF 0x4,0x1 } C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039e2 d03b BRA 0x3a5a else // A module has claimed ownership of the control transfer session. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039e4 0104 MOVLB 0x4 if(SetupPkt.DataDir == DEV_TO_HOST) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039e6 af20 BTFSS 0x20,0x7,0x1 0039e8 d025 BRA 0x3a34 { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039ea 0101 MOVLB 0x1 if(SetupPkt.wLength < wCount._word) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039ec 51d0 MOVF 0xd0,0x0,0x1 0039ee 0104 MOVLB 0x4 0039f0 5d26 SUBWF 0x26,0x0,0x1 0039f2 0101 MOVLB 0x1 0039f4 51d1 MOVF 0xd1,0x0,0x1 0039f6 0104 MOVLB 0x4 0039f8 5927 SUBWFB 0x27,0x0,0x1 0039fa e204 BC 0x3a04 0039fc c426 MOVFF 0x426,0x1d0 wCount._word = SetupPkt.wLength; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 0039fe f1d0 003a00 c427 MOVFF 0x427,0x1d1 003a02 f1d1 003a04 df24 RCALL 0x384e USBCtrlTrfTxService(); C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a06 0101 MOVLB 0x1 ctrl_trf_state = CTRL_TRF_TX; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a08 0e01 MOVLW 0x1 003a0a 6fca MOVWF 0xca,0x1 /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Control Read: C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * ... | C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 1. Prepare OUT EP to respond to early termination C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * NOTE: C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * If something went wrong during the control transfer, C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * the last status stage may not be sent by the host. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * When this happens, two different things could happen C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * depending on the host. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * a) The host could send out a RESET. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * b) The host could send out a new SETUP transaction C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * without sending a RESET first. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * To properly handle case (b), the OUT EP must be setup C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * to receive either a zero length OUT transaction, or a C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * new SETUP transaction. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Since the SETUP transaction requires the DTS bit to be C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * DAT0 while the zero length OUT status requires the DTS C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * bit to be DAT1, the DTS bit check by the hardware should C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * be disabled. This way the SIE could accept either of C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * the two transactions. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Furthermore, the Cnt byte should be set to prepare for C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * the SETUP data (8-byte or more), and the buffer address C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * should be pointed to SetupPkt. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a0c 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a0e 0e08 MOVLW 0x8 003a10 6f01 MOVWF 0x1,0x1 003a12 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&SetupPkt; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a14 0e20 MOVLW 0x20 003a16 6f02 MOVWF 0x2,0x1 003a18 0e04 MOVLW 0x4 003a1a 6f03 MOVWF 0x3,0x1 003a1c 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE; // Note: DTSEN is 0! C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a1e 0e80 MOVLW 0x80 003a20 6f00 MOVWF 0x0,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 2. Prepare IN EP to transfer data, Cnt should have C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * been initialized by responsible request owner. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a22 0104 MOVLB 0x4 ep0Bi.ADR = (byte*)&CtrlTrfData; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a24 0e28 MOVLW 0x28 003a26 6f06 MOVWF 0x6,0x1 003a28 0e04 MOVLW 0x4 003a2a 6f07 MOVWF 0x7,0x1 003a2c 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a2e 0ec8 MOVLW 0xc8 003a30 6f04 MOVWF 0x4,0x1 } C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a32 d013 BRA 0x3a5a else // (SetupPkt.DataDir == HOST_TO_DEV) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a34 0101 MOVLB 0x1 ctrl_trf_state = CTRL_TRF_RX; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a36 0e02 MOVLW 0x2 003a38 6fca MOVWF 0xca,0x1 /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Control Write: C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * ... | C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 1. Prepare IN EP to respond to early termination C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * This is the same as a Zero Length Packet Response C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * for control transfer without a data stage C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a3a 0104 MOVLB 0x4 ep0Bi.Cnt = 0; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a3c 6b05 CLRF 0x5,0x1 003a3e 0104 MOVLB 0x4 ep0Bi.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a40 0ec8 MOVLW 0xc8 003a42 6f04 MOVWF 0x4,0x1 C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /* C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * 2. Prepare OUT EP to receive data. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c */ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a44 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a46 0e08 MOVLW 0x8 003a48 6f01 MOVWF 0x1,0x1 003a4a 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&CtrlTrfData; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a4c 0e28 MOVLW 0x28 003a4e 6f02 MOVWF 0x2,0x1 003a50 0e04 MOVLW 0x4 003a52 6f03 MOVWF 0x3,0x1 003a54 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT1|_DTSEN; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a56 0ec8 MOVLW 0xc8 003a58 6f00 MOVWF 0x0,0x1 }//end if(SetupPkt.DataDir == DEV_TO_HOST) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c }//end if(ctrl_trf_session_owner == MUID_NULL) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a5a 0012 RETURN 0x0 }//end USBCtrlEPServiceComplete C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /****************************************************************************** C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Function: void USBPrepareForNextSetupTrf(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * PreCondition: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Input: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Output: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Side Effects: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Overview: The routine forces EP0 OUT to be ready for a new Setup C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * transaction, and forces EP0 IN to be owned by CPU. C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c * Note: None C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c void USBPrepareForNextSetupTrf(void) C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c { C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a5c 0101 MOVLB 0x1 ctrl_trf_state = WAIT_SETUP; // See usbctrltrf.h C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a5e 6bca CLRF 0xca,0x1 003a60 0104 MOVLB 0x4 ep0Bo.Cnt = EP0_BUFF_SIZE; // Defined in usbcfg.h C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a62 0e08 MOVLW 0x8 003a64 6f01 MOVWF 0x1,0x1 003a66 0104 MOVLB 0x4 ep0Bo.ADR = (byte*)&SetupPkt; C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a68 0e20 MOVLW 0x20 003a6a 6f02 MOVWF 0x2,0x1 003a6c 0e04 MOVLW 0x4 003a6e 6f03 MOVWF 0x3,0x1 003a70 0104 MOVLB 0x4 ep0Bo.Stat._byte = _USIE|_DAT0|_DTSEN; // EP0 buff dsc init, see usbmmap.h C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a72 0e88 MOVLW 0x88 003a74 6f00 MOVWF 0x0,0x1 003a76 0104 MOVLB 0x4 ep0Bi.Stat._byte = _UCPU; // EP0 IN buffer initialization C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c 003a78 6b04 CLRF 0x4,0x1 003a7a 0012 RETURN 0x0 }//end USBPrepareForNextSetupTrf C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /** EOF usbctrltrf.c *********************************************************/ C:\Projects\UBW\FW\D_143\system\usb\usbctrltrf\usbctrltrf.c /********************************************************************* C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Microchip USB C18 Firmware Version 1.0 C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c ********************************************************************* C:\Projects\UBW\FW\D_143\user\user.c * FileName: user.c C:\Projects\UBW\FW\D_143\user\user.c * Dependencies: See INCLUDES section below C:\Projects\UBW\FW\D_143\user\user.c * Processor: PIC18 C:\Projects\UBW\FW\D_143\user\user.c * Compiler: C18 2.30.01+ C:\Projects\UBW\FW\D_143\user\user.c * Company: Microchip Technology, Inc. C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Software License Agreement C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * The software supplied herewith by Microchip Technology Incorporated C:\Projects\UBW\FW\D_143\user\user.c * (the “Company”) for its PICmicro® Microcontroller is intended and C:\Projects\UBW\FW\D_143\user\user.c * supplied to you, the Company’s customer, for use solely and C:\Projects\UBW\FW\D_143\user\user.c * exclusively on Microchip PICmicro Microcontroller products. The C:\Projects\UBW\FW\D_143\user\user.c * software is owned by the Company and/or its supplier, and is C:\Projects\UBW\FW\D_143\user\user.c * protected under applicable copyright laws. All rights are reserved. C:\Projects\UBW\FW\D_143\user\user.c * Any use in violation of the foregoing restrictions may subject the C:\Projects\UBW\FW\D_143\user\user.c * user to criminal sanctions under applicable laws, as well as to C:\Projects\UBW\FW\D_143\user\user.c * civil liability for the breach of the terms and conditions of this C:\Projects\UBW\FW\D_143\user\user.c * license. C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES, C:\Projects\UBW\FW\D_143\user\user.c * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED C:\Projects\UBW\FW\D_143\user\user.c * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A C:\Projects\UBW\FW\D_143\user\user.c * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, C:\Projects\UBW\FW\D_143\user\user.c * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR C:\Projects\UBW\FW\D_143\user\user.c * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Author Date Comment C:\Projects\UBW\FW\D_143\user\user.c *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C:\Projects\UBW\FW\D_143\user\user.c * Rawin Rojvanit 11/19/04 Original. C:\Projects\UBW\FW\D_143\user\user.c * Brian Schmalz 03/15/06 Added user code to impliment C:\Projects\UBW\FW\D_143\user\user.c * firmware version D v1.0 for UBW C:\Projects\UBW\FW\D_143\user\user.c * project. See www.greta.dhs.org/UBW C:\Projects\UBW\FW\D_143\user\user.c * Brian Schmalz 05/04/06 Starting version 1.1, which will C:\Projects\UBW\FW\D_143\user\user.c * include several fixes. See website. C:\Projects\UBW\FW\D_143\user\user.c * BPS 06/21/06 Starting v1.2 - C:\Projects\UBW\FW\D_143\user\user.c * - Fixed problem with I packets (from T command) filling up TX buffer C:\Projects\UBW\FW\D_143\user\user.c * and not letting any incoming commands be received. (strange) C:\Projects\UBW\FW\D_143\user\user.c * - Adding several commands - Analog inputs being the biggest set. C:\Projects\UBW\FW\D_143\user\user.c * - Also Byte read/Byte write (PEEK/POKE) anywhere in memory C:\Projects\UBW\FW\D_143\user\user.c * - Individual pin I/O and direction C:\Projects\UBW\FW\D_143\user\user.c * BPS 08/16/06 v1.3 - Fixed bug with USB startup C:\Projects\UBW\FW\D_143\user\user.c * BPS 09/09/06 v1.4 - Starting 1.4 C:\Projects\UBW\FW\D_143\user\user.c * - Fixed Microchip bug with early silicon - UCONbits.PKTDIS = 0; C:\Projects\UBW\FW\D_143\user\user.c * - Adding BO and BC commands for parallel output to graphics pannels C:\Projects\UBW\FW\D_143\user\user.c * BPS 12/06/06 v1.4 - More work on 1.4 C:\Projects\UBW\FW\D_143\user\user.c * - Re-wrote all I/O buffering code for increased speed and functionality C:\Projects\UBW\FW\D_143\user\user.c * - Re-wrote error handling code C:\Projects\UBW\FW\D_143\user\user.c * - Added delays to BC/BO commands to help Corey C:\Projects\UBW\FW\D_143\user\user.c * BPS 01/06/07 v1.4 - Added RC command for servos C:\Projects\UBW\FW\D_143\user\user.c * BPS 03/07/07 v1.4.1 - Changed blink rate for SFE C:\Projects\UBW\FW\D_143\user\user.c * BPS 05/24/07 v1.4.2 - Fixed RC command bug - it C:\Projects\UBW\FW\D_143\user\user.c * wouldn't shut off. C:\Projects\UBW\FW\D_143\user\user.c * BPS 08/28/07 v1.4.3 - Allowed UBW to run without C:\Projects\UBW\FW\D_143\user\user.c * usb connected. C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c ********************************************************************/ C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c /** I N C L U D E S **********************************************************/ C:\Projects\UBW\FW\D_143\user\user.c #include C:\Projects\UBW\FW\D_143\user\user.c #include C:\Projects\UBW\FW\D_143\user\user.c #include C:\Projects\UBW\FW\D_143\user\user.c #include C:\Projects\UBW\FW\D_143\user\user.c #include C:\Projects\UBW\FW\D_143\user\user.c #include "system\typedefs.h" C:\Projects\UBW\FW\D_143\user\user.c #include "system\usb\usb.h" C:\Projects\UBW\FW\D_143\user\user.c #include "io_cfg.h" // I/O pin mapping C:\Projects\UBW\FW\D_143\user\user.c #include "user\user.h" C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c /** D E F I N E S ********************************************************/ C:\Projects\UBW\FW\D_143\user\user.c #define bitset(var,bitno) ((var) |= (1 << (bitno))) C:\Projects\UBW\FW\D_143\user\user.c #define bitclr(var,bitno) ((var) &= ~(1 << (bitno))) C:\Projects\UBW\FW\D_143\user\user.c #define bittst(var,bitno) (var& (1 << (bitno))) C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // For the RC command, we define a little data structure that holds the C:\Projects\UBW\FW\D_143\user\user.c // values assoicated with a particular servo connection C:\Projects\UBW\FW\D_143\user\user.c // It's port, pin, value (position) and state (INACTIVE, PRIMED or TIMING) C:\Projects\UBW\FW\D_143\user\user.c // Later on we make an array of these (19 elements long - 19 pins) to track C:\Projects\UBW\FW\D_143\user\user.c // the values of all of the servos. C:\Projects\UBW\FW\D_143\user\user.c typedef enum { C:\Projects\UBW\FW\D_143\user\user.c kOFF = 1 C:\Projects\UBW\FW\D_143\user\user.c ,kWAITING C:\Projects\UBW\FW\D_143\user\user.c ,kPRIMED C:\Projects\UBW\FW\D_143\user\user.c ,kTIMING C:\Projects\UBW\FW\D_143\user\user.c } tRC_state; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #define kRC_DATA_SIZE 24 // In structs, since there are 3 ports of 8 bits each C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #define kTX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\D_143\user\user.c #define kRX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #define kUSART_TX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\D_143\user\user.c #define kUSART_RX_BUF_SIZE 64 // In bytes C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Enum for extract_num() function parameter C:\Projects\UBW\FW\D_143\user\user.c typedef enum { C:\Projects\UBW\FW\D_143\user\user.c kCHAR C:\Projects\UBW\FW\D_143\user\user.c ,kUCHAR C:\Projects\UBW\FW\D_143\user\user.c ,kINT C:\Projects\UBW\FW\D_143\user\user.c ,kUINT C:\Projects\UBW\FW\D_143\user\user.c ,kASCII_CHAR C:\Projects\UBW\FW\D_143\user\user.c ,kUCASE_ASCII_CHAR C:\Projects\UBW\FW\D_143\user\user.c } tExtractType; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #define advance_RX_buf_out() \ C:\Projects\UBW\FW\D_143\user\user.c { \ C:\Projects\UBW\FW\D_143\user\user.c g_RX_buf_out++; \ C:\Projects\UBW\FW\D_143\user\user.c if (kRX_BUF_SIZE == g_RX_buf_out) \ C:\Projects\UBW\FW\D_143\user\user.c { \ C:\Projects\UBW\FW\D_143\user\user.c g_RX_buf_out = 0; \ C:\Projects\UBW\FW\D_143\user\user.c } \ C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #define kISR_FIFO_A_DEPTH 3 C:\Projects\UBW\FW\D_143\user\user.c #define kISR_FIFO_D_DEPTH 3 C:\Projects\UBW\FW\D_143\user\user.c #define kPR2_RELOAD 250 // For 1ms TMR2 tick C:\Projects\UBW\FW\D_143\user\user.c #define kCR 0x0D C:\Projects\UBW\FW\D_143\user\user.c #define kLF 0x0A C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // defines for the error_byte byte - each bit has a meaning C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_TX_BUF_OVERRUN 2 C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_RX_BUFFER_OVERRUN 3 C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_MISSING_PARAMETER 4 C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_PRINTED_ERROR 5 // We've already printed out an error C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT 6 C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_EXTRA_CHARACTERS 7 C:\Projects\UBW\FW\D_143\user\user.c #define kERROR_BYTE_UNKNOWN_COMMAND 8 // Part of command parser, not error handler C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c /** V A R I A B L E S ********************************************************/ C:\Projects\UBW\FW\D_143\user\user.c #pragma udata access fast_vars C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Rate variable - how fast does interrupt fire to capture inputs? C:\Projects\UBW\FW\D_143\user\user.c near unsigned int time_between_updates; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned int ISR_D_RepeatRate; // How many 1ms ticks between Digital updates C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char ISR_D_FIFO_in; // In pointer C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char ISR_D_FIFO_out; // Out pointer C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char ISR_D_FIFO_length; // Current FIFO depth C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned int ISR_A_RepeatRate; // How many 1ms ticks between Analog updates C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char ISR_A_FIFO_in; // In pointer C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char ISR_A_FIFO_out; // Out pointer C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char ISR_A_FIFO_length; // Current FIFO depth C:\Projects\UBW\FW\D_143\user\user.c near volatile unsigned char AnalogEnable; // Maximum ADC channel to convert C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // This byte has each of its bits used as a seperate error flag C:\Projects\UBW\FW\D_143\user\user.c near unsigned char error_byte; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // RC servo variables C:\Projects\UBW\FW\D_143\user\user.c // First the main array of data for each servo C:\Projects\UBW\FW\D_143\user\user.c near unsigned char g_RC_primed_ptr; C:\Projects\UBW\FW\D_143\user\user.c near unsigned char g_RC_next_ptr; C:\Projects\UBW\FW\D_143\user\user.c near unsigned char g_RC_timing_ptr; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Used only in LowISR C:\Projects\UBW\FW\D_143\user\user.c near unsigned int D_tick_counter; C:\Projects\UBW\FW\D_143\user\user.c near unsigned int A_tick_counter; C:\Projects\UBW\FW\D_143\user\user.c near unsigned char A_cur_channel; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // ROM strings C:\Projects\UBW\FW\D_143\user\user.c const rom char st_OK[] = {"OK\r\n"}; C:\Projects\UBW\FW\D_143\user\user.c const rom char st_LFCR[] = {"\r\n"}; C:\Projects\UBW\FW\D_143\user\user.c const rom char st_version[] = {"UBW FW D Version 1.4.3\r\n"}; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #pragma udata ISR_buf=0x100 C:\Projects\UBW\FW\D_143\user\user.c volatile unsigned int ISR_A_FIFO[12][kISR_FIFO_A_DEPTH]; // Stores the most recent analog conversions C:\Projects\UBW\FW\D_143\user\user.c volatile unsigned char ISR_D_FIFO[3][kISR_FIFO_D_DEPTH]; // FIFO of actual data C:\Projects\UBW\FW\D_143\user\user.c volatile tRC_state g_RC_state[kRC_DATA_SIZE]; // Stores states for each pin for RC command C:\Projects\UBW\FW\D_143\user\user.c volatile unsigned int g_RC_value[kRC_DATA_SIZE]; // Stores reload values for TMR0 C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #pragma udata com_buf=0x200 C:\Projects\UBW\FW\D_143\user\user.c // USB Transmit buffer for packets (back to PC) C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_TX_buf[kTX_BUF_SIZE]; C:\Projects\UBW\FW\D_143\user\user.c // USB Receiving buffer for commands as they come from PC C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_RX_buf[kRX_BUF_SIZE]; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // USART Receiving buffer for data coming from the USART C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_USART_RX_buf[kUSART_RX_BUF_SIZE]; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // USART Transmit buffer for data going to the USART C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_USART_TX_buf[kUSART_TX_BUF_SIZE]; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // These variables are in normal storage space C:\Projects\UBW\FW\D_143\user\user.c #pragma udata C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // These are used for the Fast Parallel Output routines C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_BO_init; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_BO_strobe_mask; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_BO_wait_mask; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_BO_wait_delay; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_BO_strobe_delay; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Pointers to USB transmit (back to PC) buffer C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_TX_buf_in; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_TX_buf_out; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Pointers to USB receive (from PC) buffer C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_RX_buf_in; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_RX_buf_out; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // In and out pointers to our USART input buffer C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_USART_RX_buf_in; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_USART_RX_buf_out; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // In and out pointers to our USART output buffer C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_USART_TX_buf_in; C:\Projects\UBW\FW\D_143\user\user.c unsigned char g_USART_TX_buf_out; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Normally set to TRUE. Able to set FALSE to not send "OK" message after packet recepetion C:\Projects\UBW\FW\D_143\user\user.c BOOL g_ack_enable; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c /** P R I V A T E P R O T O T Y P E S ***************************************/ C:\Projects\UBW\FW\D_143\user\user.c void BlinkUSBStatus (void); // Handles blinking the USB status LED C:\Projects\UBW\FW\D_143\user\user.c BOOL SwitchIsPressed (void); // Check to see if the user (PRG) switch is pressed C:\Projects\UBW\FW\D_143\user\user.c void parse_packet (void); // Take a full packet and dispatch it to the right function C:\Projects\UBW\FW\D_143\user\user.c signed short long extract_number (tExtractType type); // Pull a number paramter out of the packet C:\Projects\UBW\FW\D_143\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\D_143\user\user.c void parse_R_packet (void); // R for resetting UBW C:\Projects\UBW\FW\D_143\user\user.c void parse_C_packet (void); // C for configuring I/O and analog pins C:\Projects\UBW\FW\D_143\user\user.c void parse_CX_packet (void); // CX For configuring serial port C:\Projects\UBW\FW\D_143\user\user.c void parse_O_packet (void); // O for output digital to pins C:\Projects\UBW\FW\D_143\user\user.c void parse_I_packet (void); // I for input digital from pins C:\Projects\UBW\FW\D_143\user\user.c void parse_V_packet (void); // V for printing version C:\Projects\UBW\FW\D_143\user\user.c void parse_A_packet (void); // A for requesting analog inputs C:\Projects\UBW\FW\D_143\user\user.c void parse_T_packet (void); // T for setting up timed I/O (digital or analog) C:\Projects\UBW\FW\D_143\user\user.c void parse_PI_packet (void); // PI for reading a single pin C:\Projects\UBW\FW\D_143\user\user.c void parse_PO_packet (void); // PO for setting a single pin state C:\Projects\UBW\FW\D_143\user\user.c void parse_PD_packet (void); // PD for setting a pin's direction C:\Projects\UBW\FW\D_143\user\user.c void parse_MR_packet (void); // MR for Memory Read C:\Projects\UBW\FW\D_143\user\user.c void parse_MW_packet (void); // MW for Memory Write C:\Projects\UBW\FW\D_143\user\user.c void parse_TX_packet (void); // TX for transmitting serial C:\Projects\UBW\FW\D_143\user\user.c void parse_RX_packet (void); // RX for receiving serial C:\Projects\UBW\FW\D_143\user\user.c void parse_RC_packet (void); // RC is for outputing RC servo pulses C:\Projects\UBW\FW\D_143\user\user.c void parse_BO_packet (void); // BO sends data to fast parallel output C:\Projects\UBW\FW\D_143\user\user.c void parse_BC_packet (void); // BC configures fast parallel outputs C:\Projects\UBW\FW\D_143\user\user.c void parse_BS_packet (void); // BS sends binary data to fast parallel output C:\Projects\UBW\FW\D_143\user\user.c void parse_CU_packet (void); // CU configures UBW (system wide parameters) C:\Projects\UBW\FW\D_143\user\user.c void parse_SS_packet (void); // SS Send SPI C:\Projects\UBW\FW\D_143\user\user.c void parse_RS_packet (void); // RS Receive SPI C:\Projects\UBW\FW\D_143\user\user.c void parse_CS_packet (void); // CS Configure SPI C:\Projects\UBW\FW\D_143\user\user.c void parse_SI_packet (void); // SI Send I2C C:\Projects\UBW\FW\D_143\user\user.c void parse_RI_packet (void); // RI Receive I2C C:\Projects\UBW\FW\D_143\user\user.c void parse_CI_packet (void); // CI Configure I2C C:\Projects\UBW\FW\D_143\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\D_143\user\user.c void print_ack (void); // Print "OK" after packet is parsed C:\Projects\UBW\FW\D_143\user\user.c int _user_putc (char c); // Our UBS based stream character printer C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c /** D E C L A R A T I O N S **************************************************/ C:\Projects\UBW\FW\D_143\user\user.c #pragma code C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #pragma interruptlow low_ISR C:\Projects\UBW\FW\D_143\user\user.c 000844 cfd8 MOVFF 0xfd8,0xfe4 void low_ISR(void) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // Do we have a Timer2 interrupt? (1ms rate) C:\Projects\UBW\FW\D_143\user\user.c 000868 a29e BTFSS 0x9e,0x1,0x0 if (PIR1bits.TMR2IF) C:\Projects\UBW\FW\D_143\user\user.c 00086a d101 BRA 0xa6e { C:\Projects\UBW\FW\D_143\user\user.c // Clear the interrupt C:\Projects\UBW\FW\D_143\user\user.c 00086c 929e BCF 0x9e,0x1,0x0 PIR1bits.TMR2IF = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // The most time critical part of this interrupt service routine is the C:\Projects\UBW\FW\D_143\user\user.c // handling of the RC command's servo output pulses. C:\Projects\UBW\FW\D_143\user\user.c // Each time we get this interrupt, we look to see if the next pin on the C:\Projects\UBW\FW\D_143\user\user.c // list has a value greater than zero. If so, we arm set it high and set C:\Projects\UBW\FW\D_143\user\user.c // it's state to PRIMED. Then we advance the pointers to the next pair. C:\Projects\UBW\FW\D_143\user\user.c 00086e 0e03 MOVLW 0x3 if (kPRIMED == g_RC_state[g_RC_primed_ptr]) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // This is easy, throw the value into the timer C:\Projects\UBW\FW\D_143\user\user.c 000884 500e MOVF 0xe,0x0,0x0 TMR0H = g_RC_value[g_RC_primed_ptr] >> 8; C:\Projects\UBW\FW\D_143\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\D_143\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\D_143\user\user.c // Then make sure the timer's interrupt enable is set C:\Projects\UBW\FW\D_143\user\user.c 0008ca 8af2 BSF 0xf2,0x5,0x0 INTCONbits.TMR0IE = 1; C:\Projects\UBW\FW\D_143\user\user.c // And be sure to clear the flag too C:\Projects\UBW\FW\D_143\user\user.c 0008cc 94f2 BCF 0xf2,0x2,0x0 INTCONbits.TMR0IF = 0; C:\Projects\UBW\FW\D_143\user\user.c // Turn on Timer0 C:\Projects\UBW\FW\D_143\user\user.c 0008ce 8ed5 BSF 0xd5,0x7,0x0 T0CONbits.TMR0ON = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // And set this pin's state to timing C:\Projects\UBW\FW\D_143\user\user.c 0008d0 500e MOVF 0xe,0x0,0x0 g_RC_state[g_RC_primed_ptr] = kTIMING; C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // Remember which pin is now timing C:\Projects\UBW\FW\D_143\user\user.c 0008e0 500e MOVF 0xe,0x0,0x0 g_RC_timing_ptr = g_RC_primed_ptr; C:\Projects\UBW\FW\D_143\user\user.c 0008e2 6e10 MOVWF 0x10,0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 0008e4 0e02 MOVLW 0x2 if (kWAITING == g_RC_state[g_RC_next_ptr]) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // If the value is zero, then shut this pin off C:\Projects\UBW\FW\D_143\user\user.c // otherwise, prime it for sending a pulse C:\Projects\UBW\FW\D_143\user\user.c 0008fa 500f MOVF 0xf,0x0,0x0 if (0 == g_RC_value[g_RC_next_ptr]) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000914 500f MOVF 0xf,0x0,0x0 g_RC_state[g_RC_next_ptr] = kOFF; C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000924 d033 BRA 0x98c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Set the bit high C:\Projects\UBW\FW\D_143\user\user.c 000926 0e08 MOVLW 0x8 if (g_RC_next_ptr < 8) C:\Projects\UBW\FW\D_143\user\user.c 000928 5c0f SUBWF 0xf,0x0,0x0 00092a e20c BC 0x944 { C:\Projects\UBW\FW\D_143\user\user.c 00092c 0e07 MOVLW 0x7 bitset (LATA, g_RC_next_ptr & 0x7); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000942 d01a BRA 0x978 else if (g_RC_next_ptr < 16) C:\Projects\UBW\FW\D_143\user\user.c 000944 0e10 MOVLW 0x10 000946 5c0f SUBWF 0xf,0x0,0x0 000948 e20c BC 0x962 { C:\Projects\UBW\FW\D_143\user\user.c 00094a 0e07 MOVLW 0x7 bitset (LATB, g_RC_next_ptr & 0x7); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000960 d00b BRA 0x978 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 000962 0e07 MOVLW 0x7 bitset (LATC, g_RC_next_ptr & 0x7); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // Set the state to primed so we know to do next C:\Projects\UBW\FW\D_143\user\user.c 000978 500f MOVF 0xf,0x0,0x0 g_RC_state[g_RC_next_ptr] = kPRIMED; C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000988 500f MOVF 0xf,0x0,0x0 g_RC_primed_ptr = g_RC_next_ptr; C:\Projects\UBW\FW\D_143\user\user.c 00098a 6e0e MOVWF 0xe,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // And always advance the main pointer C:\Projects\UBW\FW\D_143\user\user.c // NOTE: we need to skip RA6, RA7, and RC3, RC4, and RC5 C:\Projects\UBW\FW\D_143\user\user.c // (Because UBW doesn't bring those pins out to headers) C:\Projects\UBW\FW\D_143\user\user.c 00098c 2a0f INCF 0xf,0x1,0x0 g_RC_next_ptr++; C:\Projects\UBW\FW\D_143\user\user.c 00098e 0e06 MOVLW 0x6 if (6 == g_RC_next_ptr) C:\Projects\UBW\FW\D_143\user\user.c 000990 5c0f SUBWF 0xf,0x0,0x0 000992 e103 BNZ 0x99a { C:\Projects\UBW\FW\D_143\user\user.c 000994 0e08 MOVLW 0x8 g_RC_next_ptr = 8; C:\Projects\UBW\FW\D_143\user\user.c 000996 6e0f MOVWF 0xf,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000998 d00a BRA 0x9ae else if (19 == g_RC_next_ptr) C:\Projects\UBW\FW\D_143\user\user.c 00099a 0e13 MOVLW 0x13 00099c 5c0f SUBWF 0xf,0x0,0x0 00099e e103 BNZ 0x9a6 { C:\Projects\UBW\FW\D_143\user\user.c 0009a0 0e16 MOVLW 0x16 g_RC_next_ptr = 22; C:\Projects\UBW\FW\D_143\user\user.c 0009a2 6e0f MOVWF 0xf,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 0009a4 d004 BRA 0x9ae else if (kRC_DATA_SIZE == g_RC_next_ptr) C:\Projects\UBW\FW\D_143\user\user.c 0009a6 0e18 MOVLW 0x18 0009a8 5c0f SUBWF 0xf,0x0,0x0 0009aa e101 BNZ 0x9ae { C:\Projects\UBW\FW\D_143\user\user.c 0009ac 6a0f CLRF 0xf,0x0 g_RC_next_ptr = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // See if it's time to fire off an I packet C:\Projects\UBW\FW\D_143\user\user.c 0009ae 0e00 MOVLW 0x0 if (ISR_D_RepeatRate > 0) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 0009ba 2a11 INCF 0x11,0x1,0x0 D_tick_counter++; C:\Projects\UBW\FW\D_143\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\D_143\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\D_143\user\user.c 0009ca 6a11 CLRF 0x11,0x0 D_tick_counter = 0; C:\Projects\UBW\FW\D_143\user\user.c 0009cc 6a12 CLRF 0x12,0x0 // Tell the main code to send an I packet C:\Projects\UBW\FW\D_143\user\user.c 0009ce 0e03 MOVLW 0x3 if (ISR_D_FIFO_length < kISR_FIFO_D_DEPTH) C:\Projects\UBW\FW\D_143\user\user.c 0009d0 5c06 SUBWF 0x6,0x0,0x0 0009d2 e21f BC 0xa12 { C:\Projects\UBW\FW\D_143\user\user.c // And copy over our port values C:\Projects\UBW\FW\D_143\user\user.c 0009d4 5004 MOVF 0x4,0x0,0x0 ISR_D_FIFO[0][ISR_D_FIFO_in] = PORTA; C:\Projects\UBW\FW\D_143\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\D_143\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\D_143\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\D_143\user\user.c 000a06 0e03 MOVLW 0x3 if (ISR_D_FIFO_in >= kISR_FIFO_D_DEPTH) C:\Projects\UBW\FW\D_143\user\user.c 000a08 5c04 SUBWF 0x4,0x0,0x0 000a0a e301 BNC 0xa0e { C:\Projects\UBW\FW\D_143\user\user.c 000a0c 6a04 CLRF 0x4,0x0 ISR_D_FIFO_in = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000a0e 2a06 INCF 0x6,0x1,0x0 ISR_D_FIFO_length++; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000a10 d002 BRA 0xa16 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Stop the madness! Something is wrong, we're C:\Projects\UBW\FW\D_143\user\user.c // not getting our packets out. So kill the C:\Projects\UBW\FW\D_143\user\user.c // timer. C:\Projects\UBW\FW\D_143\user\user.c 000a12 6a02 CLRF 0x2,0x0 ISR_D_RepeatRate = 0; C:\Projects\UBW\FW\D_143\user\user.c 000a14 6a03 CLRF 0x3,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // See if it's time to fire off an A packet C:\Projects\UBW\FW\D_143\user\user.c 000a16 0e00 MOVLW 0x0 if ((ISR_A_RepeatRate > 0) && (AnalogEnable > 0)) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000a28 2a13 INCF 0x13,0x1,0x0 A_tick_counter++; C:\Projects\UBW\FW\D_143\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\D_143\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\D_143\user\user.c 000a38 6a13 CLRF 0x13,0x0 A_tick_counter = 0; C:\Projects\UBW\FW\D_143\user\user.c 000a3a 6a14 CLRF 0x14,0x0 // Tell the main code to send an A packet C:\Projects\UBW\FW\D_143\user\user.c 000a3c 0e03 MOVLW 0x3 if (ISR_A_FIFO_length < kISR_FIFO_A_DEPTH) C:\Projects\UBW\FW\D_143\user\user.c 000a3e 5c0b SUBWF 0xb,0x0,0x0 000a40 e207 BC 0xa50 { C:\Projects\UBW\FW\D_143\user\user.c 000a42 2a09 INCF 0x9,0x1,0x0 ISR_A_FIFO_in++; C:\Projects\UBW\FW\D_143\user\user.c 000a44 0e03 MOVLW 0x3 if (ISR_A_FIFO_in >= kISR_FIFO_A_DEPTH) C:\Projects\UBW\FW\D_143\user\user.c 000a46 5c09 SUBWF 0x9,0x0,0x0 000a48 e301 BNC 0xa4c { C:\Projects\UBW\FW\D_143\user\user.c 000a4a 6a09 CLRF 0x9,0x0 ISR_A_FIFO_in = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000a4c 2a0b INCF 0xb,0x1,0x0 ISR_A_FIFO_length++; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000a4e d002 BRA 0xa54 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Stop the madness! Something is wrong, we're C:\Projects\UBW\FW\D_143\user\user.c // not getting our packets out. So kill the A C:\Projects\UBW\FW\D_143\user\user.c // packets. C:\Projects\UBW\FW\D_143\user\user.c 000a50 6a07 CLRF 0x7,0x0 ISR_A_RepeatRate = 0; C:\Projects\UBW\FW\D_143\user\user.c 000a52 6a08 CLRF 0x8,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // See if it's time to start analog conversions C:\Projects\UBW\FW\D_143\user\user.c 000a54 500c MOVF 0xc,0x0,0x0 if (AnalogEnable > 0) C:\Projects\UBW\FW\D_143\user\user.c 000a56 0800 SUBLW 0x0 000a58 e20a BC 0xa6e { C:\Projects\UBW\FW\D_143\user\user.c // Set the channel to zero to start off with C:\Projects\UBW\FW\D_143\user\user.c 000a5a 6a15 CLRF 0x15,0x0 A_cur_channel = 0; C:\Projects\UBW\FW\D_143\user\user.c 000a5c 5015 MOVF 0x15,0x0,0x0 ADCON0 = (A_cur_channel << 2) + 1; C:\Projects\UBW\FW\D_143\user\user.c 000a5e 0d04 MULLW 0x4 000a60 28f3 INCF 0xf3,0x0,0x0 000a62 6ec2 MOVWF 0xc2,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Clear the interrupt C:\Projects\UBW\FW\D_143\user\user.c 000a64 9c9e BCF 0x9e,0x6,0x0 PIR1bits.ADIF = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // And make sure to always use low priority. C:\Projects\UBW\FW\D_143\user\user.c 000a66 9c9f BCF 0x9f,0x6,0x0 IPR1bits.ADIP = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Set the interrupt enable C:\Projects\UBW\FW\D_143\user\user.c 000a68 8c9d BSF 0x9d,0x6,0x0 PIE1bits.ADIE = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Make sure it's on! C:\Projects\UBW\FW\D_143\user\user.c 000a6a 80c2 BSF 0xc2,0x0,0x0 ADCON0bits.ADON = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // And tell the A/D to GO! C:\Projects\UBW\FW\D_143\user\user.c 000a6c 82c2 BSF 0xc2,0x1,0x0 ADCON0bits.GO_DONE = 1; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Do we have an analog interrupt? C:\Projects\UBW\FW\D_143\user\user.c 000a6e ac9e BTFSS 0x9e,0x6,0x0 if (PIR1bits.ADIF) C:\Projects\UBW\FW\D_143\user\user.c 000a70 d02d BRA 0xacc { C:\Projects\UBW\FW\D_143\user\user.c // Clear the interrupt C:\Projects\UBW\FW\D_143\user\user.c 000a72 9c9e BCF 0x9e,0x6,0x0 PIR1bits.ADIF = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Read out the value that we just converted, and store it. C:\Projects\UBW\FW\D_143\user\user.c 000a8a 5015 MOVF 0x15,0x0,0x0 ISR_A_FIFO[A_cur_channel][ISR_A_FIFO_in] = C:\Projects\UBW\FW\D_143\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\D_143\user\user.c | C:\Projects\UBW\FW\D_143\user\user.c 000a74 50c4 MOVF 0xc4,0x0,0x0 ((unsigned int)ADRESH << 8); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // Incriment the channel and write the new one in C:\Projects\UBW\FW\D_143\user\user.c 000ab6 2a15 INCF 0x15,0x1,0x0 A_cur_channel++; C:\Projects\UBW\FW\D_143\user\user.c 000ab8 500c MOVF 0xc,0x0,0x0 if (A_cur_channel >= AnalogEnable) C:\Projects\UBW\FW\D_143\user\user.c 000aba 5c15 SUBWF 0x15,0x0,0x0 000abc e302 BNC 0xac2 { C:\Projects\UBW\FW\D_143\user\user.c // We're done, so just sit and wait C:\Projects\UBW\FW\D_143\user\user.c // Turn off our interrupts though. C:\Projects\UBW\FW\D_143\user\user.c 000abe 9c9d BCF 0x9d,0x6,0x0 PIE1bits.ADIE = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000ac0 d005 BRA 0xacc else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Update the channel number C:\Projects\UBW\FW\D_143\user\user.c 000ac2 5015 MOVF 0x15,0x0,0x0 ADCON0 = (A_cur_channel << 2) + 1; C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000aca 82c2 BSF 0xc2,0x1,0x0 ADCON0bits.GO_DONE = 1; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Do we have a TMR0 interrupt? (RC command) C:\Projects\UBW\FW\D_143\user\user.c // TMR0 is in 16 bit mode, and counts up to FFFF and overflows, generating C:\Projects\UBW\FW\D_143\user\user.c // this interrupt. C:\Projects\UBW\FW\D_143\user\user.c 000acc a4f2 BTFSS 0xf2,0x2,0x0 if (INTCONbits.TMR0IF) C:\Projects\UBW\FW\D_143\user\user.c 000ace d042 BRA 0xb54 { C:\Projects\UBW\FW\D_143\user\user.c // Turn off Timer0 C:\Projects\UBW\FW\D_143\user\user.c 000ad0 9ed5 BCF 0xd5,0x7,0x0 T0CONbits.TMR0ON = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Clear the interrupt C:\Projects\UBW\FW\D_143\user\user.c 000ad2 94f2 BCF 0xf2,0x2,0x0 INTCONbits.TMR0IF = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // And disable it C:\Projects\UBW\FW\D_143\user\user.c 000ad4 9af2 BCF 0xf2,0x5,0x0 INTCONbits.TMR0IE = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Only do our stuff if the pin is in the proper state C:\Projects\UBW\FW\D_143\user\user.c 000ad6 0e04 MOVLW 0x4 if (kTIMING == g_RC_state[g_RC_timing_ptr]) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // All we need to do is clear the pin and change its state to kWAITING C:\Projects\UBW\FW\D_143\user\user.c 000aec 0e08 MOVLW 0x8 if (g_RC_timing_ptr < 8) C:\Projects\UBW\FW\D_143\user\user.c 000aee 5c10 SUBWF 0x10,0x0,0x0 000af0 e20d BC 0xb0c { C:\Projects\UBW\FW\D_143\user\user.c 000af2 0e07 MOVLW 0x7 bitclr (LATA, g_RC_timing_ptr & 0x7); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000b0a d01c BRA 0xb44 else if (g_RC_timing_ptr < 16) C:\Projects\UBW\FW\D_143\user\user.c 000b0c 0e10 MOVLW 0x10 000b0e 5c10 SUBWF 0x10,0x0,0x0 000b10 e20d BC 0xb2c { C:\Projects\UBW\FW\D_143\user\user.c 000b12 0e07 MOVLW 0x7 bitclr (LATB, g_RC_timing_ptr & 0x7); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000b2a d00c BRA 0xb44 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 000b2c 0e07 MOVLW 0x7 bitclr (LATC, g_RC_timing_ptr & 0x7); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000b44 5010 MOVF 0x10,0x0,0x0 g_RC_state[g_RC_timing_ptr] = kWAITING; C:\Projects\UBW\FW\D_143\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\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000b54 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\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\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c #pragma interrupt high_ISR C:\Projects\UBW\FW\D_143\user\user.c 000b76 cfda MOVFF 0xfda,0xfe4 void high_ISR(void) C:\Projects\UBW\FW\D_143\user\user.c 000b78 ffe4 000b7a cfe2 MOVFF 0xfe2,0xfda 000b7c ffda 000b7e 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c 000b80 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000b82 cfe5 MOVFF 0xfe5,0xfda 000b84 ffda 000b86 0011 RETFIE 0x1 C:\Projects\UBW\FW\D_143\user\user.c 000b88 cfd9 MOVFF 0xfd9,0xfe6 void UserInit(void) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c char i, j; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Make all of 3 digital inputs C:\Projects\UBW\FW\D_143\user\user.c 000b94 6a89 CLRF 0x89,0x0 LATA = 0x00; C:\Projects\UBW\FW\D_143\user\user.c 000b96 6892 SETF 0x92,0x0 TRISA = 0xFF; C:\Projects\UBW\FW\D_143\user\user.c // Turn all analog inputs into digital inputs C:\Projects\UBW\FW\D_143\user\user.c 000b98 0e0f MOVLW 0xf ADCON1 = 0x0F; C:\Projects\UBW\FW\D_143\user\user.c 000b9a 6ec1 MOVWF 0xc1,0x0 // Turn off the ADC C:\Projects\UBW\FW\D_143\user\user.c 000b9c 90c2 BCF 0xc2,0x0,0x0 ADCON0bits.ADON = 0; C:\Projects\UBW\FW\D_143\user\user.c // Turn off our own idea of how many analog channels to convert C:\Projects\UBW\FW\D_143\user\user.c 000b9e 6a0c CLRF 0xc,0x0 AnalogEnable = 0; C:\Projects\UBW\FW\D_143\user\user.c 000ba0 0e07 MOVLW 0x7 CMCON = 0x07; // Comparators as digital inputs C:\Projects\UBW\FW\D_143\user\user.c 000ba2 6eb4 MOVWF 0xb4,0x0 // Make all of PORTB inputs C:\Projects\UBW\FW\D_143\user\user.c 000ba4 6a8a CLRF 0x8a,0x0 LATB = 0x00; C:\Projects\UBW\FW\D_143\user\user.c 000ba6 6893 SETF 0x93,0x0 TRISB = 0xFF; C:\Projects\UBW\FW\D_143\user\user.c // Make all of PORTC inputs C:\Projects\UBW\FW\D_143\user\user.c 000ba8 6a8b CLRF 0x8b,0x0 LATC = 0x00; C:\Projects\UBW\FW\D_143\user\user.c 000baa 6894 SETF 0x94,0x0 TRISC = 0xFF; C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c // Make all of PORTD and PORTE inputs too C:\Projects\UBW\FW\D_143\user\user.c LATD = 0x00; C:\Projects\UBW\FW\D_143\user\user.c TRISD = 0xFF; C:\Projects\UBW\FW\D_143\user\user.c LATE = 0x00; C:\Projects\UBW\FW\D_143\user\user.c TRISE = 0xFF; C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Initalize LED I/Os to outputs C:\Projects\UBW\FW\D_143\user\user.c 000bac 0efc MOVLW 0xfc mInitAllLEDs(); C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000bb4 8494 BSF 0x94,0x2,0x0 mInitSwitch(); C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Start off always using "OK" acknoledge. C:\Projects\UBW\FW\D_143\user\user.c 000bb6 0101 MOVLB 0x1 g_ack_enable = TRUE; C:\Projects\UBW\FW\D_143\user\user.c 000bb8 0e01 MOVLW 0x1 000bba 6fbe MOVWF 0xbe,0x1 C:\Projects\UBW\FW\D_143\user\user.c // Use our own special output function for STDOUT C:\Projects\UBW\FW\D_143\user\user.c 000bbc 0101 MOVLB 0x1 stdout = _H_USER; C:\Projects\UBW\FW\D_143\user\user.c 000bbe 69dc SETF 0xdc,0x1 000bc0 69dd SETF 0xdd,0x1 C:\Projects\UBW\FW\D_143\user\user.c // Initalize all of the ISR FIFOs C:\Projects\UBW\FW\D_143\user\user.c 000bc2 6a0a CLRF 0xa,0x0 ISR_A_FIFO_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bc4 6a09 CLRF 0x9,0x0 ISR_A_FIFO_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bc6 6a0b CLRF 0xb,0x0 ISR_A_FIFO_length = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bc8 6a05 CLRF 0x5,0x0 ISR_D_FIFO_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bca 6a04 CLRF 0x4,0x0 ISR_D_FIFO_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bcc 6a06 CLRF 0x6,0x0 ISR_D_FIFO_length = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Make sure that our timer stuff starts out disabled C:\Projects\UBW\FW\D_143\user\user.c 000bce 6a02 CLRF 0x2,0x0 ISR_D_RepeatRate = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bd0 6a03 CLRF 0x3,0x0 000bd2 6a07 CLRF 0x7,0x0 ISR_A_RepeatRate = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bd4 6a08 CLRF 0x8,0x0 000bd6 6a11 CLRF 0x11,0x0 D_tick_counter = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bd8 6a12 CLRF 0x12,0x0 000bda 6a13 CLRF 0x13,0x0 A_tick_counter = 0; C:\Projects\UBW\FW\D_143\user\user.c 000bdc 6a14 CLRF 0x14,0x0 000bde 6a15 CLRF 0x15,0x0 A_cur_channel = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now init our registers C:\Projects\UBW\FW\D_143\user\user.c // The prescaler will be at 16 C:\Projects\UBW\FW\D_143\user\user.c 000be0 82ca BSF 0xca,0x1,0x0 T2CONbits.T2CKPS1 = 1; C:\Projects\UBW\FW\D_143\user\user.c 000be2 80ca BSF 0xca,0x0,0x0 T2CONbits.T2CKPS0 = 1; C:\Projects\UBW\FW\D_143\user\user.c // We want the TMR2 post scaler to be a 3 C:\Projects\UBW\FW\D_143\user\user.c 000be4 9cca BCF 0xca,0x6,0x0 T2CONbits.T2OUTPS3 = 0; C:\Projects\UBW\FW\D_143\user\user.c 000be6 9aca BCF 0xca,0x5,0x0 T2CONbits.T2OUTPS2 = 0; C:\Projects\UBW\FW\D_143\user\user.c 000be8 88ca BSF 0xca,0x4,0x0 T2CONbits.T2OUTPS1 = 1; C:\Projects\UBW\FW\D_143\user\user.c 000bea 96ca BCF 0xca,0x3,0x0 T2CONbits.T2OUTPS0 = 0; C:\Projects\UBW\FW\D_143\user\user.c // Set our reload value C:\Projects\UBW\FW\D_143\user\user.c 000bec 0efa MOVLW 0xfa PR2 = kPR2_RELOAD; C:\Projects\UBW\FW\D_143\user\user.c 000bee 6ecb MOVWF 0xcb,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Set up the Analog to Digital converter C:\Projects\UBW\FW\D_143\user\user.c // Clear out the FIFO data C:\Projects\UBW\FW\D_143\user\user.c 000bf0 6adf CLRF 0xdf,0x0 for (i = 0; i < 12; i++) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000c0a 0e01 MOVLW 0x1 for (j = 0; j < kISR_FIFO_A_DEPTH; j++) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000c28 cfdf MOVFF 0xfdf,0x2a ISR_A_FIFO[i][j] = 0; C:\Projects\UBW\FW\D_143\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\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Inialize USB TX and RX buffer management C:\Projects\UBW\FW\D_143\user\user.c 000c7a 0101 MOVLB 0x1 g_RX_buf_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c7c 6bb8 CLRF 0xb8,0x1 000c7e 0101 MOVLB 0x1 g_RX_buf_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c80 6bb9 CLRF 0xb9,0x1 000c82 0101 MOVLB 0x1 g_TX_buf_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c84 6bb6 CLRF 0xb6,0x1 000c86 0101 MOVLB 0x1 g_TX_buf_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c88 6bb7 CLRF 0xb7,0x1 C:\Projects\UBW\FW\D_143\user\user.c // And the USART TX and RX buffer management C:\Projects\UBW\FW\D_143\user\user.c 000c8a 0101 MOVLB 0x1 g_USART_RX_buf_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c8c 6bba CLRF 0xba,0x1 000c8e 0101 MOVLB 0x1 g_USART_RX_buf_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c90 6bbb CLRF 0xbb,0x1 000c92 0101 MOVLB 0x1 g_USART_TX_buf_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c94 6bbc CLRF 0xbc,0x1 000c96 0101 MOVLB 0x1 g_USART_TX_buf_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c98 6bbd CLRF 0xbd,0x1 C:\Projects\UBW\FW\D_143\user\user.c // Clear out the RC servo output pointer values C:\Projects\UBW\FW\D_143\user\user.c 000c9a 6a0e CLRF 0xe,0x0 g_RC_primed_ptr = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c9c 6a0f CLRF 0xf,0x0 g_RC_next_ptr = 0; C:\Projects\UBW\FW\D_143\user\user.c 000c9e 6a10 CLRF 0x10,0x0 g_RC_timing_ptr = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Clear the RC data structure C:\Projects\UBW\FW\D_143\user\user.c 000ca0 6adf CLRF 0xdf,0x0 for (i = 0; i < kRC_DATA_SIZE; i++) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c 000cba cfdf MOVFF 0xfdf,0xfe9 g_RC_value[i] = 0; C:\Projects\UBW\FW\D_143\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\D_143\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\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Enable TMR0 for our RC timing operation C:\Projects\UBW\FW\D_143\user\user.c 000cf0 86d5 BSF 0xd5,0x3,0x0 T0CONbits.PSA = 1; // Do NOT use the prescaler C:\Projects\UBW\FW\D_143\user\user.c 000cf2 9ad5 BCF 0xd5,0x5,0x0 T0CONbits.T0CS = 0; // Use internal clock C:\Projects\UBW\FW\D_143\user\user.c 000cf4 9cd5 BCF 0xd5,0x6,0x0 T0CONbits.T08BIT = 0; // 16 bit timer C:\Projects\UBW\FW\D_143\user\user.c 000cf6 94f2 BCF 0xf2,0x2,0x0 INTCONbits.TMR0IF = 0; // Clear the interrupt flag C:\Projects\UBW\FW\D_143\user\user.c 000cf8 9af2 BCF 0xf2,0x5,0x0 INTCONbits.TMR0IE = 0; // And clear the interrupt enable C:\Projects\UBW\FW\D_143\user\user.c 000cfa 94f1 BCF 0xf1,0x2,0x0 INTCON2bits.TMR0IP = 0; // Low priority C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Enable interrupt priorities C:\Projects\UBW\FW\D_143\user\user.c 000cfc 8ed0 BSF 0xd0,0x7,0x0 RCONbits.IPEN = 1; C:\Projects\UBW\FW\D_143\user\user.c 000cfe 94ca BCF 0xca,0x2,0x0 T2CONbits.TMR2ON = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 000d00 829d BSF 0x9d,0x1,0x0 PIE1bits.TMR2IE = 1; C:\Projects\UBW\FW\D_143\user\user.c 000d02 929f BCF 0x9f,0x1,0x0 IPR1bits.TMR2IP = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 000d04 8ef2 BSF 0xf2,0x7,0x0 INTCONbits.GIEH = 1; // Turn high priority interrupts on C:\Projects\UBW\FW\D_143\user\user.c 000d06 8cf2 BSF 0xf2,0x6,0x0 INTCONbits.GIEL = 1; // Turn low priority interrupts on C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Turn on the Timer2 C:\Projects\UBW\FW\D_143\user\user.c 000d08 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 000d0a 0e02 MOVLW 0x2 }//end UserInit C:\Projects\UBW\FW\D_143\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\D_143\user\user.c /****************************************************************************** C:\Projects\UBW\FW\D_143\user\user.c * Function: void ProcessIO(void) C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * PreCondition: None C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Input: None C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Output: None C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Side Effects: None C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Overview: In this function, we check for a new packet that just C:\Projects\UBW\FW\D_143\user\user.c * arrived via USB. We do a few checks on the packet to see C:\Projects\UBW\FW\D_143\user\user.c * if it is worthy of us trying to interpret it. If it is, C:\Projects\UBW\FW\D_143\user\user.c * we go and call the proper function based upon the first C:\Projects\UBW\FW\D_143\user\user.c * character of the packet. C:\Projects\UBW\FW\D_143\user\user.c * NOTE: We need to see everything in one packet (i.e. we C:\Projects\UBW\FW\D_143\user\user.c * won't treat the USB data as a stream and try to find our C:\Projects\UBW\FW\D_143\user\user.c * start and end of packets within the stream. We just look C:\Projects\UBW\FW\D_143\user\user.c * at the first character of each packet for a command and C:\Projects\UBW\FW\D_143\user\user.c * check that there's a CR as the last character of the C:\Projects\UBW\FW\D_143\user\user.c * packet. C:\Projects\UBW\FW\D_143\user\user.c * C:\Projects\UBW\FW\D_143\user\user.c * Note: None C:\Projects\UBW\FW\D_143\user\user.c *****************************************************************************/ C:\Projects\UBW\FW\D_143\user\user.c 000d1e cfd9 MOVFF 0xfd9,0xfe6 void ProcessIO(void) C:\Projects\UBW\FW\D_143\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\D_143\user\user.c static BOOL in_cr = FALSE; C:\Projects\UBW\FW\D_143\user\user.c static byte last_fifo_size; C:\Projects\UBW\FW\D_143\user\user.c unsigned char tst_char; C:\Projects\UBW\FW\D_143\user\user.c 000d2a 0e01 MOVLW 0x1 BOOL got_full_packet = FALSE; C:\Projects\UBW\FW\D_143\user\user.c 000d2c 6adb CLRF 0xdb,0x0 000d2e 0101 MOVLB 0x1 cdc_rx_len = 0; C:\Projects\UBW\FW\D_143\user\user.c 000d30 6b99 CLRF 0x99,0x1 C:\Projects\UBW\FW\D_143\user\user.c 000d32 ec11 CALL 0x2622,0x0 BlinkUSBStatus(); C:\Projects\UBW\FW\D_143\user\user.c 000d34 f013 C:\Projects\UBW\FW\D_143\user\user.c // Check for any new I packets (from T command) ready to go out C:\Projects\UBW\FW\D_143\user\user.c 000d36 5006 MOVF 0x6,0x0,0x0 while (ISR_D_FIFO_length > 0) C:\Projects\UBW\FW\D_143\user\user.c 000d38 0800 SUBLW 0x0 000d3a e209 BC 0xd4e 000d4c d7f4 BRA 0xd36 { C:\Projects\UBW\FW\D_143\user\user.c // Spit out an I packet first C:\Projects\UBW\FW\D_143\user\user.c 000d3c ec0a CALL 0x1614,0x0 parse_I_packet (); C:\Projects\UBW\FW\D_143\user\user.c 000d3e f00b C:\Projects\UBW\FW\D_143\user\user.c // Then upate our I packet fifo stuff C:\Projects\UBW\FW\D_143\user\user.c 000d40 2a05 INCF 0x5,0x1,0x0 ISR_D_FIFO_out++; C:\Projects\UBW\FW\D_143\user\user.c 000d42 0e03 MOVLW 0x3 if (ISR_D_FIFO_out == kISR_FIFO_D_DEPTH) C:\Projects\UBW\FW\D_143\user\user.c 000d44 5c05 SUBWF 0x5,0x0,0x0 000d46 e101 BNZ 0xd4a { C:\Projects\UBW\FW\D_143\user\user.c 000d48 6a05 CLRF 0x5,0x0 ISR_D_FIFO_out = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000d4a 0606 DECF 0x6,0x1,0x0 ISR_D_FIFO_length--; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Check for a new A packet (from T command) ready to go out C:\Projects\UBW\FW\D_143\user\user.c 000d4e 500b MOVF 0xb,0x0,0x0 while (ISR_A_FIFO_length > 0) C:\Projects\UBW\FW\D_143\user\user.c 000d50 0800 SUBLW 0x0 000d52 e209 BC 0xd66 000d64 d7f4 BRA 0xd4e { C:\Projects\UBW\FW\D_143\user\user.c // Spit out an A packet first C:\Projects\UBW\FW\D_143\user\user.c 000d54 ec36 CALL 0x166c,0x0 parse_A_packet (); C:\Projects\UBW\FW\D_143\user\user.c 000d56 f00b C:\Projects\UBW\FW\D_143\user\user.c // Then update our A packet fifo stuff C:\Projects\UBW\FW\D_143\user\user.c 000d58 2a0a INCF 0xa,0x1,0x0 ISR_A_FIFO_out++; C:\Projects\UBW\FW\D_143\user\user.c 000d5a 0e03 MOVLW 0x3 if (ISR_A_FIFO_out == kISR_FIFO_A_DEPTH) C:\Projects\UBW\FW\D_143\user\user.c 000d5c 5c0a SUBWF 0xa,0x0,0x0 000d5e e101 BNZ 0xd62 { C:\Projects\UBW\FW\D_143\user\user.c 000d60 6a0a CLRF 0xa,0x0 ISR_A_FIFO_out = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000d62 060b DECF 0xb,0x1,0x0 ISR_A_FIFO_length--; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Pull in some new data if there is new data to pull in C:\Projects\UBW\FW\D_143\user\user.c if( C:\Projects\UBW\FW\D_143\user\user.c !mCDCUsartRxIsBusy() C:\Projects\UBW\FW\D_143\user\user.c 000d66 0104 MOVLB 0x4 && C:\Projects\UBW\FW\D_143\user\user.c 000d68 0104 MOVLB 0x4 000d6a 5118 MOVF 0x18,0x0,0x1 000d6c 0b80 ANDLW 0x80 !( C:\Projects\UBW\FW\D_143\user\user.c 000d70 0e06 MOVLW 0x6 (usb_device_state < CONFIGURED_STATE) C:\Projects\UBW\FW\D_143\user\user.c 000d72 0101 MOVLB 0x1 000d74 5dd2 SUBWF 0xd2,0x0,0x1 || C:\Projects\UBW\FW\D_143\user\user.c (UCONbits.SUSPND == 1) C:\Projects\UBW\FW\D_143\user\user.c 000d76 e368 BNC 0xe48 ) C:\Projects\UBW\FW\D_143\user\user.c 000d78 506d MOVF 0x6d,0x0,0x0 000d7a 0b02 ANDLW 0x2 000d7c e165 BNZ 0xe48 000d6e e16c BNZ 0xe48 ) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Copy data from dual-ram buffer to user's buffer C:\Projects\UBW\FW\D_143\user\user.c 000d7e 0101 MOVLB 0x1 for(cdc_rx_len = 0; cdc_rx_len < CDC_BULK_BD_OUT.Cnt; cdc_rx_len++) C:\Projects\UBW\FW\D_143\user\user.c 000d80 6b99 CLRF 0x99,0x1 000d82 0104 MOVLB 0x4 000d84 5119 MOVF 0x19,0x0,0x1 000d86 0101 MOVLB 0x1 000d88 5d99 SUBWF 0x99,0x0,0x1 000d8a e253 BC 0xe32 000e2c 0101 MOVLB 0x1 000e2e 2b99 INCF 0x99,0x1,0x1 000e30 d7a8 BRA 0xd82 { C:\Projects\UBW\FW\D_143\user\user.c // Check to see if we are in a CR/LF situation C:\Projects\UBW\FW\D_143\user\user.c 000d8c 0101 MOVLB 0x1 tst_char = cdc_data_rx[cdc_rx_len]; C:\Projects\UBW\FW\D_143\user\user.c 000d8e 5199 MOVF 0x99,0x0,0x1 000d90 6aea CLRF 0xea,0x0 000d92 0f08 ADDLW 0x8 000d94 6ee9 MOVWF 0xe9,0x0 000d96 0e05 MOVLW 0x5 000d98 22ea ADDWFC 0xea,0x1,0x0 000d9a cfef MOVFF 0xfef,0xfdf 000d9c ffdf if ( C:\Projects\UBW\FW\D_143\user\user.c 000d9e 0101 MOVLB 0x1 !in_cr C:\Projects\UBW\FW\D_143\user\user.c 000da0 51d6 MOVF 0xd6,0x0,0x1 && C:\Projects\UBW\FW\D_143\user\user.c ( C:\Projects\UBW\FW\D_143\user\user.c 000da4 0e0d MOVLW 0xd kCR == tst_char C:\Projects\UBW\FW\D_143\user\user.c 000da6 6e2a MOVWF 0x2a,0x0 000da8 50df MOVF 0xdf,0x0,0x0 000daa 5c2a SUBWF 0x2a,0x0,0x0 || C:\Projects\UBW\FW\D_143\user\user.c 000dae 0e0a MOVLW 0xa kLF == tst_char C:\Projects\UBW\FW\D_143\user\user.c 000db0 6e2b MOVWF 0x2b,0x0 000db2 50df MOVF 0xdf,0x0,0x0 000dac e005 BZ 0xdb8 ) C:\Projects\UBW\FW\D_143\user\user.c 000db4 5c2b SUBWF 0x2b,0x0,0x0 000db6 e112 BNZ 0xddc 000da2 e11c BNZ 0xddc ) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 000db8 0101 MOVLB 0x1 in_cr = TRUE; C:\Projects\UBW\FW\D_143\user\user.c 000dba 0e01 MOVLW 0x1 000dbc 6fd6 MOVWF 0xd6,0x1 000dbe 0101 MOVLB 0x1 g_RX_buf[g_RX_buf_in] = kCR; C:\Projects\UBW\FW\D_143\user\user.c 000dc0 51b8 MOVF 0xb8,0x0,0x1 000dc2 6aea CLRF 0xea,0x0 000dc4 0f40 ADDLW 0x40 000dc6 6ee9 MOVWF 0xe9,0x0 000dc8 0e02 MOVLW 0x2 000dca 22ea ADDWFC 0xea,0x1,0x0 000dcc 0e0d MOVLW 0xd 000dce 6eef MOVWF 0xef,0x0 000dd0 0101 MOVLB 0x1 g_RX_buf_in++; C:\Projects\UBW\FW\D_143\user\user.c 000dd2 2bb8 INCF 0xb8,0x1,0x1 C:\Projects\UBW\FW\D_143\user\user.c // At this point, we know we have a full packet C:\Projects\UBW\FW\D_143\user\user.c // of information from the PC to parse C:\Projects\UBW\FW\D_143\user\user.c 000dd4 52de MOVF 0xde,0x1,0x0 got_full_packet = TRUE; C:\Projects\UBW\FW\D_143\user\user.c 000dd6 0e01 MOVLW 0x1 000dd8 6edd MOVWF 0xdd,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000dda d015 BRA 0xe06 else if ( C:\Projects\UBW\FW\D_143\user\user.c 000ddc 0e0d MOVLW 0xd tst_char != kCR C:\Projects\UBW\FW\D_143\user\user.c 000dde 5cdf SUBWF 0xdf,0x0,0x0 && C:\Projects\UBW\FW\D_143\user\user.c 000de2 0e0a MOVLW 0xa tst_char != kLF C:\Projects\UBW\FW\D_143\user\user.c 000de0 e011 BZ 0xe04 ) C:\Projects\UBW\FW\D_143\user\user.c 000de4 5cdf SUBWF 0xdf,0x0,0x0 000de6 e00e BZ 0xe04 { C:\Projects\UBW\FW\D_143\user\user.c // Only add a byte if it is not a CR or LF C:\Projects\UBW\FW\D_143\user\user.c 000de8 0101 MOVLB 0x1 g_RX_buf[g_RX_buf_in] = tst_char; C:\Projects\UBW\FW\D_143\user\user.c 000dea 51b8 MOVF 0xb8,0x0,0x1 000dec 6aea CLRF 0xea,0x0 000dee 0f40 ADDLW 0x40 000df0 6ee9 MOVWF 0xe9,0x0 000df2 0e02 MOVLW 0x2 000df4 22ea ADDWFC 0xea,0x1,0x0 000df6 cfdf MOVFF 0xfdf,0xfef 000df8 ffef 000dfa 0101 MOVLB 0x1 in_cr = FALSE; C:\Projects\UBW\FW\D_143\user\user.c 000dfc 6bd6 CLRF 0xd6,0x1 000dfe 0101 MOVLB 0x1 g_RX_buf_in++; C:\Projects\UBW\FW\D_143\user\user.c 000e00 2bb8 INCF 0xb8,0x1,0x1 } C:\Projects\UBW\FW\D_143\user\user.c 000e02 d001 BRA 0xe06 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 000e04 d013 BRA 0xe2c continue; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c // Check for buffer wraparound C:\Projects\UBW\FW\D_143\user\user.c 000e06 0e40 MOVLW 0x40 if (kRX_BUF_SIZE == g_RX_buf_in) C:\Projects\UBW\FW\D_143\user\user.c 000e08 0101 MOVLB 0x1 000e0a 5db8 SUBWF 0xb8,0x0,0x1 000e0c e102 BNZ 0xe12 { C:\Projects\UBW\FW\D_143\user\user.c 000e0e 0101 MOVLB 0x1 g_RX_buf_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000e10 6bb8 CLRF 0xb8,0x1 } C:\Projects\UBW\FW\D_143\user\user.c // If we hit the out pointer, then this is bad. C:\Projects\UBW\FW\D_143\user\user.c 000e12 0101 MOVLB 0x1 if (g_RX_buf_in == g_RX_buf_out) C:\Projects\UBW\FW\D_143\user\user.c 000e14 51b9 MOVF 0xb9,0x0,0x1 000e16 0101 MOVLB 0x1 000e18 5db8 SUBWF 0xb8,0x0,0x1 000e1a e102 BNZ 0xe20 { C:\Projects\UBW\FW\D_143\user\user.c 000e1c 860d BSF 0xd,0x3,0x0 bitset (error_byte, kERROR_BYTE_RX_BUFFER_OVERRUN); C:\Projects\UBW\FW\D_143\user\user.c 000e1e d009 BRA 0xe32 break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c // Now, if we've gotten a full command (user send ) then C:\Projects\UBW\FW\D_143\user\user.c // go call the code that deals with that command, and then C:\Projects\UBW\FW\D_143\user\user.c // keep parsing. (This allows multiple small commands per packet) C:\Projects\UBW\FW\D_143\user\user.c 000e20 0e01 MOVLW 0x1 if (got_full_packet) C:\Projects\UBW\FW\D_143\user\user.c 000e22 50db MOVF 0xdb,0x0,0x0 000e24 e003 BZ 0xe2c { C:\Projects\UBW\FW\D_143\user\user.c 000e26 d91c RCALL 0x1060 parse_packet (); C:\Projects\UBW\FW\D_143\user\user.c 000e28 0e01 MOVLW 0x1 got_full_packet = FALSE; C:\Projects\UBW\FW\D_143\user\user.c 000e2a 6adb CLRF 0xdb,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Prepare dual-ram buffer for next OUT transaction C:\Projects\UBW\FW\D_143\user\user.c 000e32 0104 MOVLB 0x4 CDC_BULK_BD_OUT.Cnt = sizeof(cdc_data_rx); C:\Projects\UBW\FW\D_143\user\user.c 000e34 0e40 MOVLW 0x40 000e36 6f19 MOVWF 0x19,0x1 000e38 0e40 MOVLW 0x40 mUSBBufferReady(CDC_BULK_BD_OUT); C:\Projects\UBW\FW\D_143\user\user.c 000e3a 0104 MOVLB 0x4 000e3c 1718 ANDWF 0x18,0x1,0x1 000e3e 0104 MOVLB 0x4 000e40 7d18 BTG 0x18,0x6,0x1 000e42 0e88 MOVLW 0x88 000e44 0104 MOVLB 0x4 000e46 1318 IORWF 0x18,0x1,0x1 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Check for any errors logged in error_byte that need to be sent out C:\Projects\UBW\FW\D_143\user\user.c 000e48 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 000e4a e101 BNZ 0xe4e 000e4c d081 BRA 0xf50 { C:\Projects\UBW\FW\D_143\user\user.c 000e4e a00d BTFSS 0xd,0x0,0x0 if (bittst (error_byte, 0)) C:\Projects\UBW\FW\D_143\user\user.c 000e50 d010 BRA 0xe72 { C:\Projects\UBW\FW\D_143\user\user.c // Unused as of yet C:\Projects\UBW\FW\D_143\user\user.c 000e52 0e5f MOVLW 0x5f printf ((far rom char *)"!0 \r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000e54 6e2a MOVWF 0x2a,0x0 000e56 0e40 MOVLW 0x40 000e58 6e2b MOVWF 0x2b,0x0 000e5a 6a2c CLRF 0x2c,0x0 000e5c c02a MOVFF 0x2a,0xfe6 000e5e ffe6 000e60 c02b MOVFF 0x2b,0xfe6 000e62 ffe6 000e64 c02c MOVFF 0x2c,0xfe6 000e66 ffe6 000e68 ec5f CALL 0x42be,0x0 000e6a f021 000e6c 52e5 MOVF 0xe5,0x1,0x0 000e6e 52e5 MOVF 0xe5,0x1,0x0 000e70 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000e72 a20d BTFSS 0xd,0x1,0x0 if (bittst (error_byte, 1)) C:\Projects\UBW\FW\D_143\user\user.c 000e74 d010 BRA 0xe96 { C:\Projects\UBW\FW\D_143\user\user.c // Unused as of yet C:\Projects\UBW\FW\D_143\user\user.c 000e76 0e59 MOVLW 0x59 printf ((far rom char *)"!1 \r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000e78 6e2a MOVWF 0x2a,0x0 000e7a 0e40 MOVLW 0x40 000e7c 6e2b MOVWF 0x2b,0x0 000e7e 6a2c CLRF 0x2c,0x0 000e80 c02a MOVFF 0x2a,0xfe6 000e82 ffe6 000e84 c02b MOVFF 0x2b,0xfe6 000e86 ffe6 000e88 c02c MOVFF 0x2c,0xfe6 000e8a ffe6 000e8c ec5f CALL 0x42be,0x0 000e8e f021 000e90 52e5 MOVF 0xe5,0x1,0x0 000e92 52e5 MOVF 0xe5,0x1,0x0 000e94 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000e96 a40d BTFSS 0xd,0x2,0x0 if (bittst (error_byte, kERROR_BYTE_TX_BUF_OVERRUN)) C:\Projects\UBW\FW\D_143\user\user.c 000e98 d010 BRA 0xeba { C:\Projects\UBW\FW\D_143\user\user.c 000e9a 0e3d MOVLW 0x3d printf ((far rom char *)"!2 Err: TX Buffer overrun\r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000e9c 6e2a MOVWF 0x2a,0x0 000e9e 0e40 MOVLW 0x40 000ea0 6e2b MOVWF 0x2b,0x0 000ea2 6a2c CLRF 0x2c,0x0 000ea4 c02a MOVFF 0x2a,0xfe6 000ea6 ffe6 000ea8 c02b MOVFF 0x2b,0xfe6 000eaa ffe6 000eac c02c MOVFF 0x2c,0xfe6 000eae ffe6 000eb0 ec5f CALL 0x42be,0x0 000eb2 f021 000eb4 52e5 MOVF 0xe5,0x1,0x0 000eb6 52e5 MOVF 0xe5,0x1,0x0 000eb8 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000eba a60d BTFSS 0xd,0x3,0x0 if (bittst (error_byte, kERROR_BYTE_RX_BUFFER_OVERRUN)) C:\Projects\UBW\FW\D_143\user\user.c 000ebc d010 BRA 0xede { C:\Projects\UBW\FW\D_143\user\user.c 000ebe 0e21 MOVLW 0x21 printf ((far rom char *)"!3 Err: RX Buffer overrun\r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000ec0 6e2a MOVWF 0x2a,0x0 000ec2 0e40 MOVLW 0x40 000ec4 6e2b MOVWF 0x2b,0x0 000ec6 6a2c CLRF 0x2c,0x0 000ec8 c02a MOVFF 0x2a,0xfe6 000eca ffe6 000ecc c02b MOVFF 0x2b,0xfe6 000ece ffe6 000ed0 c02c MOVFF 0x2c,0xfe6 000ed2 ffe6 000ed4 ec5f CALL 0x42be,0x0 000ed6 f021 000ed8 52e5 MOVF 0xe5,0x1,0x0 000eda 52e5 MOVF 0xe5,0x1,0x0 000edc 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000ede a80d BTFSS 0xd,0x4,0x0 if (bittst (error_byte, kERROR_BYTE_MISSING_PARAMETER)) C:\Projects\UBW\FW\D_143\user\user.c 000ee0 d010 BRA 0xf02 { C:\Projects\UBW\FW\D_143\user\user.c 000ee2 0e02 MOVLW 0x2 printf ((far rom char *)"!4 Err: Missing parameter(s)\r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000ee4 6e2a MOVWF 0x2a,0x0 000ee6 0e40 MOVLW 0x40 000ee8 6e2b MOVWF 0x2b,0x0 000eea 6a2c CLRF 0x2c,0x0 000eec c02a MOVFF 0x2a,0xfe6 000eee ffe6 000ef0 c02b MOVFF 0x2b,0xfe6 000ef2 ffe6 000ef4 c02c MOVFF 0x2c,0xfe6 000ef6 ffe6 000ef8 ec5f CALL 0x42be,0x0 000efa f021 000efc 52e5 MOVF 0xe5,0x1,0x0 000efe 52e5 MOVF 0xe5,0x1,0x0 000f00 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000f02 aa0d BTFSS 0xd,0x5,0x0 if (bittst (error_byte, kERROR_BYTE_PRINTED_ERROR)) C:\Projects\UBW\FW\D_143\user\user.c 000f04 d000 BRA 0xf06 { C:\Projects\UBW\FW\D_143\user\user.c // We don't need to do anything since something has already been printed out C:\Projects\UBW\FW\D_143\user\user.c //printf ((rom char *)"!5\r\n"); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000f06 ac0d BTFSS 0xd,0x6,0x0 if (bittst (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT)) C:\Projects\UBW\FW\D_143\user\user.c 000f08 d010 BRA 0xf2a { C:\Projects\UBW\FW\D_143\user\user.c 000f0a 0ee1 MOVLW 0xe1 printf ((far rom char *)"!6 Err: Invalid paramter value\r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000f0c 6e2a MOVWF 0x2a,0x0 000f0e 0e3f MOVLW 0x3f 000f10 6e2b MOVWF 0x2b,0x0 000f12 6a2c CLRF 0x2c,0x0 000f14 c02a MOVFF 0x2a,0xfe6 000f16 ffe6 000f18 c02b MOVFF 0x2b,0xfe6 000f1a ffe6 000f1c c02c MOVFF 0x2c,0xfe6 000f1e ffe6 000f20 ec5f CALL 0x42be,0x0 000f22 f021 000f24 52e5 MOVF 0xe5,0x1,0x0 000f26 52e5 MOVF 0xe5,0x1,0x0 000f28 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000f2a ae0d BTFSS 0xd,0x7,0x0 if (bittst (error_byte, kERROR_BYTE_EXTRA_CHARACTERS)) C:\Projects\UBW\FW\D_143\user\user.c 000f2c d010 BRA 0xf4e { C:\Projects\UBW\FW\D_143\user\user.c 000f2e 0ec8 MOVLW 0xc8 printf ((far rom char *)"!7 Err: Extra parmater\r\n"); C:\Projects\UBW\FW\D_143\user\user.c 000f30 6e2a MOVWF 0x2a,0x0 000f32 0e3f MOVLW 0x3f 000f34 6e2b MOVWF 0x2b,0x0 000f36 6a2c CLRF 0x2c,0x0 000f38 c02a MOVFF 0x2a,0xfe6 000f3a ffe6 000f3c c02b MOVFF 0x2b,0xfe6 000f3e ffe6 000f40 c02c MOVFF 0x2c,0xfe6 000f42 ffe6 000f44 ec5f CALL 0x42be,0x0 000f46 f021 000f48 52e5 MOVF 0xe5,0x1,0x0 000f4a 52e5 MOVF 0xe5,0x1,0x0 000f4c 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000f4e 6a0d CLRF 0xd,0x0 error_byte = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Go send any data that needs sending to PC C:\Projects\UBW\FW\D_143\user\user.c 000f50 d835 RCALL 0xfbc check_and_send_TX_data (); C:\Projects\UBW\FW\D_143\user\user.c 000f52 0e02 MOVLW 0x2 } C:\Projects\UBW\FW\D_143\user\user.c 000f54 5ce1 SUBWF 0xe1,0x0,0x0 000f56 e202 BC 0xf5c 000f58 6ae1 CLRF 0xe1,0x0 000f5a 52e5 MOVF 0xe5,0x1,0x0 000f5c 6ee1 MOVWF 0xe1,0x0 000f5e 52e5 MOVF 0xe5,0x1,0x0 000f60 cfe7 MOVFF 0xfe7,0xfd9 000f62 ffd9 000f64 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // This is our replacement for the standard putc routine C:\Projects\UBW\FW\D_143\user\user.c // This enables printf() and all related functions to print to C:\Projects\UBW\FW\D_143\user\user.c // the UBS output (i.e. to the PC) buffer C:\Projects\UBW\FW\D_143\user\user.c 000f66 cfd9 MOVFF 0xfd9,0xfe6 int _user_putc (char c) C:\Projects\UBW\FW\D_143\user\user.c 000f68 ffe6 000f6a cfe1 MOVFF 0xfe1,0xfd9 000f6c ffd9 { C:\Projects\UBW\FW\D_143\user\user.c // Copy the character into the output buffer C:\Projects\UBW\FW\D_143\user\user.c 000f6e 0101 MOVLB 0x1 g_TX_buf[g_TX_buf_in] = c; C:\Projects\UBW\FW\D_143\user\user.c 000f70 51b6 MOVF 0xb6,0x0,0x1 000f72 6aea CLRF 0xea,0x0 000f74 0f00 ADDLW 0x0 000f76 6ee9 MOVWF 0xe9,0x0 000f78 0e02 MOVLW 0x2 000f7a 22ea ADDWFC 0xea,0x1,0x0 000f7c 0efe MOVLW 0xfe 000f7e cfdb MOVFF 0xfdb,0xfef 000f80 ffef 000f82 0101 MOVLB 0x1 g_TX_buf_in++; C:\Projects\UBW\FW\D_143\user\user.c 000f84 2bb6 INCF 0xb6,0x1,0x1 C:\Projects\UBW\FW\D_143\user\user.c // Check for wrap around C:\Projects\UBW\FW\D_143\user\user.c 000f86 0e40 MOVLW 0x40 if (kTX_BUF_SIZE == g_TX_buf_in) C:\Projects\UBW\FW\D_143\user\user.c 000f88 0101 MOVLB 0x1 000f8a 5db6 SUBWF 0xb6,0x0,0x1 000f8c e102 BNZ 0xf92 { C:\Projects\UBW\FW\D_143\user\user.c 000f8e 0101 MOVLB 0x1 g_TX_buf_in = 0; C:\Projects\UBW\FW\D_143\user\user.c 000f90 6bb6 CLRF 0xb6,0x1 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Also check to see if we bumpted up against our output pointer C:\Projects\UBW\FW\D_143\user\user.c 000f92 0101 MOVLB 0x1 if (g_TX_buf_in == g_TX_buf_out) C:\Projects\UBW\FW\D_143\user\user.c 000f94 51b7 MOVF 0xb7,0x0,0x1 000f96 0101 MOVLB 0x1 000f98 5db6 SUBWF 0xb6,0x0,0x1 000f9a e101 BNZ 0xf9e { C:\Projects\UBW\FW\D_143\user\user.c 000f9c 840d BSF 0xd,0x2,0x0 bitset (error_byte, kERROR_BYTE_TX_BUF_OVERRUN); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 000f9e 0efe MOVLW 0xfe return (c); C:\Projects\UBW\FW\D_143\user\user.c 000fa0 cfdb MOVFF 0xfdb,0x2a 000fa2 f02a 000fa4 6a2b CLRF 0x2b,0x0 000fa6 be2a BTFSC 0x2a,0x7,0x0 000fa8 682b SETF 0x2b,0x0 000faa c02a MOVFF 0x2a,0xff3 000fac fff3 000fae c02b MOVFF 0x2b,0xff4 000fb0 fff4 000fb2 d000 BRA 0xfb4 000fb4 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 000fb6 cfe7 MOVFF 0xfe7,0xfd9 000fb8 ffd9 000fba 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // In this function, we check to see it is OK to transmit. If so C:\Projects\UBW\FW\D_143\user\user.c // we see if there is any data to transmit to PC. If so, we schedule C:\Projects\UBW\FW\D_143\user\user.c // it for sending. C:\Projects\UBW\FW\D_143\user\user.c 000fbc cfd9 MOVFF 0xfd9,0xfe6 void check_and_send_TX_data (void) C:\Projects\UBW\FW\D_143\user\user.c 000fbe ffe6 000fc0 cfe1 MOVFF 0xfe1,0xfd9 000fc2 ffd9 000fc4 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c char temp; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Only send if we're not already sending something C:\Projects\UBW\FW\D_143\user\user.c if ( C:\Projects\UBW\FW\D_143\user\user.c 000fc6 0101 MOVLB 0x1 mUSBUSARTIsTxTrfReady () C:\Projects\UBW\FW\D_143\user\user.c 000fc8 519a MOVF 0x9a,0x0,0x1 && C:\Projects\UBW\FW\D_143\user\user.c !( C:\Projects\UBW\FW\D_143\user\user.c 000fcc 0e06 MOVLW 0x6 (usb_device_state < CONFIGURED_STATE) C:\Projects\UBW\FW\D_143\user\user.c 000fce 0101 MOVLB 0x1 000fd0 5dd2 SUBWF 0xd2,0x0,0x1 || C:\Projects\UBW\FW\D_143\user\user.c (UCONbits.SUSPND == 1) C:\Projects\UBW\FW\D_143\user\user.c 000fd2 e341 BNC 0x1056 ) C:\Projects\UBW\FW\D_143\user\user.c 000fd4 506d MOVF 0x6d,0x0,0x0 000fd6 0b02 ANDLW 0x2 000fd8 e13e BNZ 0x1056 000fca e145 BNZ 0x1056 ) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // And only send if there's something there to send C:\Projects\UBW\FW\D_143\user\user.c 000fda 0101 MOVLB 0x1 if (g_TX_buf_out != g_TX_buf_in) C:\Projects\UBW\FW\D_143\user\user.c 000fdc 51b6 MOVF 0xb6,0x0,0x1 000fde 0101 MOVLB 0x1 000fe0 5db7 SUBWF 0xb7,0x0,0x1 000fe2 e039 BZ 0x1056 { C:\Projects\UBW\FW\D_143\user\user.c // Now decide if we need to break it up into two parts or not C:\Projects\UBW\FW\D_143\user\user.c 000fe4 0101 MOVLB 0x1 if (g_TX_buf_in > g_TX_buf_out) C:\Projects\UBW\FW\D_143\user\user.c 000fe6 51b7 MOVF 0xb7,0x0,0x1 000fe8 0101 MOVLB 0x1 000fea 80d8 BSF 0xd8,0x0,0x0 000fec 55b6 SUBFWB 0xb6,0x0,0x1 000fee e21a BC 0x1024 { C:\Projects\UBW\FW\D_143\user\user.c // Since IN is beyond OUT, only need one chunk C:\Projects\UBW\FW\D_143\user\user.c 000ff0 0101 MOVLB 0x1 temp = g_TX_buf_in - g_TX_buf_out; C:\Projects\UBW\FW\D_143\user\user.c 000ff2 51b7 MOVF 0xb7,0x0,0x1 000ff4 0101 MOVLB 0x1 000ff6 5db6 SUBWF 0xb6,0x0,0x1 000ff8 6edf MOVWF 0xdf,0x0 000ffa 0101 MOVLB 0x1 mUSBUSARTTxRam (&g_TX_buf[g_TX_buf_out], temp); C:\Projects\UBW\FW\D_143\user\user.c 000ffc 51b7 MOVF 0xb7,0x0,0x1 000ffe 0101 MOVLB 0x1 001000 6f9b MOVWF 0x9b,0x1 001002 6b9c CLRF 0x9c,0x1 001004 0e00 MOVLW 0x0 001006 0101 MOVLB 0x1 001008 279b ADDWF 0x9b,0x1,0x1 00100a 0e02 MOVLW 0x2 00100c 0101 MOVLB 0x1 00100e 239c ADDWFC 0x9c,0x1,0x1 001010 cfdf MOVFF 0xfdf,0x19f 001012 f19f 001014 0101 MOVLB 0x1 001016 6ba0 CLRF 0xa0,0x1 001018 0101 MOVLB 0x1 00101a 0e01 MOVLW 0x1 00101c 6f9a MOVWF 0x9a,0x1 // Now that we've scheduled the data for sending, C:\Projects\UBW\FW\D_143\user\user.c // update the pointer C:\Projects\UBW\FW\D_143\user\user.c 00101e c1b6 MOVFF 0x1b6,0x1b7 g_TX_buf_out = g_TX_buf_in; C:\Projects\UBW\FW\D_143\user\user.c 001020 f1b7 } C:\Projects\UBW\FW\D_143\user\user.c 001022 d019 BRA 0x1056 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Since IN is before OUT, we need to send from OUT to the end C:\Projects\UBW\FW\D_143\user\user.c // of the buffer, then the next time around we'll catch C:\Projects\UBW\FW\D_143\user\user.c // from the beginning to IN. C:\Projects\UBW\FW\D_143\user\user.c 001024 0e40 MOVLW 0x40 temp = kTX_BUF_SIZE - g_TX_buf_out; C:\Projects\UBW\FW\D_143\user\user.c 001026 0101 MOVLB 0x1 001028 80d8 BSF 0xd8,0x0,0x0 00102a 55b7 SUBFWB 0xb7,0x0,0x1 00102c 6edf MOVWF 0xdf,0x0 00102e 0101 MOVLB 0x1 mUSBUSARTTxRam (&g_TX_buf[g_TX_buf_out], temp); C:\Projects\UBW\FW\D_143\user\user.c 001030 51b7 MOVF 0xb7,0x0,0x1 001032 0101 MOVLB 0x1 001034 6f9b MOVWF 0x9b,0x1 001036 6b9c CLRF 0x9c,0x1 001038 0e00 MOVLW 0x0 00103a 0101 MOVLB 0x1 00103c 279b ADDWF 0x9b,0x1,0x1 00103e 0e02 MOVLW 0x2 001040 0101 MOVLB 0x1 001042 239c ADDWFC 0x9c,0x1,0x1 001044 cfdf MOVFF 0xfdf,0x19f 001046 f19f 001048 0101 MOVLB 0x1 00104a 6ba0 CLRF 0xa0,0x1 00104c 0101 MOVLB 0x1 00104e 0e01 MOVLW 0x1 001050 6f9a MOVWF 0x9a,0x1 // Now that we've scheduled the data for sending, C:\Projects\UBW\FW\D_143\user\user.c // update the pointer C:\Projects\UBW\FW\D_143\user\user.c 001052 0101 MOVLB 0x1 g_TX_buf_out = 0; C:\Projects\UBW\FW\D_143\user\user.c 001054 6bb7 CLRF 0xb7,0x1 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001056 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001058 52e5 MOVF 0xe5,0x1,0x0 00105a cfe7 MOVFF 0xfe7,0xfd9 00105c ffd9 00105e 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Look at the new packet, see what command it is, and C:\Projects\UBW\FW\D_143\user\user.c // route it appropriately. We come in knowing that C:\Projects\UBW\FW\D_143\user\user.c // our packet is in g_RX_buf[], and that the beginning C:\Projects\UBW\FW\D_143\user\user.c // of the packet is at g_RX_buf_out, and the end (CR) is at C:\Projects\UBW\FW\D_143\user\user.c // g_RX_buf_in. Note that because of buffer wrapping, C:\Projects\UBW\FW\D_143\user\user.c // g_RX_buf_in may be less than g_RX_buf_out. C:\Projects\UBW\FW\D_143\user\user.c 001060 cfd9 MOVFF 0xfd9,0xfe6 void parse_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001062 ffe6 001064 cfe1 MOVFF 0xfe1,0xfd9 001066 ffd9 001068 0e04 MOVLW 0x4 00106a 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c 00106c 6ade CLRF 0xde,0x0 unsigned int command = 0; C:\Projects\UBW\FW\D_143\user\user.c 00106e 6add CLRF 0xdd,0x0 001070 0e02 MOVLW 0x2 unsigned char cmd1 = 0; C:\Projects\UBW\FW\D_143\user\user.c 001072 6adb CLRF 0xdb,0x0 001074 0e03 MOVLW 0x3 unsigned char cmd2 = 0; C:\Projects\UBW\FW\D_143\user\user.c 001076 6adb CLRF 0xdb,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Always grab the first character (which is the first byte of the command) C:\Projects\UBW\FW\D_143\user\user.c 001078 0101 MOVLB 0x1 cmd1 = toupper (g_RX_buf[g_RX_buf_out]); C:\Projects\UBW\FW\D_143\user\user.c 00107a 51b9 MOVF 0xb9,0x0,0x1 00107c 6aea CLRF 0xea,0x0 00107e 0f40 ADDLW 0x40 001080 6ee9 MOVWF 0xe9,0x0 001082 0e02 MOVLW 0x2 001084 22ea ADDWFC 0xea,0x1,0x0 001086 50ef MOVF 0xef,0x0,0x0 001088 6ee6 MOVWF 0xe6,0x0 00108a 6ae6 CLRF 0xe6,0x0 00108c ec58 CALL 0x44b0,0x0 00108e f022 001090 52e5 MOVF 0xe5,0x1,0x0 001092 52e5 MOVF 0xe5,0x1,0x0 001094 0e02 MOVLW 0x2 001096 cff3 MOVFF 0xff3,0xfdb 001098 ffdb 00109a 0101 MOVLB 0x1 advance_RX_buf_out(); C:\Projects\UBW\FW\D_143\user\user.c 00109c 2bb9 INCF 0xb9,0x1,0x1 00109e 0e40 MOVLW 0x40 0010a0 0101 MOVLB 0x1 0010a2 5db9 SUBWF 0xb9,0x0,0x1 0010a4 e102 BNZ 0x10aa 0010a6 0101 MOVLB 0x1 0010a8 6bb9 CLRF 0xb9,0x1 0010aa 0e02 MOVLW 0x2 command = cmd1; C:\Projects\UBW\FW\D_143\user\user.c 0010ac 50db MOVF 0xdb,0x0,0x0 0010ae 6ede MOVWF 0xde,0x0 0010b0 6add CLRF 0xdd,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Only grab second one if it is not a comma C:\Projects\UBW\FW\D_143\user\user.c 0010b2 0101 MOVLB 0x1 if (g_RX_buf[g_RX_buf_out] != ',' && g_RX_buf[g_RX_buf_out] != kCR) C:\Projects\UBW\FW\D_143\user\user.c 0010b4 51b9 MOVF 0xb9,0x0,0x1 0010b6 6aea CLRF 0xea,0x0 0010b8 0f40 ADDLW 0x40 0010ba 6ee9 MOVWF 0xe9,0x0 0010bc 0e02 MOVLW 0x2 0010be 22ea ADDWFC 0xea,0x1,0x0 0010c0 50ef MOVF 0xef,0x0,0x0 0010c2 082c SUBLW 0x2c 0010c4 e035 BZ 0x1130 0010c6 0101 MOVLB 0x1 0010c8 51b9 MOVF 0xb9,0x0,0x1 0010ca 6aea CLRF 0xea,0x0 0010cc 0f40 ADDLW 0x40 0010ce 6ee9 MOVWF 0xe9,0x0 0010d0 0e02 MOVLW 0x2 0010d2 22ea ADDWFC 0xea,0x1,0x0 0010d4 50ef MOVF 0xef,0x0,0x0 0010d6 080d SUBLW 0xd 0010d8 e02b BZ 0x1130 { C:\Projects\UBW\FW\D_143\user\user.c 0010da 0101 MOVLB 0x1 cmd2 = toupper (g_RX_buf[g_RX_buf_out]); C:\Projects\UBW\FW\D_143\user\user.c 0010dc 51b9 MOVF 0xb9,0x0,0x1 0010de 6aea CLRF 0xea,0x0 0010e0 0f40 ADDLW 0x40 0010e2 6ee9 MOVWF 0xe9,0x0 0010e4 0e02 MOVLW 0x2 0010e6 22ea ADDWFC 0xea,0x1,0x0 0010e8 50ef MOVF 0xef,0x0,0x0 0010ea 6ee6 MOVWF 0xe6,0x0 0010ec 6ae6 CLRF 0xe6,0x0 0010ee ec58 CALL 0x44b0,0x0 0010f0 f022 0010f2 52e5 MOVF 0xe5,0x1,0x0 0010f4 52e5 MOVF 0xe5,0x1,0x0 0010f6 0e03 MOVLW 0x3 0010f8 cff3 MOVFF 0xff3,0xfdb 0010fa ffdb 0010fc 0101 MOVLB 0x1 advance_RX_buf_out(); C:\Projects\UBW\FW\D_143\user\user.c 0010fe 2bb9 INCF 0xb9,0x1,0x1 001100 0e40 MOVLW 0x40 001102 0101 MOVLB 0x1 001104 5db9 SUBWF 0xb9,0x0,0x1 001106 e102 BNZ 0x110c 001108 0101 MOVLB 0x1 00110a 6bb9 CLRF 0xb9,0x1 00110c 0e02 MOVLW 0x2 command = ((unsigned int)(cmd1) << 8) + cmd2; C:\Projects\UBW\FW\D_143\user\user.c 00110e cfdb MOVFF 0xfdb,0x2c 001110 f02c 001112 c02c MOVFF 0x2c,0x2d 001114 f02d 001116 6a2c CLRF 0x2c,0x0 001118 0e03 MOVLW 0x3 00111a 50db MOVF 0xdb,0x0,0x0 00111c 0100 MOVLB 0x0 00111e 242c ADDWF 0x2c,0x0,0x0 001120 6e2a MOVWF 0x2a,0x0 001122 0e00 MOVLW 0x0 001124 202d ADDWFC 0x2d,0x0,0x0 001126 6e2b MOVWF 0x2b,0x0 001128 c02a MOVFF 0x2a,0xfde 00112a ffde 00112c c02b MOVFF 0x2b,0xfdd 00112e ffdd } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now 'command' is equal to one or two bytes of our command C:\Projects\UBW\FW\D_143\user\user.c 001130 0e00 MOVLW 0x0 switch (command) C:\Projects\UBW\FW\D_143\user\user.c 001132 cfdb MOVFF 0xfdb,0x1e 001134 f01e 001136 0e01 MOVLW 0x1 001138 cfdb MOVFF 0xfdb,0x1f 00113a f01f 00113c 0e49 MOVLW 0x49 00113e 181e XORWF 0x1e,0x0,0x0 001140 e102 BNZ 0x1146 001142 0e43 MOVLW 0x43 001144 181f XORWF 0x1f,0x0,0x0 001146 e101 BNZ 0x114a 001148 d0d7 BRA 0x12f8 00114a 0e49 MOVLW 0x49 00114c 181e XORWF 0x1e,0x0,0x0 00114e e102 BNZ 0x1154 001150 0e52 MOVLW 0x52 001152 181f XORWF 0x1f,0x0,0x0 001154 e101 BNZ 0x1158 001156 d0cd BRA 0x12f2 001158 0e49 MOVLW 0x49 00115a 181e XORWF 0x1e,0x0,0x0 00115c e102 BNZ 0x1162 00115e 0e53 MOVLW 0x53 001160 181f XORWF 0x1f,0x0,0x0 001162 e101 BNZ 0x1166 001164 d0c3 BRA 0x12ec 001166 0e53 MOVLW 0x53 001168 181e XORWF 0x1e,0x0,0x0 00116a e102 BNZ 0x1170 00116c 0e43 MOVLW 0x43 00116e 181f XORWF 0x1f,0x0,0x0 001170 e101 BNZ 0x1174 001172 d0b9 BRA 0x12e6 001174 0e53 MOVLW 0x53 001176 181e XORWF 0x1e,0x0,0x0 001178 e102 BNZ 0x117e 00117a 0e52 MOVLW 0x52 00117c 181f XORWF 0x1f,0x0,0x0 00117e e101 BNZ 0x1182 001180 d0af BRA 0x12e0 001182 0e53 MOVLW 0x53 001184 181e XORWF 0x1e,0x0,0x0 001186 e102 BNZ 0x118c 001188 0e53 MOVLW 0x53 00118a 181f XORWF 0x1f,0x0,0x0 00118c e101 BNZ 0x1190 00118e d0a5 BRA 0x12da 001190 0e53 MOVLW 0x53 001192 181e XORWF 0x1e,0x0,0x0 001194 e102 BNZ 0x119a 001196 0e42 MOVLW 0x42 001198 181f XORWF 0x1f,0x0,0x0 00119a e101 BNZ 0x119e 00119c d09b BRA 0x12d4 00119e 0e43 MOVLW 0x43 0011a0 181e XORWF 0x1e,0x0,0x0 0011a2 e102 BNZ 0x11a8 0011a4 0e42 MOVLW 0x42 0011a6 181f XORWF 0x1f,0x0,0x0 0011a8 e101 BNZ 0x11ac 0011aa d091 BRA 0x12ce 0011ac 0e43 MOVLW 0x43 0011ae 181e XORWF 0x1e,0x0,0x0 0011b0 e102 BNZ 0x11b6 0011b2 0e52 MOVLW 0x52 0011b4 181f XORWF 0x1f,0x0,0x0 0011b6 e101 BNZ 0x11ba 0011b8 d087 BRA 0x12c8 0011ba 0e4f MOVLW 0x4f 0011bc 181e XORWF 0x1e,0x0,0x0 0011be e102 BNZ 0x11c4 0011c0 0e42 MOVLW 0x42 0011c2 181f XORWF 0x1f,0x0,0x0 0011c4 e101 BNZ 0x11c8 0011c6 d07d BRA 0x12c2 0011c8 0e57 MOVLW 0x57 0011ca 181e XORWF 0x1e,0x0,0x0 0011cc e102 BNZ 0x11d2 0011ce 0e4d MOVLW 0x4d 0011d0 181f XORWF 0x1f,0x0,0x0 0011d2 e075 BZ 0x12be 0011d4 0e52 MOVLW 0x52 0011d6 181e XORWF 0x1e,0x0,0x0 0011d8 e102 BNZ 0x11de 0011da 0e4d MOVLW 0x4d 0011dc 181f XORWF 0x1f,0x0,0x0 0011de e06d BZ 0x12ba 0011e0 0e44 MOVLW 0x44 0011e2 181e XORWF 0x1e,0x0,0x0 0011e4 e102 BNZ 0x11ea 0011e6 0e50 MOVLW 0x50 0011e8 181f XORWF 0x1f,0x0,0x0 0011ea e065 BZ 0x12b6 0011ec 0e4f MOVLW 0x4f 0011ee 181e XORWF 0x1e,0x0,0x0 0011f0 e102 BNZ 0x11f6 0011f2 0e50 MOVLW 0x50 0011f4 181f XORWF 0x1f,0x0,0x0 0011f6 e05d BZ 0x12b2 0011f8 0e49 MOVLW 0x49 0011fa 181e XORWF 0x1e,0x0,0x0 0011fc e102 BNZ 0x1202 0011fe 0e50 MOVLW 0x50 001200 181f XORWF 0x1f,0x0,0x0 001202 e055 BZ 0x12ae 001204 0e58 MOVLW 0x58 001206 181e XORWF 0x1e,0x0,0x0 001208 e102 BNZ 0x120e 00120a 0e54 MOVLW 0x54 00120c 181f XORWF 0x1f,0x0,0x0 00120e e04c BZ 0x12a8 001210 0e54 MOVLW 0x54 001212 181e XORWF 0x1e,0x0,0x0 001214 e101 BNZ 0x1218 001216 501f MOVF 0x1f,0x0,0x0 001218 e045 BZ 0x12a4 00121a 0e41 MOVLW 0x41 00121c 181e XORWF 0x1e,0x0,0x0 00121e e101 BNZ 0x1222 001220 501f MOVF 0x1f,0x0,0x0 001222 e03e BZ 0x12a0 001224 0e56 MOVLW 0x56 001226 181e XORWF 0x1e,0x0,0x0 001228 e101 BNZ 0x122c 00122a 501f MOVF 0x1f,0x0,0x0 00122c e037 BZ 0x129c 00122e 0e49 MOVLW 0x49 001230 181e XORWF 0x1e,0x0,0x0 001232 e101 BNZ 0x1236 001234 501f MOVF 0x1f,0x0,0x0 001236 e030 BZ 0x1298 001238 0e4f MOVLW 0x4f 00123a 181e XORWF 0x1e,0x0,0x0 00123c e101 BNZ 0x1240 00123e 501f MOVF 0x1f,0x0,0x0 001240 e029 BZ 0x1294 001242 0e55 MOVLW 0x55 001244 181e XORWF 0x1e,0x0,0x0 001246 e102 BNZ 0x124c 001248 0e43 MOVLW 0x43 00124a 181f XORWF 0x1f,0x0,0x0 00124c e021 BZ 0x1290 00124e 0e58 MOVLW 0x58 001250 181e XORWF 0x1e,0x0,0x0 001252 e102 BNZ 0x1258 001254 0e43 MOVLW 0x43 001256 181f XORWF 0x1f,0x0,0x0 001258 e018 BZ 0x128a 00125a 0e43 MOVLW 0x43 00125c 181e XORWF 0x1e,0x0,0x0 00125e e101 BNZ 0x1262 001260 501f MOVF 0x1f,0x0,0x0 001262 e011 BZ 0x1286 001264 0e52 MOVLW 0x52 001266 181e XORWF 0x1e,0x0,0x0 001268 e101 BNZ 0x126c 00126a 501f MOVF 0x1f,0x0,0x0 00126c e00a BZ 0x1282 00126e 0e58 MOVLW 0x58 001270 181e XORWF 0x1e,0x0,0x0 001272 e102 BNZ 0x1278 001274 0e52 MOVLW 0x52 001276 181f XORWF 0x1f,0x0,0x0 001278 e001 BZ 0x127c 00127a d041 BRA 0x12fe { C:\Projects\UBW\FW\D_143\user\user.c case ('R' * 256) + 'X': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // For receiving serial C:\Projects\UBW\FW\D_143\user\user.c 00127c ecc4 CALL 0x1b88,0x0 parse_RX_packet (); C:\Projects\UBW\FW\D_143\user\user.c 00127e f00d 001280 d07d BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'R': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Reset command (resets everything to power-on state) C:\Projects\UBW\FW\D_143\user\user.c 001282 d8b3 RCALL 0x13ea parse_R_packet (); C:\Projects\UBW\FW\D_143\user\user.c 001284 d07b BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'C': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Configure command (configure ports for Input or Ouptut) C:\Projects\UBW\FW\D_143\user\user.c 001286 d936 RCALL 0x14f4 parse_C_packet (); C:\Projects\UBW\FW\D_143\user\user.c 001288 d079 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('C' * 256) + 'X': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // For configuring serial port C:\Projects\UBW\FW\D_143\user\user.c 00128a ecc6 CALL 0x1b8c,0x0 parse_CX_packet (); C:\Projects\UBW\FW\D_143\user\user.c 00128c f00d 00128e d076 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('C' * 256) + 'U': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // For configuring UBW C:\Projects\UBW\FW\D_143\user\user.c 001290 d8b0 RCALL 0x13f2 parse_CU_packet (); C:\Projects\UBW\FW\D_143\user\user.c 001292 d074 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'O': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Output command (tell the ports to output something) C:\Projects\UBW\FW\D_143\user\user.c 001294 d98c RCALL 0x15ae parse_O_packet (); C:\Projects\UBW\FW\D_143\user\user.c 001296 d072 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'I': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Input command (return the current status of the ports) C:\Projects\UBW\FW\D_143\user\user.c 001298 d9bd RCALL 0x1614 parse_I_packet (); C:\Projects\UBW\FW\D_143\user\user.c 00129a d070 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'V': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Version command C:\Projects\UBW\FW\D_143\user\user.c 00129c d9d6 RCALL 0x164a parse_V_packet (); C:\Projects\UBW\FW\D_143\user\user.c 00129e d06e BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'A': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Analog command C:\Projects\UBW\FW\D_143\user\user.c 0012a0 d9e5 RCALL 0x166c parse_A_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012a2 d06c BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case 'T': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // For timed I/O C:\Projects\UBW\FW\D_143\user\user.c 0012a4 d8e6 RCALL 0x1472 parse_T_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012a6 d06a BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('T' * 256) + 'X': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // For transmitting serial C:\Projects\UBW\FW\D_143\user\user.c 0012a8 ecc2 CALL 0x1b84,0x0 parse_TX_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012aa f00d 0012ac d067 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('P' * 256) + 'I': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // PI for reading a single pin C:\Projects\UBW\FW\D_143\user\user.c 0012ae db51 RCALL 0x1952 parse_PI_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012b0 d065 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('P' * 256) + 'O': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // PO for setting a single pin C:\Projects\UBW\FW\D_143\user\user.c 0012b2 dbcf RCALL 0x1a52 parse_PO_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012b4 d063 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c case ('P' * 256) + 'D': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // PD for setting a pin's direction C:\Projects\UBW\FW\D_143\user\user.c 0012b6 dab1 RCALL 0x181a parse_PD_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012b8 d061 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('M' * 256) + 'R': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // MR for Memory Read C:\Projects\UBW\FW\D_143\user\user.c 0012ba da6e RCALL 0x1798 parse_MR_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012bc d05f BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('M' * 256) + 'W': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // MW for Memory Write C:\Projects\UBW\FW\D_143\user\user.c 0012be da37 RCALL 0x172e parse_MW_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012c0 d05d BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('B' * 256) + 'O': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // MR for Fast Parallel Output C:\Projects\UBW\FW\D_143\user\user.c 0012c2 ecb4 CALL 0x1d68,0x0 parse_BO_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012c4 f00e 0012c6 d05a BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('R' * 256) + 'C': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // RC for RC servo output C:\Projects\UBW\FW\D_143\user\user.c 0012c8 ecc8 CALL 0x1b90,0x0 parse_RC_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012ca f00d 0012cc d057 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('B' * 256) + 'C': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // BC for Fast Parallel Configure C:\Projects\UBW\FW\D_143\user\user.c 0012ce ec6d CALL 0x1cda,0x0 parse_BC_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012d0 f00e 0012d2 d054 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('B' * 256) + 'S': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // BS for Fast Binary Stream output C:\Projects\UBW\FW\D_143\user\user.c 0012d4 ecfb CALL 0x1ff6,0x0 parse_BS_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012d6 f00f 0012d8 d051 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('S' * 256) + 'S': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // SS for Send SPI C:\Projects\UBW\FW\D_143\user\user.c 0012da ecb7 CALL 0x216e,0x0 parse_SS_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012dc f010 0012de d04e BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('R' * 256) + 'S': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // RS for Receive SPI C:\Projects\UBW\FW\D_143\user\user.c 0012e0 ecba CALL 0x2174,0x0 parse_RS_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012e2 f010 0012e4 d04b BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('C' * 256) + 'S': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // CS for Configure SPI C:\Projects\UBW\FW\D_143\user\user.c 0012e6 ecbd CALL 0x217a,0x0 parse_CS_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012e8 f010 0012ea d048 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('S' * 256) + 'I': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // SI for Send I2C C:\Projects\UBW\FW\D_143\user\user.c 0012ec ecc0 CALL 0x2180,0x0 parse_SI_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012ee f010 0012f0 d045 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('R' * 256) + 'I': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // RI for Receive I2C C:\Projects\UBW\FW\D_143\user\user.c 0012f2 ecc3 CALL 0x2186,0x0 parse_RI_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012f4 f010 0012f6 d042 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c case ('C' * 256) + 'I': C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // CI for Configure I2C C:\Projects\UBW\FW\D_143\user\user.c 0012f8 ecc6 CALL 0x218c,0x0 parse_CI_packet (); C:\Projects\UBW\FW\D_143\user\user.c 0012fa f010 0012fc d03f BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c default: C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0012fe 0e03 MOVLW 0x3 if (0 == cmd2) C:\Projects\UBW\FW\D_143\user\user.c 001300 50db MOVF 0xdb,0x0,0x0 001302 e11a BNZ 0x1338 { C:\Projects\UBW\FW\D_143\user\user.c // Send back 'unknown command' error C:\Projects\UBW\FW\D_143\user\user.c printf ( C:\Projects\UBW\FW\D_143\user\user.c (far rom char *)"!8 Err: Unknown command '%c:%2X'\r\n" C:\Projects\UBW\FW\D_143\user\user.c 001314 0ea5 MOVLW 0xa5 ,cmd1 C:\Projects\UBW\FW\D_143\user\user.c 001316 6e2a MOVWF 0x2a,0x0 001318 0e3f MOVLW 0x3f 00131a 6e2b MOVWF 0x2b,0x0 00131c 6a2c CLRF 0x2c,0x0 00131e c02a MOVFF 0x2a,0xfe6 001320 ffe6 001322 c02b MOVFF 0x2b,0xfe6 001324 ffe6 001326 c02c MOVFF 0x2c,0xfe6 001328 ffe6 00130c 0e02 MOVLW 0x2 ,cmd1 C:\Projects\UBW\FW\D_143\user\user.c 00130e cfdb MOVFF 0xfdb,0xfe6 001310 ffe6 001312 6ae6 CLRF 0xe6,0x0 001304 0e02 MOVLW 0x2 ); C:\Projects\UBW\FW\D_143\user\user.c 001306 cfdb MOVFF 0xfdb,0xfe6 001308 ffe6 00130a 6ae6 CLRF 0xe6,0x0 00132a ec5f CALL 0x42be,0x0 00132c f021 00132e 6e2d MOVWF 0x2d,0x0 001330 0e07 MOVLW 0x7 001332 5ee1 SUBWF 0xe1,0x1,0x0 001334 502d MOVF 0x2d,0x0,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001336 d021 BRA 0x137a else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Send back 'unknown command' error C:\Projects\UBW\FW\D_143\user\user.c printf ( C:\Projects\UBW\FW\D_143\user\user.c (far rom char *)"!8 Err: Unknown command '%c%c:%2X%2X'\r\n" C:\Projects\UBW\FW\D_143\user\user.c 001358 0e7d MOVLW 0x7d ,cmd1 C:\Projects\UBW\FW\D_143\user\user.c 00135a 6e2a MOVWF 0x2a,0x0 00135c 0e3f MOVLW 0x3f 00135e 6e2b MOVWF 0x2b,0x0 001360 6a2c CLRF 0x2c,0x0 001362 c02a MOVFF 0x2a,0xfe6 001364 ffe6 001366 c02b MOVFF 0x2b,0xfe6 001368 ffe6 00136a c02c MOVFF 0x2c,0xfe6 00136c ffe6 001350 0e02 MOVLW 0x2 ,cmd2 C:\Projects\UBW\FW\D_143\user\user.c 001352 cfdb MOVFF 0xfdb,0xfe6 001354 ffe6 001356 6ae6 CLRF 0xe6,0x0 001348 0e03 MOVLW 0x3 ,cmd1 C:\Projects\UBW\FW\D_143\user\user.c 00134a cfdb MOVFF 0xfdb,0xfe6 00134c ffe6 00134e 6ae6 CLRF 0xe6,0x0 001340 0e02 MOVLW 0x2 ,cmd2 C:\Projects\UBW\FW\D_143\user\user.c 001342 cfdb MOVFF 0xfdb,0xfe6 001344 ffe6 001346 6ae6 CLRF 0xe6,0x0 001338 0e03 MOVLW 0x3 ); C:\Projects\UBW\FW\D_143\user\user.c 00133a cfdb MOVFF 0xfdb,0xfe6 00133c ffe6 00133e 6ae6 CLRF 0xe6,0x0 00136e ec5f CALL 0x42be,0x0 001370 f021 001372 6e2d MOVWF 0x2d,0x0 001374 0e0b MOVLW 0xb 001376 5ee1 SUBWF 0xe1,0x1,0x0 001378 502d MOVF 0x2d,0x0,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 00137a d000 BRA 0x137c break; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Double check that our output pointer is now at the ending C:\Projects\UBW\FW\D_143\user\user.c // If it is not, this indicates that there were extra characters that C:\Projects\UBW\FW\D_143\user\user.c // the command parsing routine didn't eat. This would be an error and needs C:\Projects\UBW\FW\D_143\user\user.c // to be reported. (Ignore for Reset command because FIFO pointers get cleared.) C:\Projects\UBW\FW\D_143\user\user.c if ( C:\Projects\UBW\FW\D_143\user\user.c 00137c 0101 MOVLB 0x1 (g_RX_buf[g_RX_buf_out] != kCR && 0 == error_byte) C:\Projects\UBW\FW\D_143\user\user.c 00137e 51b9 MOVF 0xb9,0x0,0x1 001380 6aea CLRF 0xea,0x0 001382 0f40 ADDLW 0x40 001384 6ee9 MOVWF 0xe9,0x0 001386 0e02 MOVLW 0x2 001388 22ea ADDWFC 0xea,0x1,0x0 00138a 50ef MOVF 0xef,0x0,0x0 00138c 080d SUBLW 0xd 00138e e00d BZ 0x13aa 001390 500d MOVF 0xd,0x0,0x0 001392 e10b BNZ 0x13aa && C:\Projects\UBW\FW\D_143\user\user.c 001394 0e52 MOVLW 0x52 ('R' != command) C:\Projects\UBW\FW\D_143\user\user.c 001396 6e2a MOVWF 0x2a,0x0 001398 6a2b CLRF 0x2b,0x0 00139a 50df MOVF 0xdf,0x0,0x0 00139c 182a XORWF 0x2a,0x0,0x0 00139e e103 BNZ 0x13a6 0013a0 52de MOVF 0xde,0x1,0x0 0013a2 50dd MOVF 0xdd,0x0,0x0 0013a4 182b XORWF 0x2b,0x0,0x0 0013a6 e001 BZ 0x13aa ) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0013a8 8e0d BSF 0xd,0x7,0x0 bitset (error_byte, kERROR_BYTE_EXTRA_CHARACTERS); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Clean up by skipping over any bytes we haven't eaten C:\Projects\UBW\FW\D_143\user\user.c // This is safe since we parse each packet as we get a C:\Projects\UBW\FW\D_143\user\user.c // (i.e. g_RX_buf_in doesn't move while we are in this routine) C:\Projects\UBW\FW\D_143\user\user.c 0013aa c1b8 MOVFF 0x1b8,0x1b9 g_RX_buf_out = g_RX_buf_in; C:\Projects\UBW\FW\D_143\user\user.c 0013ac f1b9 0013ae 0e04 MOVLW 0x4 } C:\Projects\UBW\FW\D_143\user\user.c 0013b0 5ce1 SUBWF 0xe1,0x0,0x0 0013b2 e202 BC 0x13b8 0013b4 6ae1 CLRF 0xe1,0x0 0013b6 52e5 MOVF 0xe5,0x1,0x0 0013b8 6ee1 MOVWF 0xe1,0x0 0013ba 52e5 MOVF 0xe5,0x1,0x0 0013bc cfe7 MOVFF 0xfe7,0xfd9 0013be ffd9 0013c0 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // Print out the positive acknoledgement that the packet was received C:\Projects\UBW\FW\D_143\user\user.c // if we have acks turned on. C:\Projects\UBW\FW\D_143\user\user.c void print_ack(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0013c2 0101 MOVLB 0x1 if (g_ack_enable) C:\Projects\UBW\FW\D_143\user\user.c 0013c4 51be MOVF 0xbe,0x0,0x1 0013c6 e010 BZ 0x13e8 { C:\Projects\UBW\FW\D_143\user\user.c 0013c8 0e7c MOVLW 0x7c printf ((far rom char *)st_OK); C:\Projects\UBW\FW\D_143\user\user.c 0013ca 6e2a MOVWF 0x2a,0x0 0013cc 0e45 MOVLW 0x45 0013ce 6e2b MOVWF 0x2b,0x0 0013d0 6a2c CLRF 0x2c,0x0 0013d2 c02a MOVFF 0x2a,0xfe6 0013d4 ffe6 0013d6 c02b MOVFF 0x2b,0xfe6 0013d8 ffe6 0013da c02c MOVFF 0x2c,0xfe6 0013dc ffe6 0013de ec5f CALL 0x42be,0x0 0013e0 f021 0013e2 52e5 MOVF 0xe5,0x1,0x0 0013e4 52e5 MOVF 0xe5,0x1,0x0 0013e6 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 0013e8 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Return all I/Os to their default power-on values C:\Projects\UBW\FW\D_143\user\user.c void parse_R_packet(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0013ea ecc4 CALL 0xb88,0x0 UserInit (); C:\Projects\UBW\FW\D_143\user\user.c 0013ec f005 0013ee dfe9 RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 0013f0 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // CU is "Configure UBW" and controls system-wide configruation values C:\Projects\UBW\FW\D_143\user\user.c // "CU,," C:\Projects\UBW\FW\D_143\user\user.c // C:\Projects\UBW\FW\D_143\user\user.c // 1 {1|0} turns on or off the 'ack' ("OK" at end of packets) C:\Projects\UBW\FW\D_143\user\user.c 0013f2 cfd9 MOVFF 0xfd9,0xfe6 void parse_CU_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 0013f4 ffe6 0013f6 cfe1 MOVFF 0xfe1,0xfd9 0013f8 ffd9 0013fa 0e03 MOVLW 0x3 0013fc 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char parameter_number; C:\Projects\UBW\FW\D_143\user\user.c signed int paramater_value; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 0013fe 0e01 MOVLW 0x1 parameter_number = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001400 6ee6 MOVWF 0xe6,0x0 001402 ecc9 CALL 0x2192,0x0 001404 f010 001406 52e5 MOVF 0xe5,0x1,0x0 001408 501d MOVF 0x1d,0x0,0x0 00140a 6edf MOVWF 0xdf,0x0 00140c 0e02 MOVLW 0x2 paramater_value = extract_number (kINT); C:\Projects\UBW\FW\D_143\user\user.c 00140e 6ee6 MOVWF 0xe6,0x0 001410 ecc9 CALL 0x2192,0x0 001412 f010 001414 52e5 MOVF 0xe5,0x1,0x0 001416 52de MOVF 0xde,0x1,0x0 001418 c01d MOVFF 0x1d,0xfde 00141a ffde 00141c c01e MOVFF 0x1e,0xfdd 00141e ffdd 001420 52dd MOVF 0xdd,0x1,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 001422 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001424 e001 BZ 0x1428 { C:\Projects\UBW\FW\D_143\user\user.c 001426 d01b BRA 0x145e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001428 04df DECF 0xdf,0x0,0x0 if (1 == parameter_number) C:\Projects\UBW\FW\D_143\user\user.c 00142a e118 BNZ 0x145c { C:\Projects\UBW\FW\D_143\user\user.c 00142c 50d9 MOVF 0xd9,0x0,0x0 if (0 == paramater_value || 1 == paramater_value) C:\Projects\UBW\FW\D_143\user\user.c 00142e 0f01 ADDLW 0x1 001430 6ee9 MOVWF 0xe9,0x0 001432 cfda MOVFF 0xfda,0xfea 001434 ffea 001436 50ee MOVF 0xee,0x0,0x0 001438 10ed IORWF 0xed,0x0,0x0 00143a e00b BZ 0x1452 00143c 0e01 MOVLW 0x1 00143e 6e2a MOVWF 0x2a,0x0 001440 6a2b CLRF 0x2b,0x0 001442 0e01 MOVLW 0x1 001444 50db MOVF 0xdb,0x0,0x0 001446 182a XORWF 0x2a,0x0,0x0 001448 e103 BNZ 0x1450 00144a 0e02 MOVLW 0x2 00144c 50db MOVF 0xdb,0x0,0x0 00144e 182b XORWF 0x2b,0x0,0x0 001450 e104 BNZ 0x145a { C:\Projects\UBW\FW\D_143\user\user.c 001452 0e01 MOVLW 0x1 g_ack_enable = paramater_value; C:\Projects\UBW\FW\D_143\user\user.c 001454 cfdb MOVFF 0xfdb,0x1be 001456 f1be } C:\Projects\UBW\FW\D_143\user\user.c 001458 d001 BRA 0x145c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 00145a 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 00145c dfb2 RCALL 0x13c2 print_ack(); C:\Projects\UBW\FW\D_143\user\user.c 00145e 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001460 5ce1 SUBWF 0xe1,0x0,0x0 001462 e202 BC 0x1468 001464 6ae1 CLRF 0xe1,0x0 001466 52e5 MOVF 0xe5,0x1,0x0 001468 6ee1 MOVWF 0xe1,0x0 00146a 52e5 MOVF 0xe5,0x1,0x0 00146c cfe7 MOVFF 0xfe7,0xfd9 00146e ffd9 001470 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // "T" Packet C:\Projects\UBW\FW\D_143\user\user.c // Causes PIC to sample digital or analog inputs at a regular interval and send C:\Projects\UBW\FW\D_143\user\user.c // I (or A) packets back at that interval. C:\Projects\UBW\FW\D_143\user\user.c // Send T,0,0 to stop I (or A) packets C:\Projects\UBW\FW\D_143\user\user.c // FORMAT: T,, C:\Projects\UBW\FW\D_143\user\user.c // is 0 for digital (I packets) and 1 for analog (A packets) C:\Projects\UBW\FW\D_143\user\user.c // EXAMPLE: "T,4000,0" to send an I packet back every 4 seconds. C:\Projects\UBW\FW\D_143\user\user.c // EXAMPLE: "T,2000,1" to send an A packet back every 2 seconds. C:\Projects\UBW\FW\D_143\user\user.c 001472 cfd9 MOVFF 0xfd9,0xfe6 void parse_T_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001474 ffe6 001476 cfe1 MOVFF 0xfe1,0xfd9 001478 ffd9 00147a 0e03 MOVLW 0x3 00147c 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned int value; C:\Projects\UBW\FW\D_143\user\user.c 00147e 0e02 MOVLW 0x2 unsigned char mode = 0; C:\Projects\UBW\FW\D_143\user\user.c 001480 6adb CLRF 0xdb,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Extract the value C:\Projects\UBW\FW\D_143\user\user.c 001482 0e03 MOVLW 0x3 time_between_updates = extract_number (kUINT); C:\Projects\UBW\FW\D_143\user\user.c 001484 6ee6 MOVWF 0xe6,0x0 001486 ecc9 CALL 0x2192,0x0 001488 f010 00148a 52e5 MOVF 0xe5,0x1,0x0 00148c c01d MOVFF 0x1d,0x0 00148e f000 001490 c01e MOVFF 0x1e,0x1 001492 f001 // Extract the value C:\Projects\UBW\FW\D_143\user\user.c 001494 0e01 MOVLW 0x1 mode = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001496 6ee6 MOVWF 0xe6,0x0 001498 ecc9 CALL 0x2192,0x0 00149a f010 00149c 52e5 MOVF 0xe5,0x1,0x0 00149e 0e02 MOVLW 0x2 0014a0 c01d MOVFF 0x1d,0xfdb 0014a2 ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 0014a4 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 0014a6 e001 BZ 0x14aa { C:\Projects\UBW\FW\D_143\user\user.c 0014a8 d01b BRA 0x14e0 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now start up the timer at the right rate or shut C:\Projects\UBW\FW\D_143\user\user.c // it down. C:\Projects\UBW\FW\D_143\user\user.c 0014aa 0e02 MOVLW 0x2 if (0 == mode) C:\Projects\UBW\FW\D_143\user\user.c 0014ac 50db MOVF 0xdb,0x0,0x0 0014ae e10c BNZ 0x14c8 { C:\Projects\UBW\FW\D_143\user\user.c 0014b0 5000 MOVF 0x0,0x0,0x0 if (0 == time_between_updates) C:\Projects\UBW\FW\D_143\user\user.c 0014b2 1001 IORWF 0x1,0x0,0x0 0014b4 e103 BNZ 0x14bc { C:\Projects\UBW\FW\D_143\user\user.c // Turn off sending of I packets. C:\Projects\UBW\FW\D_143\user\user.c 0014b6 6a02 CLRF 0x2,0x0 ISR_D_RepeatRate = 0; C:\Projects\UBW\FW\D_143\user\user.c 0014b8 6a03 CLRF 0x3,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 0014ba d005 BRA 0x14c6 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0014bc 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Eventually gaurd this section from interrupts C:\Projects\UBW\FW\D_143\user\user.c 0014be c000 MOVFF 0x0,0x2 ISR_D_RepeatRate = time_between_updates; C:\Projects\UBW\FW\D_143\user\user.c 0014c0 f002 0014c2 c001 MOVFF 0x1,0x3 0014c4 f003 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 0014c6 d00b BRA 0x14de else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0014c8 5000 MOVF 0x0,0x0,0x0 if (0 == time_between_updates) C:\Projects\UBW\FW\D_143\user\user.c 0014ca 1001 IORWF 0x1,0x0,0x0 0014cc e103 BNZ 0x14d4 { C:\Projects\UBW\FW\D_143\user\user.c // Turn off sending of A packets. C:\Projects\UBW\FW\D_143\user\user.c 0014ce 6a07 CLRF 0x7,0x0 ISR_A_RepeatRate = 0; C:\Projects\UBW\FW\D_143\user\user.c 0014d0 6a08 CLRF 0x8,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 0014d2 d005 BRA 0x14de else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0014d4 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Eventually gaurd this section from interrupts C:\Projects\UBW\FW\D_143\user\user.c 0014d6 c000 MOVFF 0x0,0x7 ISR_A_RepeatRate = time_between_updates; C:\Projects\UBW\FW\D_143\user\user.c 0014d8 f007 0014da c001 MOVFF 0x1,0x8 0014dc f008 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 0014de df71 RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 0014e0 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 0014e2 5ce1 SUBWF 0xe1,0x0,0x0 0014e4 e202 BC 0x14ea 0014e6 6ae1 CLRF 0xe1,0x0 0014e8 52e5 MOVF 0xe5,0x1,0x0 0014ea 6ee1 MOVWF 0xe1,0x0 0014ec 52e5 MOVF 0xe5,0x1,0x0 0014ee cfe7 MOVFF 0xfe7,0xfd9 0014f0 ffd9 0014f2 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // FORMAT: C,,,, C:\Projects\UBW\FW\D_143\user\user.c // EXAMPLE: "C,255,0,4,0" C:\Projects\UBW\FW\D_143\user\user.c // is the byte sent to the Data Direction (DDR) regsiter for C:\Projects\UBW\FW\D_143\user\user.c // each port. A 1 in a bit location means input, a 0 means output. C:\Projects\UBW\FW\D_143\user\user.c // is a value between 0 and 12. It tells the UBW C:\Projects\UBW\FW\D_143\user\user.c // how many analog inputs to enable. If a zero is sent for this C:\Projects\UBW\FW\D_143\user\user.c // parameter, all analog inputs are disabled. C:\Projects\UBW\FW\D_143\user\user.c // For the other values, see the following chart to know what pins are C:\Projects\UBW\FW\D_143\user\user.c // used for what: C:\Projects\UBW\FW\D_143\user\user.c // C:\Projects\UBW\FW\D_143\user\user.c // Note that in the following chart, PortE is references. This port C:\Projects\UBW\FW\D_143\user\user.c // only exists on the 40 and 44 pin versions of the UBW. For the C:\Projects\UBW\FW\D_143\user\user.c // 28 pin versions of the UBW, all PortE based analog pins will return C:\Projects\UBW\FW\D_143\user\user.c // zero. C:\Projects\UBW\FW\D_143\user\user.c // C:\Projects\UBW\FW\D_143\user\user.c // Analog Inputs Enabled Pins Used For Analog Inputs C:\Projects\UBW\FW\D_143\user\user.c // --------------- --------------------- ------------------------------- C:\Projects\UBW\FW\D_143\user\user.c // 0 C:\Projects\UBW\FW\D_143\user\user.c // 1 AN0 A0 C:\Projects\UBW\FW\D_143\user\user.c // 2 AN0,AN1 A0,A1 C:\Projects\UBW\FW\D_143\user\user.c // 3 AN0,AN1,AN2 A0,A1,A2 C:\Projects\UBW\FW\D_143\user\user.c // 4 AN0,AN1,AN2,AN3 A0,A1,A2,A3 C:\Projects\UBW\FW\D_143\user\user.c // 5 AN0,AN1,AN2,AN3,AN4 A0,A1,A2,A3,A5 C:\Projects\UBW\FW\D_143\user\user.c // 6 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0 C:\Projects\UBW\FW\D_143\user\user.c // AN5 C:\Projects\UBW\FW\D_143\user\user.c // 7 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1 C:\Projects\UBW\FW\D_143\user\user.c // AN5,AN6 C:\Projects\UBW\FW\D_143\user\user.c // 8 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2 C:\Projects\UBW\FW\D_143\user\user.c // AN5,AN6,AN7 C:\Projects\UBW\FW\D_143\user\user.c // 9 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2 C:\Projects\UBW\FW\D_143\user\user.c // AN5,AN6,AN7,AN8 C:\Projects\UBW\FW\D_143\user\user.c // 10 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2,B3 C:\Projects\UBW\FW\D_143\user\user.c // AN5,AN6,AN7,AN8, C:\Projects\UBW\FW\D_143\user\user.c // AN9 C:\Projects\UBW\FW\D_143\user\user.c // 11 AN0,AN1,AN2,AN3,AN4, A0,A1,A2,A3,A5,E0,E1,E2,B2,B3,B1 C:\Projects\UBW\FW\D_143\user\user.c // AN5,AN6,AN7,AN8, C:\Projects\UBW\FW\D_143\user\user.c // AB9,AN10 C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // AN5,AN6,AN7,AN8, C:\Projects\UBW\FW\D_143\user\user.c // AN9,AN10,AN11 C:\Projects\UBW\FW\D_143\user\user.c // NOTE: it is up to the user to tell the proper port direction bits to be C:\Projects\UBW\FW\D_143\user\user.c // inputs for the analog channels they wish to use. C:\Projects\UBW\FW\D_143\user\user.c 0014f4 cfd9 MOVFF 0xfd9,0xfe6 void parse_C_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 0014f6 ffe6 0014f8 cfe1 MOVFF 0xfe1,0xfd9 0014fa ffd9 0014fc 0e04 MOVLW 0x4 0014fe 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char PA, PB, PC, AA; C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c unsigned char PD, PE; C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Extract each of the four values. C:\Projects\UBW\FW\D_143\user\user.c 001500 0e01 MOVLW 0x1 PA = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001502 6ee6 MOVWF 0xe6,0x0 001504 ecc9 CALL 0x2192,0x0 001506 f010 001508 52e5 MOVF 0xe5,0x1,0x0 00150a 501d MOVF 0x1d,0x0,0x0 00150c 6edf MOVWF 0xdf,0x0 00150e 0e01 MOVLW 0x1 PB = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001510 6ee6 MOVWF 0xe6,0x0 001512 ecc9 CALL 0x2192,0x0 001514 f010 001516 52e5 MOVF 0xe5,0x1,0x0 001518 0e01 MOVLW 0x1 00151a c01d MOVFF 0x1d,0xfdb 00151c ffdb 00151e 0e01 MOVLW 0x1 PC = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001520 6ee6 MOVWF 0xe6,0x0 001522 ecc9 CALL 0x2192,0x0 001524 f010 001526 52e5 MOVF 0xe5,0x1,0x0 001528 0e02 MOVLW 0x2 00152a c01d MOVFF 0x1d,0xfdb 00152c ffdb #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c PD = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c PE = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c 00152e 0e01 MOVLW 0x1 AA = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001530 6ee6 MOVWF 0xe6,0x0 001532 ecc9 CALL 0x2192,0x0 001534 f010 001536 52e5 MOVF 0xe5,0x1,0x0 001538 0e03 MOVLW 0x3 00153a c01d MOVFF 0x1d,0xfdb 00153c ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 00153e 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001540 e001 BZ 0x1544 { C:\Projects\UBW\FW\D_143\user\user.c 001542 d02b BRA 0x159a return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now write those values to the data direction registers. C:\Projects\UBW\FW\D_143\user\user.c 001544 50df MOVF 0xdf,0x0,0x0 TRISA = PA; C:\Projects\UBW\FW\D_143\user\user.c 001546 6e92 MOVWF 0x92,0x0 001548 0e01 MOVLW 0x1 TRISB = PB; C:\Projects\UBW\FW\D_143\user\user.c 00154a 50db MOVF 0xdb,0x0,0x0 00154c 6e93 MOVWF 0x93,0x0 00154e 0e02 MOVLW 0x2 TRISC = PC; C:\Projects\UBW\FW\D_143\user\user.c 001550 50db MOVF 0xdb,0x0,0x0 001552 6e94 MOVWF 0x94,0x0 #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c TRISD = PD; C:\Projects\UBW\FW\D_143\user\user.c TRISE = PE; C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Handle the analog value. C:\Projects\UBW\FW\D_143\user\user.c // Maximum value of 12. C:\Projects\UBW\FW\D_143\user\user.c 001554 0e03 MOVLW 0x3 if (AA > 12) C:\Projects\UBW\FW\D_143\user\user.c 001556 50db MOVF 0xdb,0x0,0x0 001558 080c SUBLW 0xc 00155a e205 BC 0x1566 { C:\Projects\UBW\FW\D_143\user\user.c 00155c 0e0c MOVLW 0xc AA = 12; C:\Projects\UBW\FW\D_143\user\user.c 00155e 6ef3 MOVWF 0xf3,0x0 001560 0e03 MOVLW 0x3 001562 cff3 MOVFF 0xff3,0xfdb 001564 ffdb } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // If we are turning off Analog inputs C:\Projects\UBW\FW\D_143\user\user.c 001566 0e03 MOVLW 0x3 if (0 == AA) C:\Projects\UBW\FW\D_143\user\user.c 001568 50db MOVF 0xdb,0x0,0x0 00156a e105 BNZ 0x1576 { C:\Projects\UBW\FW\D_143\user\user.c // Turn all analog inputs into digital inputs C:\Projects\UBW\FW\D_143\user\user.c 00156c 0e0f MOVLW 0xf ADCON1 = 0x0F; C:\Projects\UBW\FW\D_143\user\user.c 00156e 6ec1 MOVWF 0xc1,0x0 // Turn off the ADC C:\Projects\UBW\FW\D_143\user\user.c 001570 90c2 BCF 0xc2,0x0,0x0 ADCON0bits.ADON = 0; C:\Projects\UBW\FW\D_143\user\user.c // Turn off our own idea of how many analog channels to convert C:\Projects\UBW\FW\D_143\user\user.c 001572 6a0c CLRF 0xc,0x0 AnalogEnable = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001574 d011 BRA 0x1598 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c // Some protection from ISR C:\Projects\UBW\FW\D_143\user\user.c 001576 6a0c CLRF 0xc,0x0 AnalogEnable = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // We're turning some on. C:\Projects\UBW\FW\D_143\user\user.c // Start by selecting channel zero C:\Projects\UBW\FW\D_143\user\user.c 001578 6ac2 CLRF 0xc2,0x0 ADCON0 = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Then enabling the proper number of channels C:\Projects\UBW\FW\D_143\user\user.c 00157a 0e03 MOVLW 0x3 ADCON1 = 15 - AA; C:\Projects\UBW\FW\D_143\user\user.c 00157c cfdb MOVFF 0xfdb,0xfe6 00157e ffe6 001580 0e0f MOVLW 0xf 001582 52e5 MOVF 0xe5,0x1,0x0 001584 80d8 BSF 0xd8,0x0,0x0 001586 54e7 SUBFWB 0xe7,0x0,0x0 001588 6ec1 MOVWF 0xc1,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Set up ADCON2 options C:\Projects\UBW\FW\D_143\user\user.c // A/D Result right justified C:\Projects\UBW\FW\D_143\user\user.c // Acq time = 20 Tad (?) C:\Projects\UBW\FW\D_143\user\user.c // Tad = Fosc/64 C:\Projects\UBW\FW\D_143\user\user.c 00158a 0ebe MOVLW 0xbe ADCON2 = 0b10111110; C:\Projects\UBW\FW\D_143\user\user.c 00158c 6ec0 MOVWF 0xc0,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Turn on the ADC C:\Projects\UBW\FW\D_143\user\user.c 00158e 80c2 BSF 0xc2,0x0,0x0 ADCON0bits.ADON = 1; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Tell ourselves how many channels to convert, and turn on ISR conversions C:\Projects\UBW\FW\D_143\user\user.c 001590 0e03 MOVLW 0x3 AnalogEnable = AA; C:\Projects\UBW\FW\D_143\user\user.c 001592 50db MOVF 0xdb,0x0,0x0 001594 6e0c MOVWF 0xc,0x0 C:\Projects\UBW\FW\D_143\user\user.c 001596 84ca BSF 0xca,0x2,0x0 T2CONbits.TMR2ON = 1; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001598 df14 RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 00159a 0e04 MOVLW 0x4 } C:\Projects\UBW\FW\D_143\user\user.c 00159c 5ce1 SUBWF 0xe1,0x0,0x0 00159e e202 BC 0x15a4 0015a0 6ae1 CLRF 0xe1,0x0 0015a2 52e5 MOVF 0xe5,0x1,0x0 0015a4 6ee1 MOVWF 0xe1,0x0 0015a6 52e5 MOVF 0xe5,0x1,0x0 0015a8 cfe7 MOVFF 0xfe7,0xfd9 0015aa ffd9 0015ac 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // Outputs values to the ports pins that are set up as outputs. C:\Projects\UBW\FW\D_143\user\user.c // Example "O,121,224,002" C:\Projects\UBW\FW\D_143\user\user.c 0015ae cfd9 MOVFF 0xfd9,0xfe6 void parse_O_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 0015b0 ffe6 0015b2 cfe1 MOVFF 0xfe1,0xfd9 0015b4 ffd9 0015b6 0e03 MOVLW 0x3 0015b8 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char PA, PB, PC; C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c unsigned char PD, PE; C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Extract each of the values. C:\Projects\UBW\FW\D_143\user\user.c 0015ba 0e01 MOVLW 0x1 PA = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 0015bc 6ee6 MOVWF 0xe6,0x0 0015be ecc9 CALL 0x2192,0x0 0015c0 f010 0015c2 52e5 MOVF 0xe5,0x1,0x0 0015c4 501d MOVF 0x1d,0x0,0x0 0015c6 6edf MOVWF 0xdf,0x0 0015c8 0e01 MOVLW 0x1 PB = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 0015ca 6ee6 MOVWF 0xe6,0x0 0015cc ecc9 CALL 0x2192,0x0 0015ce f010 0015d0 52e5 MOVF 0xe5,0x1,0x0 0015d2 0e01 MOVLW 0x1 0015d4 c01d MOVFF 0x1d,0xfdb 0015d6 ffdb 0015d8 0e01 MOVLW 0x1 PC = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 0015da 6ee6 MOVWF 0xe6,0x0 0015dc ecc9 CALL 0x2192,0x0 0015de f010 0015e0 52e5 MOVF 0xe5,0x1,0x0 0015e2 0e02 MOVLW 0x2 0015e4 c01d MOVFF 0x1d,0xfdb 0015e6 ffdb #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c PD = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c PE = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 0015e8 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 0015ea e001 BZ 0x15ee { C:\Projects\UBW\FW\D_143\user\user.c 0015ec d009 BRA 0x1600 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c // Now write those values to the data port registers. C:\Projects\UBW\FW\D_143\user\user.c 0015ee 50df MOVF 0xdf,0x0,0x0 LATA = PA; C:\Projects\UBW\FW\D_143\user\user.c 0015f0 6e89 MOVWF 0x89,0x0 0015f2 0e01 MOVLW 0x1 LATB = PB; C:\Projects\UBW\FW\D_143\user\user.c 0015f4 50db MOVF 0xdb,0x0,0x0 0015f6 6e8a MOVWF 0x8a,0x0 0015f8 0e02 MOVLW 0x2 LATC = PC; C:\Projects\UBW\FW\D_143\user\user.c 0015fa 50db MOVF 0xdb,0x0,0x0 0015fc 6e8b MOVWF 0x8b,0x0 #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c LATD = PD; C:\Projects\UBW\FW\D_143\user\user.c LATE = PE; C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 0015fe dee1 RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001600 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001602 5ce1 SUBWF 0xe1,0x0,0x0 001604 e202 BC 0x160a 001606 6ae1 CLRF 0xe1,0x0 001608 52e5 MOVF 0xe5,0x1,0x0 00160a 6ee1 MOVWF 0xe1,0x0 00160c 52e5 MOVF 0xe5,0x1,0x0 00160e cfe7 MOVFF 0xfe7,0xfd9 001610 ffd9 001612 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // Read in the three I/O ports (A,B,C) and create C:\Projects\UBW\FW\D_143\user\user.c // a packet to send back with all of values. C:\Projects\UBW\FW\D_143\user\user.c // Example: "I,143,221,010" C:\Projects\UBW\FW\D_143\user\user.c // Remember that on UBW 28 pin boards, we only have C:\Projects\UBW\FW\D_143\user\user.c // Port A bits 0 through 5 C:\Projects\UBW\FW\D_143\user\user.c // Port B bits 0 through 7 C:\Projects\UBW\FW\D_143\user\user.c // Port C bits 0,1,2 and 6,7 C:\Projects\UBW\FW\D_143\user\user.c // And that Port C bits 0,1,2 are used for C:\Projects\UBW\FW\D_143\user\user.c // User1 LED, User2 LED and Program switch respectively. C:\Projects\UBW\FW\D_143\user\user.c // The rest will be read in as zeros. C:\Projects\UBW\FW\D_143\user\user.c void parse_I_packet(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c printf ( C:\Projects\UBW\FW\D_143\user\user.c (far rom char*)"I,%03i,%03i,%03i,%03i,%03i\r\n", C:\Projects\UBW\FW\D_143\user\user.c PORTA, C:\Projects\UBW\FW\D_143\user\user.c PORTB, C:\Projects\UBW\FW\D_143\user\user.c PORTC, C:\Projects\UBW\FW\D_143\user\user.c PORTD, C:\Projects\UBW\FW\D_143\user\user.c PORTE C:\Projects\UBW\FW\D_143\user\user.c ); C:\Projects\UBW\FW\D_143\user\user.c #else C:\Projects\UBW\FW\D_143\user\user.c printf ( C:\Projects\UBW\FW\D_143\user\user.c 001626 0e6a MOVLW 0x6a (far rom char*)"I,%03i,%03i,%03i\r\n", C:\Projects\UBW\FW\D_143\user\user.c 001628 6e2a MOVWF 0x2a,0x0 00162a 0e3f MOVLW 0x3f 00162c 6e2b MOVWF 0x2b,0x0 00162e 6a2c CLRF 0x2c,0x0 001630 c02a MOVFF 0x2a,0xfe6 001632 ffe6 001634 c02b MOVFF 0x2b,0xfe6 001636 ffe6 001638 c02c MOVFF 0x2c,0xfe6 00163a ffe6 001620 5080 MOVF 0x80,0x0,0x0 PORTA, C:\Projects\UBW\FW\D_143\user\user.c 001622 6ee6 MOVWF 0xe6,0x0 001624 6ae6 CLRF 0xe6,0x0 00161a 5081 MOVF 0x81,0x0,0x0 PORTB, C:\Projects\UBW\FW\D_143\user\user.c 00161c 6ee6 MOVWF 0xe6,0x0 00161e 6ae6 CLRF 0xe6,0x0 001614 5082 MOVF 0x82,0x0,0x0 PORTC C:\Projects\UBW\FW\D_143\user\user.c 001616 6ee6 MOVWF 0xe6,0x0 ); C:\Projects\UBW\FW\D_143\user\user.c 001618 6ae6 CLRF 0xe6,0x0 00163c ec5f CALL 0x42be,0x0 00163e f021 001640 6e2d MOVWF 0x2d,0x0 001642 0e09 MOVLW 0x9 001644 5ee1 SUBWF 0xe1,0x1,0x0 001646 502d MOVF 0x2d,0x0,0x0 #endif C:\Projects\UBW\FW\D_143\user\user.c 001648 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // All we do here is just print out our version number C:\Projects\UBW\FW\D_143\user\user.c void parse_V_packet(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 00164a 0e84 MOVLW 0x84 printf ((far rom char *)st_version); C:\Projects\UBW\FW\D_143\user\user.c 00164c 6e2a MOVWF 0x2a,0x0 00164e 0e45 MOVLW 0x45 001650 6e2b MOVWF 0x2b,0x0 001652 6a2c CLRF 0x2c,0x0 001654 c02a MOVFF 0x2a,0xfe6 001656 ffe6 001658 c02b MOVFF 0x2b,0xfe6 00165a ffe6 00165c c02c MOVFF 0x2c,0xfe6 00165e ffe6 001660 ec5f CALL 0x42be,0x0 001662 f021 001664 52e5 MOVF 0xe5,0x1,0x0 001666 52e5 MOVF 0xe5,0x1,0x0 001668 52e5 MOVF 0xe5,0x1,0x0 00166a 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // A is for read Analog inputs C:\Projects\UBW\FW\D_143\user\user.c // Just print out the last analog values for each of the C:\Projects\UBW\FW\D_143\user\user.c // enabled channels. The number of value returned in the C:\Projects\UBW\FW\D_143\user\user.c // A packet depend upon the number of analog inputs enabled. C:\Projects\UBW\FW\D_143\user\user.c // The user can enabled any number of analog inputs between C:\Projects\UBW\FW\D_143\user\user.c // 0 and 12. (none enabled, through all 12 analog inputs enabled). C:\Projects\UBW\FW\D_143\user\user.c // Returned packet will look like "A,0,0,0,0,0,0" if C:\Projects\UBW\FW\D_143\user\user.c // six analog inputs are enabled but they are all C:\Projects\UBW\FW\D_143\user\user.c // grounded. Note that each one is a 10 bit C:\Projects\UBW\FW\D_143\user\user.c // value, where 0 means the intput was at ground, and C:\Projects\UBW\FW\D_143\user\user.c // 1024 means it was at +5 V. (Or whatever the USB +5 C:\Projects\UBW\FW\D_143\user\user.c // pin is at.) C:\Projects\UBW\FW\D_143\user\user.c 00166c cfd9 MOVFF 0xfd9,0xfe6 void parse_A_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 00166e ffe6 001670 cfe1 MOVFF 0xfe1,0xfd9 001672 ffd9 001674 52e6 MOVF 0xe6,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c 001676 6adf CLRF 0xdf,0x0 char channel = 0; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Put the beginning of the packet in place C:\Projects\UBW\FW\D_143\user\user.c 001678 0e68 MOVLW 0x68 printf ((far rom char *)"A"); C:\Projects\UBW\FW\D_143\user\user.c 00167a 6e2a MOVWF 0x2a,0x0 00167c 0e3f MOVLW 0x3f 00167e 6e2b MOVWF 0x2b,0x0 001680 6a2c CLRF 0x2c,0x0 001682 c02a MOVFF 0x2a,0xfe6 001684 ffe6 001686 c02b MOVFF 0x2b,0xfe6 001688 ffe6 00168a c02c MOVFF 0x2c,0xfe6 00168c ffe6 00168e ec5f CALL 0x42be,0x0 001690 f021 001692 52e5 MOVF 0xe5,0x1,0x0 001694 52e5 MOVF 0xe5,0x1,0x0 001696 52e5 MOVF 0xe5,0x1,0x0 C:\Projects\UBW\FW\D_143\user\user.c // Now add each analog value C:\Projects\UBW\FW\D_143\user\user.c 001698 6adf CLRF 0xdf,0x0 for (channel = 0; channel < AnalogEnable; channel++) C:\Projects\UBW\FW\D_143\user\user.c 00169a 500c MOVF 0xc,0x0,0x0 00169c 5cdf SUBWF 0xdf,0x0,0x0 00169e e232 BC 0x1704 001700 2adf INCF 0xdf,0x1,0x0 001702 d7cb BRA 0x169a { C:\Projects\UBW\FW\D_143\user\user.c printf( C:\Projects\UBW\FW\D_143\user\user.c (far rom char *)",%04u" C:\Projects\UBW\FW\D_143\user\user.c 0016a0 cfdf MOVFF 0xfdf,0x2a ,ISR_A_FIFO[channel][ISR_A_FIFO_out] C:\Projects\UBW\FW\D_143\user\user.c 0016a2 f02a 0016a4 6a2b CLRF 0x2b,0x0 0016a6 be2a BTFSC 0x2a,0x7,0x0 0016a8 682b SETF 0x2b,0x0 0016aa 0e06 MOVLW 0x6 0016ac 022b MULWF 0x2b,0x0 0016ae cff3 MOVFF 0xff3,0x2b 0016b0 f02b 0016b2 0e06 MOVLW 0x6 0016b4 022a MULWF 0x2a,0x0 0016b6 cff3 MOVFF 0xff3,0x2a 0016b8 f02a 0016ba 50f4 MOVF 0xf4,0x0,0x0 0016bc 262b ADDWF 0x2b,0x1,0x0 0016be 0e00 MOVLW 0x0 0016c0 262a ADDWF 0x2a,0x1,0x0 0016c2 0e01 MOVLW 0x1 0016c4 222b ADDWFC 0x2b,0x1,0x0 0016c6 500a MOVF 0xa,0x0,0x0 0016c8 0d02 MULLW 0x2 0016ca 502a MOVF 0x2a,0x0,0x0 0016cc 24f3 ADDWF 0xf3,0x0,0x0 0016ce 6ee9 MOVWF 0xe9,0x0 0016d0 502b MOVF 0x2b,0x0,0x0 0016d2 20f4 ADDWFC 0xf4,0x0,0x0 0016d4 6eea MOVWF 0xea,0x0 0016de 0e62 MOVLW 0x62 0016e0 6e2c MOVWF 0x2c,0x0 0016e2 0e3f MOVLW 0x3f 0016e4 6e2d MOVWF 0x2d,0x0 0016e6 6a2e CLRF 0x2e,0x0 0016e8 c02c MOVFF 0x2c,0xfe6 0016ea ffe6 0016ec c02d MOVFF 0x2d,0xfe6 0016ee ffe6 0016f0 c02e MOVFF 0x2e,0xfe6 0016f2 ffe6 0016d6 cfee MOVFF 0xfee,0xfe6 ); C:\Projects\UBW\FW\D_143\user\user.c 0016d8 ffe6 0016da cfef MOVFF 0xfef,0xfe6 0016dc ffe6 0016f4 ec5f CALL 0x42be,0x0 0016f6 f021 0016f8 6e2f MOVWF 0x2f,0x0 0016fa 0e05 MOVLW 0x5 0016fc 5ee1 SUBWF 0xe1,0x1,0x0 0016fe 502f MOVF 0x2f,0x0,0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Add \r\n and terminating zero. C:\Projects\UBW\FW\D_143\user\user.c 001704 0e81 MOVLW 0x81 printf ((far rom char *)st_LFCR); C:\Projects\UBW\FW\D_143\user\user.c 001706 6e2a MOVWF 0x2a,0x0 001708 0e45 MOVLW 0x45 00170a 6e2b MOVWF 0x2b,0x0 00170c 6a2c CLRF 0x2c,0x0 00170e c02a MOVFF 0x2a,0xfe6 001710 ffe6 001712 c02b MOVFF 0x2b,0xfe6 001714 ffe6 001716 c02c MOVFF 0x2c,0xfe6 001718 ffe6 00171a ec5f CALL 0x42be,0x0 00171c f021 00171e 52e5 MOVF 0xe5,0x1,0x0 001720 52e5 MOVF 0xe5,0x1,0x0 001722 52e5 MOVF 0xe5,0x1,0x0 001724 52e5 MOVF 0xe5,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001726 52e5 MOVF 0xe5,0x1,0x0 001728 cfe7 MOVFF 0xfe7,0xfd9 00172a ffd9 00172c 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // MW is for Memory Write C:\Projects\UBW\FW\D_143\user\user.c // "MW,," C:\Projects\UBW\FW\D_143\user\user.c // is a decimal value between 0 and 4096 indicating the RAM address to write to C:\Projects\UBW\FW\D_143\user\user.c // is a decimal value between 0 and 255 that is the value to write C:\Projects\UBW\FW\D_143\user\user.c 00172e cfd9 MOVFF 0xfd9,0xfe6 void parse_MW_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001730 ffe6 001732 cfe1 MOVFF 0xfe1,0xfd9 001734 ffd9 001736 0e03 MOVLW 0x3 001738 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned int location; C:\Projects\UBW\FW\D_143\user\user.c unsigned char value; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 00173a 0e03 MOVLW 0x3 location = extract_number (kUINT); C:\Projects\UBW\FW\D_143\user\user.c 00173c 6ee6 MOVWF 0xe6,0x0 00173e ecc9 CALL 0x2192,0x0 001740 f010 001742 52e5 MOVF 0xe5,0x1,0x0 001744 c01d MOVFF 0x1d,0xfde 001746 ffde 001748 c01e MOVFF 0x1e,0xfdd 00174a ffdd 00174c 0e01 MOVLW 0x1 value = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 00174e 6ee6 MOVWF 0xe6,0x0 001750 ecc9 CALL 0x2192,0x0 001752 f010 001754 52e5 MOVF 0xe5,0x1,0x0 001756 0e02 MOVLW 0x2 001758 c01d MOVFF 0x1d,0xfdb 00175a ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 00175c 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 00175e e001 BZ 0x1762 { C:\Projects\UBW\FW\D_143\user\user.c 001760 d011 BRA 0x1784 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c // Limit check the address and write the byte in C:\Projects\UBW\FW\D_143\user\user.c 001762 cfde MOVFF 0xfde,0x2a if (location < 4096) C:\Projects\UBW\FW\D_143\user\user.c 001764 f02a 001766 cfdd MOVFF 0xfdd,0x2b 001768 f02b 00176a 0e00 MOVLW 0x0 00176c 5c2a SUBWF 0x2a,0x0,0x0 00176e 0e10 MOVLW 0x10 001770 582b SUBWFB 0x2b,0x0,0x0 001772 e207 BC 0x1782 { C:\Projects\UBW\FW\D_143\user\user.c 001774 cfde MOVFF 0xfde,0xfe9 *((unsigned char *)location) = value; C:\Projects\UBW\FW\D_143\user\user.c 001776 ffe9 001778 cfdd MOVFF 0xfdd,0xfea 00177a ffea 00177c 0e02 MOVLW 0x2 00177e cfdb MOVFF 0xfdb,0xfef 001780 ffef } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001782 de1f RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001784 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001786 5ce1 SUBWF 0xe1,0x0,0x0 001788 e202 BC 0x178e 00178a 6ae1 CLRF 0xe1,0x0 00178c 52e5 MOVF 0xe5,0x1,0x0 00178e 6ee1 MOVWF 0xe1,0x0 001790 52e5 MOVF 0xe5,0x1,0x0 001792 cfe7 MOVFF 0xfe7,0xfd9 001794 ffd9 001796 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // MR is for Memory Read C:\Projects\UBW\FW\D_143\user\user.c // "MW," C:\Projects\UBW\FW\D_143\user\user.c // is a decimal value between 0 and 4096 indicating the RAM address to read from C:\Projects\UBW\FW\D_143\user\user.c // The UBW will then send a "MR," packet back to the PC C:\Projects\UBW\FW\D_143\user\user.c // where is the byte value read from the address C:\Projects\UBW\FW\D_143\user\user.c 001798 cfd9 MOVFF 0xfd9,0xfe6 void parse_MR_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 00179a ffe6 00179c cfe1 MOVFF 0xfe1,0xfd9 00179e ffd9 0017a0 0e03 MOVLW 0x3 0017a2 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned int location; C:\Projects\UBW\FW\D_143\user\user.c unsigned char value; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 0017a4 0e03 MOVLW 0x3 location = extract_number (kUINT); C:\Projects\UBW\FW\D_143\user\user.c 0017a6 6ee6 MOVWF 0xe6,0x0 0017a8 ecc9 CALL 0x2192,0x0 0017aa f010 0017ac 52e5 MOVF 0xe5,0x1,0x0 0017ae c01d MOVFF 0x1d,0xfde 0017b0 ffde 0017b2 c01e MOVFF 0x1e,0xfdd 0017b4 ffdd C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 0017b6 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 0017b8 e001 BZ 0x17bc { C:\Projects\UBW\FW\D_143\user\user.c 0017ba d025 BRA 0x1806 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Limit check the address and write the byte in C:\Projects\UBW\FW\D_143\user\user.c 0017bc cfde MOVFF 0xfde,0x2a if (location < 4096) C:\Projects\UBW\FW\D_143\user\user.c 0017be f02a 0017c0 cfdd MOVFF 0xfdd,0x2b 0017c2 f02b 0017c4 0e00 MOVLW 0x0 0017c6 5c2a SUBWF 0x2a,0x0,0x0 0017c8 0e10 MOVLW 0x10 0017ca 582b SUBWFB 0x2b,0x0,0x0 0017cc e207 BC 0x17dc { C:\Projects\UBW\FW\D_143\user\user.c 0017ce cfde MOVFF 0xfde,0xfe9 value = *((unsigned char *)location); C:\Projects\UBW\FW\D_143\user\user.c 0017d0 ffe9 0017d2 cfdd MOVFF 0xfdd,0xfea 0017d4 ffea 0017d6 0e02 MOVLW 0x2 0017d8 cfef MOVFF 0xfef,0xfdb 0017da ffdb } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now send back the MR packet C:\Projects\UBW\FW\D_143\user\user.c printf ( C:\Projects\UBW\FW\D_143\user\user.c (far rom char *)"MR,%03u\r\n" C:\Projects\UBW\FW\D_143\user\user.c 0017e4 0e58 MOVLW 0x58 ,value C:\Projects\UBW\FW\D_143\user\user.c 0017e6 6e2a MOVWF 0x2a,0x0 0017e8 0e3f MOVLW 0x3f 0017ea 6e2b MOVWF 0x2b,0x0 0017ec 6a2c CLRF 0x2c,0x0 0017ee c02a MOVFF 0x2a,0xfe6 0017f0 ffe6 0017f2 c02b MOVFF 0x2b,0xfe6 0017f4 ffe6 0017f6 c02c MOVFF 0x2c,0xfe6 0017f8 ffe6 0017dc 0e02 MOVLW 0x2 ); C:\Projects\UBW\FW\D_143\user\user.c 0017de cfdb MOVFF 0xfdb,0xfe6 0017e0 ffe6 0017e2 6ae6 CLRF 0xe6,0x0 0017fa ec5f CALL 0x42be,0x0 0017fc f021 0017fe 6e2d MOVWF 0x2d,0x0 001800 0e05 MOVLW 0x5 001802 5ee1 SUBWF 0xe1,0x1,0x0 001804 502d MOVF 0x2d,0x0,0x0 001806 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001808 5ce1 SUBWF 0xe1,0x0,0x0 00180a e202 BC 0x1810 00180c 6ae1 CLRF 0xe1,0x0 00180e 52e5 MOVF 0xe5,0x1,0x0 001810 6ee1 MOVWF 0xe1,0x0 001812 52e5 MOVF 0xe5,0x1,0x0 001814 cfe7 MOVFF 0xfe7,0xfd9 001816 ffd9 001818 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // PD is for Pin Direction C:\Projects\UBW\FW\D_143\user\user.c // "PD,,," C:\Projects\UBW\FW\D_143\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\D_143\user\user.c // is a number between 0 and 7 and indicates which pin to change direction on C:\Projects\UBW\FW\D_143\user\user.c // is "1" for input, "0" for output C:\Projects\UBW\FW\D_143\user\user.c 00181a cfd9 MOVFF 0xfd9,0xfe6 void parse_PD_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 00181c ffe6 00181e cfe1 MOVFF 0xfe1,0xfd9 001820 ffd9 001822 0e03 MOVLW 0x3 001824 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char port; C:\Projects\UBW\FW\D_143\user\user.c unsigned char pin; C:\Projects\UBW\FW\D_143\user\user.c unsigned char direction; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001826 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\D_143\user\user.c 001828 6ee6 MOVWF 0xe6,0x0 00182a ecc9 CALL 0x2192,0x0 00182c f010 00182e 52e5 MOVF 0xe5,0x1,0x0 001830 501d MOVF 0x1d,0x0,0x0 001832 6edf MOVWF 0xdf,0x0 001834 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001836 6ee6 MOVWF 0xe6,0x0 001838 ecc9 CALL 0x2192,0x0 00183a f010 00183c 52e5 MOVF 0xe5,0x1,0x0 00183e 0e01 MOVLW 0x1 001840 c01d MOVFF 0x1d,0xfdb 001842 ffdb 001844 0e01 MOVLW 0x1 direction = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001846 6ee6 MOVWF 0xe6,0x0 001848 ecc9 CALL 0x2192,0x0 00184a f010 00184c 52e5 MOVF 0xe5,0x1,0x0 00184e 0e02 MOVLW 0x2 001850 c01d MOVFF 0x1d,0xfdb 001852 ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 001854 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001856 e001 BZ 0x185a { C:\Projects\UBW\FW\D_143\user\user.c 001858 d072 BRA 0x193e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Limit check the parameters C:\Projects\UBW\FW\D_143\user\user.c 00185a 0e02 MOVLW 0x2 if (direction > 1) C:\Projects\UBW\FW\D_143\user\user.c 00185c 50db MOVF 0xdb,0x0,0x0 00185e 0801 SUBLW 0x1 001860 e202 BC 0x1866 { C:\Projects\UBW\FW\D_143\user\user.c 001862 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001864 d06c BRA 0x193e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001866 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\D_143\user\user.c 001868 50db MOVF 0xdb,0x0,0x0 00186a 0807 SUBLW 0x7 00186c e202 BC 0x1872 { C:\Projects\UBW\FW\D_143\user\user.c 00186e 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001870 d066 BRA 0x193e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001872 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\D_143\user\user.c 001874 6e2a MOVWF 0x2a,0x0 001876 50df MOVF 0xdf,0x0,0x0 001878 5c2a SUBWF 0x2a,0x0,0x0 00187a e11c BNZ 0x18b4 { C:\Projects\UBW\FW\D_143\user\user.c 00187c 0e02 MOVLW 0x2 if (0 == direction) C:\Projects\UBW\FW\D_143\user\user.c 00187e 50db MOVF 0xdb,0x0,0x0 001880 e10d BNZ 0x189c { C:\Projects\UBW\FW\D_143\user\user.c 001882 0e01 MOVLW 0x1 bitclr (DDRA, pin); C:\Projects\UBW\FW\D_143\user\user.c 001884 6ef3 MOVWF 0xf3,0x0 001886 0e01 MOVLW 0x1 001888 50db MOVF 0xdb,0x0,0x0 00188a e004 BZ 0x1894 00188c 90d8 BCF 0xd8,0x0,0x0 00188e 36f3 RLCF 0xf3,0x1,0x0 001890 06e8 DECF 0xe8,0x1,0x0 001892 e1fc BNZ 0x188c 001894 50f3 MOVF 0xf3,0x0,0x0 001896 1ce8 COMF 0xe8,0x0,0x0 001898 1692 ANDWF 0x92,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 00189a d00b BRA 0x18b2 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 00189c 0e01 MOVLW 0x1 bitset (DDRA, pin); C:\Projects\UBW\FW\D_143\user\user.c 00189e 6ef3 MOVWF 0xf3,0x0 0018a0 0e01 MOVLW 0x1 0018a2 50db MOVF 0xdb,0x0,0x0 0018a4 e004 BZ 0x18ae 0018a6 90d8 BCF 0xd8,0x0,0x0 0018a8 36f3 RLCF 0xf3,0x1,0x0 0018aa 06e8 DECF 0xe8,0x1,0x0 0018ac e1fc BNZ 0x18a6 0018ae 50f3 MOVF 0xf3,0x0,0x0 0018b0 1292 IORWF 0x92,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 0018b2 d044 BRA 0x193c else if ('B' == port) C:\Projects\UBW\FW\D_143\user\user.c 0018b4 0e42 MOVLW 0x42 0018b6 6e2a MOVWF 0x2a,0x0 0018b8 50df MOVF 0xdf,0x0,0x0 0018ba 5c2a SUBWF 0x2a,0x0,0x0 0018bc e11c BNZ 0x18f6 { C:\Projects\UBW\FW\D_143\user\user.c 0018be 0e02 MOVLW 0x2 if (0 == direction) C:\Projects\UBW\FW\D_143\user\user.c 0018c0 50db MOVF 0xdb,0x0,0x0 0018c2 e10d BNZ 0x18de { C:\Projects\UBW\FW\D_143\user\user.c 0018c4 0e01 MOVLW 0x1 bitclr (DDRB, pin); C:\Projects\UBW\FW\D_143\user\user.c 0018c6 6ef3 MOVWF 0xf3,0x0 0018c8 0e01 MOVLW 0x1 0018ca 50db MOVF 0xdb,0x0,0x0 0018cc e004 BZ 0x18d6 0018ce 90d8 BCF 0xd8,0x0,0x0 0018d0 36f3 RLCF 0xf3,0x1,0x0 0018d2 06e8 DECF 0xe8,0x1,0x0 0018d4 e1fc BNZ 0x18ce 0018d6 50f3 MOVF 0xf3,0x0,0x0 0018d8 1ce8 COMF 0xe8,0x0,0x0 0018da 1693 ANDWF 0x93,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 0018dc d00b BRA 0x18f4 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 0018de 0e01 MOVLW 0x1 bitset (DDRB, pin); C:\Projects\UBW\FW\D_143\user\user.c 0018e0 6ef3 MOVWF 0xf3,0x0 0018e2 0e01 MOVLW 0x1 0018e4 50db MOVF 0xdb,0x0,0x0 0018e6 e004 BZ 0x18f0 0018e8 90d8 BCF 0xd8,0x0,0x0 0018ea 36f3 RLCF 0xf3,0x1,0x0 0018ec 06e8 DECF 0xe8,0x1,0x0 0018ee e1fc BNZ 0x18e8 0018f0 50f3 MOVF 0xf3,0x0,0x0 0018f2 1293 IORWF 0x93,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 0018f4 d023 BRA 0x193c else if ('C' == port) C:\Projects\UBW\FW\D_143\user\user.c 0018f6 0e43 MOVLW 0x43 0018f8 6e2a MOVWF 0x2a,0x0 0018fa 50df MOVF 0xdf,0x0,0x0 0018fc 5c2a SUBWF 0x2a,0x0,0x0 0018fe e11c BNZ 0x1938 { C:\Projects\UBW\FW\D_143\user\user.c 001900 0e02 MOVLW 0x2 if (0 == direction) C:\Projects\UBW\FW\D_143\user\user.c 001902 50db MOVF 0xdb,0x0,0x0 001904 e10d BNZ 0x1920 { C:\Projects\UBW\FW\D_143\user\user.c 001906 0e01 MOVLW 0x1 bitclr (DDRC, pin); C:\Projects\UBW\FW\D_143\user\user.c 001908 6ef3 MOVWF 0xf3,0x0 00190a 0e01 MOVLW 0x1 00190c 50db MOVF 0xdb,0x0,0x0 00190e e004 BZ 0x1918 001910 90d8 BCF 0xd8,0x0,0x0 001912 36f3 RLCF 0xf3,0x1,0x0 001914 06e8 DECF 0xe8,0x1,0x0 001916 e1fc BNZ 0x1910 001918 50f3 MOVF 0xf3,0x0,0x0 00191a 1ce8 COMF 0xe8,0x0,0x0 00191c 1694 ANDWF 0x94,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 00191e d00b BRA 0x1936 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001920 0e01 MOVLW 0x1 bitset (DDRC, pin); C:\Projects\UBW\FW\D_143\user\user.c 001922 6ef3 MOVWF 0xf3,0x0 001924 0e01 MOVLW 0x1 001926 50db MOVF 0xdb,0x0,0x0 001928 e004 BZ 0x1932 00192a 90d8 BCF 0xd8,0x0,0x0 00192c 36f3 RLCF 0xf3,0x1,0x0 00192e 06e8 DECF 0xe8,0x1,0x0 001930 e1fc BNZ 0x192a 001932 50f3 MOVF 0xf3,0x0,0x0 001934 1294 IORWF 0x94,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c else if ('D' == port) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c if (0 == direction) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitclr (DDRD, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitset (DDRD, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else if ('E' == port) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c if (0 == direction) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitclr (DDRE, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitset (DDRE, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c 001936 d002 BRA 0x193c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001938 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 00193a d001 BRA 0x193e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 00193c dd42 RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 00193e 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001940 5ce1 SUBWF 0xe1,0x0,0x0 001942 e202 BC 0x1948 001944 6ae1 CLRF 0xe1,0x0 001946 52e5 MOVF 0xe5,0x1,0x0 001948 6ee1 MOVWF 0xe1,0x0 00194a 52e5 MOVF 0xe5,0x1,0x0 00194c cfe7 MOVFF 0xfe7,0xfd9 00194e ffd9 001950 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // PI is for Pin Input C:\Projects\UBW\FW\D_143\user\user.c // "PI,," C:\Projects\UBW\FW\D_143\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\D_143\user\user.c // is a number between 0 and 7 and indicates which pin to read C:\Projects\UBW\FW\D_143\user\user.c // The command returns a "PI," packet, C:\Projects\UBW\FW\D_143\user\user.c // where is the value (0 or 1 for digital, 0 to 1024 for Analog) C:\Projects\UBW\FW\D_143\user\user.c // value for that pin. C:\Projects\UBW\FW\D_143\user\user.c 001952 cfd9 MOVFF 0xfd9,0xfe6 void parse_PI_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001954 ffe6 001956 cfe1 MOVFF 0xfe1,0xfd9 001958 ffd9 00195a 0e03 MOVLW 0x3 00195c 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char port; C:\Projects\UBW\FW\D_143\user\user.c unsigned char pin; C:\Projects\UBW\FW\D_143\user\user.c 00195e 0e02 MOVLW 0x2 unsigned char value = 0; C:\Projects\UBW\FW\D_143\user\user.c 001960 6adb CLRF 0xdb,0x0 C:\Projects\UBW\FW\D_143\user\user.c 001962 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\D_143\user\user.c 001964 6ee6 MOVWF 0xe6,0x0 001966 ecc9 CALL 0x2192,0x0 001968 f010 00196a 52e5 MOVF 0xe5,0x1,0x0 00196c 501d MOVF 0x1d,0x0,0x0 00196e 6edf MOVWF 0xdf,0x0 001970 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001972 6ee6 MOVWF 0xe6,0x0 001974 ecc9 CALL 0x2192,0x0 001976 f010 001978 52e5 MOVF 0xe5,0x1,0x0 00197a 0e01 MOVLW 0x1 00197c c01d MOVFF 0x1d,0xfdb 00197e ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 001980 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001982 e001 BZ 0x1986 { C:\Projects\UBW\FW\D_143\user\user.c 001984 d05c BRA 0x1a3e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Limit check the parameters C:\Projects\UBW\FW\D_143\user\user.c 001986 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\D_143\user\user.c 001988 50db MOVF 0xdb,0x0,0x0 00198a 0807 SUBLW 0x7 00198c e202 BC 0x1992 { C:\Projects\UBW\FW\D_143\user\user.c 00198e 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001990 d056 BRA 0x1a3e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Then test the bit in question based upon port C:\Projects\UBW\FW\D_143\user\user.c 001992 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\D_143\user\user.c 001994 6e2a MOVWF 0x2a,0x0 001996 50df MOVF 0xdf,0x0,0x0 001998 5c2a SUBWF 0x2a,0x0,0x0 00199a e110 BNZ 0x19bc { C:\Projects\UBW\FW\D_143\user\user.c 00199c 0e01 MOVLW 0x1 value = bittst (PORTA, pin); C:\Projects\UBW\FW\D_143\user\user.c 00199e 6ef3 MOVWF 0xf3,0x0 0019a0 0e01 MOVLW 0x1 0019a2 50db MOVF 0xdb,0x0,0x0 0019a4 e004 BZ 0x19ae 0019a6 90d8 BCF 0xd8,0x0,0x0 0019a8 36f3 RLCF 0xf3,0x1,0x0 0019aa 06e8 DECF 0xe8,0x1,0x0 0019ac e1fc BNZ 0x19a6 0019ae 50f3 MOVF 0xf3,0x0,0x0 0019b0 1480 ANDWF 0x80,0x0,0x0 0019b2 6ee7 MOVWF 0xe7,0x0 0019b4 0e02 MOVLW 0x2 0019b6 cfe7 MOVFF 0xfe7,0xfdb 0019b8 ffdb } C:\Projects\UBW\FW\D_143\user\user.c 0019ba d02c BRA 0x1a14 else if ('B' == port) C:\Projects\UBW\FW\D_143\user\user.c 0019bc 0e42 MOVLW 0x42 0019be 6e2a MOVWF 0x2a,0x0 0019c0 50df MOVF 0xdf,0x0,0x0 0019c2 5c2a SUBWF 0x2a,0x0,0x0 0019c4 e110 BNZ 0x19e6 { C:\Projects\UBW\FW\D_143\user\user.c 0019c6 0e01 MOVLW 0x1 value = bittst (PORTB, pin); C:\Projects\UBW\FW\D_143\user\user.c 0019c8 6ef3 MOVWF 0xf3,0x0 0019ca 0e01 MOVLW 0x1 0019cc 50db MOVF 0xdb,0x0,0x0 0019ce e004 BZ 0x19d8 0019d0 90d8 BCF 0xd8,0x0,0x0 0019d2 36f3 RLCF 0xf3,0x1,0x0 0019d4 06e8 DECF 0xe8,0x1,0x0 0019d6 e1fc BNZ 0x19d0 0019d8 50f3 MOVF 0xf3,0x0,0x0 0019da 1481 ANDWF 0x81,0x0,0x0 0019dc 6ee7 MOVWF 0xe7,0x0 0019de 0e02 MOVLW 0x2 0019e0 cfe7 MOVFF 0xfe7,0xfdb 0019e2 ffdb } C:\Projects\UBW\FW\D_143\user\user.c 0019e4 d017 BRA 0x1a14 else if ('C' == port) C:\Projects\UBW\FW\D_143\user\user.c 0019e6 0e43 MOVLW 0x43 0019e8 6e2a MOVWF 0x2a,0x0 0019ea 50df MOVF 0xdf,0x0,0x0 0019ec 5c2a SUBWF 0x2a,0x0,0x0 0019ee e110 BNZ 0x1a10 { C:\Projects\UBW\FW\D_143\user\user.c 0019f0 0e01 MOVLW 0x1 value = bittst (PORTC, pin); C:\Projects\UBW\FW\D_143\user\user.c 0019f2 6ef3 MOVWF 0xf3,0x0 0019f4 0e01 MOVLW 0x1 0019f6 50db MOVF 0xdb,0x0,0x0 0019f8 e004 BZ 0x1a02 0019fa 90d8 BCF 0xd8,0x0,0x0 0019fc 36f3 RLCF 0xf3,0x1,0x0 0019fe 06e8 DECF 0xe8,0x1,0x0 001a00 e1fc BNZ 0x19fa 001a02 50f3 MOVF 0xf3,0x0,0x0 001a04 1482 ANDWF 0x82,0x0,0x0 001a06 6ee7 MOVWF 0xe7,0x0 001a08 0e02 MOVLW 0x2 001a0a cfe7 MOVFF 0xfe7,0xfdb 001a0c ffdb } C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c else if ('D' == port) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c value = bittst (PORTD, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else if ('E' == port) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c value = bittst (PORTE, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c 001a0e d002 BRA 0x1a14 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001a10 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001a12 d015 BRA 0x1a3e return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now send back our response C:\Projects\UBW\FW\D_143\user\user.c printf( C:\Projects\UBW\FW\D_143\user\user.c (far rom char *)"PI,%1u\r\n" C:\Projects\UBW\FW\D_143\user\user.c 001a1c 0e4f MOVLW 0x4f ,value C:\Projects\UBW\FW\D_143\user\user.c 001a1e 6e2a MOVWF 0x2a,0x0 001a20 0e3f MOVLW 0x3f 001a22 6e2b MOVWF 0x2b,0x0 001a24 6a2c CLRF 0x2c,0x0 001a26 c02a MOVFF 0x2a,0xfe6 001a28 ffe6 001a2a c02b MOVFF 0x2b,0xfe6 001a2c ffe6 001a2e c02c MOVFF 0x2c,0xfe6 001a30 ffe6 001a14 0e02 MOVLW 0x2 ); C:\Projects\UBW\FW\D_143\user\user.c 001a16 cfdb MOVFF 0xfdb,0xfe6 001a18 ffe6 001a1a 6ae6 CLRF 0xe6,0x0 001a32 ec5f CALL 0x42be,0x0 001a34 f021 001a36 6e2d MOVWF 0x2d,0x0 001a38 0e05 MOVLW 0x5 001a3a 5ee1 SUBWF 0xe1,0x1,0x0 001a3c 502d MOVF 0x2d,0x0,0x0 001a3e 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001a40 5ce1 SUBWF 0xe1,0x0,0x0 001a42 e202 BC 0x1a48 001a44 6ae1 CLRF 0xe1,0x0 001a46 52e5 MOVF 0xe5,0x1,0x0 001a48 6ee1 MOVWF 0xe1,0x0 001a4a 52e5 MOVF 0xe5,0x1,0x0 001a4c cfe7 MOVFF 0xfe7,0xfd9 001a4e ffd9 001a50 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // PO is for Pin Output C:\Projects\UBW\FW\D_143\user\user.c // "PO,,," C:\Projects\UBW\FW\D_143\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\D_143\user\user.c // is a number between 0 and 7 and indicates which pin to write out the value to C:\Projects\UBW\FW\D_143\user\user.c // is "1" or "0" and indicates the state to change the pin to C:\Projects\UBW\FW\D_143\user\user.c 001a52 cfd9 MOVFF 0xfd9,0xfe6 void parse_PO_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001a54 ffe6 001a56 cfe1 MOVFF 0xfe1,0xfd9 001a58 ffd9 001a5a 0e03 MOVLW 0x3 001a5c 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char port; C:\Projects\UBW\FW\D_143\user\user.c unsigned char pin; C:\Projects\UBW\FW\D_143\user\user.c unsigned char value; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001a5e 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\D_143\user\user.c 001a60 6ee6 MOVWF 0xe6,0x0 001a62 db97 RCALL 0x2192 001a64 52e5 MOVF 0xe5,0x1,0x0 001a66 501d MOVF 0x1d,0x0,0x0 001a68 6edf MOVWF 0xdf,0x0 001a6a 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001a6c 6ee6 MOVWF 0xe6,0x0 001a6e db91 RCALL 0x2192 001a70 52e5 MOVF 0xe5,0x1,0x0 001a72 0e01 MOVLW 0x1 001a74 c01d MOVFF 0x1d,0xfdb 001a76 ffdb 001a78 0e01 MOVLW 0x1 value = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001a7a 6ee6 MOVWF 0xe6,0x0 001a7c db8a RCALL 0x2192 001a7e 52e5 MOVF 0xe5,0x1,0x0 001a80 0e02 MOVLW 0x2 001a82 c01d MOVFF 0x1d,0xfdb 001a84 ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 001a86 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001a88 e001 BZ 0x1a8c { C:\Projects\UBW\FW\D_143\user\user.c 001a8a d072 BRA 0x1b70 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Limit check the parameters C:\Projects\UBW\FW\D_143\user\user.c 001a8c 0e02 MOVLW 0x2 if (value > 1) C:\Projects\UBW\FW\D_143\user\user.c 001a8e 50db MOVF 0xdb,0x0,0x0 001a90 0801 SUBLW 0x1 001a92 e202 BC 0x1a98 { C:\Projects\UBW\FW\D_143\user\user.c 001a94 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001a96 d06c BRA 0x1b70 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001a98 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\D_143\user\user.c 001a9a 50db MOVF 0xdb,0x0,0x0 001a9c 0807 SUBLW 0x7 001a9e e202 BC 0x1aa4 { C:\Projects\UBW\FW\D_143\user\user.c 001aa0 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001aa2 d066 BRA 0x1b70 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001aa4 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\D_143\user\user.c 001aa6 6e2a MOVWF 0x2a,0x0 001aa8 50df MOVF 0xdf,0x0,0x0 001aaa 5c2a SUBWF 0x2a,0x0,0x0 001aac e11c BNZ 0x1ae6 { C:\Projects\UBW\FW\D_143\user\user.c 001aae 0e02 MOVLW 0x2 if (0 == value) C:\Projects\UBW\FW\D_143\user\user.c 001ab0 50db MOVF 0xdb,0x0,0x0 001ab2 e10d BNZ 0x1ace { C:\Projects\UBW\FW\D_143\user\user.c 001ab4 0e01 MOVLW 0x1 bitclr (LATA, pin); C:\Projects\UBW\FW\D_143\user\user.c 001ab6 6ef3 MOVWF 0xf3,0x0 001ab8 0e01 MOVLW 0x1 001aba 50db MOVF 0xdb,0x0,0x0 001abc e004 BZ 0x1ac6 001abe 90d8 BCF 0xd8,0x0,0x0 001ac0 36f3 RLCF 0xf3,0x1,0x0 001ac2 06e8 DECF 0xe8,0x1,0x0 001ac4 e1fc BNZ 0x1abe 001ac6 50f3 MOVF 0xf3,0x0,0x0 001ac8 1ce8 COMF 0xe8,0x0,0x0 001aca 1689 ANDWF 0x89,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001acc d00b BRA 0x1ae4 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001ace 0e01 MOVLW 0x1 bitset (LATA, pin); C:\Projects\UBW\FW\D_143\user\user.c 001ad0 6ef3 MOVWF 0xf3,0x0 001ad2 0e01 MOVLW 0x1 001ad4 50db MOVF 0xdb,0x0,0x0 001ad6 e004 BZ 0x1ae0 001ad8 90d8 BCF 0xd8,0x0,0x0 001ada 36f3 RLCF 0xf3,0x1,0x0 001adc 06e8 DECF 0xe8,0x1,0x0 001ade e1fc BNZ 0x1ad8 001ae0 50f3 MOVF 0xf3,0x0,0x0 001ae2 1289 IORWF 0x89,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001ae4 d044 BRA 0x1b6e else if ('B' == port) C:\Projects\UBW\FW\D_143\user\user.c 001ae6 0e42 MOVLW 0x42 001ae8 6e2a MOVWF 0x2a,0x0 001aea 50df MOVF 0xdf,0x0,0x0 001aec 5c2a SUBWF 0x2a,0x0,0x0 001aee e11c BNZ 0x1b28 { C:\Projects\UBW\FW\D_143\user\user.c 001af0 0e02 MOVLW 0x2 if (0 == value) C:\Projects\UBW\FW\D_143\user\user.c 001af2 50db MOVF 0xdb,0x0,0x0 001af4 e10d BNZ 0x1b10 { C:\Projects\UBW\FW\D_143\user\user.c 001af6 0e01 MOVLW 0x1 bitclr (LATB, pin); C:\Projects\UBW\FW\D_143\user\user.c 001af8 6ef3 MOVWF 0xf3,0x0 001afa 0e01 MOVLW 0x1 001afc 50db MOVF 0xdb,0x0,0x0 001afe e004 BZ 0x1b08 001b00 90d8 BCF 0xd8,0x0,0x0 001b02 36f3 RLCF 0xf3,0x1,0x0 001b04 06e8 DECF 0xe8,0x1,0x0 001b06 e1fc BNZ 0x1b00 001b08 50f3 MOVF 0xf3,0x0,0x0 001b0a 1ce8 COMF 0xe8,0x0,0x0 001b0c 168a ANDWF 0x8a,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001b0e d00b BRA 0x1b26 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001b10 0e01 MOVLW 0x1 bitset (LATB, pin); C:\Projects\UBW\FW\D_143\user\user.c 001b12 6ef3 MOVWF 0xf3,0x0 001b14 0e01 MOVLW 0x1 001b16 50db MOVF 0xdb,0x0,0x0 001b18 e004 BZ 0x1b22 001b1a 90d8 BCF 0xd8,0x0,0x0 001b1c 36f3 RLCF 0xf3,0x1,0x0 001b1e 06e8 DECF 0xe8,0x1,0x0 001b20 e1fc BNZ 0x1b1a 001b22 50f3 MOVF 0xf3,0x0,0x0 001b24 128a IORWF 0x8a,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001b26 d023 BRA 0x1b6e else if ('C' == port) C:\Projects\UBW\FW\D_143\user\user.c 001b28 0e43 MOVLW 0x43 001b2a 6e2a MOVWF 0x2a,0x0 001b2c 50df MOVF 0xdf,0x0,0x0 001b2e 5c2a SUBWF 0x2a,0x0,0x0 001b30 e11c BNZ 0x1b6a { C:\Projects\UBW\FW\D_143\user\user.c 001b32 0e02 MOVLW 0x2 if (0 == value) C:\Projects\UBW\FW\D_143\user\user.c 001b34 50db MOVF 0xdb,0x0,0x0 001b36 e10d BNZ 0x1b52 { C:\Projects\UBW\FW\D_143\user\user.c 001b38 0e01 MOVLW 0x1 bitclr (LATC, pin); C:\Projects\UBW\FW\D_143\user\user.c 001b3a 6ef3 MOVWF 0xf3,0x0 001b3c 0e01 MOVLW 0x1 001b3e 50db MOVF 0xdb,0x0,0x0 001b40 e004 BZ 0x1b4a 001b42 90d8 BCF 0xd8,0x0,0x0 001b44 36f3 RLCF 0xf3,0x1,0x0 001b46 06e8 DECF 0xe8,0x1,0x0 001b48 e1fc BNZ 0x1b42 001b4a 50f3 MOVF 0xf3,0x0,0x0 001b4c 1ce8 COMF 0xe8,0x0,0x0 001b4e 168b ANDWF 0x8b,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001b50 d00b BRA 0x1b68 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001b52 0e01 MOVLW 0x1 bitset (LATC, pin); C:\Projects\UBW\FW\D_143\user\user.c 001b54 6ef3 MOVWF 0xf3,0x0 001b56 0e01 MOVLW 0x1 001b58 50db MOVF 0xdb,0x0,0x0 001b5a e004 BZ 0x1b64 001b5c 90d8 BCF 0xd8,0x0,0x0 001b5e 36f3 RLCF 0xf3,0x1,0x0 001b60 06e8 DECF 0xe8,0x1,0x0 001b62 e1fc BNZ 0x1b5c 001b64 50f3 MOVF 0xf3,0x0,0x0 001b66 128b IORWF 0x8b,0x1,0x0 } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c #ifdef __18F4550 C:\Projects\UBW\FW\D_143\user\user.c else if ('D' == port) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c if (0 == value) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitclr (LATD, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitset (LATD, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else if ('E' == port) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c if (0 == value) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitclr (LATE, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c bitset (LATE, pin); C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c #endif C:\Projects\UBW\FW\D_143\user\user.c 001b68 d002 BRA 0x1b6e else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001b6a 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001b6c d001 BRA 0x1b70 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001b6e dc29 RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001b70 0e03 MOVLW 0x3 } C:\Projects\UBW\FW\D_143\user\user.c 001b72 5ce1 SUBWF 0xe1,0x0,0x0 001b74 e202 BC 0x1b7a 001b76 6ae1 CLRF 0xe1,0x0 001b78 52e5 MOVF 0xe5,0x1,0x0 001b7a 6ee1 MOVWF 0xe1,0x0 001b7c 52e5 MOVF 0xe5,0x1,0x0 001b7e cfe7 MOVFF 0xfe7,0xfd9 001b80 ffd9 001b82 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // TX is for Serial Transmit C:\Projects\UBW\FW\D_143\user\user.c // "TX,," C:\Projects\UBW\FW\D_143\user\user.c // is a count of the number of bytes in the field. C:\Projects\UBW\FW\D_143\user\user.c // It must never be larger than the number of bytes that are currently free in the C:\Projects\UBW\FW\D_143\user\user.c // software TX buffer or some data will get lost. C:\Projects\UBW\FW\D_143\user\user.c // are the bytes that you want the UBW to send. It will store them C:\Projects\UBW\FW\D_143\user\user.c // in its software TX buffer until there is time to send them out the TX pin. C:\Projects\UBW\FW\D_143\user\user.c // If you send in "0" for a C:\Projects\UBW\FW\D_143\user\user.c // then the UBW will send back a "TX," packet, C:\Projects\UBW\FW\D_143\user\user.c // where is the number of bytes currently available in the C:\Projects\UBW\FW\D_143\user\user.c // software TX buffer. C:\Projects\UBW\FW\D_143\user\user.c void parse_TX_packet(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001b84 dc1e RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001b86 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // RX is for Serial Receive C:\Projects\UBW\FW\D_143\user\user.c // "RX," C:\Projects\UBW\FW\D_143\user\user.c // is the maximum number of characters that you want the UBW to send C:\Projects\UBW\FW\D_143\user\user.c // back to you in the RX packet. If you use "0" for then the UBW C:\Projects\UBW\FW\D_143\user\user.c // will just send you the current number of bytes in it's RX buffer, and if C:\Projects\UBW\FW\D_143\user\user.c // there have been any buffer overruns since the last time a of C:\Projects\UBW\FW\D_143\user\user.c // "0" was received by the UBW. C:\Projects\UBW\FW\D_143\user\user.c // This command will send back a "RX,," C:\Projects\UBW\FW\D_143\user\user.c // or "RX,," packet depending upon if you send C:\Projects\UBW\FW\D_143\user\user.c // "0" or something else for C:\Projects\UBW\FW\D_143\user\user.c // in the returning RX packet is a count of the number of bytes C:\Projects\UBW\FW\D_143\user\user.c // in the field. It will never be more than the C:\Projects\UBW\FW\D_143\user\user.c // you sent in. C:\Projects\UBW\FW\D_143\user\user.c // is the data (in raw form - byte for byte what was received - C:\Projects\UBW\FW\D_143\user\user.c // i.e. not translated in any way, into ASCII values or anything else) that the UBW C:\Projects\UBW\FW\D_143\user\user.c // received. This may include s and NULLs among any other bytes, so make sure C:\Projects\UBW\FW\D_143\user\user.c // your PC application treates the RX packet coming back from the UBW in a speical way C:\Projects\UBW\FW\D_143\user\user.c // so as not to screw up normal packet processing if any special caracters are received. C:\Projects\UBW\FW\D_143\user\user.c // is a valule between 0 and MAX_SERIAL_RX_BUFFER_SIZE that records C:\Projects\UBW\FW\D_143\user\user.c // the total number of bytes, at that point in time, that the UBW is holding, waiting C:\Projects\UBW\FW\D_143\user\user.c // to pass on to the PC. C:\Projects\UBW\FW\D_143\user\user.c // has several bits. C:\Projects\UBW\FW\D_143\user\user.c // Bit 0 = Software RX Buffer Overrun (1 means software RX buffer (on RX pin) C:\Projects\UBW\FW\D_143\user\user.c // has been overrun and data has been lost) This will happen if you don't C:\Projects\UBW\FW\D_143\user\user.c // read the data out of the UWB often enough and the data is coming in too fast. C:\Projects\UBW\FW\D_143\user\user.c // Bit 1 = Software TX Buffer Overrun (1 means software TX buffer (on TX pin) C:\Projects\UBW\FW\D_143\user\user.c // as been overrun and data hs been lost. This will happen if you send too much C:\Projects\UBW\FW\D_143\user\user.c // data to the UBW and you have the serial port set to a low baud rate. C:\Projects\UBW\FW\D_143\user\user.c void parse_RX_packet(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001b88 dc1c RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001b8a 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // CX is for setting up serial port parameters C:\Projects\UBW\FW\D_143\user\user.c // TBD C:\Projects\UBW\FW\D_143\user\user.c void parse_CX_packet(void) C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001b8c dc1a RCALL 0x13c2 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001b8e 0012 RETURN 0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // RC is for outputting RC servo pulses on a pin C:\Projects\UBW\FW\D_143\user\user.c // "RC,,," C:\Projects\UBW\FW\D_143\user\user.c // is "A", "B", "C" and indicates the port C:\Projects\UBW\FW\D_143\user\user.c // is a number between 0 and 7 and indicates which pin to output the new value on C:\Projects\UBW\FW\D_143\user\user.c // is an unsigned 16 bit number between 0 and 11890. C:\Projects\UBW\FW\D_143\user\user.c // If is "0" then the RC output on that pin is disabled. C:\Projects\UBW\FW\D_143\user\user.c // Otherwise = 1 means 1ms pulse, = 11890 means 2ms pulse, C:\Projects\UBW\FW\D_143\user\user.c // any value inbetween means proportional pulse values between those two C:\Projects\UBW\FW\D_143\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\D_143\user\user.c // The RC command will continue to send out pulses at the last set value on C:\Projects\UBW\FW\D_143\user\user.c // each pin that has RC output with a repition rate of 1 pulse about every 19ms. C:\Projects\UBW\FW\D_143\user\user.c // If you have RC output enabled on a pin, outputting a digital value to that pin C:\Projects\UBW\FW\D_143\user\user.c // will be overwritten the next time the RC pulses. Make sure to turn off the RC C:\Projects\UBW\FW\D_143\user\user.c // output if you want to use the pin for something else. C:\Projects\UBW\FW\D_143\user\user.c 001b90 cfd9 MOVFF 0xfd9,0xfe6 void parse_RC_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001b92 ffe6 001b94 cfe1 MOVFF 0xfe1,0xfd9 001b96 ffd9 001b98 0e04 MOVLW 0x4 001b9a 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char port; C:\Projects\UBW\FW\D_143\user\user.c unsigned char pin; C:\Projects\UBW\FW\D_143\user\user.c unsigned int value; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001b9c 0e05 MOVLW 0x5 port = extract_number (kUCASE_ASCII_CHAR); C:\Projects\UBW\FW\D_143\user\user.c 001b9e 6ee6 MOVWF 0xe6,0x0 001ba0 daf8 RCALL 0x2192 001ba2 52e5 MOVF 0xe5,0x1,0x0 001ba4 501d MOVF 0x1d,0x0,0x0 001ba6 6edf MOVWF 0xdf,0x0 001ba8 0e01 MOVLW 0x1 pin = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001baa 6ee6 MOVWF 0xe6,0x0 001bac daf2 RCALL 0x2192 001bae 52e5 MOVF 0xe5,0x1,0x0 001bb0 0e01 MOVLW 0x1 001bb2 c01d MOVFF 0x1d,0xfdb 001bb4 ffdb 001bb6 0e03 MOVLW 0x3 value = extract_number (kUINT); C:\Projects\UBW\FW\D_143\user\user.c 001bb8 6ee6 MOVWF 0xe6,0x0 001bba daeb RCALL 0x2192 001bbc 52e5 MOVF 0xe5,0x1,0x0 001bbe 0e02 MOVLW 0x2 001bc0 c01d MOVFF 0x1d,0xfdb 001bc2 ffdb 001bc4 0e03 MOVLW 0x3 001bc6 c01e MOVFF 0x1e,0xfdb 001bc8 ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 001bca 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001bcc e001 BZ 0x1bd0 { C:\Projects\UBW\FW\D_143\user\user.c 001bce d07b BRA 0x1cc6 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Max value user can input. (min is zero) C:\Projects\UBW\FW\D_143\user\user.c 001bd0 50d9 MOVF 0xd9,0x0,0x0 if (value > 11890) C:\Projects\UBW\FW\D_143\user\user.c 001bd2 0f02 ADDLW 0x2 001bd4 6ee9 MOVWF 0xe9,0x0 001bd6 cfda MOVFF 0xfda,0xfea 001bd8 ffea 001bda 0e72 MOVLW 0x72 001bdc 80d8 BSF 0xd8,0x0,0x0 001bde 54ee SUBFWB 0xee,0x0,0x0 001be0 0e2e MOVLW 0x2e 001be2 54ed SUBFWB 0xed,0x0,0x0 001be4 e202 BC 0x1bea { C:\Projects\UBW\FW\D_143\user\user.c 001be6 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001be8 d06e BRA 0x1cc6 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Now get Value in the form that TMR0 needs it C:\Projects\UBW\FW\D_143\user\user.c // TMR0 needs to get filled with values from 65490 (1ms) to 53600 (2ms) C:\Projects\UBW\FW\D_143\user\user.c 001bea 50d9 MOVF 0xd9,0x0,0x0 if (value != 0) C:\Projects\UBW\FW\D_143\user\user.c 001bec 0f02 ADDLW 0x2 001bee 6ee9 MOVWF 0xe9,0x0 001bf0 cfda MOVFF 0xfda,0xfea 001bf2 ffea 001bf4 50ee MOVF 0xee,0x0,0x0 001bf6 10ed IORWF 0xed,0x0,0x0 001bf8 e01f BZ 0x1c38 { C:\Projects\UBW\FW\D_143\user\user.c 001bfa 682d SETF 0x2d,0x0 value = (65535 - (value + 45)); C:\Projects\UBW\FW\D_143\user\user.c 001bfc 682e SETF 0x2e,0x0 001bfe 6a2f CLRF 0x2f,0x0 001c00 0e2d MOVLW 0x2d 001c02 6ee7 MOVWF 0xe7,0x0 001c04 0e02 MOVLW 0x2 001c06 cfdb MOVFF 0xfdb,0x30 001c08 f030 001c0a 0e03 MOVLW 0x3 001c0c cfdb MOVFF 0xfdb,0x31 001c0e f031 001c10 50e7 MOVF 0xe7,0x0,0x0 001c12 2630 ADDWF 0x30,0x1,0x0 001c14 0e00 MOVLW 0x0 001c16 2231 ADDWFC 0x31,0x1,0x0 001c18 6a32 CLRF 0x32,0x0 001c1a 5030 MOVF 0x30,0x0,0x0 001c1c 5c2d SUBWF 0x2d,0x0,0x0 001c1e 6e2a MOVWF 0x2a,0x0 001c20 5031 MOVF 0x31,0x0,0x0 001c22 582e SUBWFB 0x2e,0x0,0x0 001c24 6e2b MOVWF 0x2b,0x0 001c26 5032 MOVF 0x32,0x0,0x0 001c28 582f SUBWFB 0x2f,0x0,0x0 001c2a 6e2c MOVWF 0x2c,0x0 001c2c 0e02 MOVLW 0x2 001c2e c02a MOVFF 0x2a,0xfdb 001c30 ffdb 001c32 0e03 MOVLW 0x3 001c34 c02b MOVFF 0x2b,0xfdb 001c36 ffdb } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001c38 0e01 MOVLW 0x1 if (pin > 7) C:\Projects\UBW\FW\D_143\user\user.c 001c3a 50db MOVF 0xdb,0x0,0x0 001c3c 0807 SUBLW 0x7 001c3e e202 BC 0x1c44 { C:\Projects\UBW\FW\D_143\user\user.c 001c40 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001c42 d041 BRA 0x1cc6 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001c44 0e41 MOVLW 0x41 if ('A' == port) C:\Projects\UBW\FW\D_143\user\user.c 001c46 6e2a MOVWF 0x2a,0x0 001c48 50df MOVF 0xdf,0x0,0x0 001c4a 5c2a SUBWF 0x2a,0x0,0x0 001c4c e102 BNZ 0x1c52 { C:\Projects\UBW\FW\D_143\user\user.c 001c4e 6adf CLRF 0xdf,0x0 port = 0; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c 001c50 d012 BRA 0x1c76 else if ('B' == port) C:\Projects\UBW\FW\D_143\user\user.c 001c52 0e42 MOVLW 0x42 001c54 6e2a MOVWF 0x2a,0x0 001c56 50df MOVF 0xdf,0x0,0x0 001c58 5c2a SUBWF 0x2a,0x0,0x0 001c5a e103 BNZ 0x1c62 { C:\Projects\UBW\FW\D_143\user\user.c 001c5c 0e08 MOVLW 0x8 port = 8; C:\Projects\UBW\FW\D_143\user\user.c 001c5e 6edf MOVWF 0xdf,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001c60 d00a BRA 0x1c76 else if ('C' == port) C:\Projects\UBW\FW\D_143\user\user.c 001c62 0e43 MOVLW 0x43 001c64 6e2a MOVWF 0x2a,0x0 001c66 50df MOVF 0xdf,0x0,0x0 001c68 5c2a SUBWF 0x2a,0x0,0x0 001c6a e103 BNZ 0x1c72 { C:\Projects\UBW\FW\D_143\user\user.c 001c6c 0e10 MOVLW 0x10 port = 16; C:\Projects\UBW\FW\D_143\user\user.c 001c6e 6edf MOVWF 0xdf,0x0 } C:\Projects\UBW\FW\D_143\user\user.c 001c70 d002 BRA 0x1c76 else C:\Projects\UBW\FW\D_143\user\user.c { C:\Projects\UBW\FW\D_143\user\user.c 001c72 8c0d BSF 0xd,0x6,0x0 bitset (error_byte, kERROR_BYTE_PARAMATER_OUTSIDE_LIMIT); C:\Projects\UBW\FW\D_143\user\user.c 001c74 d028 BRA 0x1cc6 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Store the new RC time value C:\Projects\UBW\FW\D_143\user\user.c 001c76 0e01 MOVLW 0x1 g_RC_value[pin + port] = value; C:\Projects\UBW\FW\D_143\user\user.c 001c78 50db MOVF 0xdb,0x0,0x0 001c7a 24df ADDWF 0xdf,0x0,0x0 001c7c 6ee9 MOVWF 0xe9,0x0 001c7e 6aea CLRF 0xea,0x0 001c80 90d8 BCF 0xd8,0x0,0x0 001c82 36e9 RLCF 0xe9,0x1,0x0 001c84 36ea RLCF 0xea,0x1,0x0 001c86 0e69 MOVLW 0x69 001c88 26e9 ADDWF 0xe9,0x1,0x0 001c8a 0e01 MOVLW 0x1 001c8c 22ea ADDWFC 0xea,0x1,0x0 001c8e 0e02 MOVLW 0x2 001c90 cfdb MOVFF 0xfdb,0xfee 001c92 ffee 001c94 0e03 MOVLW 0x3 001c96 cfdb MOVFF 0xfdb,0xfed 001c98 ffed // Only set this state if we are off - if we are already running on C:\Projects\UBW\FW\D_143\user\user.c // this pin, then the new value will be picked up next time around (19ms) C:\Projects\UBW\FW\D_143\user\user.c 001c9a 0e01 MOVLW 0x1 if (kOFF == g_RC_state[pin + port]) C:\Projects\UBW\FW\D_143\user\user.c 001c9c 50db MOVF 0xdb,0x0,0x0 001c9e 24df ADDWF 0xdf,0x0,0x0 001ca0 6aea CLRF 0xea,0x0 001ca2 0f51 ADDLW 0x51 001ca4 6ee9 MOVWF 0xe9,0x0 001ca6 0e01 MOVLW 0x1 001ca8 22ea ADDWFC 0xea,0x1,0x0 001caa 04ef DECF 0xef,0x0,0x0 001cac e10a BNZ 0x1cc2 { C:\Projects\UBW\FW\D_143\user\user.c 001cae 0e01 MOVLW 0x1 g_RC_state[pin + port] = kWAITING; C:\Projects\UBW\FW\D_143\user\user.c 001cb0 50db MOVF 0xdb,0x0,0x0 001cb2 24df ADDWF 0xdf,0x0,0x0 001cb4 6aea CLRF 0xea,0x0 001cb6 0f51 ADDLW 0x51 001cb8 6ee9 MOVWF 0xe9,0x0 001cba 0e01 MOVLW 0x1 001cbc 22ea ADDWFC 0xea,0x1,0x0 001cbe 0e02 MOVLW 0x2 001cc0 6eef MOVWF 0xef,0x0 } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001cc2 ece1 CALL 0x13c2,0x0 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001cc4 f009 001cc6 0e04 MOVLW 0x4 } C:\Projects\UBW\FW\D_143\user\user.c 001cc8 5ce1 SUBWF 0xe1,0x0,0x0 001cca e202 BC 0x1cd0 001ccc 6ae1 CLRF 0xe1,0x0 001cce 52e5 MOVF 0xe5,0x1,0x0 001cd0 6ee1 MOVWF 0xe1,0x0 001cd2 52e5 MOVF 0xe5,0x1,0x0 001cd4 cfe7 MOVFF 0xfe7,0xfd9 001cd6 ffd9 001cd8 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // BC is for Bulk Configure C:\Projects\UBW\FW\D_143\user\user.c // BC,,,,, C:\Projects\UBW\FW\D_143\user\user.c // This command sets up the mask and strobe bits on port A for the C:\Projects\UBW\FW\D_143\user\user.c // BO (Bulk Output) command below. Also suck in wait delay, strobe delay, etc. C:\Projects\UBW\FW\D_143\user\user.c 001cda cfd9 MOVFF 0xfd9,0xfe6 void parse_BC_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001cdc ffe6 001cde cfe1 MOVFF 0xfe1,0xfd9 001ce0 ffd9 001ce2 0e05 MOVLW 0x5 001ce4 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char BO_init; C:\Projects\UBW\FW\D_143\user\user.c unsigned char BO_strobe_mask; C:\Projects\UBW\FW\D_143\user\user.c unsigned char BO_wait_mask; C:\Projects\UBW\FW\D_143\user\user.c unsigned char BO_wait_delay; C:\Projects\UBW\FW\D_143\user\user.c unsigned char BO_strobe_delay; C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c 001ce6 0e01 MOVLW 0x1 BO_init = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001ce8 6ee6 MOVWF 0xe6,0x0 001cea da53 RCALL 0x2192 001cec 52e5 MOVF 0xe5,0x1,0x0 001cee 501d MOVF 0x1d,0x0,0x0 001cf0 6edf MOVWF 0xdf,0x0 001cf2 0e01 MOVLW 0x1 BO_wait_mask = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001cf4 6ee6 MOVWF 0xe6,0x0 001cf6 da4d RCALL 0x2192 001cf8 52e5 MOVF 0xe5,0x1,0x0 001cfa 0e02 MOVLW 0x2 001cfc c01d MOVFF 0x1d,0xfdb 001cfe ffdb 001d00 0e01 MOVLW 0x1 BO_wait_delay = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001d02 6ee6 MOVWF 0xe6,0x0 001d04 da46 RCALL 0x2192 001d06 52e5 MOVF 0xe5,0x1,0x0 001d08 0e03 MOVLW 0x3 001d0a c01d MOVFF 0x1d,0xfdb 001d0c ffdb 001d0e 0e01 MOVLW 0x1 BO_strobe_mask = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001d10 6ee6 MOVWF 0xe6,0x0 001d12 da3f RCALL 0x2192 001d14 52e5 MOVF 0xe5,0x1,0x0 001d16 0e01 MOVLW 0x1 001d18 c01d MOVFF 0x1d,0xfdb 001d1a ffdb 001d1c 0e01 MOVLW 0x1 BO_strobe_delay = extract_number (kUCHAR); C:\Projects\UBW\FW\D_143\user\user.c 001d1e 6ee6 MOVWF 0xe6,0x0 001d20 da38 RCALL 0x2192 001d22 52e5 MOVF 0xe5,0x1,0x0 001d24 0e04 MOVLW 0x4 001d26 c01d MOVFF 0x1d,0xfdb 001d28 ffdb C:\Projects\UBW\FW\D_143\user\user.c // Bail if we got a conversion error C:\Projects\UBW\FW\D_143\user\user.c 001d2a 500d MOVF 0xd,0x0,0x0 if (error_byte) C:\Projects\UBW\FW\D_143\user\user.c 001d2c e001 BZ 0x1d30 { C:\Projects\UBW\FW\D_143\user\user.c 001d2e d012 BRA 0x1d54 return; C:\Projects\UBW\FW\D_143\user\user.c } C:\Projects\UBW\FW\D_143\user\user.c C:\Projects\UBW\FW\D_143\user\user.c // Copy over values to their gloabls C:\Projects\UBW\FW\D_143\user\user.c 001d30 cfdf MOVFF 0xfdf,0x1b1 g_BO_init = BO_init; C:\Projects\UBW\FW\D_143\user\user.c 001d32 f1b1 001d34 0e02 MOVLW 0x2 g_BO_wait_mask = BO_wait_mask; C:\Projects\UBW\FW\D_143\user\user.c 001d36 cfdb MOVFF 0xfdb,0x1b3 001d38 f1b3 001d3a 0e01 MOVLW 0x1 g_BO_strobe_mask = BO_strobe_mask; C:\Projects\UBW\FW\D_143\user\user.c 001d3c cfdb MOVFF 0xfdb,0x1b2 001d3e f1b2 001d40 0e03 MOVLW 0x3 g_BO_wait_delay = BO_wait_delay; C:\Projects\UBW\FW\D_143\user\user.c 001d42 cfdb MOVFF 0xfdb,0x1b4 001d44 f1b4 001d46 0e04 MOVLW 0x4 g_BO_strobe_delay = BO_strobe_delay; C:\Projects\UBW\FW\D_143\user\user.c 001d48 cfdb MOVFF 0xfdb,0x1b5 001d4a f1b5 // And initalize Port A C:\Projects\UBW\FW\D_143\user\user.c 001d4c c1b1 MOVFF 0x1b1,0xf89 LATA = g_BO_init; C:\Projects\UBW\FW\D_143\user\user.c 001d4e ff89 C:\Projects\UBW\FW\D_143\user\user.c 001d50 ece1 CALL 0x13c2,0x0 print_ack (); C:\Projects\UBW\FW\D_143\user\user.c 001d52 f009 001d54 0e05 MOVLW 0x5 } C:\Projects\UBW\FW\D_143\user\user.c 001d56 5ce1 SUBWF 0xe1,0x0,0x0 001d58 e202 BC 0x1d5e 001d5a 6ae1 CLRF 0xe1,0x0 001d5c 52e5 MOVF 0xe5,0x1,0x0 001d5e 6ee1 MOVWF 0xe1,0x0 001d60 52e5 MOVF 0xe5,0x1,0x0 001d62 cfe7 MOVFF 0xfe7,0xfd9 001d64 ffd9 001d66 0012 RETURN 0x0 C:\Projects\UBW\FW\D_143\user\user.c // Bulk Output (BO) C:\Projects\UBW\FW\D_143\user\user.c // BO,4AF2C124 C:\Projects\UBW\FW\D_143\user\user.c // After the inital comma, pull in hex values and spit them out to port A C:\Projects\UBW\FW\D_143\user\user.c // Note that the procedure here is as follows: C:\Projects\UBW\FW\D_143\user\user.c // 1) Write new value to PortB C:\Projects\UBW\FW\D_143\user\user.c // 2) Assert C:\Projects\UBW\FW\D_143\user\user.c // 3) Wait for (if not zero) C:\Projects\UBW\FW\D_143\user\user.c // 4) Deassert C:\Projects\UBW\FW\D_143\user\user.c // 5) Wait for to be asserted C:\Projects\UBW\FW\D_143\user\user.c // 6) Wait for to be deasserted C:\Projects\UBW\FW\D_143\user\user.c // 7) If 5) or 6) takes longer than then just move on to next byte C:\Projects\UBW\FW\D_143\user\user.c // Repeat for each byte C:\Projects\UBW\FW\D_143\user\user.c 001d68 cfd9 MOVFF 0xfd9,0xfe6 void parse_BO_packet(void) C:\Projects\UBW\FW\D_143\user\user.c 001d6a ffe6 001d6c cfe1 MOVFF 0xfe1,0xfd9 001d6e ffd9 001d70 0e04 MOVLW 0x4 001d72 26e1 ADDWF 0xe1,0x1,0x0 { C:\Projects\UBW\FW\D_143\user\user.c unsigned char BO_data_byte; C:\Projects\UBW\FW\D_143\user\user.c un