Token system for storing non-volatile information. See Tokens for documentation.

License#

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.

/***************************************************************************/
#ifndef __TOKEN_H__
#define __TOKEN_H__

#if defined(CORTEXM3)
  #ifdef MINIMAL_HAL
    #include "cortexm3/nvm-token.h"
    #include "cortexm3/mfg-token.h"
  #else //MINIMAL_HAL
    #include "cortexm3/token.h"
  #endif //MINIMAL_HAL
#elif (defined(EMBER_TEST) && !defined(ZIGBEE_STACK_ON_HOST))
  #include "generic/token-ram.h"
#elif (defined(EZSP_HOST) || defined(UNIX_HOST)) && defined(EMBER_AF_API_TOKEN)
  #include "unix/host/token.h"
#else
  #error invalid platform
#endif

EmberStatus halStackInitTokens(void);

// NOTE:
// The following API as written below is purely for doxygen
// documentation purposes.  The live API used in code is actually macros
// defined in the platform specific token headers and provide abstraction
// that can allow easy and efficient access to tokens in different
// implementations.

#ifdef DOXYGEN_SHOULD_SKIP_THIS

#define halCommonGetToken(data, token)

#define halCommonGetMfgToken(data, token)

#define halCommonGetIndexedToken(data, token, index)

#define halCommonSetToken(token, data)

#define halCommonSetIndexedToken(token, index, data)

#define halCommonIncrementCounterToken(token)

#endif //DOXYGEN_SHOULD_SKIP_THIS

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// These interfaces serve only as a glue layer
// to link creator codes to tokens (primarily for *test code)
  #define INVALID_EE_ADDRESS 0xFFFF
uint16_t getTokenAddress(uint16_t creator);
uint8_t getTokenSize(uint16_t creator);
uint8_t getTokenArraySize(uint16_t creator);

#endif //DOXYGEN_SHOULD_SKIP_THIS

#endif // __TOKEN_H__

Macros#

#define
halCommonGetToken (data, token)

Macro that copies the token value from non-volatile storage into a RAM location. This macro can only be used with tokens that are defined using DEFINE_BASIC_TOKEN.

#define
halCommonGetMfgToken (data, token)

Macro that copies the token value from non-volatile storage into a RAM location. This macro can only be used with tokens that are defined using DEFINE_MFG_TOKEN.

#define
halCommonGetIndexedToken (data, token, index)

Macro that copies the token value from non-volatile storage into a RAM location. This macro can only be used with tokens that are defined using DEFINE_INDEXED_TOKEN.

#define
halCommonSetToken (token, data)

Macro that sets the value of a token in non-volatile storage. This macro can only be used with tokens that are defined using DEFINE_BASIC_TOKEN.

#define
halCommonSetIndexedToken (token, index, data)

Macro that sets the value of a token in non-volatile storage. This macro can only be used with tokens that are defined using DEFINE_INDEXED_TOKEN.

#define

Macro that increments the value of a token that is a counter. This macro can only be used with tokens that are defined using either DEFINE_COUNTER_TOKEN.

Functions#

Initializes and enables the token system. Checks if the manufacturing and stack non-volatile data versions are correct.

Macro Definition Documentation#

halCommonGetToken#

#define halCommonGetToken

Macro that copies the token value from non-volatile storage into a RAM location. This macro can only be used with tokens that are defined using DEFINE_BASIC_TOKEN.

Note

  • To better understand the parameters of this macro, refer to the example of token usage above.


Definition at line 318 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h

halCommonGetMfgToken#

#define halCommonGetMfgToken

Macro that copies the token value from non-volatile storage into a RAM location. This macro can only be used with tokens that are defined using DEFINE_MFG_TOKEN.

Note

  • To better understand the parameters of this macro, refer to the example of token usage above.


Definition at line 333 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h

halCommonGetIndexedToken#

#define halCommonGetIndexedToken

Macro that copies the token value from non-volatile storage into a RAM location. This macro can only be used with tokens that are defined using DEFINE_INDEXED_TOKEN.

Note

  • To better understand the parameters of this macro, refer to the example of token usage above.


Definition at line 349 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h

halCommonSetToken#

#define halCommonSetToken

Macro that sets the value of a token in non-volatile storage. This macro can only be used with tokens that are defined using DEFINE_BASIC_TOKEN.

Note

  • To better understand the parameters of this macro, refer to the example of token usage above. For EFR32 devices this function must not be called in IRQ context as it can cause data corruption.


Definition at line 365 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h

halCommonSetIndexedToken#

#define halCommonSetIndexedToken

Macro that sets the value of a token in non-volatile storage. This macro can only be used with tokens that are defined using DEFINE_INDEXED_TOKEN.

Note

  • To better understand the parameters of this macro, refer to the example of token usage above.


Definition at line 382 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h

halCommonIncrementCounterToken#

#define halCommonIncrementCounterToken

Macro that increments the value of a token that is a counter. This macro can only be used with tokens that are defined using either DEFINE_COUNTER_TOKEN.

Note

  • To better understand the parameters of this macro, refer to the example of token usage above.


Definition at line 395 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h

Function Documentation#

halStackInitTokens#

EmberStatus halStackInitTokens (void )

Initializes and enables the token system. Checks if the manufacturing and stack non-volatile data versions are correct.

Parameters
N/A

Returns

  • An EmberStatus value indicating the success or failure of the command.


Definition at line 294 of file /mnt/raid/workspaces/ws.2dqDELv9z/overlay/gsdk/platform/base/hal/micro/token.h