This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

2591换到2592 zstack版本问题

Other Parts Discussed in Thread: CC2592, CC2591, CC2530

我现在zstack版本是1.3.1,里面是不支持cc2592的,以前用的是2591,所以想升级版本,想请问下能不能直接替换某个或某些文件,还是说得整体升级?因为已经快开发完了,无线发送的时候才发现这问题。谢谢!

  • 新版SDK支持CC2592,建议你更新到Z-mesh 1.0 sdk:
    www.ti.com/.../Z-STACK-ARCHIVE

    www.ti.com/.../swra465a.pdf
  • 到macRadioTurnOnPower裡面去改一下暫存器OBSSELx的設定就好了吧

  • 你好,请问TI有没有什么官方的升级指南呢?
  • PA_LNA_CC2591的宏定义替换为PA_LNA_CC2592

    你看一下你那个版本的mac_radio_defs.c里面有PA_LNA_CC2592吗,没有就升级一下SDK

  • 就參考 www.ti.com/.../swru191f.pdf 改控制PA/LNA暫存器就行了
  • 你好,早上一开始就是把OBSSEL4改为OBSSEL0,还是不行,所以才来咨询的,应该除了OBSSELx寄存器,没其他需要改的了吧?
  • 你CC2530接CC2592的線路可以貼上來看看嘛?
  •  应该没问题吧,P1_1、P1_0正常连接,P0_7拉高。

  • 你的暫存器OBSSELx的設定是怎樣的?
  • 你好,你的接线方式完全和我们的一样。可以直接参考高版本SDK里面的设置如下:

    /**************************************************************************************************
      Filename:       mac_radio_defs.c
      Revised:        $Date: 2015-02-17 14:17:44 -0800 (Tue, 17 Feb 2015) $
      Revision:       $Revision: 42683 $
    
      Description:    Describe the purpose and contents of the file.
    
    
      Copyright 2006-2015 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    /* ------------------------------------------------------------------------------------------------
     *                                             Includes
     * ------------------------------------------------------------------------------------------------
     */
    #include "mac_radio_defs.h"
    #include "hal_types.h"
    #include "hal_assert.h"
    #include "hal_mcu.h"
    #include "mac_pib.h"
    
    /* ------------------------------------------------------------------------------------------------
     *                                        Global Variables
     * ------------------------------------------------------------------------------------------------
     */
    
    uint8 reqTxBoost = FALSE;  /* CC2533/34-specific register settings to achieve highest Tx power. */
    uint8 paLnaChip = PA_LNA_NONE;
       
    #if defined HAL_PA_LNA_SE2431L || defined MAC_RUNTIME_SE2431L
      #define CPS_DIR         P0DIR
      #define CPS_PIN_OUTPUT  BV(7)  
        
      #define ANT_CSD_SEL_DIR P1DIR 
      #define CSD_PIN_OUTPUT   BV(3)  
      #define ANT_SEL_OUTPUT   BV(0)
    
    #else
      #define CPS_DIR         P0DIR
      #define CPS_PIN_OUTPUT  0 
        
      #define ANT_CSD_SEL_DIR P1DIR 
      #define CSD_PIN_OUTPUT   0 
      #define ANT_SEL_OUTPUT   0 
    
    #endif
    
    /* ------------------------------------------------------------------------------------------------
     *                                        Global Constants
     * ------------------------------------------------------------------------------------------------
     */
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590 && \
        !defined HAL_PA_LNA_SE2431L && !defined HAL_PA_LNA_CC2592)
    
    const uint8 CODE macRadioDefsTxPwrBare[] =
    {
      3,  /* tramsmit power level of the first entry */
      (uint8)(int8)-22, /* transmit power level of the last entry */
      /*   3 dBm */   0xF5,   /* characterized as  4.5 dBm in datasheet */
      /*   2 dBm */   0xE5,   /* characterized as  2.5 dBm in datasheet */
      /*   1 dBm */   0xD5,   /* characterized as  1   dBm in datasheet */
      /*   0 dBm */   0xD5,   /* characterized as  1   dBm in datasheet */
      /*  -1 dBm */   0xC5,   /* characterized as -0.5 dBm in datasheet */
      /*  -2 dBm */   0xB5,   /* characterized as -1.5 dBm in datasheet */
      /*  -3 dBm */   0xA5,   /* characterized as -3   dBm in datasheet */
      /*  -4 dBm */   0x95,   /* characterized as -4   dBm in datasheet */
      /*  -5 dBm */   0x95,
      /*  -6 dBm */   0x85,   /* characterized as -6   dBm in datasheet */
      /*  -7 dBm */   0x85,
      /*  -8 dBm */   0x75,   /* characterized as -8   dBm in datasheet */
      /*  -9 dBm */   0x75,
      /* -10 dBm */   0x65,   /* characterized as -10  dBm in datasheet */
      /* -11 dBm */   0x65,
      /* -12 dBm */   0x55,   /* characterized as -12  dBm in datasheet */
      /* -13 dBm */   0x55,
      /* -14 dBm */   0x45,   /* characterized as -14  dBm in datasheet */
      /* -15 dBm */   0x45,
      /* -16 dBm */   0x35,   /* characterized as -16  dBm in datasheet */
      /* -17 dBm */   0x35,
      /* -18 dBm */   0x25,   /* characterized as -18  dBm in datasheet */
      /* -19 dBm */   0x25,
      /* -20 dBm */   0x15,   /* characterized as -20  dBm in datasheet */
      /* -21 dBm */   0x15,
      /* -22 dBm */   0x05    /* characterized as -22  dBm in datasheet */
    };
    #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
              defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
              (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590 && \
              !defined HAL_PA_LNA_SE2431L && !defined HAL_PA_LNA_CC2592) */
    
    #if defined HAL_PA_LNA || defined MAC_RUNTIME_CC2591
    const uint8 CODE macRadioDefsTxPwrCC2591[] =
    {
      20,  /* tramsmit power level of the first entry */
      (uint8)(int8)10, /* transmit power level of the last entry */
      /*  20 dBm */   0xE5,   /* characterized as 20 dBm in datasheet */
      /*  19 dBm */   0xD5,   /* characterized as 19 dBm in datasheet */
      /*  18 dBm */   0xC5,   /* characterized as 18 dBm in datasheet */
      /*  17 dBm */   0xB5,   /* characterized as 17 dBm in datasheet */
      /*  16 dBm */   0xA5,   /* characterized as 16 dBm in datasheet */
      /*  15 dBm */   0xA5,
      /*  14 dBm */   0x95,   /* characterized as 14.5 dBm in datasheet */
      /*  13 dBm */   0x85,   /* characterized as 13 dBm in datasheet */
      /*  12 dBm */   0x85,
      /*  11 dBm */   0x75,   /* characterized as 11.5 dBm in datasheet */
      /*  10 dBm */   0x65    /* characterized as 10 dBm in datasheet */
    };
    #endif
    
    #if defined HAL_PA_LNA_CC2592 || defined MAC_RUNTIME_CC2592
    const uint8 CODE macRadioDefsTxPwrCC2592[] =
    {
      21,  /* tramsmit power level of the first entry */
      (uint8)(int8)10, /* transmit power level of the last entry */
      /*  21 dBm */   0xF4,   /* characterized as 21.47 dBm */
      /*  20 dBm */   0xD4,   /* characterized as 20.26 dBm */
      /*  19 dBm */   0xC0,   /* characterized as 19.31 dBm */
      /*  18 dBm */   0xA5,   /* characterized as 18.21 dBm */
      /*  17 dBm */   0x95,   /* characterized as 17.14 dBm */
      /*  16 dBm */   0x82,   /* characterized as 16.27 dBm */
      /*  15 dBm */   0x72,   /* characterized as 15.15 dBm */
      /*  14 dBm */   0x63,   /* characterized as 14.12 dBm */
      /*  13 dBm */   0x61,   /* characterized as 13.24 dBm */
      /*  12 dBm */   0x55,   /* characterized as 11.93 dBm */
      /*  11 dBm */   0x50,   /* characterized as 10.90 dBm */
      /*  10 dBm */   0x49    /* characterized as 10.29 dBm */
    };
    #endif
    
    #if defined HAL_PA_LNA_CC2590 || defined MAC_RUNTIME_CC2590
    const uint8 CODE macRadioDefsTxPwrCC2590[] =
    {
      11,  /* tramsmit power level of the first entry */
      (uint8)(int8)-15, /* transmit power level of the last entry */
      /* Note that the characterization is preliminary */
      /* 11 dBm */   0xF5,   /* characterized as 11.1 dBm */
      /* 10 dBm */   0xF5,
      /*  9 dBm */   0xE5,   /* characterized as 9.3 dBm */
      /*  8 dBm */   0xD5,   /* characterized as 7.7 dBm */
      /*  7 dBm */   0xD5,
      /*  6 dBm */   0xC5,   /* characterized as 6.4 dBm */
      /*  5 dBm */   0xB5,   /* characterized as 5.2 dBm */
      /*  4 dBm */   0xA5,   /* characterized as 3.6 dBm */
      /*  3 dBm */   0xA5,
      /*  2 dBm */   0x95,   /* characterized as 1.6 dBm */
      /*  1 dBm */   0x95,
      /*  0 dBm */   0x85,   /* characterized as 0.4 dBm */
      /* -1 dBm */   0x75,   /* characterized as -1.1 dBm */
      /* -2 dBm */   0x75,
      /* -3 dBm */   0x65,   /* characterized as -2.9 dBm */
      /* -4 dBm */   0x65,
      /* -5 dBm */   0x55,   /* characterized as -5.0 dBm */
      /* -6 dBm */   0x55,
      /* -7 dBm */   0x45,   /* characterized as -7.3 dBm*/
      /* -8 dBm */   0x45,
      /* -9 dBm */   0x45,
      /* -10 dBm */  0x35,   /* characterized as -9.7 dBm */
      /* -11 dBm */  0x25,   /* characterized as -11.3 dBm */
      /* -12 dBm */  0x25,
      /* -13 dBm */  0x15,   /* characterized as -13.3 dBm */
      /* -14 dBm */  0x15,
      /* -15 dBm */  0x05    /* characterized as -15.4 dBm */
    };
    #endif
    
    #if defined (HAL_PA_LNA_SE2431L) || defined (MAC_RUNTIME_SE2431L)
    const uint8 CODE macRadioDefsTxPwrSE2431L[] =
    {
      22,  /* tramsmit power level of the first entry */
      (uint8)(int8)10, /* transmit power level of the last entry */
      /* Note that the characterization is preliminary */
      /* 22 dBm */   0xF5,   /* characterized as 21.5 dBm */
      /* 21 dBm */   0xE5,   /* characterized as 21.1 dBm */
      /* 20 dBm */   0xD5,   /* characterized as 20.5 dBm */
      /* 19 dBm */   0xC5,   /* characterized as 19.7 dBm */
      /* 18 dBm */   0xB5,   /* characterized as 18.8 dBm */
      /* 17 dBm */   0xA5,   /* characterized as 17.4 dBm */
      /* 16 dBm */   0x95,   /* characterized as 15.5 dBm */
      /* 15 dBm */   0x95,   /* characterized as 15.5 dBm */
      /* 14 dBm */   0x85,   /* characterized as 14.2 dBm */
      /* 13 dBm */   0x85,   /* characterized as 14.2 dBm */
      /* 12 dBm */   0x75,   /* characterized as 12.3 dBm */
      /* 11 dBm */   0x75,   /* characterized as 12.3 dBm */
      /* 10 dBm */   0x65,   /* characterized as 10.6 dBm */
    };
    #endif
    
    const uint8 CODE macRadioDefsTxPwrBare0x95[] =
    {
      7,  /* tramsmit power level of the first entry */
      (uint8)(int8)-20, /* transmit power level of the last entry */
      /*   7 dBm */   0xFD,   /* characterized as  7   dBm in datasheet */
      /*   6 dBm */   0xFD,   /* clip to 7 dBm */
      /*   5 dBm */   0xFD,   /* clip to 7 dBm */
      /*   4 dBm */   0xEC,   /* characterized as  4.5 dBm in datasheet */
      /*   3 dBm */   0xDC,   /* characterized as  3   dBm in datasheet */
      /*   2 dBm */   0xDC,
      /*   1 dBm */   0xCC,   /* characterized as  1.7 dBm in datasheet */
      /*   0 dBm */   0xBC,   /* characterized as  0.3 dBm in datasheet */
      /*  -1 dBm */   0xAC,   /* characterized as -1   dBm in datasheet */
      /*  -2 dBm */   0xAC,
      /*  -3 dBm */   0x9C,   /* characterized as -2.8 dBm in datasheet */
      /*  -4 dBm */   0x9C,
      /*  -5 dBm */   0x8C,   /* characterized as -4.1 dBm in datasheet */
      /*  -6 dBm */   0x7C,   /* characterized as -5.9 dBm in datasheet */
      /*  -7 dBm */   0x7C,
      /*  -8 dBm */   0x6C,   /* characterized as -7.7 dBm in datasheet */
      /*  -9 dBm */   0x6C,
      /* -10 dBm */   0x5C,   /* characterized as -9.9 dBm in datasheet */
      /* -11 dBm */   0x5C,
      /* -12 dBm */   0x5C,   /* characterized as -9.9 dBm in datasheet */
      /* -13 dBm */   0x4C,   /* characterized as -12.8 dBm in datasheet */
      /* -14 dBm */   0x4C,
      /* -15 dBm */   0x3C,   /* characterized as -14.9 dBm in datasheet */
      /* -16 dBm */   0x3C,
      /* -17 dBm */   0x2C,   /* characterized as -16.6 dBm in datasheet */
      /* -18 dBm */   0x2C,
      /* -19 dBm */   0x1C,   /* characterized as -18.7 dBm in datasheet */
      /* -20 dBm */   0x1C    /* characterized as -18.7 dBm in datasheet */
    };
    
    
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
        defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
    
    /* TX power table array */
    const uint8 CODE *const CODE macRadioDefsTxPwrTables[] =
    {
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590 && \
        !defined HAL_PA_LNA_SE2431L && !defined HAL_PA_LNA_CC2592)
      macRadioDefsTxPwrBare,
    #endif
    
    #if defined HAL_PA_LNA || defined MAC_RUNTIME_CC2591
      macRadioDefsTxPwrCC2591,
    #endif
    
    #if defined HAL_PA_LNA_CC2590 || defined MAC_RUNTIME_CC2590
      macRadioDefsTxPwrCC2590,
    #endif
    
    #if defined HAL_PA_LNA_SE2431L || defined MAC_RUNTIME_SE2431L
      macRadioDefsTxPwrSE2431L,
    #endif
    
    #if defined HAL_PA_LNA_CC2592 || defined MAC_RUNTIME_CC2592
      macRadioDefsTxPwrCC2592,
    #endif
    };
    
    /* TX power table array. */
    /* TODO: Please note that the cc2533 uses the
     * same TXPOWER table with or without PA/LNA here.
     */
    const uint8 CODE *const CODE macRadioDefsTxPwrTables0x95[] =
    {
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
      (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590)
      macRadioDefsTxPwrBare0x95,
    #endif
    
    #if defined HAL_PA_LNA || defined MAC_RUNTIME_CC2591
      macRadioDefsTxPwrBare0x95,
    #endif
    
    #if defined HAL_PA_LNA_CC2590 || defined MAC_RUNTIME_CC2590
      macRadioDefsTxPwrBare0x95,
    #endif
    };
    
    /* RSSI offset adjustment value array */
    const int8 CODE macRadioDefsRssiAdj[] =
    {
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590 && \
        !defined HAL_PA_LNA_CC2590 && !defined HAL_PA_LNA_CC2592)
      0,
    #endif
    
    #if defined HAL_PA_LNA || defined MAC_RUNTIME_CC2591
      -6, /* high gain mode */
      6,  /* low gain mode */
    #endif
    
    #if defined HAL_PA_LNA_CC2590 || defined MAC_RUNTIME_CC2590
     -10,
      0,
    #endif
    
    #if defined HAL_PA_LNA_SE2431L || defined MAC_RUNTIME_SE2431L
    -12,   /*high gain mode of SE2431L*/
     0,    /*Low gain mode of SE2431L */
    #endif
    
    #if defined HAL_PA_LNA_CC2592 || defined MAC_RUNTIME_CC2592
     /* TBD Placeholder for CC2530+CC2592 */
     -10,
     -5,
    #endif
    };
    
    
    /* Sensitivity adjusts*/
    const int8 CODE macRadioDefsSensitivityAdj[] =
    {
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
      defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
      (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590 && \
      !defined HAL_PA_LNA_SE2431L && !defined HAL_PA_LNA_CC2592)
      0,
    #endif
    
    #if defined HAL_PA_LNA || defined MAC_RUNTIME_CC2591
    /* -98.8 approximated to -98 MAC_RADIO_RECEIVER_SENSITIVITY_DBM -1 = -98 */
      -1, 
    #endif
    
    #if defined HAL_PA_LNA_CC2590 || defined MAC_RUNTIME_CC2590
      -1,
    #endif
    
    #if defined HAL_PA_LNA_SE2431L || defined MAC_RUNTIME_SE2431L
    /* -101.8 approximated to -101. MAC_RADIO_RECEIVER_SENSITIVITY_DBM -4 = -101 */
      -4, 
    #endif
    
    #if defined HAL_PA_LNA_CC2592 || defined MAC_RUNTIME_CC2592
     /* TBD Placeholder for CC2530+CC2592 */
      -1,
    #endif
    };
    
    
    /* Saturation adjusts*/
    const int8 CODE macRadioDefsSaturationAdj[] =
    {
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
      defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
      (!defined HAL_PA_LNA && !defined HAL_PA_LNA_CC2590 && \
      !defined HAL_PA_LNA_SE2431L && !defined HAL_PA_LNA_CC2592)
      0,
    #endif
    
    #if defined HAL_PA_LNA || defined MAC_RUNTIME_CC2591
      0,  
    #endif
    
    #if defined HAL_PA_LNA_CC2590 || defined MAC_RUNTIME_CC2590
      0,
    #endif
    
    #if defined HAL_PA_LNA_SE2431L || defined MAC_RUNTIME_SE2431L
    /* 5.5 approximated to 5. MAC_RADIO_RECEIVER_SATURATION_DBM -5 = 5 */
      -5,   
    #endif
    
    #if defined HAL_PA_LNA_CC2592 || defined MAC_RUNTIME_CC2592
     /* TBD Placeholder for CC2530+CC2592 */
      0,
    #endif
    };
    
    #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || ... */
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
        defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
    uint8 macRadioDefsRefTableId = 0;
    #endif
    
    /* RF observable control register value to output PA signal */
    #define RFC_OBS_CTRL_PA_PD_INV        0x68
    
    /* RF observable control register value to output LNA signal */
    #define RFC_OBS_CTRL_LNAMIX_PD_INV    0x6A
    
    /* OBSSELn register value to select RF observable 0 */
    #define OBSSEL_OBS_CTRL0             0xFB
    
    /* OBSSELn register value to select RF observable 1 */
    #define OBSSEL_OBS_CTRL1             0xFC
    
    
    /**************************************************************************************************
     * @fn          MAC_SelectRadioRegTable
     *
     * @brief       Select radio register table in case multiple register tables are included
     *              in the build
     *
     * @param       txPwrTblIdx - TX power register value table index
     * @param       rssiAdjIdx - RSSI adjustment value index
     *
     * @return      none
     **************************************************************************************************
     */
    extern void MAC_SetRadioRegTable ( uint8 txPwrTblIdx, uint8 rssiAdjIdx )
    {
      /* Depending on compile flags, the parameters may not be used */
      (void) txPwrTblIdx;
      (void) rssiAdjIdx;
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 ||  \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592
      if (txPwrTblIdx >= sizeof(macRadioDefsTxPwrTables)/sizeof(macRadioDefsTxPwrTables[0]))
      {
        txPwrTblIdx = 0;
      }
    #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 */
    
    #if defined (MAC_RUNTIME_CC2591) || defined (MAC_RUNTIME_CC2590) || \
        defined (MAC_RUNTIME_SE2431L)  || defined (MAC_RUNTIME_CC2592) || \
        defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590) || \
        defined (HAL_PA_LNA_SE2431L)  || defined (HAL_PA_LNA_CC2592)
      if (rssiAdjIdx >= sizeof(macRadioDefsRssiAdj)/sizeof(macRadioDefsRssiAdj[0]))
      {
        rssiAdjIdx = 0;
      }
    
      macRadioDefsRefTableId = (txPwrTblIdx << 4) | rssiAdjIdx;
    
    #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || .. */
      
     
    #if defined (MAC_RUNTIME_CC2591) && defined (MAC_RUNTIME_CC2590) && \
        defined (MAC_RUNTIME_SE2431L) && defined (MAC_RUNTIME_CC2592)
    /* Determining PA LNA chip used from txPwrIdx*/  
      switch (txPwrTblIdx)
      {
      case MAC_CC2591_TX_PWR_TABLE_IDX:
        paLnaChip = PA_LNA_CC2591;
        break;
        
      case MAC_CC2590_TX_PWR_TABLE_IDX:
        paLnaChip = PA_LNA_CC2590;
        break;
        
      case MAC_SE2431L_TX_PWR_TABLE_IDX:
        paLnaChip = PA_LNA_SE2431L;
        break;
      
      case MAC_CC2592_TX_PWR_TABLE_IDX:
        paLnaChip = PA_LNA_CC2592;
        break;
        
        default
          paLnaChip = PA_LNA_NONE;
        break;
      }
    #elif defined (MAC_RUNTIME_CC2591) || defined (HAL_PA_LNA)
      paLnaChip = PA_LNA_CC2591;
    #elif defined (MAC_RUNTIME_CC2590) || defined (HAL_PA_LNA_CC2590)
      paLnaChip = PA_LNA_CC2590;
    #elif defined (MAC_RUNTIME_SE2431L) || defined (HAL_PA_LNA_SE2431L)
      paLnaChip = PA_LNA_SE2431L;
    #elif defined (MAC_RUNTIME_CC2592) || defined (HAL_PA_LNA_CC2592)
      paLnaChip = PA_LNA_CC2592;
    #else
      paLnaChip = PA_LNA_NONE;
    #endif
      
      if (paLnaChip == PA_LNA_SE2431L)
      {
        /* Setting CPS as Output by setting P0DIR = 0x80 */
        CPS_DIR  |= CPS_PIN_OUTPUT; 
        
        /* Setting CSD and Antenns Select as Output by setting P1DIR = 0x9 */
        ANT_CSD_SEL_DIR |= (CSD_PIN_OUTPUT | ANT_SEL_OUTPUT);
        
       /* Now EN or CSD line is controlled via software so setting it high here 
        * to start the SE2431L frontend
        */
        HAL_PA_LNA_RX_CSD_HIGH();
      }  
    }
    
    
    /**************************************************************************************************
     * @fn          macRadioTurnOnPower
     *
     * @brief       Logic and sequence for powering up the radio.
     *
     * @param       none
     *
     * @return      none
     **************************************************************************************************
     */
    MAC_INTERNAL_API void macRadioTurnOnPower(void)
    {
      /* Enable RF error trap */
      MAC_MCU_RFERR_ENABLE_INTERRUPT();
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592
      /* table ID is referenced only when runtime configuration is enabled */
      if (macRadioDefsRefTableId & 0xf0)
    #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 */
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
        defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
      { /* either if compound statement or non-conditional compound statement */
        
        /* (Re-)Configure PA and LNA control signals to RF frontend chips.
        * Note that The register values are not retained during sleep.
        */
        
        if (paLnaChip == PA_LNA_SE2431L)
        {
          /* CPS or P0_7 maps closely to the HGM line */
          HAL_PA_LNA_RX_HGM(); 
      
          /* EN or CSD line is controlled via software so setting it high here to start the SE2431L frontend */
          HAL_PA_LNA_RX_CSD_HIGH();
          
          /* CTX or P1_1 maps closely to PAEN */
          RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV;
          OBSSEL1       = OBSSEL_OBS_CTRL0;
        }
        else if(paLnaChip == PA_LNA_CC2592)
        {
          /* P1_1 -> PAEN */
          RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV;
          OBSSEL1       = OBSSEL_OBS_CTRL0;
          
          /* P1_0 -> EN (LNA control) */
          RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV;
          OBSSEL0       = OBSSEL_OBS_CTRL1;
        }  
        else 
        {   
          /* P1_1 -> PAEN */
          RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV;
          OBSSEL1       = OBSSEL_OBS_CTRL0;
          
          /* P1_4 -> EN (LNA control) */
          RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV;
          OBSSEL4       = OBSSEL_OBS_CTRL1;
        }
        
        /* For any RX, change CCA settings for CC2591 compression workaround.
        * This will override LNA control if CC2591_COMPRESSION_WORKAROUND
        * flag is defined.
        */
      }
    #endif /* defined MAC_RUNTIME_CC2591 || ... || defined HAL_PA_LNA_SE2431L... */
    
      if (macChipVersion <= REV_B)
      {
        /* radio initializations for disappearing RAM; PG1.0 and before only */
        MAC_RADIO_SET_PAN_ID(pMacPib->panId);
        MAC_RADIO_SET_SHORT_ADDR(pMacPib->shortAddress);
        MAC_RADIO_SET_IEEE_ADDR(pMacPib->extendedAddress.addr.extAddr);
      }
    
      /* Turn on frame filtering */
      MAC_RADIO_TURN_ON_RX_FRAME_FILTERING();
    }
    
    
    /**************************************************************************************************
     * @fn          macRadioTurnOffPower
     *
     * @brief       Logic and sequence for powering down the radio.
     *
     * @param       none
     *
     * @return      none
     **************************************************************************************************
     */
    MAC_INTERNAL_API void macRadioTurnOffPower(void)
    {
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592
      /* table ID is referenced only when runtime configuration is enabled */
      if (macRadioDefsRefTableId & 0xf0)
    #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 */
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \
        defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
        defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
      { /* either if compound statement or non-conditional compound statement */
        
        if (paLnaChip == PA_LNA_SE2431L)
        {
          HAL_PA_LNA_RX_LGM(); 
          HAL_PA_LNA_RX_CSD_LOW();
        }
        else 
        {   
          if (paLnaChip == PA_LNA_CC2591  ||  paLnaChip == PA_LNA_CC2590)
          {
            /* Set direction of P1_4 to output and pulled down to prevent any leakage
             * when used to drive PA LNA		
    		 */
            P1DIR |= BV(4);
            P1_4 = 0;
          }
        }
      }
      #endif /* defined MAC_RUNTIME_CC2591 || ... || defined HAL_PA_LNA_SE2431L */
      /* Disable RF error trap */
      MAC_MCU_RFERR_DISABLE_INTERRUPT();
    }
    
    
    /**************************************************************************************************
     *                                  Compile Time Integrity Checks
     **************************************************************************************************
     */
    #if (HAL_CPU_CLOCK_MHZ != 32)
    #error "ERROR: The only tested/supported clock speed is 32 MHz."
    #endif
    
    #if (MAC_RADIO_RECEIVER_SENSITIVITY_DBM > MAC_SPEC_MIN_RECEIVER_SENSITIVITY)
    #error "ERROR: Radio sensitivity does not meet specification."
    #endif
    
    #if defined (HAL_PA_LNA) && defined (HAL_PA_LNA_CC2590)
    #error "ERROR: HAL_PA_LNA and HAL_PA_LNA_CC2590 cannot be both defined."
    #endif
    
    #if defined (HAL_PA_LNA) && defined (MAC_RUNTIME_CC2591)
    #error "ERROR: HAL_PA_LNA and MAC_RUNTIME_CC2591 cannot be both defined."
    #endif
    
    #if defined (HAL_PA_LNA_CC2590) && defined (MAC_RUNTIME_CC2590)
    #error "ERROR: HAL_PA_LNA_CC2590 and MAC_RUNTIME_CC2590 cannot be both defined."
    #endif
    
    #if defined (HAL_PA_LNA_SE2431L) && defined (MAC_RUNTIME_SE2431L)
    #error "ERROR: HAL_PA_LNA_SE2431L and MAC_RUNTIME_SE2431L cannot be both defined."
    #endif
    
    #if defined (HAL_PA_LNA_CC2592) && defined (MAC_RUNTIME_CC2592)
    #error "ERROR: HAL_PA_LNA_CC2592 and MAC_RUNTIME_CC2592 cannot be both defined."
    #endif
    
    #if defined (CC2591_COMPRESSION_WORKAROUND)
    #warning "WARNING: Contact TI customer support if your reference design is based on CC2530-CC2591EM rev 2.0 or prior."
    #endif
    
    /**************************************************************************************************/
    /**************************************************************************************************
      Filename:       mac_radio_def.h
      Revised:        $Date: 2014-06-05 16:56:45 -0700 (Thu, 05 Jun 2014) $
      Revision:       $Revision: 38844 $
    
      Description:    Describe the purpose and contents of the file.
    
    
      Copyright 2006-2014 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License"). You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product. Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    #ifndef MAC_RADIO_DEFS_H
    #define MAC_RADIO_DEFS_H
    
    /* ------------------------------------------------------------------------------------------------
     *                                             Includes
     * ------------------------------------------------------------------------------------------------
     */
    #include "hal_defs.h"
    #include "hal_board_cfg.h"
    #include "hal_mac_cfg.h"
    #include "mac_spec.h"
    #include "mac_mcu.h"
    #include "mac_mem.h"
    #include "mac_csp_tx.h"
    #include "mac_assert.h"
    #include "mac_high_level.h"
    #include "hal_sleep.h"
    #include "mac_radio.h"
    
    /* ------------------------------------------------------------------------------------------------
     *                                      Target Specific Defines
     * ------------------------------------------------------------------------------------------------
     */
    
    /* PA LNA chip used */
    #define PA_LNA_NONE    0  
    #define PA_LNA_CC2591  1 
    #define PA_LNA_CC2590  2
    #define PA_LNA_SE2431L 3
    #define PA_LNA_CC2592  4
       
    /* immediate strobe commands */
    #define ISTXCAL       0xEC
    #define ISRXON        0xE3
    #define ISTXON        0xE9
    #define ISTXONCCA     0xEA
    #define ISRFOFF       0xEF
    #define ISFLUSHRX     0xED
    #define ISFLUSHTX     0xEE
    #define ISACK         0xE6
    #define ISACKPEND     0xE7
    #define ISNACK        0xE8
    
    /* FSCTRLL */
    #define FREQ_2405MHZ                  0x0B
    
    /* FSMSTAT1 */
    #define TX_ACTIVE                     BV(1)
    #define CCA                           BV(4)
    #define SFD                           BV(5)
    #define FIFOP                         BV(6)
    #define FIFO                          BV(7)
    
    /* IEN0 */
    #define RFERRIE                       BV(0)
    
    /* IEN2 */
    #define RFIE                          BV(0)
    
    /* FRMCTRL0 */
    #define FRMCTRL0_RESET_VALUE          0x40
    #define ENERGY_SCAN                   BV(4)
    #define AUTOACK                       BV(5)
    #define RX_MODE(x)                    ((x) << 2)
    #define RX_MODE_INFINITE_RECEPTION    RX_MODE(2)
    #define RX_MODE_NORMAL_OPERATION      RX_MODE(0)
    
    /* FRMCTRL1 */
    #define PENDING_OR                    BV(2)
    
    /* FRMFILT0 */
    #define PAN_COORDINATOR               BV(1)
    #define FRAME_FILTER_EN               BV(0)
    
    #define FRAME_VERSION(x)              ((x) << 3)
    #define FRAME_FILTER_MAX_VERSION      FRAME_VERSION(1)
    
    /* SRCMATCH */
    #define PEND_DATAREQ_ONLY             BV(2)
    #define AUTOPEND                      BV(1)
    #define SRC_MATCH_EN                  BV(0)
    
    /* SRCRESINDEX */
    #define AUTOPEND_RES                  BV(6)
    
    /* MDMCTRL1 */
    #define CORR_THR_SFD                  BV(5)
    #define CORR_THR                      0x14
    
    /* CCACTRL0 */
    #define CCA_THR                       0xFC   /* -4-76=-80dBm when CC2530 operated alone or with CC2591 in LGM */
    #define CCA_THR_HGM                   0x06   /* 6-76=-70dBm when CC2530 operated with CC2591 in HGM */
    #define CCA_THR_MINUS_20              0x38
    #define CCA_THR_CC2533                0xF8
    
    /* CCACTRL1 */
    #define CCA_OTHER_MODE_11             0x1A
    #define CCA_OTHER_MODE_01             0x0A
    
    /* FSMSTATE */
    #define FSM_FFCTRL_STATE_RX_INF       31      /* infinite reception state - not documented in datasheet */
    
    /* ADCCON1 */
    #define RCTRL1                        BV(3)
    #define RCTRL0                        BV(2)
    #define RCTRL_BITS                    (RCTRL1 | RCTRL0)
    #define RCTRL_CLOCK_LFSR              RCTRL0
    
    /* CSPCTRL */
    #define CPU_CTRL                      BV(0)
    #define CPU_CTRL_ON                   CPU_CTRL
    #define CPU_CTRL_OFF                  (!(CPU_CTRL))
    
    /* TXFILTCFG */
    #define TXFILTCFG                     XREG( 0x61FA )
    #define TXFILTCFG_RESET_VALUE         0x09
    
    /* ------------------------------------------------------------------------------------------------
     *                                    Unique Radio Define
     * ------------------------------------------------------------------------------------------------
     */
    #define MAC_RADIO_CC2530
    #define FEATURE_MAC_RADIO_HARDWARE_OVERFLOW_NO_ROLLOVER
    
    
    /* ------------------------------------------------------------------------------------------------
     *                                    Common Radio Defines
     * ------------------------------------------------------------------------------------------------
     */
    #define MAC_RADIO_CHANNEL_DEFAULT               11
    #define MAC_RADIO_CHANNEL_INVALID               0xFF
    #define MAC_RADIO_TX_POWER_INVALID              0xFF
    
    #define MAC_RADIO_RECEIVER_SENSITIVITY_DBM      -97 /* dBm */
    #define MAC_RADIO_RECEIVER_SATURATION_DBM       10  /* dBm */
    
    /* Reduce RX power consumption current to 20mA at the cost of some sensitivity
     * Note: This feature can be applied to CC2530 and CC2533 only.
     */
    #ifdef FEATURE_CC253X_LOW_POWER_RX
    #undef  HAL_MAC_RSSI_OFFSET
    #define HAL_MAC_RSSI_OFFSET                     -61 /* no unit */
    #endif
       
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592
    # define MAC_RADIO_SENSITIVITY_OFFSET(x)         st(  x += macRadioDefsSensitivityAdj[macRadioDefsRefTableId>> 4]; )
    # define MAC_RADIO_SATURATION_OFFSET(x)          st(  x += macRadioDefsSaturationAdj[macRadioDefsRefTableId>> 4]; )
    
    #elif defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
          defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
    # define MAC_RADIO_SENSITIVITY_OFFSET(x)         st(  x += macRadioDefsSensitivityAdj[0]; )
    # define MAC_RADIO_SATURATION_OFFSET(x)          st(  x += macRadioDefsSaturationAdj[0]; )
    
    #else
    # define MAC_RADIO_SENSITIVITY_OFFSET(x)
    # define MAC_RADIO_SATURATION_OFFSET(x) 
    
    #endif
    
    /* offset applied to hardware RSSI value to get RF power level in dBm units */
    #define MAC_RADIO_RSSI_OFFSET                   HAL_MAC_RSSI_OFFSET
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_SE2431L ||  defined MAC_RUNTIME_CC2592 || \
        defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
        defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
    # define MAC_RADIO_RSSI_LNA_OFFSET(x)            st(  x += macRadioDefsRssiAdj[macRadioDefsRefTableId&0x0F]; )
    #else
    # define MAC_RADIO_RSSI_LNA_OFFSET(x)
    #endif
          
    
    
    /* precise values for small delay on both receive and transmit side */
    #define MAC_RADIO_RX_TX_PROP_DELAY_MIN_USEC     3.076  /* usec */
    #define MAC_RADIO_RX_TX_PROP_DELAY_MAX_USEC     3.284  /* usec */
    
    /* register value table offset */
    #define MAC_RADIO_DEFS_TBL_TXPWR_FIRST_ENTRY   0
    #define MAC_RADIO_DEFS_TBL_TXPWR_LAST_ENTRY    1
    #define MAC_RADIO_DEFS_TBL_TXPWR_ENTRIES       2
    
    /* RF observable control register value to output PA signal */
    #define RFC_OBS_CTRL_PA_PD_INV        0x68
    
    /* RF observable control register value to output LNA signal */
    #define RFC_OBS_CTRL_LNAMIX_PD_INV    0x6A
    
    /* RF observable control register value to output LNA signal
     * for CC2591 compression workaround.
     */
    #define RFC_OBS_CTRL_DEMOD_CCA        0x0D
    
    /* OBSSELn register value to select RF observable 0 */
    #define OBSSEL_OBS_CTRL0             0xFB
    
    /* OBSSELn register value to select RF observable 1 */
    #define OBSSEL_OBS_CTRL1             0xFC
    
    #define MAC_RADIO_CHANNEL_INVALID               0xFF
    
    
    /* ------------------------------------------------------------------------------------------------
     *                                      Common Radio Macros
     * ------------------------------------------------------------------------------------------------
     */
    #define MAC_RADIO_MCU_INIT()                          macMcuInit()
    
    #define MAC_RADIO_TURN_ON_POWER()                     macRadioTurnOnPower()
    #define MAC_RADIO_TURN_OFF_POWER()                    macRadioTurnOffPower()
    #define MAC_RADIO_TURN_ON_OSC()                       MAC_ASSERT(SLEEPSTA & XOSC_STB)/* oscillator should already be stable, it's mcu oscillator too */
    #define MAC_RADIO_TURN_OFF_OSC()                      /* don't do anything, oscillator is also mcu oscillator */
    
    #define MAC_RADIO_RX_FIFO_HAS_OVERFLOWED()            ((FSMSTAT1 & FIFOP) && !(FSMSTAT1 & FIFO))
    #define MAC_RADIO_RX_FIFO_IS_EMPTY()                  (!(FSMSTAT1 & FIFO) && !(FSMSTAT1 & FIFOP))
    
    #define MAC_RADIO_SET_RX_THRESHOLD(x)                 st( FIFOPCTRL = ((x)-1); )
    #define MAC_RADIO_RX_IS_AT_THRESHOLD()                (FSMSTAT1 & FIFOP)
    #define MAC_RADIO_ENABLE_RX_THRESHOLD_INTERRUPT()     MAC_MCU_FIFOP_ENABLE_INTERRUPT()
    #define MAC_RADIO_DISABLE_RX_THRESHOLD_INTERRUPT()    MAC_MCU_FIFOP_DISABLE_INTERRUPT()
    #define MAC_RADIO_CLEAR_RX_THRESHOLD_INTERRUPT_FLAG() MAC_MCU_FIFOP_CLEAR_INTERRUPT()
    
    #define MAC_RADIO_TX_ACK()                            MAC_RADIO_TURN_OFF_PENDING_OR()
    #define MAC_RADIO_TX_ACK_PEND()                       MAC_RADIO_TURN_ON_PENDING_OR()
    
    #define MAC_RADIO_RX_ON()                             st( RFST = ISRXON;    )
    #define MAC_RADIO_RXTX_OFF()                          st( RFST = ISRFOFF;   )
    #define MAC_RADIO_FLUSH_RX_FIFO()                     st( RFST = ISFLUSHRX; RFST = ISFLUSHRX; )
    #define MAC_RADIO_FLUSH_TX_FIFO()                     st( RFST = ISFLUSHTX; )
    
    #define MAC_RADIO_READ_RX_FIFO(pData,len)             macMemReadRxFifo((pData),(uint8)(len))
    #define MAC_RADIO_WRITE_TX_FIFO(pData,len)            macMemWriteTxFifo((pData),(uint8)(len))
    
    #define MAC_RADIO_SET_PAN_COORDINATOR(b)              st( FRMFILT0 = (FRMFILT0 & ~PAN_COORDINATOR) | (PAN_COORDINATOR * (b!=0)); )
    #define MAC_RADIO_SET_CHANNEL(x)                      st( FREQCTRL = FREQ_2405MHZ + 5 * ((x) - 11); )
    
    #define MAC_RADIO_SELECT_BOOST_MODE(x)                st( \
      if ((*(uint8 *)(P_INFOPAGE+0x03) == 0x95) || (*(uint8 *)(P_INFOPAGE+0x03) == 0x34)) \
      { \
        /* If boost mode is enabled, it is used for specific higher power levels. \
         * Thus, the code below must be in sync with which entries of pTable utilize boost mode. \
         * Currently, boost mode is only for >= 5dBm which corresponds to register setting 0xFD. \
         */ \
        reqTxBoost = ((x) == 0xFD) ? TRUE : FALSE; \
      } \
    )
    
    #define MAC_RADIO_SELECT_PTABLE(PTABLE)               st( \
      if ((*(uint8 *)(P_INFOPAGE+0x03) == 0x95) || (*(uint8 *)(P_INFOPAGE+0x03) == 0x34)) \
      { \
        MAC_RADIO_SELECT_PTABLE_CC2533((PTABLE)); \
      } \
      else \
      { \
        MAC_RADIO_SELECT_PTABLE_CC2530((PTABLE)); \
      } \
    )
    
    #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \
        defined MAC_RUNTIME_CC2592 || defined MAC_RUNTIME_SE2431L
    
    #define MAC_RADIO_SELECT_PTABLE_CC2530(PTABLE) \
      st( (PTABLE) = macRadioDefsTxPwrTables[macRadioDefsRefTableId >> 4]; )
    
    #define MAC_RADIO_SELECT_PTABLE_CC2533(PTABLE) \
      st( (PTABLE) = macRadioDefsTxPwrTables0x95[macRadioDefsRefTableId >> 4]; )
    
    #elif defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \
        defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592
    
    #define MAC_RADIO_SELECT_PTABLE_CC2530(PTABLE) \
      st( (PTABLE) = macRadioDefsTxPwrTables[0]; )
    
    #define MAC_RADIO_SELECT_PTABLE_CC2533(PTABLE) \
      st( (PTABLE) = macRadioDefsTxPwrTables0x95[0]; )
    
    #else
    
    #define MAC_RADIO_SELECT_PTABLE_CC2530(PTABLE) \
      st( (PTABLE) = macRadioDefsTxPwrBare; )
    
    #define MAC_RADIO_SELECT_PTABLE_CC2533(PTABLE) \
      st( (PTABLE) = macRadioDefsTxPwrBare0x95; )
    
    #endif
    
    #define MAC_RADIO_SET_TX_POWER(x)                     st( \
      if ((*(uint8 *)(P_INFOPAGE+0x03) == 0x95) || (*(uint8 *)(P_INFOPAGE+0x03) == 0x34)) \
      { \
         TXPOWER = macPhyTxPower; \
        if (reqTxBoost)  /* Configure the specific Boost Mode Tx register settings. */\
        { \
          FSCTRL = 0xF5; \
          TXCTRL = 0x74; \
        } \
        else             /* Restore non-boosted/default values. */\
        { \
          FSCTRL = 0x55; \
          TXCTRL = 0x69; \
        } \
      } \
      else \
      { \
         TXPOWER = x;\
      }\
     )\
    
    #define MAC_RADIO_SET_PAN_ID(x)                       st( PAN_ID0 = (x) & 0xFF; PAN_ID1 = (x) >> 8; )
    #define MAC_RADIO_SET_SHORT_ADDR(x)                   st( SHORT_ADDR0 = (x) & 0xFF; SHORT_ADDR1 = (x) >> 8; )
    #define MAC_RADIO_SET_IEEE_ADDR(p)                    macMemWriteRam((macRam_t *) &EXT_ADDR0, p, 8)
    
    #define MAC_RADIO_REQUEST_ACK_TX_DONE_CALLBACK()      st( MAC_MCU_TXACKDONE_CLEAR_INTERRUPT(); MAC_MCU_TXACKDONE_ENABLE_INTERRUPT(); )
    #define MAC_RADIO_CANCEL_ACK_TX_DONE_CALLBACK()       MAC_MCU_TXACKDONE_DISABLE_INTERRUPT()
    
    #define MAC_RADIO_RANDOM_BYTE()                       macMcuRandomByte()
    #define MAC_RADIO_RANDOM_WORD()                       macMcuRandomWord()
    
    #define MAC_RADIO_TX_RESET()                          macCspTxReset()
    #define MAC_RADIO_TX_PREP_CSMA_UNSLOTTED()            macCspTxPrepCsmaUnslotted()
    #define MAC_RADIO_TX_PREP_CSMA_SLOTTED()              macCspTxPrepCsmaSlotted()
    #define MAC_RADIO_TX_PREP_SLOTTED()                   macCspTxPrepSlotted()
    #define MAC_RADIO_TX_PREP_GREEN_POWER()               macCspTxPrepGreenPower()
    #define MAC_RADIO_TX_GO_CSMA()                        macCspTxGoCsma()
    #define MAC_RADIO_TX_GO_SLOTTED()                     macCspTxGoSlotted()
    #define MAC_RADIO_TX_GO_SLOTTED_CSMA()                macCspTxGoCsma()
    #define MAC_RADIO_TX_GO_GREEN_POWER()                 macCspTxGoGreenPower()
    
    #define MAC_RADIO_FORCE_TX_DONE_IF_PENDING()          macCspForceTxDoneIfPending()
    
    #define MAC_RADIO_TX_REQUEST_ACK_TIMEOUT_CALLBACK()   macCspTxRequestAckTimeoutCallback()
    #define MAC_RADIO_TX_CANCEL_ACK_TIMEOUT_CALLBACK()    macCspTxCancelAckTimeoutCallback()
    
    #define MAC_RADIO_TIMER_TICKS_PER_USEC()              HAL_CPU_CLOCK_MHZ /* never fractional */
    #define MAC_RADIO_TIMER_TICKS_PER_BACKOFF()           (HAL_CPU_CLOCK_MHZ * MAC_SPEC_USECS_PER_BACKOFF)
    #define MAC_RADIO_TIMER_TICKS_PER_SYMBOL()            (HAL_CPU_CLOCK_MHZ * MAC_SPEC_USECS_PER_SYMBOL)
    
    #define MAC_RADIO_TIMER_CAPTURE()                     macMcuTimerCapture()
    #define MAC_RADIO_TIMER_FORCE_DELAY(x)                macMcuTimerForceDelay(x)
    
    #define MAC_RADIO_TIMER_SLEEP()                       st( T2CTRL &= ~TIMER2_RUN; while(T2CTRL & TIMER2_STATE); )
    #define MAC_RADIO_TIMER_WAKE_UP()                     st( st( while (CLKCONSTA != (CLKCONCMD_32MHZ | OSC_32KHZ)); ); \
                                                              T2CTRL |= (TIMER2_RUN | TIMER2_SYNC); \
                                                              while(!(T2CTRL & TIMER2_STATE)); )
    
    #define MAC_RADIO_BACKOFF_COUNT()                     macMcuOverflowCount()
    #define MAC_RADIO_BACKOFF_CAPTURE()                   macMcuOverflowCapture()
    #define MAC_RADIO_BACKOFF_SET_COUNT(x)                macMcuOverflowSetCount(x)
    #define MAC_RADIO_BACKOFF_SET_COMPARE(x)              macMcuOverflowSetCompare(x)
    
    #define MAC_RADIO_BACKOFF_COMPARE_CLEAR_INTERRUPT()    st( T2IRQF  = (TIMER2_OVF_COMPARE1F ^ 0xFF); )
    #define MAC_RADIO_BACKOFF_COMPARE_ENABLE_INTERRUPT()   st( T2IRQM |= TIMER2_OVF_COMPARE1M; )
    #define MAC_RADIO_BACKOFF_COMPARE_DISABLE_INTERRUPT()  st( T2IRQM &= ~TIMER2_OVF_COMPARE1M; )
    
    #define MAC_RADIO_BACKOFF_SET_PERIOD(x)               macMcuOverflowSetPeriod(x)
    #define MAC_RADIO_BACKOFF_PERIOD_CLEAR_INTERRUPT()    st( T2IRQF  = (TIMER2_OVF_PERF ^ 0xFF); )
    #define MAC_RADIO_BACKOFF_PERIOD_ENABLE_INTERRUPT()   st( T2IRQM |= TIMER2_OVF_PERM; )
    #define MAC_RADIO_BACKOFF_PERIOD_DISABLE_INTERRUPT()  st( T2IRQM &= ~TIMER2_OVF_PERM; )
    
    #define MAC_RADIO_RECORD_MAX_RSSI_START()             macMcuRecordMaxRssiStart()
    #define MAC_RADIO_RECORD_MAX_RSSI_STOP()              macMcuRecordMaxRssiStop()
    
    #define MAC_RADIO_TURN_ON_RX_FRAME_FILTERING()        st( FRMFILT0  = 0; \
                                                              FRMFILT0 |= (FRAME_FILTER_EN | FRAME_FILTER_MAX_VERSION); )
    #define MAC_RADIO_TURN_OFF_RX_FRAME_FILTERING()       st( FRMFILT0 &= ~FRAME_FILTER_EN; )
    
    /*--------Source Matching------------*/
    
    #define MAC_RADIO_TURN_ON_AUTO_ACK()                  st( FRMCTRL0 |= AUTOACK; )
    #define MAC_RADIO_CANCEL_TX_ACK()                     st( RFST = ISNACK; )
    
    #define MAC_RADIO_TURN_ON_AUTOPEND_DATAREQ_ONLY()     st( SRCMATCH |= PEND_DATAREQ_ONLY; )
    
    #define MAC_RADIO_TURN_ON_SRC_MATCH()                 st( SRCMATCH |= SRC_MATCH_EN; )
    #define MAC_RADIO_TURN_ON_AUTOPEND()                  st( SRCMATCH |= AUTOPEND; )
    #define MAC_RADIO_IS_AUTOPEND_ON()                    ( SRCMATCH & AUTOPEND )
    #define MAC_RADIO_SRC_MATCH_RESINDEX(p)               st( p = SRCRESINDEX; )
    
    #define MAC_RADIO_TURN_ON_PENDING_OR()                st( FRMCTRL1 |= PENDING_OR; )
    #define MAC_RADIO_TURN_OFF_PENDING_OR()               st( FRMCTRL1 &= ~PENDING_OR; )
    
    #define MAC_RADIO_SRC_MATCH_GET_SHORTADDR_EN()        macSrcMatchGetShortAddrEnableBit()
    #define MAC_RADIO_SRC_MATCH_GET_EXTADDR_EN()          macSrcMatchGetExtAddrEnableBit()
    #define MAC_RADIO_SRC_MATCH_GET_SHORTADDR_PENDEN()    macSrcMatchGetShortAddrPendEnBit()
    #define MAC_RADIO_SRC_MATCH_GET_EXTADDR_PENDEN()      macSrcMatchGetExtAddrPendEnBit()
    
    #define MAC_RADIO_GET_SRC_SHORTPENDEN(p)              macMemReadRam( (uint8*)&SRCSHORTPENDEN0, (p), 3 )
    #define MAC_RADIO_GET_SRC_EXTENPEND(p)                macMemReadRam( (uint8*)&SRCEXTPENDEN0, (p), 3 )
    #define MAC_RADIO_GET_SRC_SHORTEN(p)                  macMemReadRam( (uint8*)&SRCSHORTEN0, (p), 3 )
    #define MAC_RADIO_GET_SRC_EXTEN(p)                    macMemReadRam( (uint8*)&SRCEXTEN0, (p), 3 )
    
    #define MAC_RADIO_SRC_MATCH_SET_SHORTPENDEN(p)        macMemWriteRam( (uint8*)&SRCSHORTPENDEN0, (p), 3 )
    #define MAC_RADIO_SRC_MATCH_SET_EXTPENDEN(p)          macMemWriteRam( (uint8*)&SRCEXTPENDEN0, (p), 3 )
    #define MAC_RADIO_SRC_MATCH_SET_SHORTEN(x)            osal_buffer_uint24( (uint8*)&SRCSHORTEN0, (x) )
    #define MAC_RADIO_SRC_MATCH_SET_EXTEN(x)              osal_buffer_uint24( (uint8*)&SRCEXTEN0, (x) )
    #define MAC_RADIO_SRC_MATCH_RESULT()                  MAC_SrcMatchCheckResult()
    
    #define MAC_RADIO_SRC_MATCH_INIT_EXTPENDEN()          st( SRCEXTPENDEN0 = 0; \
                                                              SRCEXTPENDEN1 = 0; \
                                                              SRCEXTPENDEN2 = 0; )
    #define MAC_RADIO_SRC_MATCH_INIT_SHORTPENDEN()        st( SRCSHORTPENDEN0 = 0; \
                                                              SRCSHORTPENDEN1 = 0; \
                                                              SRCSHORTPENDEN2 = 0; )
    
    #define MAC_RADIO_SRC_MATCH_TABLE_WRITE(offset, p, len)    macMemWriteRam( (macRam_t *)(SRC_ADDR_TABLE + (offset)), (p), (len) )
    #define MAC_RADIO_SRC_MATCH_TABLE_READ(offset, p, len)     macMemReadRam( SRC_ADDR_TABLE + (offset), (p), (len))
    
    
    /* ----------- PA/LNA control ---------- */
    /* For Skyworks parts only CPS maps closely to the HGM line */
    #define HAL_PA_LNA_RX_HGM()                           st( P0_7 = 1; )
    #define HAL_PA_LNA_RX_LGM()                           st( P0_7 = 0; )
    
    
    /* ----------- PA/LNA SKE2431L control ---------- */
    /* CSD Line high maps closely to EN which is controlled by hardware */ 
    #define HAL_PA_LNA_RX_CSD_HIGH()                          st( P1_3 = 1; ) 
    
    /* case of CC2590 CC2591 and CC2592. Non Skyworks part */
    #define HAL_PA_LNA_RX_CSD_LOW()                           st( P1_3 = 0; ) 
    
    /* ------------------------------------------------------------------------------------------------
     *                                        Global Variables
     * ------------------------------------------------------------------------------------------------
     */
    
    extern uint8 reqTxBoost;  /* CC2533/34-specific register settings to achieve highest Tx power. */
    extern uint8 paLnaChip;
    
    /* ------------------------------------------------------------------------------------------------
     *                                    Common Radio Externs
     * ------------------------------------------------------------------------------------------------
     */
    extern uint8 macRadioDefsRefTableId;
    extern const uint8 CODE *const CODE macRadioDefsTxPwrTables[];
    extern const uint8 CODE *const CODE macRadioDefsTxPwrTables0x95[];
    extern const int8 CODE macRadioDefsRssiAdj[];
    extern const int8 CODE macRadioDefsSensitivityAdj[];
    extern const int8 CODE macRadioDefsSaturationAdj[];
    extern const uint8 CODE macRadioDefsTxPwrBare[];
    extern const uint8 CODE macRadioDefsTxPwrBare0x95[];
    extern int8 macRadioRecieverSensitivity;
    extern int8 macRadioRecieverSaturation; 
    
    
    
    MAC_INTERNAL_API void macRadioTurnOnPower(void);
    MAC_INTERNAL_API void macRadioTurnOffPower(void);
    
    
    /* ------------------------------------------------------------------------------------------------
     *                              Transmit Power Setting Configuration
     * ------------------------------------------------------------------------------------------------
     */
    
    /*
     *  To use actual register values for setting power level, uncomment the following #define.
     *  In this case, the value passed to the set power function will be written directly to TXCTRLL.
     *  Characterized values for this register can be found in the datasheet in the "power settings" table.
     */
    //#define HAL_MAC_USE_REGISTER_POWER_VALUES
    
    
    /**************************************************************************************************
     */
    #endif
    

  • 就跟随官方的设置嘛, /* P1_1 -> PAEN */
    RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV;
    OBSSEL1 = OBSSEL_OBS_CTRL0;

    /* P1_0 -> EN (LNA control) */
    RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV;
    OBSSEL0 = OBSSEL_OBS_CTRL1;
  • 用示波器量CC2530作RF TX/RX時P1.1和P1.0有沒有正常運作

  • 你好,下午量了下刚刚又确认了下,都是低电平,没有一高一低。
  • 看看你的應用程序有沒有把P1.1和P1.0設置成其他功能