?? lpnonstreaming.asm
字號(hào):
;--------------------------------------------------------------------------
;
; Filename: lpnonstreaming.asm
;
; Description: User functions to access the LP radio. This file contains
; the functions and support for the actual operational
; routines that actually perform transmit and receive
; operations. These are the functions that change between the
; streaming and non-streaming versions of the driver.
;
; This is the non-streaming version of the LP radio driver
;
;--------------------------------------------------------------------------
; WirelessUSB LP Radio Driver Version 1.0
; $Revision: 3 $
;--------------------------------------------------------------------------
;
; Copyright 2005-2006, Cypress Semiconductor Corporation.
;
; This software is owned by Cypress Semiconductor Corporation (Cypress)
; and is protected by and subject to worldwide patent protection (United
; States and foreign), United States copyright laws and international
; treaty provisions. Cypress hereby grants to licensee a personal,
; non-exclusive, non-transferable license to copy, use, modify, create
; derivative works of, and compile the Cypress Source Code and derivative
; works for the sole purpose of creating custom software in support of
; licensee product to be used only in conjunction with a Cypress integrated
; circuit as specified in the applicable agreement. Any reproduction,
; modification, translation, compilation, or representation of this
; software except as specified above is prohibited without the express
; written permission of Cypress.
;
; Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
; WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
; Cypress reserves the right to make changes without further notice to the
; materials described herein. Cypress does not assume any liability arising
; out of the application or use of any product or circuit described herein.
; Cypress does not authorize its products for use as critical components in
; life-support systems where a malfunction or failure may reasonably be
; expected to result in significant injury to the user. The inclusion of
; Cypress' product in a life-support systems application implies that the
; manufacturer assumes all risk of such use and in doing so indemnifies
; Cypress against all charges.
;
; Use may be limited by and subject to the applicable Cypress software
; license agreement.
;
;--------------------------------------------------------------------------
;--------------------------------------------------------------------------;
; ;
; I N C L U D E F I L E S ;
; ;
;--------------------------------------------------------------------------;
INCLUDE "lpradio.inc"
INCLUDE "spim_radio.inc"
INCLUDE "psocgpioint.inc"
INCLUDE "lpregs.inc"
INCLUDE "m8c.inc"
INCLUDE "irqmacros.inc"
;--------------------------------------------------------------------------;
; ;
; V A R I A B L E S ;
; ;
;--------------------------------------------------------------------------;
AREA bss
RadioBytesRead:: BLK 1 ; Can we fold this into one of the other variables?
RadioRssiShadow: BLK 1 ; Can we fold this into one of the other variables?
;--------------------------------------------------------------------------;
; ;
; C O D E ;
; ;
;--------------------------------------------------------------------------;
AREA UserModules (ROM, REL)
;
; Disable the code compressor.
;
DISABLE_CODE_COMPRESSION
;--------------------------------------------------------------------------;
; ;
; T R A N S M I T a n d R E C E I V E ;
; ;
;--------------------------------------------------------------------------;
.section
;--------------------------------------------------------------------------------
;
; RadioStartTransmit:
; Start the transmission of a packet. The location of the
; packet buffer to transmit must have previously been set
; with a call to RadioSetPtr.
;
; After starting the transmission of a packet with this call,
; the state of the transmit operation should be check by
; calling RadioGetTransmitState. When RadioGetTransmitState
; indicates that the transmission has completed a call
; should be made to RadioEndTransmit.
;
; After calling RadioStartTransmit NO CALLS can be made to the
; configuration access routines until the transmit operation is
; terminated with a call to RadioEndTransmit or RadioAbort.
; Until one of those calls is made to end the transmit operation
; the only other call supported is RadioGetTransmitState.
;
; 'C' Call: void RadioStartTransmit(BYTE retryCount, RADIO_LENGTH length);
; (A call to RadioSetPtr must have been made prior to the
; call to RadioStartTransmit.)
;
; Assembly Call: A: retry count
; X: packet length
;
; Assembly Return: A: Undefined
; X: Undefined
;
_RadioStartTransmit::
RadioStartTransmit::
MOV [RadioRetryCount], A ; Save count
MOV [RadioPacketLength], X ; and length.
RadioRestartTransmit:
MOV [RadioState], RADIO_TX
MOV [RadioTemp2], ( TX_GO | TX_CLR | TXC_IRQ | TXE_IRQ) ; the current value.
;
; The write that starts the transmit and the movement of the data into the buffer
; must happen atomically. There can be no interrupt caused delay between them.
;
.ShortPacket: PUSH_F_MESSY
PUSH_PERM_IE_THROUGH_A
CLEAR_PERM_IE
CLEAR_TEMP_IE
MOV [RadioWipPtr], <RadioTemp1 ; Burst write the
MOV A, TX_LENGTH_ADR ; to start the TX.
MOV X, 2
MOV [RadioWipLen], X
CALL RadioBurstWriteWip ; Write length and TX control as burst.
MOV X, [RadioPacketLength]
MOV A, TX_BUFFER_ADR
CALL RadioFileWrite ; Burst the data in
POP_PERM_IE_THROUGH_A
POP_F_RET ; Restore the IRQ enablement state.
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioGetTransmitState:
; Returns the state of the current transmit operation.
; This call should be made after starting a transmit
; operation with the RadioStartTransmit function.
;
; Although the bits in the status register in the hardware clear
; automatically, we make them sticky until the RadioEndReceive.
;
; 'C' Call: RADIO_STATE RadioGetTransmitState(void);
;
; Assembly Call: A: Unused
; X: Unused
;
; Assembly Return: A: State
; X: Undefined
;
_RadioGetTransmitState::
RadioGetTransmitState::
;
; Poll the IRQ line to see if there is something to do.
;
TST REG[LP_IRQ_Data_ADDR], LP_IRQ_MASK ; Has the interrupt asserted?
JZ RGTSDone ; No, just return the state.
;
; Something interesting is happening at the IRQ, find out what.
;
RadioGetTransmitStateIsr:
MOV A, TX_IRQ_STATUS_ADR
CALL RadioReadStatusDebounced
AND A, (TXE_IRQ | TXC_IRQ)
OR [RadioState], A
CMP A, TXC_IRQ
JZ RGTSDone
;
; Workaround for CDT3847. When this issue occurs, the IRQ is asserted while both TXC and TXE are not set.
; Read the RX_IRQ_STATUS register will clear up the IRQ. We don't need to do the read if there is just a
; simple error, but no harm.
;
MOV A, RX_IRQ_STATUS_ADR ; Clear the RX IRQ.
CALL RadioRead
OR [RadioState], (TXE_IRQ | TXC_IRQ)
;
; Maybe retry the failed transmit.
;
MOV A, [RadioRetryCount]
JZ RGTSDone
DEC [RadioRetryCount] ; Decrement the TX retry count
CALL RadioRestartTransmit ; Try again.
RGTSDone: MOV A, [RadioState]
RET
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioEndTransmit:Completes a transmit operation.
;
; 'C' Call: void RadioEndTransmit(void);
;
; Assembly Call: A: Unused
; X: Unused
;
; Assembly Return: A: Undefined
; X: Undefined
;
_RadioEndTransmit::
RadioEndTransmit::
RadioEndOperation:
RadioDone: 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 retryCount, RADIO_LENGTH length);
; (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
.WaitLoop: CALL RadioGetTransmitState
MOV [RadioTemp2], A
TST [RadioTemp2], TXC_IRQ | TXE_IRQ
JZ .WaitLoop
CALL RadioEndTransmit
MOV A, [RadioTemp2]
RET
.endsection
.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.
;
; The receive is started by hitting the "RX_GO" bit. All the
; 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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -