⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lpnonstreaming.asm

📁 the newest cypress wirelessusb LP and PROC LP radio driver
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        RET

;-----------------------------------------------------------------------------
;
; RadioEndTransmit: Completes a transmit operation.
;
; 'C' Call:        void RadioEndTransmit(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: Preserved
;                  X: Undefined
;
_RadioEndTransmit::
 RadioEndTransmit::
        RAM_SETPAGE_CUR >RadioDriverRamPage
        MOV     [RadioState], RADIO_IDLE        ; Clear our status.
        RET
.endsection

.section
;-----------------------------------------------------------------------------
;
; RadioBlockingTransmit:
;                  Transmit a packet. Block execution until it completes.
;                  This function attempts to transmit a packet. The address
;                  of the packet buffer should have previously been set with
;                  a call to RadioSetPtr.
;
;                  This routine gives the user very little control - probably
;                  less than most applications will require. This function is
;                  primarily intended for very simple applications that have
;                  no use for a time-out.
;
; 'C' Call:        RADIO_STATE RadioBlockingTransmit(BYTE retryCt,
;                                                    RADIO_LENGTH len);
;                  (A call to RadioSetPtr must have been made prior to the
;                  call to RadioBlockingTransmit.)
;
; Assembly Call:   A: retryCount
;                  X: length
;                  RadioPtr: Address of packet buffer
;                  
; Assembly Return: A: RADIO_STATE
;                  X: Undefined
;-----------------------------------------------------------------------------
_RadioBlockingTransmit::
 RadioBlockingTransmit::
        CALL    RadioStartTransmit
                   
.Wait:  CALL    RadioGetTransmitState
        MOV     [RadioTemp2], A
        TST     [RadioTemp2], TXC_IRQ | TXE_IRQ
        JZ      .Wait

        JMP     RadioEndTransmit        ; A = RADIO_STATE
.endsection

;--------------------------------------------------------------------------;
;                                                                          ;
;                 R E C E I V E                                            ;
;                                                                          ;
;--------------------------------------------------------------------------;
.section
;-----------------------------------------------------------------------------
;
; RadioStartReceive:
;                  Start the reception of a packet. The location and length of
;                  the packet buffer to receive the data into must have
;                  previously been set with a call to RadioSetPtr and
;                  RadioSetLength.
;
;                  After starting the reception of a packet with this call,
;                  the state of the receive operation should be checked by
;                  calling RadioGetReceiveState. When RadioGetReceiveState
;                  indicates that the transmission has completed a call
;                  should be made to RadioEndReceive.
;
;                  Receive is started by setting RX_GO" bit. All interesting
;                  interrupt enables are set and RadioGetReceiveState
;                  can be called in a polling loop in systems that do not use
;                  interrupts, or can be called directly in an interrupt
;                  handler.
;
;                  After calling RadioStartReceive NO CALLS can be made to the
;                  configuration access routines until receive operation is
;                  terminated with a call to RadioEndReceive or RadioAbort.
;                  Until a call is made to end the receive operation
;                  the only other calls supported are RadioGetReceiveState and
;                  RadioGetRssi.
;
; 'C' Call:        void RadioStartReceive(void);
;                  (A call to RadioSetPtr must have been made prior to the
;                  call to RadioStartReceive.)
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: Undefined
;                  X: Undefined
;-----------------------------------------------------------------------------
_RadioStartReceive::
 RadioStartReceive::
        RAM_SETPAGE_CUR >RadioDriverRamPage
  IF (SYSTEM_LARGE_MEMORY_MODEL)
        MOV     [RadioWipPtr+1], [RadioPtr+1] ; MSByte of pointer
  ENDIF
        MOV     [RadioWipPtr+0], [RadioPtr+0]
        MOV     [RadioWipLen],   [RadioLen]   ; sizeof(RadioPtr)
        MOV     [RadioState], RADIO_RX
        MOV     [RadioBytesRead], 0

        CALL    wakeupRadio

        MOV     A, RX_CTRL_ADR
        MOV     X, (RX_GO | RXC_IRQ | RXE_IRQ)
        CALL    RadioWrite

        MOV     A, RX_IRQ_STATUS_ADR
        JMP     RadioRead               // Clr SOP detect bit
                    
;-----------------------------------------------------------------------------
;
; RadioGetReceiveState:
;                  Returns the state of the current receive operation.
;                  This call should be made after RadioStartReceive()
;
;                  Although  bits in the state register in the hardware clear
;                  automatically, we make them sticky until RadioEndReceive.
;
; 'C' Call:        RADIO_STATE RadioGetReceiveState(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: State
;                  X: Undefined
;-----------------------------------------------------------------------------
_RadioGetReceiveState::
 RadioGetReceiveState::
        RAM_SETPAGE_CUR >RadioDriverRamPage
        TST_IRQ_PIN
        JZ      exitRx                  ; Nothing interesting, exit

RadioGetReceiveStateIsr:                ; Entry via RadioInterrupt() wrapper
        MOV     A, RX_IRQ_STATUS_ADR
        CALL    RadioReadStatusDebounced
        AND     A, (RXBERR_IRQ | RXE_IRQ | RXC_IRQ)
        OR      [RadioState], A         ; Make bits sticky

        TST     [RadioState], (RXBERR_IRQ | RXE_IRQ) ; If Error,
        JZ      exitRx                               ;  then set RXC/RXE
        OR      [RadioState], (RXC_IRQ | RXE_IRQ)    ;  because radio is done

exitRx:
        MOV     A, [RadioState]         ;  State calls and return them.
        RET                    
    
;-----------------------------------------------------------------------------
;
; RadioEndReceive: Complete a receive operation.
;
; 'C' Call:        RADIO_LENGTH RadioEndReceive(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: # of bytes copied to User's Buf
;                  X: Undefined
;-----------------------------------------------------------------------------
_RadioEndReceive::
 RadioEndReceive::
        MOV     A, RX_CFG_ADR           ; Read current VLD_EN setting
        CALL    RadioRead               ; (RadioRead also sets CUR_PP)
        MOV     [RadioTemp3], A         ;

        MOV     A, RX_COUNT_ADR         ; Total # bytes through RFIFO
        CALL    RadioRead               ; (RadioRead also sets CUR_PP)
        TST     [RadioTemp3], VLD_EN
        JZ      .S2                     ; Normal (VLD_EN == 0)
        ASL     A                       ; 2x, every data byte has a valid byte
.S2:    MOV     [RadioTemp3], A         ; # Bytes in RFIFO

        TST     [RadioState], RXE_IRQ   ;
        JZ      .S1                     ; No error, unload the final byte(s)
        MOV     A, LP_FIFO_SIZE         ; RXE, purge full RFIFO to recove
.S1:
        MOV     X, RX_BUFFER_ADR
        SWAP    A, X
        CALL    RadioFileReadWip        ; Final RFIFO unload

        ; --------------------------------------------------------------------
        ; If User wanted END_STATE_SLEEP, then undo 
        ;  RadioStartReceive()'s intermediate END_STATE_IDLE override.
        ; --------------------------------------------------------------------
        IsRadioSleep                    ; If user's end state != SLEEP
        JNZ     isAwake                 ;  then no workaround was invoked.

        ; --------------------------------------------------------------------
        ; RadioRxCleanup() - end of RadioAbort() 
        ; --------------------------------------------------------------------
RadioRxCleanup:                         ;
        MOV     A, [RadioXactConfig]    ;
        OR      A, FRC_END_STATE        ; Force to User's desired end-state
        MOV     X, XACT_CFG_ADR         ;
        CALL    RadioWriteSwapped       ;
.wait:  MOV     A, XACT_CFG_ADR         ; Wait for FRC_END_STATE bit in
        CALL    RadioRead               ;  XACT_CFG register to clear
        AND     A, FRC_END_STATE        ;  indicating the Force End is
        JNZ     .wait                   ;  complete.
        ; ------------------------------

isAwake:
        MOV     A, [RadioTemp3]         ; Byte count
        JMP     RadioEndTransmit        ; Set radio mode IDLE
.endsection


.section
;-----------------------------------------------------------------------------
;
; RadioForceState:  Force radio to desired state NOW.
;                   Updates global RadioXacConfig shadow variable.
;                   Sometimes used to wake/sleep radio to measure voltage.
;
;  We must ensure SLEEP only transitions to IDLE (and recovers if problem).
;  RadioForceState(END_STATE_IDLE) MUST be called prior to TX_GO or RX_GO 
;   whenever radio may be in SLEEP.
;
; 'C' Call:        void RadioForceState(XACT_CONFIG endStateBitsOnly);
;
; Assembly Call:   A: RadioXactConfig END_STATE bits only, no ACK_EN, ACK_TO
;                  X: Undefined
;
; Assembly Return: A,X: Undefined
;-----------------------------------------------------------------------------
_RadioForceState::
 RadioForceState::
        RAM_SETPAGE_CUR >RadioDriverRamPage

        ; Only invoke when radio is in SLEEP

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -