2014-06-19 12:30:33 +00:00
|
|
|
/** \file cpu/stm32w108/hal/micro/cortexm3/mfg-token.h
|
|
|
|
* \brief Cortex-M3 Manufacturing token system
|
2010-10-25 09:03:38 +00:00
|
|
|
*
|
|
|
|
* <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
|
|
|
|
*/
|
2014-06-19 12:28:13 +00:00
|
|
|
|
2013-11-24 15:57:08 +00:00
|
|
|
#ifndef MFG_TOKEN_H_
|
|
|
|
#define MFG_TOKEN_H_
|
2014-06-19 12:28:13 +00:00
|
|
|
|
2015-10-30 07:55:11 +00:00
|
|
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
2010-10-25 09:03:38 +00:00
|
|
|
|
|
|
|
// The manufacturing tokens live in the Info Blocks, while all other tokens
|
|
|
|
// live in the Simulated EEPROM. This requires the token names to be defined
|
|
|
|
// as different data (mfg tokens are memory address, all others are an enum).
|
|
|
|
|
|
|
|
|
|
|
|
#define DEFINETOKENS
|
|
|
|
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Macro for translating token defs into address variables
|
2010-10-25 09:03:38 +00:00
|
|
|
* that point to the correct location in the Info Blocks. (This is the
|
|
|
|
* extern, the actual definition is found in hal/micro/cortexm3/token.c)
|
|
|
|
*
|
2015-10-30 07:55:11 +00:00
|
|
|
* \param name: The name of the token.
|
|
|
|
* \param creator: The manufacturing creators.
|
|
|
|
* \param iscnt:
|
|
|
|
* \param isidx:
|
|
|
|
* \param type: The token type. The types are found in token-stack.h.
|
|
|
|
* \param arraysize: The number of elements in an indexed token (arraysize=1
|
|
|
|
* for scalar tokens).
|
2010-10-25 09:03:38 +00:00
|
|
|
*/
|
|
|
|
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
|
2013-03-15 15:14:09 +00:00
|
|
|
extern const uint16_t TOKEN_##name;
|
2014-06-19 12:30:33 +00:00
|
|
|
#include "cpu/stm32w108/hal/micro/cortexm3/token-manufacturing.h"
|
2010-10-25 09:03:38 +00:00
|
|
|
#undef TOKEN_MFG
|
|
|
|
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Macro for translating token definitions into size variables.
|
2010-10-25 09:03:38 +00:00
|
|
|
* This provides a convenience for abstracting the 'sizeof(type)' anywhere.
|
|
|
|
*
|
2015-10-30 07:55:11 +00:00
|
|
|
* \param name: The name of the token.
|
|
|
|
* \param creator: The manufacturing creators.
|
|
|
|
* \param iscnt:
|
|
|
|
* \param isidx:
|
|
|
|
* \param type: The token type. The types are found in token-stack.h.
|
|
|
|
* \param arraysize: The number of elements in an indexed token (arraysize=1
|
|
|
|
* for scalar tokens).
|
2010-10-25 09:03:38 +00:00
|
|
|
*/
|
|
|
|
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
|
|
|
|
TOKEN_##name##_SIZE = sizeof(type),
|
|
|
|
enum {
|
2014-06-19 12:30:33 +00:00
|
|
|
#include "cpu/stm32w108/hal/micro/cortexm3/token-manufacturing.h"
|
2010-10-25 09:03:38 +00:00
|
|
|
};
|
|
|
|
#undef TOKEN_MFG
|
|
|
|
#undef TOKEN_DEF
|
2014-06-19 12:30:33 +00:00
|
|
|
|
2010-10-25 09:03:38 +00:00
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Macro for typedef'ing the CamelCase token type found in
|
2010-10-25 09:03:38 +00:00
|
|
|
* token-stack.h to a capitalized TOKEN style name that ends in _TYPE.
|
2015-10-30 07:55:11 +00:00
|
|
|
* This macro allows other macros below to use 'token\#\#_TYPE' to declare
|
2010-10-25 09:03:38 +00:00
|
|
|
* a local copy of that token.
|
|
|
|
*
|
2015-10-30 07:55:11 +00:00
|
|
|
* \param name: The name of the token.
|
|
|
|
* \param creator: The manufacturing creators.
|
|
|
|
* \param iscnt:
|
|
|
|
* \param isidx:
|
|
|
|
* \param type: The token type. The types are found in token-stack.h.
|
|
|
|
* \param arraysize: The number of elements in an indexed token (arraysize=1
|
|
|
|
* for scalar tokens).
|
2010-10-25 09:03:38 +00:00
|
|
|
*/
|
|
|
|
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
|
|
|
|
typedef type TOKEN_##name##_TYPE;
|
2014-06-19 12:30:33 +00:00
|
|
|
#include "cpu/stm32w108/hal/micro/cortexm3/token-manufacturing.h"
|
2010-10-25 09:03:38 +00:00
|
|
|
#undef TOKEN_MFG
|
|
|
|
|
2014-06-19 12:30:33 +00:00
|
|
|
#undef TOKEN_NEXT_ADDRESS
|
|
|
|
|
2010-10-25 09:03:38 +00:00
|
|
|
#define DEFINEADDRESSES
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Macro for creating a 'region' element in the enum below. This
|
2010-10-25 09:03:38 +00:00
|
|
|
* creates an element in the enum that provides a starting point (address) for
|
|
|
|
* subsequent tokens to align against. ( See hal/micro/cortexm3/token.c for
|
|
|
|
* the instances of TOKEN_NEXT_ADDRESS() );
|
|
|
|
*
|
2015-10-30 07:55:11 +00:00
|
|
|
* \param region: The name to give to the element in the address enum.
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param address: The address in EEPROM where the region begins.
|
2010-10-25 09:03:38 +00:00
|
|
|
*/
|
|
|
|
#define TOKEN_NEXT_ADDRESS(region, address) \
|
|
|
|
TOKEN_##region##_NEXT_ADDRESS = ((address) - 1),
|
|
|
|
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Macro for creating ADDRESS and END elements for each token in
|
2010-10-25 09:03:38 +00:00
|
|
|
* the enum below. The ADDRESS element is linked to from the the normal
|
2015-10-30 07:55:11 +00:00
|
|
|
* TOKEN_\#\#name macro and provides the value passed into the internal token
|
2010-10-25 09:03:38 +00:00
|
|
|
* system calls. The END element is a placeholder providing the starting
|
|
|
|
* point for the ADDRESS of the next dynamically positioned token.
|
|
|
|
*
|
2015-10-30 07:55:11 +00:00
|
|
|
* \param name: The name of the token.
|
|
|
|
* \param creator: The manufacturing creators.
|
|
|
|
* \param iscnt:
|
|
|
|
* \param isidx:
|
|
|
|
* \param type: The token type. The types are found in token-stack.h.
|
|
|
|
* \param arraysize: The number of elements in an indexed token (arraysize=1
|
|
|
|
* for scalar tokens).
|
2010-10-25 09:03:38 +00:00
|
|
|
*/
|
|
|
|
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
|
|
|
|
TOKEN_##name##_ADDRESS, \
|
|
|
|
TOKEN_##name##_END = TOKEN_##name##_ADDRESS + \
|
|
|
|
(TOKEN_##name##_SIZE * arraysize) - 1,
|
|
|
|
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief The enum that operates on the two macros above. Also provides
|
2010-10-25 09:03:38 +00:00
|
|
|
* an indentifier so the address of the top of the token system can be known.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
#include "hal/micro/cortexm3/token-manufacturing.h"
|
|
|
|
};
|
|
|
|
#undef TOKEN_MFG
|
|
|
|
#undef DEFINEADDRESSES
|
|
|
|
|
|
|
|
#undef DEFINETOKENS
|
|
|
|
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Copies the token value from non-volatile storage into a RAM
|
2010-10-25 09:03:38 +00:00
|
|
|
* location. This is the internal function that the exposed API
|
|
|
|
* (halCommonGetMfgToken) expands out to. The
|
|
|
|
* API simplifies the access into this function by hiding the size parameter.
|
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param data: A pointer to where the data being read should be placed.
|
2010-10-25 09:03:38 +00:00
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param token: The name of the token to get data from. On this platform
|
2010-10-25 09:03:38 +00:00
|
|
|
* that name is defined as an address.
|
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param index: The index to access. If the token being accessed is not an
|
2010-10-25 09:03:38 +00:00
|
|
|
* indexed token, this parameter is set by the API to be 0x7F.
|
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param len: The length of the token being worked on. This value is
|
2010-10-25 09:03:38 +00:00
|
|
|
* automatically set by the API to be the size of the token.
|
|
|
|
*/
|
2013-03-15 15:14:09 +00:00
|
|
|
void halInternalGetMfgTokenData(void *data, uint16_t token, uint8_t index, uint8_t len);
|
2010-10-25 09:03:38 +00:00
|
|
|
|
|
|
|
/**
|
2014-06-19 12:30:33 +00:00
|
|
|
* \brief Sets the value of a token in non-volatile storage. This is
|
2010-10-25 09:03:38 +00:00
|
|
|
* the internal function that the exposed API (halCommonSetMfgToken)
|
|
|
|
* expands out to. The API simplifies the access into this function
|
|
|
|
* by hiding the size parameter.
|
|
|
|
*
|
|
|
|
* <b>NOTE:</b> CIB manufacturing tokens can only be written by on-chip
|
|
|
|
* code if the token is currently unprogrammed.
|
|
|
|
*
|
|
|
|
* <b>REMEMBER:</b> The flash hardware requires writing to 16bit aligned
|
|
|
|
* addresses with a length that is multiples of 16bits.
|
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param token: The name of the token to get data from. On this platform
|
2010-10-25 09:03:38 +00:00
|
|
|
* that name is defined as an address.
|
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param data: A pointer to the data being written.
|
2010-10-25 09:03:38 +00:00
|
|
|
*
|
2014-06-19 12:30:33 +00:00
|
|
|
* \param len: The length of the token being worked on. This value is
|
2010-10-25 09:03:38 +00:00
|
|
|
* automatically set by the API to be the size of the token.
|
|
|
|
*/
|
2013-03-15 15:14:09 +00:00
|
|
|
void halInternalSetMfgTokenData(uint16_t token, void *data, uint8_t len);
|
2010-10-25 09:03:38 +00:00
|
|
|
|
|
|
|
#define halCommonGetMfgToken( data, token ) \
|
|
|
|
halInternalGetMfgTokenData(data, token, 0x7F, token##_SIZE)
|
|
|
|
|
|
|
|
#define halCommonGetIndexedMfgToken( data, token, index ) \
|
|
|
|
halInternalGetMfgTokenData(data, token, index, token##_SIZE)
|
|
|
|
|
|
|
|
#define halCommonSetMfgToken( token, data ) \
|
|
|
|
halInternalSetMfgTokenData(token, data, token##_SIZE)
|
|
|
|
|
|
|
|
#endif //DOXYGEN_SHOULD_SKIP_THIS
|
|
|
|
|
2013-11-24 15:57:08 +00:00
|
|
|
#endif //MFG_TOKEN_H_
|