亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usb_ch9.asm

?? 采用pic16c745 pic16c765開發的usb ps2鼠標程序
?? ASM
?? 第 1 頁 / 共 4 頁
字號:
;                            Software License Agreement
;
; The software supplied herewith by Microchip Technology Incorporated (the "Company")
; for its PICmicro(r) Microcontroller is intended and supplied to you, the Company's
; customer, for use solely and exclusively on Microchip PICmicro Microcontroller
; products.
;
; The software is owned by the Company and/or its supplier, and is protected under
; applicable copyright laws. All rights are reserved. Any use in violation of the
; foregoing restrictions may subject the user to criminal sanctions under applicable
; laws, as well as to civil liability for the breach of the terms and conditions of
; this license.
;
; THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, WHETHER EXPRESS,
; IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE
; COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
; CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;
; ###############################################################################
;   filename:           USB_CH9.ASM
;
; Implements the chapter 9 enumeration commands for Microchip's
; PIC16C7x5 parts.
;
; ###############################################################################
;
;   Author(s):          Dan Butler and Reston Condit
;   Company:            Microchip Technology Inc
;
;   Revision:           1.21
;   Date:               08 August 2001
;   Assembled using     MPASM 2.61
;   Revision History:
;   23 August 2000      DZB Changed descriptor pointers to 16 bits.
;   24 August 2000      DZB Moved EP1 & 2 configuration from USBReset
;                           to Set_Configuration to implement requirement in
;                           USB V1.1 spec paragraph 5.3.1.2
;   28 August 2000      DZB Force data toggle on OUT packets in PutUSB
;   20 March 2001       DZB Reduced use of common RAM
;   20 March 2001       DZB Put and Get use their own temp variable (GPtemp) to
;                           avoid collisions with the ISR's use of temp.
;   29 March 2001       DZB Fixed saving of bank bits in GetUSB
;   02 May 2001         DZB Implemented SHOW_ENUM_STATUS to show enumeration
;                           status on the PORTB LEDs: 0- Powered, 1- Default,
;                           2- addressed, 3- configured, 4- sleep, 
;                           5- EP0 Activity, 6- EP1 Activity, 7- EP2 Activity
;   03 August 2001      RAC Made distinct GetEP and PutEP macros for endpoints 1 
;                           and 2.  These functions are GetEP1, GetEP2, PutEP1, and 
;                           PutEP2.  Instances of the these macros are created in
;                           usb_ch9.asm.
;   08 August 2001      RAC Corrected various banking and paging issues.
;   15 August           RAC Added Report_desc_index function in descript.asm.
;                           This function allows more than one report descriptor
;                           to be used. 
;
;################################################################################
;
;    include files:
;       P16C765.inc     Rev 1.00
;       usb_defs.inc    Rev 1.00
;
;################################################################################

#include <p16C765.inc>
#include "usb_defs.inc"

    errorlevel -302 ; supress "register not in bank0, check page bits" message

#define SHOW_ENUM_STATUS

unbanked    udata_shr   ; these will get assigned to unbanked RAM (0x70-0x7F)
temp        res     1   ; short term temp register used in Get Interface
GPtemp      res     1   ; temporary storage location used in Get and PutEPn

    global  BufferDescriptor
    global  BufferData
    global  temp
    global  temp2
    global  EP0_maxLength
    global  EP0_start
    global  EP0_end

bank2   udata
BufferDescriptor    res     3
BufferData          res     8
USBMaskedInterrupts res     1
USB_Curr_Config     res     1
USB_status_device   res     1   ; status of device
USB_dev_req         res     1
USB_address_pending res     1
USBMaskedErrors     res     1
PIDs                res     1
EP0_start           res     2   ; pointer to first byte of data to send
EP0_end             res     1   ; pointer to last byte of data to send
EP0_maxLength       res     1
temp2               res     1
bufindex            res     1
USB_Interface       res     3   ; allow 3 interfaces to have alternate endpoints
inner               res     1
outer               res     1
dest_ptr            res     1   ; used in buffer copies for Get and
source_ptr          res     1   ; Put USB calls
hid_dest_ptr        res     1   ; used in buffer copies for HIDSetReport
hid_source_ptr      res     1   ;
counter             res     1
bytecounter         res     1   ; saved copy that will be returned in W
RP_save             res     1   ; save bank bits while copying buffers
IS_IDLE             res     1
USB_USTAT           res     1   ; copy of the USTAT register before clearing TOK_DNE

    global  USB_Curr_Config    
    global  USB_status_device
    global  USB_dev_req
    global  USB_Interface

