You are on page 1of 4

DEFINE OSC 48 DEFINE LOADER_USED 1 USBBufferSizeMax USBBufferSizeTX USBBufferSizeRX con 8 ' maximum buffer size con 8 ' input

con 8 ' output

' the USB buffer... USBBuffer Var Byte[USBBufferSizeMax] USBBufferCount Var Byte TRISB = 255 TRISA = %00000000 PORTA = %00000000 usbinit ' initialise USB... USBbuffer[0] USBbuffer[1] USBbuffer[2] USBbuffer[3] USBbuffer[4] USBbuffer[5] USBbuffer[6] USBbuffer[7] = = = = = = = = 0 0 0 0 0 0 0 0

Tip: USBService PORTA = %00000000 If PORTB = 254 then USBbuffer[2] = $38 gosub DoUSBOut goto Deba endif If PORTB = 253 then USBbuffer[3] = $1D gosub DoUSBOut goto Deba endif If PORTB = 252 then USBbuffer[2] = $38 USBbuffer[3] = $1D gosub Dousbout goto Deba endif If PORTB.7 = 0 then PORTA = %00000001 USBbuffer[0] = $0 USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB.6 = 0 then USBbuffer[0] = $0 USBbuffer[2] = $28 USBbuffer[3] = $0 gosub Dousbout goto Enter endif

If PORTB.5 = 0 then USBbuffer[0] = $0 USBbuffer[2] = $2A USBbuffer[3] = $0 gosub DoUsbout goto Back endif If PORTB.4 = 0 then USBbuffer[0] = $0 USBbuffer[2] = $1B USBbuffer[3] = $0 gosub Dousbout goto NudL endif If PORTB.3 = 0 then USBbuffer[0] = $0 USBbuffer[2] = $37 USBbuffer[3] = $0 gosub Dousbout goto NudR endif If PORTB.2 = 0 then USBbuffer[0] = $0 USBbuffer[2] = $06 USBbuffer[3] = $0 gosub DoUSBOut goto Shotagain endif

goto tip Deba: If PORTB.7 = 0 then USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB = 254 then USBbuffer[2] = $38 USBbuffer[3] = $0 gosub Dousbout endif If PORTB = 253 then USBbuffer[2] = $0 USBbuffer[3] = $1D gosub Dousbout endif If PORTB = 255 then USBbuffer[2] = $0 USBbuffer[3] = $0 gosub Dousbout else goto Tip endif goto Deba

Enter: usbservice If PORTB.7 = 0 then USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB.6 = 0 then goto enter else USBbuffer[2] = $0 gosub Dousbout goto Tip endif goto Enter Navi: usbservice If PORTB.7 = 0 then goto Navi else USBbuffer[2] = $0 gosub Dousbout PORTA = %00000000 goto Tip endif goto Navi Back: usbservice If PORTB.7 = 0 then USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB.5 = 0 then goto Back else USBbuffer[2] = $0 gosub Dousbout goto tip endif goto Back NudL: usbservice If PORTB.7 = 0 then USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB.4 = 0 then goto NudL else USBbuffer[2] = $0 gosub Dousbout goto tip

Endif goto Nudl NudR: usbservice If PORTB.7 = 0 then USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB.3 = 0 then goto NudR else USBbuffer[2] = $0 gosub Dousbout goto tip Endif goto NudR Shotagain: usbservice If PORTB.7 = 0 then USBbuffer[2] = $16 USBbuffer[3] = $0 gosub Dousbout goto Navi endif If PORTB.2 = 0 then goto Shotagain else USBbuffer[2] = $0 gosub Dousbout goto Tip endif goto Shotagain

DoUSBOut: USBBufferCount = USBBufferSizeTX ' TX buffer size USBService ' keep connection alive USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit da ta return Dousbin: USBBufferCount = USBBufferSizeRX USBService USBIn 1, USBBuffer, USBBufferCount, Dousbin return end ' RX buffer size ' keep connection alive ' read data, if available

You might also like