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

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

?? usbhidio.asm

?? VB和USB通訊示例
?? ASM
?? 第 1 頁 / 共 4 頁
字號:
     mov [interrupt_mask],A
     ipret Global_Interrupt

;----------------------------------------------------------------------
;GPIO interrupt
;Can be configured to trigger when a port bit toggles.
;Unused here.
;----------------------------------------------------------------------

GPIO_ISR:
     push A
     push X

     pop X
     mov [interrupt_mask],A
     ipret Global_Interrupt

;----------------------------------------------------------------------
;Endpoint 1 ISR
;Endpoint 1 can do IN (device to host) transfers only.
;This interrupt triggers when the host acknowledges
;receiving data from Endpoint 1.
;The ISR toggles the data 0/1 bit for the next transaction and
;sets the EnableRespondToIN bit so the chip will respond to the 
;next poll of the endpoint.
;----------------------------------------------------------------------

USB_EP1_ISR:
     push A
;Toggle the data 0/1 bit so it's correct for the next transaction.
     iord USB_EP1_TX_Config  
     xor A,40h
;The interrupt clears the EnableRespondToIN bit (bit 7) in the TX Config.
;Set this bit to 1 so data will go out on the next poll.
;This will ensure that a ReadFile API call in a Windows application
;won't hang, waiting for the device to send something.
     or A, 92h
     iowr USB_EP1_TX_Config
;Enable interrupts and return.
     mov A, [interrupt_mask]
     ipret Global_Interrupt

;----------------------------------------------------------------------
; Reset processing
; Triggers on Reset or "reserved" interrupt.
;To be safe, initialize everything.
;----------------------------------------------------------------------

Reset:
;Place the data stack pointer at the lowest address of Endpoint 0's buffer.
;This keeps the stack from writing over the USB buffers.
;The USB buffers are in high RAM;
;the data stack pointer pre-decrements on a Push instruction.

     mov A, Endpoint_0
     swap A, dsp

;Initialize to FFh
     mov A, 0ffh
     iowr Port0_Data                 ; output ones to port 0
     iowr Port1_Pullup               ; disable port 1 pullups
                                     ; select rising edge interrupts
     iowr Port1_Isink0               ; maximum isink current Port1 bit 0
     iowr Port1_Isink1               ; maximum isink current Port1 bit 1
     iowr Port1_Isink2               ; maximum isink current Port1 bit 2
     iowr Port1_Isink3               ; maximum isink current Port1 bit 3

;Initialize to 00h
     mov A, 0h
     iowr Port1_Data                 ; output zeros to port 1
     iowr Port0_Interrupt            ; disable port 0 interrupts
     iowr Port0_Pullup               ; enable port 0 pullups
     iowr Port0_Isink0               ; minimum sink current Port0 bit 0
     iowr Port0_Isink1               ; minimum sink current Port0 bit 1
     iowr Port0_Isink2               ; minimum sink current Port0 bit 2
     iowr Port0_Isink3               ; minimum sink current Port0 bit 3
     iowr Port0_Isink4               ; minimum sink current Port0 bit 4
     iowr Port0_Isink5               ; minimum sink current Port0 bit 5
     iowr Port0_Isink6               ; minimum sink current Port0 bit 6
     iowr Port0_Isink7               ; minimum sink current Port0 bit 7
     mov [Endpoint1_Byte0],A
     mov [Endpoint1_Byte1],A
     mov [Endpoint1_Byte2],A
     mov [endpoint_stall], A
     mov [remote_wakeup_status], A
     mov [configuration_status], A
     mov [loop_temp], A
     mov [start_send], A
     iowr Watchdog                   ; clear watchdog timer

;Initialize values to transmit at Endpoint 1.
;     mov A, A5h
;     mov [Data_Byte0], A
;     mov A, F0h
;     mov [Data_Byte1], A

;Enable Port 1, bit 0 interrupts.
;     mov A, 01h
;     iowr Port1_Interrupt
;
;Test what kind of reset occurred: bus or watchdog?
     iord Status_Control