#ifdef      COUNTERRORS
USB_PID_ERR         res     2   ; 16 bit counters for each error condition
USB_CRC5_ERR        res     2
USB_CRC16_ERR       res     2
USB_DFN8_ERR        res     2
USB_BTO_ERR         res     2
USB_WRT_ERR         res     2
USB_OWN_ERR         res     2
USB_BTS_ERR         res     2
#endif

    extern  Config_desc_index
    extern  Descriptions
    extern  string_index
    extern  String0
    extern  String0_end
    extern  ClassSpecificRequest
    extern  Check_Class_Specific_IN
    extern  Get_Report_Descriptor
    extern  Get_HID_Descriptor
    extern  DeviceDescriptor
    extern  StringDescriptions

; **********************************************************************
; This section contains the functions to interface with the main 
; application.
; **********************************************************************

interface	code

; **********************************************************************
; GETEP1 and GETEP2
;
; Note:  These functions are, in reality, macros defined in usb_defs.inc.
;        To save ROM, delete the instances below that you will not need.
;
; Enter with buffer pointer in IRP+FSR.  
; Checks the semaphore for the OUT endpoint, and copies the buffer 
; if available.  Restores the bank bits as we found them.
;
; Returns the bytecount in the W register and return status in the carry
; bit as follows:
; 0 - no buffer available,
; 1 - Buffer copied and buffer made available for next transfer.
; 
; The number of bytes moved is returned in W reg.
; **********************************************************************

	GETEP1		; create instance of GETEP1
	GETEP2		; create instance of GETEP2

; **********************************************************************
; PUTEP1 and PUTEP2
;
; Note:  These functions are, in reality, macros defined in usb_defs.inc.
;        To save ROM, delete the instances below that you will not need.
;
; Enter with bytecount in W and buffer pointer in IRP+FSR.
; the bytecount is encoded in the lower nybble of W.
;
; Tests the owns bit for the IN side of the specified Endpoint.
; If we own the buffer, the buffer pointed to by the FSR is copied
; to the EPn In buffer, then the owns bit is set so the data will be
; TX'd next time polled.  
;
; Returns the status in the carry bit as follows:
; 1 - buffer available and copied.
; 0 - buffer not available (try again later)
; **********************************************************************
	PUTEP1      ; create instance of PUTEP1
	PUTEP2      ; create instance of PUTEP2

; *********************************************************************
; Stall Endpoint.
; Sets the stall bit in the Endpoint Control Register.  For the control
; Endpoint, this implements a Protocol stall and is used when the request
; is invalid for the current device state.  For non-control Endpoints,
; this is a Functional Stall, meaning that the device needs outside 
; intervention and trying again later won't help until it's been serviced.
; enter with endpoint # to stall in Wreg.
; *********************************************************************
StallUSBEP
    bsf     STATUS,IRP      ; select banks 2/3
    andlw   0x03            ; try to keep things under control
    addlw   low UEP0        ; add address of endpoint control reg
    movwf   FSR
    bsf     INDF,EP_STALL   ; set stall bit
    return

; *********************************************************************
; Unstall Endpoint.
; Sets the stall bit in the Endpoint Control Register.  For the control
; Endpoint, this implements a Protocol stall and is used when the request
; is invalid for the current device state.  For non-control Endpoints,
; this is a Functional Stall, meaning that the device needs outside 
; intervention and trying again later won't help until it's been serviced.
; enter with endpoint # to stall in Wreg.
; *********************************************************************
UnstallUSBEP
    bsf     STATUS,IRP      ; select banks 2/3
    andlw   0x03            ; try to keep things under control
    addlw   low UEP0        ; add address of endpoint control reg
    movwf   FSR
    bcf     INDF,EP_STALL   ; clear stall bit
    return

; *********************************************************************
; CheckSleep
; Checks the USB Sleep bit.  If the bit is set, the
; Endpoint, this implements a Protocol stall and is used when the request
; is invalid for the current device state.  For non-control Endpoints,
; this is a Functional Stall, meaning that the device needs outside 
; intervention and trying again later won't help until it's been serviced.
; enter with endpoint # to stall in Wreg.
; *********************************************************************
CheckSleep
    global  CheckSleep

    banksel IS_IDLE
    btfss   IS_IDLE,0       ; test the bus idle bit
    goto    nosleeptoday

