DT USB Flags


Results 1 to 5 of 5

Thread: DT USB Flags

Threaded View

  1. #2
    Join Date
    Sep 2009
    Posts
    755

    Default Re: DT USB Flags

    That is ASM syntax.
    DEFINE's are just passed to LST file, after compile.
    There is no direct connection between that two pice of code.
    LED's are turned on/off with macro's in DT_HID260.pbp
    MACROs for LED:
    Code:
    ASM
        ifndef  USB_LEDPOLARITY          ; If LED polarity wasn't specified?
    USB_LEDPOLARITY = 1                  ;   default to ON when HIGH
        endif
        
    ;-------------------------------     
    LEDOFF  macro Port, Bit              ; -- Turn LED OFF --
        if (USB_LEDPOLARITY == 1)        ;   If LED is ON when HIGH?
            LOW?T  Port, Bit             ;     make it LOW
        else                             ;   otherwise
            HIGH?T Port, Bit             ;     make it HIGH
        endif
      endm
    
    ;-------------------------------  
    LEDON  macro Port,Bit                ; -- Turn LED ON --
        if (USB_LEDPOLARITY == 1)        ;   If LED is ON when HIGH?
            HIGH?T Port, Bit             ;     make it HIGH
        else                             ;   otherwise
            LOW?T  Port, Bit             ;     make it LOW
        endif
      endm
    
    ;-------------------------------  
    ifLEDisON  macro Port,Bit, Label
        if (USB_LEDPOLARITY == 1)        ; if LED is ON when HIGH
            btfsc   Port, Bit            ;   and the pin is LOW
        else                             ; or if LED is ON when LOW
            btfss   Port, Bit            ;   and the pin is HIGH
        endif                            ; then the LED is OFF
        goto      Label                  ;    so don't jump to the label
      endm                                       
    ;-------------------------------  
    ifLEDisOFF  macro Port,Bit, Label
        if (USB_LEDPOLARITY == 1)        ; if LED is ON when HIGH
            btfss   Port, Bit            ;   and the pin is HIGH
        else                             ; or if LED is ON when LOW
            btfsc   Port, Bit            ;   and the pin is LOW
        endif                            ; then the LED is ON
        goto      Label                  ;    so don't jump to the label
      endm  
    ENDASM
    As you can see from macros, Darrel used HIGH and LOW commands from PBP to handle BANK, TRIS, and output register of port.

    To turn TX LED:
    Code:
    ;----[Send USB data]--------------------------------------------------------
    DoUSBOut:
        ASM
            ifdef    USB_TXLED
                LEDON  USB_TXLED
            endif  
        ENDASM
    ....
    He call LED macro from DoUSBOut subrutine...

    Code:
    DoUSBService:
        INTS_FROM = INTS_FROM | UIR
    ASM
       ifdef USB_ServiceLED
         LEDON  USB_ServiceLED
       endif
    ENDASM
    etc...
    Last edited by pedja089; - 7th April 2015 at 17:16.

Similar Threads

  1. USB to USB flash Drive File Copier
    By surya089 in forum USB
    Replies: 2
    Last Post: - 16th December 2012, 01:22
  2. USB to USB flash Drive File Copier
    By emildownloads in forum General
    Replies: 222
    Last Post: - 27th October 2011, 01:23
  3. LCD issue - what does FLAGS = 0 really do?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th February 2008, 05:26
  4. set flags within a variable?
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th October 2006, 11:07
  5. trouble with FLAGs
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 10th November 2004, 02:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts