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

📄 lpradio.asm

📁 CYRF6936 zigbee模块设计的全部资料
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;--------------------------------------------------------------------------
;
;  Filename:    lpradio.asm
;
;  Description: User functions to access the LP radio configuration. These
;               functions are the same for the both the streaming and
;               non-streaming versions of the 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 "irqmacros.inc"

;--------------------------------------------------------------------------;
;                                                                          ;
;                            V A R I A B L E S                             ;
;                                                                          ;
;--------------------------------------------------------------------------;

                   AREA    bss

_RadioXactConfig::
RadioXactConfig::  BLK     1                           ; Current value of XACT_CFG_ADDR.
_RadioState::
 RadioState::      BLK     1                           ; The current rx or tx state.

RadioTxCount::
RadioConstAddrLo:  BLK     1                           ; Parameter to Radio TX and RX routines.

;
; These variables are re-used to the point of confusion. They are commonly used for different
;  functions, but occasionally used together as a buffer to burst into the radio registers.
;  The RadioPacketLength field is used during async rx and tx operations and therefore it
;  is NOT valid to call any functions that use it for any other purpose between a start/end
;  rx/tx pair.
;
RadioConstAddrHi:
RadioPacketLength::
RadioTemp1::       BLK     1                           ; A work area used for short bursts.

RadioFileAddr:
RadioTxControl::
RadioTemp2::       BLK     1                           ;  and other temp uses.

RadioCount:
RadioRetryCount::                                                      
RadioTemp3::       BLK     1

;--------------------------------------------------------------------------;
;                                                                          ;
;                                 C O D E                                  ;
;                                                                          ;
;--------------------------------------------------------------------------;

                   AREA    UserModules (ROM, REL)

;--------------------------------------------------------------------------;
;                                                                          ;
;                      I N I T I A L I Z A T I O N                         ;
;                                                                          ;
;--------------------------------------------------------------------------;

;
; This is all carefully crafted assembly. We do not want the code compressor
;  to attempt to optimize it by break it into little subroutines.
;
                   DISABLE_CODE_COMPRESSION            ; Code breaks if "subroutinized".

.section
;--------------------------------------------------------------------------
;
; RadioInit:       Initialize the Radio.
;
; 'C' Call:        void RadioInit(XACT_CONFIG xactConfig, TX_CONFIG txConfig);
;
; Assembly Call:   A: xactConfig
;                  X: txConfig
;
; Assembly Return: A: Garbage
;                  X: Garbage
;
_RadioInit::
 RadioInit::       MOV     [RadioTemp1], A
                   MOV     [RadioTemp2], X
                   
                   MOV     [RadioXactConfig], XACT_CFG_RST
                   
                   CALL    RadioReset

;
; We're going to want to force the RXF clock on in the streaming driver.
; Not necessary for nonstreaming driver but harmless.
;
                   MOV     A, CLK_EN_ADR
                   MOV     X, RXF
                   CALL    RadioWrite

;
; Set up to use auto-cal for VCO. Register 0x34 is left at its default value to
;  allow auto-cal to be used.
;
                   MOV     A, AUTO_CAL_TIME_ADR          ; Extend autoCal time to max.
                   MOV     X, AUTO_CAL_TIME_MAX
                   CALL    RadioWrite

                   MOV     A, AUTO_CAL_OFFSET_ADR        ; AutoCal offset to -4.
                   MOV     X, AUTO_CAL_OFFSET_MINUS_4
                   CALL    RadioWrite
                   
                   MOV     A, IO_CFG_ADR                 ; Read IO_CFG_ADR, user may have
                   CALL    RadioRead                     ;  changed it in RadioReset
                   OR      A, IRQ_POL                    ; Set IRQ polarity to positive.
                   MOV     X, IO_CFG_ADR                 ;  (Some have asked that this be
                   CALL    RadioWriteSwapped             ;  left at the default negative.)
;
; Set the XTAL Startup delay to 150uSec to handle warm restarts of the XTAL. 
;
                   MOV     A, XTAL_CFG_ADR
                   MOV     X, 0x08
                   CALL    RadioWrite
;
; Enable HiLo for quick-turn-around. Use low side injection for receive - this should result in
;  non-inverted data, so no need to hit the invert bit. Turn off AGC and force the LNA on.
; 
                   MOV     A, RX_CFG_ADR
                   MOV     X, (( RX_CFG_RST | FASTTURN_EN | LNA_EN ) & ~( HI | RXOW_EN | AUTO_AGC_EN ))
                   CALL    RadioWrite
;
; Set the TX Offset to +1MHz.
;
; THIS MEANS THE ACTUAL TRANSMIT CARRIER WILL BE 1MHz ABOVE THE PLL
;  FREQUENCY PROGRAMMED IN THE CHANNEL OR A & N REGISTERS.
;  RadioSetFrequency COMPENSATES FOR THIS OFFSET.
;
                   MOV     A, TX_OFFSET_LSB_ADR
                   MOV     X, 055h
                   CALL    RadioWrite
                   MOV     A, TX_OFFSET_MSB_ADR
                   MOV     X, 005h
                   CALL    RadioWrite
;
; Set the radio transaction and TX configuration.
;                   
                   MOV     A, [RadioTemp1]
                   CALL    RadioSetXactConfig
                   MOV     A, [RadioTemp2]
                   CALL    RadioSetTxConfig
 
                   MOV     [RadioState], RADIO_IDLE
                   RET
.endsection

;--------------------------------------------------------------------------;
;                                                                          ;
;                        C O N F I G U R A T I O N                         ;
;                                                                          ;
;--------------------------------------------------------------------------;

.section
;--------------------------------------------------------------------------------
;
; RadioSetChannel:
;                  Set the channel (frequency + 2MHz).
;
; 'C' Call:        void RadioSetChannel(BYTE channel);
;
; Assembly Call:   A: frequency
;                  X: Unused
;
; Assembly Return: A: Undefined
;                  X: Undefined
;
; Note:            FALL THROUGH INTO RadioSetFrequency.
;
 RadioSetChannel::
_RadioSetChannel::
                   ADD     A, 2

.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioSetFrequency:
;                  Set the frequency on which future communications will occur.
;
;                  THIS DRIVER SETS THE TX OFFESET AT 1 WHICH MEANS THAT THE TX
;                  CARRIER WILL BE 1MHz HIGHER THAN THE CHANNEL NUMBER WE PROGRAM.
;                  THIS FUNCTION COMPENSATES FOR THAT OFFSET BY DECREMENTING THE
;                  CHANNEL NUMBER.
;
; 'C' Call:        void RadioSetFrequency(BYTE frequency);
;
; Assembly Call:   A: frequency
;                  X: Unused
;
; Assembly Return: A: Undefined
;                  X: Undefined
;
 RadioSetFrequency::
_RadioSetFrequency::
                   CMP     A, 0
                   JZ      .Channel0
                   DEC     A
.Channel0:         MOV     X, CHANNEL_ADR              ; Write into the channel register.
                   JMP     RadioWriteSwapped

.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioGetChannel:
;                  Get the channel.
;
; 'C' Call:        BYTE RadioGetChannel(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: channel
;                  X: Undefined
;
 RadioGetChannel::
_RadioGetChannel::
                   CALL    RadioGetFrequency
                   SUB     A, 2
                   RET

.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioGetFrequency:
;                  Returns the frequency in MHz above 2.4GHz. 
;                  Example: 0 means 2.400GHz, 83 means 2.483GHz.
;
; 'C' Call:        BYTE RadioGetFrequency(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: frequency
;                  X: Undefined
;
 RadioGetFrequency::
_RadioGetFrequency::
                   MOV     A, CHANNEL_ADR              ;  into the channel register.
                   CALL    RadioRead
                   INC     A
                   RET

.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioSetTxConfig:Set the transmitter configuration.
;
; 'C' Call:        void RadioSetTxConfig(TX_CONFIG config);
;
; Assembly Call:   A: config
;                  X: Unused
;
; Assembly Return: A: Undefined
;                  X: Undefined
;
_RadioSetTxConfig::
 RadioSetTxConfig::MOV     X, TX_CFG_ADR
                   JMP     RadioWriteSwapped
                    
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioGetTxConfig:Return the transmitter configuration.
;
; 'C' Call:        TX_CONFIG RadioGetTxConfig(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: config
;                  X: Undefined
;
_RadioGetTxConfig::
 RadioGetTxConfig::MOV     A, TX_CFG_ADR
                   JMP     RadioRead
                    
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioSetXactConfig:
;                  Set the transaction configuration.
;
; 'C' Call:        void RadioSetXactConfig(XACT_CONFIG config);
;
; Assembly Call:   A: config
;                  X: Unused
;
; Assembly Return: A: Undefined
;                  X: Undefined
;
_RadioSetXactConfig::
 RadioSetXactConfig::
                   MOV    [RadioXactConfig], A
                   AND    [RadioXactConfig], ~FRC_END_STATE
                   
;
; Force the bits we don't want the user to fiddle.
;
                   MOV     X, XACT_CFG_ADR
                   JMP    RadioWriteSwapped
                   
                    
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioGetXactConfig:
;                  Return the transaction configuration.
;
; 'C' Call:        XACT_CONFIG RadioGetXactConfig(void);
;
; Assembly Call:   A: Unused
;                  X: Unused
;
; Assembly Return: A: config
;                  X: Undefined
;
_RadioGetXactConfig::
 RadioGetXactConfig::
                   MOV     A, XACT_CFG_ADR
                   JMP     RadioRead
                    
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioSetFrameConfig:
;                  Set the framing configuration.
;
; 'C' Call:        void RadioSetFrameConfig(RADIO_FRAME_CONFIG config);
;
; Assembly Call:   A: config
;                  X: Unused
;
; Assembly Return: A: Undefined
;                  X: Undefined
;
_RadioSetFrameConfig::
 RadioSetFrameConfig::
                    MOV     X, FRAMING_CFG_ADR
                    JMP     RadioWriteSwapped
                    
.endsection
.section
;--------------------------------------------------------------------------------
;
; RadioGetFrameConfig:
;                  Set the framing configuration.

⌨️ 快捷键说明

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