/************************************************************************************
* This is a global header file for setting up the functionalities that should be
* included in the build.
*
* Author(s): JRJEN1
*
* (c) Copyright 2004, Freescale, Inc.  All rights reserved.
*
* Freescale Confidential Proprietary
* Digianswer Confidential
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale.
*
* Last Inspected:
* Last Tested:
*
* Source Safe revision history (Do not edit manually) 
*   $Date: 29-04-04 13:08 $
*   $Author: Jshol1 $
*   $Revision: 22 $
*   $Workfile: FunctionalityDefines.h $
************************************************************************************/

#ifndef _FUNCTIONALITY_DEFINES_H_
#define _FUNCTIONALITY_DEFINES_H_

//#define ANTENNE_SWITCH_ENABLED  //Define ONLY used in Target.h
//#define I_AM_A_SNIFFER

//#define Type_RFD

  // All device types: (are defined because of HC08 compiler problems only)
#define gDeviceTypeRFDNBNS_d  1
#define gDeviceTypeRFDNBNV_d  2
#define gDeviceTypeRFDNB_d    3
#define gDeviceTypeRFD_d      4
#define gDeviceTypeFFDNBNS_d  5
#define gDeviceTypeFFDNBNV_d  6
#define gDeviceTypeFFDNB_d    7
#define gDeviceTypeFFDNGTS_d  8
#define gDeviceTypeFFD_d      9
#define gDeviceTypeFFDPNBNV_d 10

// Target specific compiler defines (no value) "Type_..."
#ifdef Type_RFDNBNS
	#define gDeviceType_d gDeviceTypeRFDNBNS_d
	#define DEVICE_TYPE "RFDNBNS"
#endif Type_RFDNBNS

#ifdef Type_RFDNBNV
	#define gDeviceType_d gDeviceTypeRFDNBNV_d
	#define DEVICE_TYPE "RFDNBNV"
#endif Type_RFDNBNV

#ifdef  Type_RFDNB
	#define gDeviceType_d gDeviceTypeRFDNB_d
	#define DEVICE_TYPE "RFDNB"
#endif  Type_RFDNB

#ifdef Type_RFD
	#define gDeviceType_d gDeviceTypeRFD_d
	#define DEVICE_TYPE "RFD  "
#endif Type_RFD

#ifdef Type_FFDNBNS
	#define gDeviceType_d gDeviceTypeFFDNBNS_d
	#define DEVICE_TYPE "FFDNBNS"
#endif Type_FFDNBNS

#ifdef Type_FFDNBNV
	#define gDeviceType_d gDeviceTypeFFDNBNV_d
	#define DEVICE_TYPE "FFDNBNV"
#endif Type_FFDNBNV

#ifdef Type_FFDNB
	#define gDeviceType_d gDeviceTypeFFDNB_d
	#define DEVICE_TYPE "FFDNB"
#endif Type_FFDNB

#ifdef Type_FFDNGTS
	#define gDeviceType_d gDeviceTypeFFDNGTS_d
	#define DEVICE_TYPE "FFDNGTS"
#endif Type_FFDNGTS

#ifdef Type_FFD
	#define gDeviceType_d gDeviceTypeFFD_d
	#define DEVICE_TYPE "FFD  "
#endif Type_FFD

#ifdef Type_FFDPNBNV
	#define gDeviceType_d gDeviceTypeFFDPNBNV_d
	#define DEVICE_TYPE "FFPNBNV"
#endif Type_FFDPNBNV

#ifndef gDeviceType_d // If device type is not predefined use the following definitions:

  #define DEVICE_TYPE "XXXXXXX" // Max size

  /**********************************************************************************
  ***********************************************************************************
  * Role capability definitions
  ***********************************************************************************
  **********************************************************************************/

    // Set if the device need to be able to take on the device role
  #define gDeviceCapability_d 1

    // Set if the device need to be able to take on the coordinator role
  #define gCoorCapability_d 1

  /**********************************************************************************
  ***********************************************************************************
  * Functionality inclusion definitions that depend on device type
  ***********************************************************************************
  **********************************************************************************/

    // Set if the device need to be able to take on the pan coordinator role
    // Is never set unless coordinator capability is set
  #define gPanCoorCapability_d (1 && gCoorCapability_d)

    // Set if device (in role of either device or ccordinator) supports beaconed
    // operation. Note that ...
  #define gBeaconedCapability_d 1

    // Set if device (in role of either device or PAN cordinator) supports GTS in
    // beaconed operation. Is never set unless beaconed operation is supported
  #define gGtsCapability_d (1 && gBeaconedCapability_d && (gDeviceCapability_d || gPanCoorCapability_d))

    // SCAN functionalities - optional for RFD and below (=spec. RFD)
  #define gEnergyScanCapability_d 1
  #define gActiveScanCapability_d 1

    // MCPS-PURGE.request capabilities
  #define gPurgeCapability_d 1
  
    // Set if security is supported in the MAC/PHY
  #define gSecurityCapability_d 1

    // Define to 0 to disabled or 1 to enable verification of NWK to MLME primitives
  #define gVerifyParamCapability_d 1

#else // If gDeviceType_d is defined use one of the following presets:

  #if gDeviceType_d == gDeviceTypeFFD_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        1
    #define gPanCoorCapability_d     1
    #define gBeaconedCapability_d    1
    #define gGtsCapability_d         1
    #define gEnergyScanCapability_d  1
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       1
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeFFDNGTS_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        1
    #define gPanCoorCapability_d     1
    #define gBeaconedCapability_d    1
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  1
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       1
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeFFDNB_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        1
    #define gPanCoorCapability_d     1
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  1
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       1
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeFFDNBNS_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        1
    #define gPanCoorCapability_d     1
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  1
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       1
    #define gSecurityCapability_d    0
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeFFDNBNV_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        1
    #define gPanCoorCapability_d     1
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  1
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       1
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 0
  #elif gDeviceType_d == gDeviceTypeRFD_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        0
    #define gPanCoorCapability_d     0
    #define gBeaconedCapability_d    1
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  0
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       0 
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeRFDNB_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        0
    #define gPanCoorCapability_d     0
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  0
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       0 
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeRFDNBNS_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        0
    #define gPanCoorCapability_d     0
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  0
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       0 
    #define gSecurityCapability_d    0
    #define gVerifyParamCapability_d 1
  #elif gDeviceType_d == gDeviceTypeRFDNBNV_d
    #define gDeviceCapability_d      1
    #define gCoorCapability_d        0
    #define gPanCoorCapability_d     0
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  0
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       0 
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 0
  #elif gDeviceType_d == gDeviceTypeFFDPNBNV_d
    #define gDeviceCapability_d      0
    #define gCoorCapability_d        1
    #define gPanCoorCapability_d     1
    #define gBeaconedCapability_d    0
    #define gGtsCapability_d         0
    #define gEnergyScanCapability_d  1
    #define gActiveScanCapability_d  1
    #define gPurgeCapability_d       1
    #define gSecurityCapability_d    1
    #define gVerifyParamCapability_d 0
  #else
    #error Invalid gDeviceType_d define value
  #endif // gDeviceType_d
#endif // !gDeviceType_d

/************************************************************************************
*************************************************************************************
* Functionality inclusion definitions that are not directly dependant on device type
*************************************************************************************
************************************************************************************/

  // Set if the common security library should be included.
#define gSecurityLibraryCapability_d 0

  // Set if ASP features are supported
#define gAspCapability_d             1
#define gAspPowerSaveCapability_d   (1 && gAspCapability_d)
#define gAspNvRamCapability_d       (0 && gAspCapability_d)
#define gAspEventCapability_d       (1 && gAspCapability_d)
#define gAspHwCapability_d          (1 && gAspCapability_d)
#define gAspJapanTelecCapability_d  (0 && gAspCapability_d)
#define gAspPowerLevelCapability_d  (1 && gAspCapability_d)

  // Set to 1 if new disassociate request primitive must be supported. Does not require additional code.
#define gNewDisassociateReq_d 0

  // Set to 0 if you do not want random initialisation of macDSN, macBSN, and the random backoff seed
#define gInitializeWithRandomSeed 1

  // Set to one to support the RX Enable feature
#define gRxEnableCapability_d 1

#if gGtsCapability_d==1
#undef gGtsCapability_d
#define gGtsCapability_d 1   // Master switch for GTS feature
#endif // gGtsCapability_d


/************************************************************************************
*************************************************************************************
* Buffer control definitions (numbers of but not sizes of message buffers)
*************************************************************************************
************************************************************************************/

  // Number of "small" message buffers needed
#define gTotalSmallMsgs_d 5

  // Buffers needed for TX (should be 1 but is 2 because...)
#define gBigMsgsForMinimumFunctionality_d 2

  // Buffers needed for RX
#define gBigMsgsCoorCapability_d (1 * gCoorCapability_d)

  // Buffer needed for beaconed operation (needed for either RX or TX of beacon)
#define gBigMsgsBeaconedCapability_d (1 * gBeaconedCapability_d )

  // Buffers needed for GTS (This parameter heavily depend on the usage scenario)
#define gBigMsgsGtsCapability_d (2 * gGtsCapability_d)

  // Message buffers needed for:
  // 1) If NWK want to send more than one MCPS-Data.Request before getting the
  //    corresponding MCPS-Data.Confirm
  // 2) TBD
#define gBigMsgsExtraNwkPending_d 1

  // Here any extra message buffers other than required for normal operation may be
  // defined...
#define gBigMsgsExtraOverhead_d 0

  // The sum of buffers needed for "big" messages is calculated
#define gTotalBigMsgs_d gBigMsgsForMinimumFunctionality_d +  \
                        gBigMsgsCoorCapability_d +           \
                        gBigMsgsBeaconedCapability_d +       \
                        gBigMsgsGtsCapability_d +            \
                        gBigMsgsExtraNwkPending_d +          \
                        gBigMsgsExtraOverhead_d

  // Number of big buffers not available to upper layers.
#define gBigMsgsMacOnly_d (1 && gCoorCapability_d)

  // Hack to ensure enough RAM for security by setting a maximum number of big messages:
#if gSecurityCapability_d
  #if gTotalBigMsgs_d > 5
    #undef gTotalBigMsgs_d
    #define gTotalBigMsgs_d 5
  #endif
#endif

  // Number of ACL entries in MAC PIB. 0 if security not enabled.
#define gNumAclEntryDescriptors_c (4 * gSecurityCapability_d)

/************************************************************************************
*************************************************************************************
* Proprietary stuff... 
*************************************************************************************
************************************************************************************/


  // Treemode capability
#define gTreemodeCapability_d (1 && gCoorCapability_d && gDeviceCapability_d && gBeaconedCapability_d)

  // Beacon start indications
#define gBeaconStartIndicationCapability_d 0 // Used to be: (0 || gTreemodeCapability_d)

#endif /* _FUNCTIONALITY_DEFINES_H_ */