;Was it a bus reset?
     and A, USBReset
;If yes, jump to handle it.
     jnz BusReset
     iord Status_Control
;Was it a watchdog reset?
     and A, WatchDogReset
;If no, continue to wait for a bus reset
     jz suspendReset
;
;Watchog reset:
;A watchdog reset means that the watchdog timer
;wasn't cleared for 8.192 milliseconds.
;Wait for a bus reset to bring the system alive again.
;Enable 1-millisecond interrupt only
     mov A, TIMER_ONLY
     mov [interrupt_mask],A
     iowr Global_Interrupt
;Wait for a bus reset.
WatchdogHandler:
     jmp WatchdogHandler

suspendReset:
;Return to suspend mode to wait for a USB bus reset.
     mov A, 09h
     iowr Status_Control
     nop
     jmp suspendReset

BusReset:
;Clear all reset bits.
;Set bit 0 (the run bit).
     mov A, RunBit
     iowr Status_Control
;Set up for enumeration (Endpoint 0 and 1-millisecond interrupts enabled)
     mov A, ENUMERATE_MASK
     mov [interrupt_mask],A
     iowr Global_Interrupt

wait:
;Wait until configured.
     iord USB_EP1_TX_Config
     cmp A, 0
;Clear the watchdog timer
     iowr Watchdog
;If not configured, continue to wait.
     jz wait     
;When configured, initialize loop_temp.
;Loop_temp adds a delay in the start of transmission of data.
;The chip will respond to the first IN packet no sooner than 
;230 milliseconds after enumeration is complete.
;The delay was included in Cypress' joystick code to prevent problems 
;that occurred when power cycled off and on or the joystick was plugged
;in before the host powered up.
;I've left it in because it does no harm and 
;other hardware might have similar behavior.
;During the delay, the chip sends a NAK in response to any IN packet.
     mov A, 0ffh
     mov [loop_temp], A

;Enable endpoint 1
     iord USB_EP1_TX_Config
     or A, 92h
     iowr USB_EP1_TX_Config

;======================================================================
; The main program loop.
;======================================================================

main:
;Find out if the loop_temp delay has timed out.
;Loop_temp =0 if not timed out, FFh if timed out.
     mov A, [loop_temp]
     cmp A, 0Ah
;If no, don't enable transmitting.
     jnc no_set
;If yes, enable transmitting.
     mov A, 01h
     mov [start_send], A
no_set:
;Clear the watchdog timer.
;This has to be done at least once every 8 milliseconds!
     iowr Watchdog
     iord Port0_Data
nochange:
     jmp main

;----------------------------------------------------------------------
;The Endpoint 0 ISR supports the control endpoint.
;This code enumerates and configures the hardware.
;It also responds to Set Report requests that receive data from the host.
;----------------------------------------------------------------------

USB_EP0_ISR:
     push A
     iord USB_EP0_RX_Status
;Has a Setup packet been received?
     and A, 01h
;If no, find out if it's an OUT packet.
     jz check_for_out_packet
;If yes, handle it.
;Disable Endpoint 0 interrupts.
     mov A,[interrupt_mask]
     and A, 0F7h
     mov [interrupt_mask], A
     iowr Global_Interrupt
;Find out what the Setup packet contains and handle the request.
      call StageOne
;Re-enable Endpoint 0 interrupts.
     mov A, [interrupt_mask]
     or A, 08h
     mov [interrupt_mask], A
     jmp done_with_packet

check_for_out_packet:
     iord USB_EP0_RX_Status
;Is it an OUT packet?
     and A, 02h
;If no, ignore it.
     jz done_with_packet
;If yes, process the received data.
;Disable Endpoint 0 interrupts.
     mov A,[interrupt_mask]
     and A, 0F7h
     mov [interrupt_mask], A
     iowr Global_Interrupt

;For debugging: set Port 0, bit 1 to show that we're here.
;    iord Port0_Data
;    or a, 2
;    iowr Port0_Data

;Read the first byte in the buffer
     mov a, [Endpoint_0]
;For debugging: if the first byte =12h, bring Port 0, bit 0 high
;      cmp a, 12h
;      jnz not_a_match
;      iord Port0_Data
;      or a, 4
;      iowr Port0_Data

not_a_match:

;For debugging, add 1 to each byte read
;and copy the bytes to RAM.
;These bytes will be sent back to the host.

      push X
      ;data_count holds the number of bytes left to read.
      ;X holds the index of the address to read
      ;and the index of the address to store the received data.
      ;Initialize the X register.
      mov X, 0
      
      Get_Received_Data:
      ;Find out if there are any bytes to read.
      mov A, 0
      cmp A, [data_count]
      ;Jump if nothing to read.
      jz DoneWithReceivedData

      ;Get a byte.
      mov A, [X + Endpoint_0]
      ;For debugging, increment the received value.
      ;(Endpoint 1 will send it back to the host.)
      ;If the value is 255, reset to 0.
      ;Otherwise increment it.
      cmp A, 255
      jz ResetToZero
      inc A
      jmp NewValueSet
      ResetToZero:
      mov A, 0
      NewValueSet:
      ;Save the value.
      mov [X + Data_Byte0], A
      ;Decrement the number of bytes left to read.
      dec [data_count]
      ;Increment the address to read.
      inc X
      ;Do another
      jmp Get_Received_Data

      DoneWithReceivedData:
      pop X

;For debugging, set Port 0 to match the value written.
;     iowr Port0_Data

;Handshake by sending a 0-byte data packet.
call Send0ByteDataPacket

done_with_packet:
;Re-enable Endpoint 0 interrupts.
     mov A,[interrupt_mask]
     or A, 08h
     mov [interrupt_mask], A
     ipret Global_Interrupt

;========================================================================
;Control transfers
;========================================================================

;------------------------------------------------------------------------
;Control transfer, stage one.
;Find out whether the request is a standard device or HID-class request,
;the direction of data transfer, 
;and whether the request is to a device, interface, or endpoint.
;(from Table 9.2 in the USB spec)
;------------------------------------------------------------------------

StageOne:
;Clear the Setup flag
     mov A, 00h
     iowr USB_EP0_RX_Status
;Set the StatusOuts bit to cause auto-handshake after receiving a data packet.
     mov A, 8
     iowr USB_Status_Control
;bmRequestType contains the request.
      mov A, [bmRequestType]

;Standard device requests. From the USB spec.
; host to device requests
        cmp A, 00h
        jz RequestType00                 ; bmRequestType = 00000000 device
;       cmp A, 01h                       *** not required ***  
;       jz RequestType01                 ; bmRequestType = 00000001 interface
        cmp A, 02h              
        jz RequestType02                 ; bmRequestType = 00000010 endpoint
        cmp A, 80h             
; device to host requests
        jz RequestType80                 ; bmRequestType = 10000000 device
        cmp A, 81h
        jz RequestType81                 ; bmRequestType = 10000001 interface
        cmp A, 82h
        jz RequestType82                 ; bmRequestType = 10000010 endpoint

;HID-class device requests. From the HID spec
; host to device requests
        cmp A, 21h
        jz RequestType21                 ; bmRequestType = 00100001 interface
        cmp A, 22h                       ; *** not in HID spec ***
        jz RequestType22                 ; bmRequestType = 00100010 endpoint
; device to host requests
        cmp A, A1h
        jz RequestTypeA1                 ; bmRequestType = 10100001 interface

; Stall unsupported requests
SendStall:
      mov A, A0h
     iowr USB_EP0_TX_Config
      ret

;----------------------------------------------------------------------
;Control transfer, stage two
;Find out which request it is.
;----------------------------------------------------------------------

;Host to device with device as recipient
RequestType00:

;The Remote Wakeup feature is disabled on reset.
     mov A, [bRequest]     ; load bRequest
; Clear Feature                      bRequest = 1
     cmp A, clear_feature
     jz ClearRemoteWakeup 
; Set Feature                     bRequest = 3
     cmp A, set_feature
     jz SetRemoteWakeup

; Set the device address to a non-zero value.
; Set Address                     bRequest = 5
     cmp A, set_address
     jz SetAddress

; Set Descriptor is optional.
; Set Descriptor                bRequest = 7    *** not supported ***

;If wValue is zero, the device is not configured.
;The only other legal value for this firmware is 1.
;Set Configuration           bRequest = 9
    cmp A, set_configuration
    jz SetConfiguration

;Stall unsupported requests.
    jmp SendStall


;Host to device with interface as recipient    *** not required ***
; RequestType01:
;        mov A, [bRequest]       ; load bRequest

; There are no interface features defined in the spec.
; Clear Feature                 bRequest = 1    *** not supported ***
; Set Feature                   bRequest = 3    *** not supported ***

; Set Interface is optional.
; Set Interface                 bRequest = 11   *** not supported ***

;Stall unsupported requests.
;        jmp SendStall

;Host to device with endpoint as recipient
RequestType02:
     mov A, [bRequest]     ; load bRequest

; The only standard feature defined for an endpoint is endpoint_stalled.
; Clear Feature               bRequest = 1
     cmp A, clear_feature
     jz ClearEndpointStall
; Set Feature               bRequest = 3
     cmp A, set_feature
     jz SetEndpointStall
 
;Stall unsupported functions.
    jmp SendStall

;Device to host with device as recipient
RequestType80:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区福利视频| 精品噜噜噜噜久久久久久久久试看| 视频在线在亚洲| 欧美极品美女视频| 91精品久久久久久久99蜜桃| 国产**成人网毛片九色 | 亚洲一区二区三区四区五区黄| 欧美成人伊人久久综合网| 在线精品视频一区二区三四| 国产麻豆日韩欧美久久| 亚洲v精品v日韩v欧美v专区| 国产精品国产自产拍高清av| 精品久久国产97色综合| 欧美日韩一级大片网址| 91香蕉视频mp4| 国产成人丝袜美腿| 亚洲国产日韩一级| 久久久亚洲精品石原莉奈| 精品久久人人做人人爰| 中文字幕亚洲成人| 国产精品夜夜嗨| 久久尤物电影视频在线观看| 亚洲一区欧美一区| 欧美日韩视频一区二区| 亚洲一区二区三区在线| 欧美精品九九99久久| 美女视频黄 久久| 精品电影一区二区| 欧美视频在线一区| 色婷婷激情一区二区三区| www精品美女久久久tv| 国产91色综合久久免费分享| 麻豆国产一区二区| 日韩精品成人一区二区三区 | 国产一区不卡视频| 蜜臀精品一区二区三区在线观看 | 国产激情视频一区二区在线观看| 91精品国产手机| 欧美日韩中文精品| 精品视频一区二区不卡| 色综合色狠狠综合色| 91蜜桃传媒精品久久久一区二区| yourporn久久国产精品| 成人av高清在线| 成人av电影免费在线播放| 岛国av在线一区| 成人免费高清在线观看| 99精品黄色片免费大全| 一本色道久久综合狠狠躁的推荐| 欧美伊人久久大香线蕉综合69 | 国产精品高清亚洲| 亚洲欧洲成人精品av97| 亚洲久本草在线中文字幕| 亚洲一区二区高清| 日韩精品免费视频人成| 久久69国产一区二区蜜臀| 国产91精品精华液一区二区三区 | 精品一区二区三区视频在线观看| 九九久久精品视频| 丁香婷婷综合色啪| 91在线观看下载| 色吊一区二区三区| 91精品国产综合久久精品麻豆| 欧美大白屁股肥臀xxxxxx| 国产色91在线| 一区二区三区四区视频精品免费 | 久久99最新地址| 国产69精品久久777的优势| 91麻豆免费看| 日韩一区二区视频| 欧美国产精品一区| 亚洲国产视频直播| 久久国产尿小便嘘嘘尿| 99久久久久免费精品国产| 欧美性三三影院| 久久在线免费观看| 夜夜精品视频一区二区| 国内久久婷婷综合| 一道本成人在线| 精品乱人伦小说| 亚洲精品成人少妇| 国产一区二区三区免费| 日本高清不卡一区| 亚洲影视在线播放| 看片网站欧美日韩| 91蝌蚪国产九色| 日韩写真欧美这视频| 国产精品色哟哟网站| 日韩电影在线观看电影| 成人动漫一区二区在线| 欧美日韩一区视频| 久久久久久久网| 五月天精品一区二区三区| 成人视屏免费看| 日韩欧美亚洲一区二区| 亚洲欧美电影院| 国产在线一区二区| 91丨九色丨蝌蚪富婆spa| 久久女同互慰一区二区三区| 亚洲一级二级三级在线免费观看| 国产高清无密码一区二区三区| 制服丝袜中文字幕一区| 亚洲天堂2016| 国产伦精品一区二区三区免费| 欧美色综合网站| 亚洲欧洲日韩一区二区三区| 激情综合色综合久久综合| 欧美日韩一区国产| 最新久久zyz资源站| 国产一区不卡精品| 日韩免费福利电影在线观看| 亚洲线精品一区二区三区八戒| 成人综合在线网站| 久久久久久久综合色一本| 免费人成在线不卡| 欧美性色aⅴ视频一区日韩精品| 国产精品美女久久久久aⅴ| 极品尤物av久久免费看| 91精品国产全国免费观看| 亚洲国产cao| 色综合天天性综合| 综合久久久久久| 国产精品66部| 精品久久一区二区三区| 久久福利资源站| 欧美一级国产精品| 天天色天天操综合| 欧美日本在线播放| 亚洲成年人影院| 欧美色综合天天久久综合精品| 亚洲精品中文字幕乱码三区| 91捆绑美女网站| 亚洲欧美电影一区二区| 91网站在线观看视频| 亚洲欧洲精品一区二区三区不卡| 成人av在线播放网址| 国产精品国产精品国产专区不片| www.亚洲激情.com| 亚洲图片激情小说| 色综合久久中文字幕| 亚洲一二三专区| 欧美日高清视频| 日本欧美久久久久免费播放网| 日韩丝袜美女视频| 经典一区二区三区| 久久夜色精品国产噜噜av| 国产福利一区二区三区在线视频| 国产日韩成人精品| 99久久伊人久久99| 亚洲另类色综合网站| 欧美日韩国产综合一区二区 | 日本一区二区免费在线观看视频| 国产风韵犹存在线视精品| 中文字幕不卡一区| 色婷婷综合中文久久一本| 亚洲一区二区三区四区在线| 制服丝袜av成人在线看| 99精品视频在线观看免费| 亚洲欧美韩国综合色| 在线观看一区二区精品视频| 午夜精品一区二区三区三上悠亚 | 久久久久久97三级| eeuss影院一区二区三区| 亚洲自拍偷拍图区| 91精品国产综合久久国产大片| 狠狠色丁香九九婷婷综合五月| 国产欧美精品一区| 色婷婷激情综合| 另类人妖一区二区av| 欧美国产日韩a欧美在线观看| 91精彩视频在线观看| 毛片av中文字幕一区二区| 国产欧美一区二区精品秋霞影院 | 欧洲国内综合视频| 裸体健美xxxx欧美裸体表演| 国产精品美女一区二区三区| 欧美性大战xxxxx久久久| 国模少妇一区二区三区| 日韩毛片一二三区| 欧美一级片在线看| zzijzzij亚洲日本少妇熟睡| 日韩精品一级中文字幕精品视频免费观看 | 亚洲成人综合视频| 久久精品人人做| 欧美色图免费看| 国产成人啪免费观看软件| 夜夜亚洲天天久久| 久久久久久久久久久久久女国产乱| 色婷婷久久综合| 精品一区免费av| 亚洲一区二区三区三| 久久久精品tv| 88在线观看91蜜桃国自产| 成人精品小蝌蚪| 久久99精品视频| 亚洲成人激情自拍| 国产精品萝li| 欧美成人官网二区| 精品婷婷伊人一区三区三| 99久久久精品|