[<<][staapl][>>][..]
Fri Jun 15 16:08:48 EDT 2012

Opti stuff


Might need to revert.  The building blocks seem to work but driver
doesn't respond to first SETUP packet.  EDIT: fixed.  problem was
different interface for OUT/DATA0.


\ PIC18 specific (since USB is also PIC specific): use rot<<, indirect
\ addressing using a register, and assumption that >r and r> can span
\ across procedures.
  

\ ep -- bd    
: IN    rot<< 1 + ;
: OUT   rot<< ;

\ Toggle mask for stat+ : bit 7 for and, bit 6 for xor.    
: DATA0  #x00 ; \ 0 and 0 xor
: DATA+  #xC0 ; \ 1 and 1 xor
: DATA1  #x40 ; \ 0 and 1 xor

macro
\ Just needed once, so use macros  

: bdaddr \ n -- lo hi
    rot<< rot<< 4 ; 

\ Update status register     
: stat+ \ togglemask ustat -- ustat+
    over rot>> and xor  \ Apply togglemask to DATAx bit
    #x40 and            \ Keep only DATAx, rest was filled by USB
    #x88 or ;           \ UOWN set to USB, DTSEN=1, KEN=0, INCDIS=0, BSTALL=0
    
forth
    
\ Prepare buffer descriptor to send to USB transceiver with updated
\ DATAx and buffer size.  Destroys `a' reg.  
  
: >usb \ n bd x --
    a>r
      >r bdaddr ah ! al ! r>
      @a+      \ STAT @
      stat+ >r
      !a-      \ CNT !
      r> !a    \ r> STAT ! 
    r>a ;
    
: OUT/DATA0 OUT DATA0 >usb ;
: IN/DATA0  IN  DATA0 >usb ;
: IN/DATA1  IN  DATA1 >usb ;    
: IN/DATA+  IN  DATA+ >usb ;    



[Reply][About]
[<<][staapl][>>][..]