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

📄 mac_csp_tx.lst

📁 cc2430应用实例
💻 LST
📖 第 1 页 / 共 5 页
字号:
     63          #define RPT(c)      (0xA0 | ((c) & 0x0F))  /* if condition is true jump to last label             */
     64          #define INT         (0xB9)                 /* assert IRQ_CSP_INT interrupt                        */
     65          #define INCY        (0xBD)                 /* increment CSPY                                      */
     66          #define INCMAXY(m)  (0xB0 | ((m) & 0x07))  /* increment CSPY but not above maximum value of 'm'   */
     67          #define DECY        (0xBE)                 /* decrement CSPY                                      */
     68          #define DECZ        (0xBF)                 /* decrement CSPZ                                      */
     69          #define RANDXY      (0xBC)                 /* load the lower CSPY bits of CSPX with random value  */
     70          
     71          /* strobe processor command instructions */
     72          #define SSTOP       (0xDF)    /* stop program execution                                      */
     73          #define SNOP        (0xC0)    /* no operation                                                */
     74          #define STXCALN     (0xC1)    /* enable and calibrate frequency synthesizer for TX           */
     75          #define SRXON       (0xC2)    /* turn on receiver                                            */
     76          #define STXON       (0xC3)    /* transmit after calibration                                  */
     77          #define STXONCCA    (0xC4)    /* transmit after calibration if CCA indicates clear channel   */
     78          #define SRFOFF      (0xC5)    /* turn off RX/TX                                              */
     79          #define SFLUSHRX    (0xC6)    /* flush receive FIFO                                          */
     80          #define SFLUSHTX    (0xC7)    /* flush transmit FIFO                                         */
     81          #define SACK        (0xC8)    /* send ACK frame                                              */
     82          #define SACKPEND    (0xC9)    /* send ACK frame with pending bit set                         */
     83          
     84          /* conditions for use with instructions SKIP and RPT */
     85          #define C_CCA_IS_VALID        0x00
     86          #define C_SFD_IS_ACTIVE       0x01
     87          #define C_CPU_CTRL_IS_ON      0x02
     88          #define C_END_INSTR_MEM       0x03
     89          #define C_CSPX_IS_ZERO        0x04
     90          #define C_CSPY_IS_ZERO        0x05
     91          #define C_CSPZ_IS_ZERO        0x06
     92          
     93          /* negated conditions for use with instructions SKIP and RPT */
     94          #define C_NEGATE(c)   ((c) | 0x08)
     95          #define C_CCA_IS_INVALID      C_NEGATE(C_CCA_IS_VALID)
     96          #define C_SFD_IS_INACTIVE     C_NEGATE(C_SFD_IS_ACTIVE)
     97          #define C_CPU_CTRL_IS_OFF     C_NEGATE(C_CPU_CTRL_IS_ON)
     98          #define C_NOT_END_INSTR_MEM   C_NEGATE(C_END_INSTR_MEM)
     99          #define C_CSPX_IS_NON_ZERO    C_NEGATE(C_CSPX_IS_ZERO)
    100          #define C_CSPY_IS_NON_ZERO    C_NEGATE(C_CSPY_IS_ZERO)
    101          #define C_CSPZ_IS_NON_ZERO    C_NEGATE(C_CSPZ_IS_ZERO)
    102          
    103          ///////////////////////////////////////////////////////////////////////////////////////
    104          //  REV_B_WORKAROUND : part of a workaround to help ameliorate chip bug #273.
    105          //  This bug could actually be the source of extant every-once-in-a-while problems.
    106          //  When Rev B is obsolete, delete these defines and all references to them.
    107          //  Compile errors should flag all related fixes.
    108          #define __SNOP_SKIP__     1
    109          #define __SNOP__          SNOP
    110          ///////////////////////////////////////////////////////////////////////////////////////
    111          
    112          
    113          /* ------------------------------------------------------------------------------------------------
    114           *                                         Defines
    115           * ------------------------------------------------------------------------------------------------
    116           */
    117          
    118          /* CSPY return values from CSP program */
    119          #define CSPY_RXTX_COLLISION         0
    120          #define CSPY_NO_RXTX_COLLISION      1
    121          
    122          /* CSPZ return values from CSP program */
    123          #define CSPZ_CODE_TX_DONE           0
    124          #define CSPZ_CODE_CHANNEL_BUSY      1
    125          #define CSPZ_CODE_TX_ACK_TIME_OUT   2
    126          
    127          
    128          /* ------------------------------------------------------------------------------------------------
    129           *                                          Macros
    130           * ------------------------------------------------------------------------------------------------
    131           */
    132          #define CSP_STOP_AND_CLEAR_PROGRAM()          st( RFST = ISSTOP;  )
    133          #define CSP_START_PROGRAM()                   st( RFST = ISSTART; )
    134          ////////////////////////////////////////////////////////////////////////////////////////////////////
    135          //  REV_B_WORKAROUND : workaround for chip bug #574, delete this whole mess when Rev B is obsolete.
    136          //  Compile errors will flag all instances of macro call.  Delete those too.
    137          #ifndef _REMOVE_REV_B_WORKAROUNDS
    138          #define __FIX_T2CMP_BUG__()   st( if (T2CMP == 0) { T2CMP = 1;} )
    139          #else
    140          #define __FIX_T2CMP_BUG__()
    141          #endif
    142          ////////////////////////////////////////////////////////////////////////////////////////////////////
    143          
    144          /*
    145           *  These macros improve readability of using T2CMP in conjunction with WEVENT.
    146           *
    147           *  The timer2 compare, T2CMP, only compares one byte of the 16-bit timer register.
    148           *  It is configurable and has been set to compare against the upper byte of the timer value.
    149           *  The CSP instruction WEVENT waits for the timer value to be greater than or equal
    150           *  the value of T2CMP.
    151           *
    152           *  Reading the timer value is done by reading the low byte first.  This latches the
    153           *  high byte.  A trick with the ternary operator is used by a macro below to force a
    154           *  read of the low byte when returning the value of the high byte.
    155           *
    156           *  CSP_WEVENT_SET_TRIGGER_NOW()      - sets the WEVENT trigger point at the current timer count
    157           *  CSP_WEVENT_SET_TRIGGER_SYMBOLS(x) - sets the WEVENT trigger point in symbols
    158           *  CSP_WEVENT_READ_COUNT_SYMBOLS()   - reads the current timer count in symbols
    159           */
    160          #define T2THD_TICKS_PER_SYMBOL                (MAC_RADIO_TIMER_TICKS_PER_SYMBOL() >> 8)
    161          
    162          #define CSP_WEVENT_SET_TRIGGER_NOW()          st( uint8 temp=T2TLD;  T2CMP = T2THD;  __FIX_T2CMP_BUG__(); )
    163          #define CSP_WEVENT_SET_TRIGGER_SYMBOLS(x)     st( MAC_ASSERT(x <= MAC_A_UNIT_BACKOFF_PERIOD); \
    164                                                            T2CMP = (x) * T2THD_TICKS_PER_SYMBOL; \
    165                                                            __FIX_T2CMP_BUG__(); )
    166          #define CSP_WEVENT_READ_COUNT_SYMBOLS()       (((T2TLD) ? T2THD : T2THD) / T2THD_TICKS_PER_SYMBOL)
    167          
    168          /*
    169           *  Number of bits used for aligning a slotted transmit to the backoff count (plus
    170           *  derived values).  There are restrictions on this value.  Compile time integrity
    171           *  checks will catch an illegal setting of this value.  A full explanation accompanies
    172           *  this compile time check (see bottom of this file).
    173           */
    174          #define SLOTTED_TX_MAX_BACKOFF_COUNTDOWN_NUM_BITS     4
    175          #define SLOTTED_TX_MAX_BACKOFF_COUNTDOWN              (1 << SLOTTED_TX_MAX_BACKOFF_COUNTDOWN_NUM_BITS)
    176          #define SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK       (SLOTTED_TX_MAX_BACKOFF_COUNTDOWN - 1)
    177          
    178          
    179          
    180          /* ------------------------------------------------------------------------------------------------
    181           *                                     Local Programs
    182           * ------------------------------------------------------------------------------------------------
    183           */
    184          static void cspPrepForTxProgram(void);
    185          
    186          
    187          /**************************************************************************************************
    188           * @fn          macCspTxReset
    189           *
    190           * @brief       Reset the CSP.  Immediately halts any running program.
    191           *
    192           * @param       none
    193           *
    194           * @return      none
    195           **************************************************************************************************
    196           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    197          void macCspTxReset(void)
   \                     macCspTxReset:
    198          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    199            MAC_MCU_CSP_STOP_DISABLE_INTERRUPT();
   \   000004                ; Setup parameters for call to function macMcuAndRFIM
   \   000004   79FD         MOV     R1,#-0x3
   \   000006   90....       MOV     DPTR,#(macMcuAndRFIM & 0xffff)
   \   000009   74..         MOV     A,#((macMcuAndRFIM >> 16) & 0xff)
   \   00000B   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    200            MAC_MCU_CSP_INT_DISABLE_INTERRUPT();
   \   00000E                ; Setup parameters for call to function macMcuAndRFIM
   \   00000E   79FE         MOV     R1,#-0x2
   \   000010                REQUIRE ?Subroutine1
   \   000010                ; // Fall through to label ?Subroutine1
    201            CSP_STOP_AND_CLEAR_PROGRAM();
    202          }

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine1:
   \   000000   74..         MOV     A,#((macMcuAndRFIM >> 16) & 0xff)
   \   000002   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
   \   000005   75E1FF       MOV     0xe1,#-0x1
   \   000008   02....       LJMP    ??Subroutine0_1 & 0xFFFF

   \                                 In segment BANKED_CODE, align 1, keep-with-next
   \                     ?Subroutine0:
   \   000000   75E120       MOV     0xe1,#0x20
   \   000003   75E1DF       MOV     0xe1,#-0x21
   \   000006   75E1C0       MOV     0xe1,#-0x40
   \                     ??Subroutine0_0:
   \   000009   75E1C3       MOV     0xe1,#-0x3d
   \   00000C   75E139       MOV     0xe1,#0x39
   \   00000F   75E101       MOV     0xe1,#0x1
   \   000012   75E1BE       MOV     0xe1,#-0x42
   \   000015   75E1C0       MOV     0xe1,#-0x40
   \   000018   75E109       MOV     0xe1,#0x9
   \   00001B   75E1B9       MOV     0xe1,#-0x47
   \   00001E   75E101       MOV     0xe1,#0x1
   \   000021   75E1BF       MOV     0xe1,#-0x41
   \                     ??Subroutine0_1:
   \   000024   D083         POP     DPH
   \   000026   D082         POP     DPL
   \   000028   02....       LJMP    ?BRET
    203          
    204          
    205          /*=================================================================================================
    206           * @fn          cspPrepForTxProgram
    207           *
    208           * @brief       Prepare and initialize for transmit CSP program.
    209           *              Call *before* loading the CSP program!
    210           *
    211           * @param       none
    212           *
    213           * @return      none
    214           *=================================================================================================
    215           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    216          static void cspPrepForTxProgram(void)
   \                     ??cspPrepForTxProgram:
    217          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    218            MAC_ASSERT(!(RFIM & IM_CSP_STOP)); /* already an active CSP program */
   \   000004   E591         MOV     A,0x91
   \   000006   A2E1         MOV     C,0xE0 /* A   */.1
   \   000008   5008         JNC     ??cspPrepForTxProgram_1
   \   00000A                ; Setup parameters for call to function halAssertHandler
   \   00000A   90....       MOV     DPTR,#(halAssertHandler & 0xffff)
   \   00000D   74..         MOV     A,#((halAssertHandler >> 16) & 0xff)
   \   00000F   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    219          
    220            /* set up parameters for CSP transmit program */
    221            CSPY = CSPY_NO_RXTX_COLLISION;
   \                     ??cspPrepForTxProgram_1:
   \   000012   7401         MOV     A,#0x1
   \   000014   90DF13       MOV     DPTR,#-0x20ed
   \   000017   F0           MOVX    @DPTR,A
    222            CSPZ = CSPZ_CODE_CHANNEL_BUSY;
   \   000018   90DF14       MOV     DPTR,#-0x20ec
   \   00001B   F0           MOVX    @DPTR,A
    223          
    224            /* clear the currently loaded CSP, this generates a stop interrupt which must be cleared */

⌨️ 快捷键说明

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