#ifdef SHOW_ENUM_STATUS
    banksel PORTB
    bsf     PORTB,4         ; turn on LED 4 to indicate we've gone to sleep
    banksel UIR
#endif
    bsf     STATUS,RP0      ; point to bank 3
    bcf     UIR,ACTIVITY
    bsf     UIE,ACTIVITY    ; enable the USB activity interrupt
    bsf     UCTRL,SUSPND    ; put USB regulator and transciever in low power state
    sleep                   ; and go to sleep
    nop
    bcf     UCTRL,SUSPND
    bcf     UIR,UIDLE
    bsf     UIE,UIDLE
    bcf     UIR,ACTIVITY
    bcf     UIE,ACTIVITY
#ifdef SHOW_ENUM_STATUS
    banksel PORTB
    bcf     PORTB,4         ; turn off LED 4 to indicate we're back.
#endif

nosleeptoday
    return

; *********************************************************************
; Remote Wakeup
; Checks USB_status_device to see if the host enabled Remote Wakeup
; If so, perform Remote wakeup and disable remote wakeup feature
; It is called by PortBChange
; *********************************************************************
RemoteWakeup
    global  RemoteWakeup

    banksel USB_status_device    
    btfss   USB_status_device, 1
    goto    RemoteEnd

    clrf    inner
    movlw   0xB0
    movwf   outer

    bsf     STATUS, RP0     ; BANK 3
    bsf     UCTRL, 2        ; RESUME SIGNALING
    bcf     STATUS, RP0     ; BANK 2

    incfsz  inner,f         ; DELAY over 10mS
    goto    $-1
    incfsz  outer,f
    goto    $-3

    bsf     STATUS,RP0
    bcf     UCTRL, 2        ; Clear Resume bit
    bcf     STATUS,RP0
    bcf     USB_status_device, 1    ; Disable Remote Wakeup
    
RemoteEnd
    return


; *********************************************************************
; USB Soft Detach
; Clears the DEV_ATT bit, electrically disconnecting the device to the bus.
; This removes the device from the bus, then reconnects so it can be
; re-enumerated by the host.  This is envisioned as a last ditch effort
; by the software.
; *********************************************************************
SoftDetachUSB
    global  SoftDetachUSB

    banksel UCTRL
    bcf     UCTRL,DEV_ATT   ; clear attach bit

    bcf     STATUS, RP0     ; bank 2
    
    clrf    outer
    clrf    inner

    incfsz  inner,f
    goto    $-1
    incfsz  outer,f
    goto    $-3

    pagesel InitUSB
    call    InitUSB         ; reinitialize the USB peripheral
    return


; ******************************************************************
; Init USB
; Initializes the USB peripheral, sets up the interrupts
; ******************************************************************
InitUSB
    global  InitUSB

    banksel USWSTAT
    clrf    USWSTAT         ; default to powered state
    movlw   0x01            ; mask all USB interrupts except reset
    movwf   UIE
    clrf    UIR             ; clear all USB Interrupt flags
    movlw   0x08            ; Device attached
    movwf   UCTRL

    bcf     STATUS, RP0     ; bank 2
    clrf    USB_Curr_Config
    movlw   1
    movwf   USB_status_device
    clrf    USB_Interface
    clrf    USB_Interface+1
    clrf    USB_Interface+2
    movlw   0xFF
    movwf   USB_dev_req     ; no device requests in process
#ifdef COUNTERRORS
    clrf    USB_PID_ERR
    clrf    USB_PID_ERR+1
    clrf    USB_CRC5_ERR
    clrf    USB_CRC5_ERR+1
    clrf    USB_CRC16_ERR
    clrf    USB_CRC16_ERR+1
    clrf    USB_DFN8_ERR
    clrf    USB_DFN8_ERR+1
    clrf    USB_BTO_ERR
    clrf    USB_BTO_ERR+1
    clrf    USB_WRT_ERR
    clrf    USB_WRT_ERR+1
    clrf    USB_OWN_ERR
    clrf    USB_OWN_ERR+1
    clrf    USB_BTS_ERR
    clrf    USB_BTS_ERR+1
#endif

    banksel PIR1            ; bank 0
    bcf     PIR1,USBIF      ; clear the USB flag
    bsf     STATUS,RP0      ; bank 1
    bsf     PIE1,USBIE      ; enable usb interrupt
    bsf     INTCON, 6       ; enable global and peripheral interrupts
    bsf     INTCON, 7
#ifdef SHOW_ENUM_STATUS
    bcf     STATUS,RP0      ; select bank 0
    bsf     PORTB,0         ; set bit zero to indicate Powered status
#endif
    return


; ******************************************************************
; DeInit USB
; Shuts down the USB peripheral, clears the interrupt enable.
; ******************************************************************
DeInitUSB
    global  DeInitUSB

    banksel UCTRL
    bcf     UCTRL,DEV_ATT   ; D+/D- go high Z
    bsf     UCTRL,SUSPND    ; Place USB module in low power mode.

    clrf    USWSTAT         ; set device state to powered.

    bcf     STATUS,RP1      ; select bank 1
    bcf     PIE1,USBIE      ; clear USB interrupt enable
#ifdef SHOW_ENUM_STATUS
    bcf     STATUS,RP0
    movlw   0x01
    movwf   PORTB           ; clear all lights except powered
    bsf     STATUS,RP0
#endif

    return


core    code
; The functions below are the core functions
; ******************************************************************
; USB interrupt triggered, Why?
; Poll the USB interrupt flags to find the cause.
; ******************************************************************
ServiceUSBInt
    global  ServiceUSBInt

    banksel UIR
    movf    UIR,w           ; get the USB interrupt register
    andwf   UIE,w           ; mask off the disabled interrupts
    bcf     STATUS, RP0     ; BANK 2
    btfsc   STATUS,Z        ; is there any unmasked interrupts?
    goto    ExitServiceUSBInt ; no, bail out.

    pagesel TokenDone
    movwf   USBMaskedInterrupts
    btfsc   USBMaskedInterrupts,TOK_DNE    ; was it a token done?
    call    TokenDone
    banksel USBMaskedInterrupts
    btfsc   USBMaskedInterrupts,USB_RST
    call    USBReset
    btfsc   USBMaskedInterrupts,STALL
    call    USBStall
    btfsc   USBMaskedInterrupts,UERR
    call    USBError
    btfsc   USBMaskedInterrupts,UIDLE
    call    USBSleep
    btfsc   USBMaskedInterrupts,ACTIVITY

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲国产一区二区三区va| 色婷婷综合久久久中文字幕| 精品国偷自产国产一区| 毛片不卡一区二区| 国产精品久久久久婷婷二区次| 99久久精品免费看国产| 亚洲黄一区二区三区| 欧美精品xxxxbbbb| 不卡在线视频中文字幕| 亚洲成人黄色影院| 成人欧美一区二区三区白人| 1000部国产精品成人观看| 亚洲四区在线观看| 亚洲国产精品一区二区久久| 一区二区三区四区国产精品| 国产午夜亚洲精品不卡| 亚洲精品在线一区二区| 亚洲欧美偷拍卡通变态| 国产精品久久久久久一区二区三区 | 99精品视频在线观看免费| 美女视频黄免费的久久 | 欧美一区二区三区喷汁尤物| 亚洲乱码国产乱码精品精的特点 | 国产一区二区在线影院| jlzzjlzz欧美大全| 91精品在线观看入口| 精品免费日韩av| 亚洲精品免费电影| 奇米影视一区二区三区小说| 麻豆成人91精品二区三区| 亚洲一区二区欧美激情| 欧美剧情片在线观看| 欧美男同性恋视频网站| 91久久精品一区二区三区| 波多野结衣中文一区| 亚洲成人综合网站| 中文字幕一区二区三区不卡| 国产精品伦一区| av一二三不卡影片| 久久成人精品无人区| 国产在线视频精品一区| 久久综合色8888| 懂色中文一区二区在线播放| 久久精品人人做人人爽人人| 欧美日韩国产高清一区| 日本乱人伦一区| 欧美日韩一区中文字幕| 欧美日韩你懂的| 欧美日韩美少妇| 国产欧美视频一区二区| 国产精品国产三级国产普通话三级 | 久久先锋资源网| 欧美成人猛片aaaaaaa| 国产日本欧洲亚洲| 亚洲一区二区视频| 国产精品乱码久久久久久| 制服丝袜亚洲播放| 成人h动漫精品一区二| 99久精品国产| 精品蜜桃在线看| 一区二区三区中文字幕电影| 宅男噜噜噜66一区二区66| 中文字幕不卡三区| 蜜桃av一区二区在线观看| 国产亚洲美州欧州综合国| gogo大胆日本视频一区| 午夜日韩在线观看| 国产欧美一区二区三区在线看蜜臀| 92国产精品观看| 七七婷婷婷婷精品国产| 国产精品女主播av| 免费成人在线网站| 欧美视频一区在线观看| 久久精品免视看| 国模大尺度一区二区三区| 精品成人免费观看| 一区二区三区高清在线| 不卡一区二区在线| 中文文精品字幕一区二区| 五月天婷婷综合| 日本韩国精品一区二区在线观看| 麻豆极品一区二区三区| 日韩欧美一区中文| 国产日韩欧美不卡| 在线成人av影院| 色综合久久综合| 麻豆成人av在线| 亚洲一区二区三区在线播放| 久久蜜桃一区二区| 91精品久久久久久蜜臀| 色综合中文字幕国产| 亚洲视频综合在线| 99re这里只有精品视频首页| 久88久久88久久久| 亚洲成av人片| 亚洲精品视频免费观看| 亚洲美女精品一区| 2014亚洲片线观看视频免费| 欧美美女喷水视频| 欧美日韩国产综合草草| 色呦呦国产精品| 成人av免费在线| 成人永久免费视频| 精品在线免费观看| 美国三级日本三级久久99| 五月婷婷另类国产| 亚洲三级在线免费| 久久精品视频免费| 久久久99精品免费观看| 2014亚洲片线观看视频免费| 欧美挠脚心视频网站| 欧美吞精做爰啪啪高潮| 日本久久电影网| 成人av影视在线观看| 国产久卡久卡久卡久卡视频精品| 欧美aⅴ一区二区三区视频| 三级影片在线观看欧美日韩一区二区 | 国产精品情趣视频| 国产视频一区二区在线观看| 久久久久国产精品免费免费搜索| 久久先锋影音av| 久久精品日韩一区二区三区| 国产校园另类小说区| 国产午夜精品福利| 国产精品高潮呻吟| 一区二区三区在线观看欧美| 国产精品短视频| 亚洲国产一区视频| 免费看日韩a级影片| 国产剧情一区在线| 99热99精品| 欧美色大人视频| 国产亚洲1区2区3区| 亚洲欧洲国产日本综合| 一区二区三区在线视频观看58 | 欧美在线一二三四区| 欧美精品日日鲁夜夜添| 精品国精品国产尤物美女| 国产日韩v精品一区二区| 亚洲男人的天堂在线aⅴ视频| 亚洲一区二区三区中文字幕在线| 美女国产一区二区| www.在线欧美| 91精品国产高清一区二区三区蜜臀| 欧美一区二区三区四区高清| 国产午夜精品理论片a级大结局| 亚洲欧美视频在线观看| 秋霞电影一区二区| 成人免费的视频| 日本道色综合久久| 欧美大肚乱孕交hd孕妇| 国产精品你懂的在线| 亚洲va韩国va欧美va| 国产一区二区看久久| 日本韩国一区二区| 欧美精品一区二区三区蜜桃视频 | 国产欧美综合在线观看第十页| 国产精品久久三区| 青青草国产精品97视觉盛宴| av亚洲产国偷v产偷v自拍| 91精品欧美久久久久久动漫| 中文字幕一区免费在线观看 | 亚洲成人免费视频| 成人一区二区三区视频| 日韩视频中午一区| 一卡二卡欧美日韩| 成人午夜私人影院| 欧美成人乱码一区二区三区| 亚洲图片自拍偷拍| 99re66热这里只有精品3直播| 精品久久久久久无| 婷婷成人激情在线网| 一本色道**综合亚洲精品蜜桃冫| 欧美tk—视频vk| 日韩国产精品久久| 欧美午夜理伦三级在线观看| 久久免费电影网| 精品一区二区三区视频在线观看| 日本韩国一区二区| 综合中文字幕亚洲| 国产成人综合在线播放| 精品国产一区二区三区四区四| 亚洲成人在线观看视频| 91论坛在线播放| 亚洲三级电影网站| 国产99久久久国产精品免费看| 精品国产91九色蝌蚪| 日韩va亚洲va欧美va久久| 欧美视频你懂的| 亚洲一区二区中文在线| 色综合久久天天| 专区另类欧美日韩| av资源站一区| 久久久久久久久一| 国产一区二区网址| 久久人人爽爽爽人久久久| 国产伦精品一区二区三区免费迷 | 国产亚洲成年网址在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 精品福利在线导航|