Contiki 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
cpu
stm32w108
hal
micro
cortexm3
mfg-token.h
Go to the documentation of this file.
1
/** \file cpu/stm32w108/hal/micro/cortexm3/mfg-token.h
2
* \brief Cortex-M3 Manufacturing token system
3
*
4
* <!--(C) COPYRIGHT 2010 STMicroelectronics. All rights reserved. -->
5
*/
6
7
#ifndef MFG_TOKEN_H_
8
#define MFG_TOKEN_H_
9
10
#ifndef DOXYGEN_SHOULD_SKIP_THIS
11
12
// The manufacturing tokens live in the Info Blocks, while all other tokens
13
// live in the Simulated EEPROM. This requires the token names to be defined
14
// as different data (mfg tokens are memory address, all others are an enum).
15
16
17
#define DEFINETOKENS
18
19
/**
20
* \brief Macro for translating token defs into address variables
21
* that point to the correct location in the Info Blocks. (This is the
22
* extern, the actual definition is found in hal/micro/cortexm3/token.c)
23
*
24
* \param name: The name of the token.
25
* \param creator: The manufacturing creators.
26
* \param iscnt:
27
* \param isidx:
28
* \param type: The token type. The types are found in token-stack.h.
29
* \param arraysize: The number of elements in an indexed token (arraysize=1
30
* for scalar tokens).
31
*/
32
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
33
extern const uint16_t TOKEN_##name;
34
#include "
cpu/stm32w108/hal/micro/cortexm3/token-manufacturing.h
"
35
#undef TOKEN_MFG
36
37
/**
38
* \brief Macro for translating token definitions into size variables.
39
* This provides a convenience for abstracting the 'sizeof(type)' anywhere.
40
*
41
* \param name: The name of the token.
42
* \param creator: The manufacturing creators.
43
* \param iscnt:
44
* \param isidx:
45
* \param type: The token type. The types are found in token-stack.h.
46
* \param arraysize: The number of elements in an indexed token (arraysize=1
47
* for scalar tokens).
48
*/
49
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
50
TOKEN_##name##_SIZE = sizeof(type),
51
enum
{
52
#include "
cpu/stm32w108/hal/micro/cortexm3/token-manufacturing.h
"
53
};
54
#undef TOKEN_MFG
55
#undef TOKEN_DEF
56
57
/**
58
* \brief Macro for typedef'ing the CamelCase token type found in
59
* token-stack.h to a capitalized TOKEN style name that ends in _TYPE.
60
* This macro allows other macros below to use 'token\#\#_TYPE' to declare
61
* a local copy of that token.
62
*
63
* \param name: The name of the token.
64
* \param creator: The manufacturing creators.
65
* \param iscnt:
66
* \param isidx:
67
* \param type: The token type. The types are found in token-stack.h.
68
* \param arraysize: The number of elements in an indexed token (arraysize=1
69
* for scalar tokens).
70
*/
71
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
72
typedef type TOKEN_##name##_TYPE;
73
#include "
cpu/stm32w108/hal/micro/cortexm3/token-manufacturing.h
"
74
#undef TOKEN_MFG
75
76
#undef TOKEN_NEXT_ADDRESS
77
78
#define DEFINEADDRESSES
79
/**
80
* \brief Macro for creating a 'region' element in the enum below. This
81
* creates an element in the enum that provides a starting point (address) for
82
* subsequent tokens to align against. ( See hal/micro/cortexm3/token.c for
83
* the instances of TOKEN_NEXT_ADDRESS() );
84
*
85
* \param region: The name to give to the element in the address enum.
86
* \param address: The address in EEPROM where the region begins.
87
*/
88
#define TOKEN_NEXT_ADDRESS(region, address) \
89
TOKEN_##region##_NEXT_ADDRESS = ((address) - 1),
90
91
/**
92
* \brief Macro for creating ADDRESS and END elements for each token in
93
* the enum below. The ADDRESS element is linked to from the the normal
94
* TOKEN_\#\#name macro and provides the value passed into the internal token
95
* system calls. The END element is a placeholder providing the starting
96
* point for the ADDRESS of the next dynamically positioned token.
97
*
98
* \param name: The name of the token.
99
* \param creator: The manufacturing creators.
100
* \param iscnt:
101
* \param isidx:
102
* \param type: The token type. The types are found in token-stack.h.
103
* \param arraysize: The number of elements in an indexed token (arraysize=1
104
* for scalar tokens).
105
*/
106
#define TOKEN_MFG(name,creator,iscnt,isidx,type,arraysize,...) \
107
TOKEN_##name##_ADDRESS, \
108
TOKEN_##name##_END = TOKEN_##name##_ADDRESS + \
109
(TOKEN_##name##_SIZE * arraysize) - 1,
110
111
/**
112
* \brief The enum that operates on the two macros above. Also provides
113
* an indentifier so the address of the top of the token system can be known.
114
*/
115
enum
{
116
#include "
hal/micro/cortexm3/token-manufacturing.h
"
117
};
118
#undef TOKEN_MFG
119
#undef DEFINEADDRESSES
120
121
#undef DEFINETOKENS
122
123
/**
124
* \brief Copies the token value from non-volatile storage into a RAM
125
* location. This is the internal function that the exposed API
126
* (halCommonGetMfgToken) expands out to. The
127
* API simplifies the access into this function by hiding the size parameter.
128
*
129
* \param data: A pointer to where the data being read should be placed.
130
*
131
* \param token: The name of the token to get data from. On this platform
132
* that name is defined as an address.
133
*
134
* \param index: The index to access. If the token being accessed is not an
135
* indexed token, this parameter is set by the API to be 0x7F.
136
*
137
* \param len: The length of the token being worked on. This value is
138
* automatically set by the API to be the size of the token.
139
*/
140
void
halInternalGetMfgTokenData(
void
*data, uint16_t token, uint8_t index, uint8_t len);
141
142
/**
143
* \brief Sets the value of a token in non-volatile storage. This is
144
* the internal function that the exposed API (halCommonSetMfgToken)
145
* expands out to. The API simplifies the access into this function
146
* by hiding the size parameter.
147
*
148
* <b>NOTE:</b> CIB manufacturing tokens can only be written by on-chip
149
* code if the token is currently unprogrammed.
150
*
151
* <b>REMEMBER:</b> The flash hardware requires writing to 16bit aligned
152
* addresses with a length that is multiples of 16bits.
153
*
154
* \param token: The name of the token to get data from. On this platform
155
* that name is defined as an address.
156
*
157
* \param data: A pointer to the data being written.
158
*
159
* \param len: The length of the token being worked on. This value is
160
* automatically set by the API to be the size of the token.
161
*/
162
void
halInternalSetMfgTokenData(uint16_t token,
void
*data, uint8_t len);
163
164
#define halCommonGetMfgToken( data, token ) \
165
halInternalGetMfgTokenData(data, token, 0x7F, token##_SIZE)
166
167
#define halCommonGetIndexedMfgToken( data, token, index ) \
168
halInternalGetMfgTokenData(data, token, index, token##_SIZE)
169
170
#define halCommonSetMfgToken( token, data ) \
171
halInternalSetMfgTokenData(token, data, token##_SIZE)
172
173
#endif //DOXYGEN_SHOULD_SKIP_THIS
174
175
#endif //MFG_TOKEN_H_
token-manufacturing.h
Definitions for manufacturing tokens.
Generated on Thu Jul 6 2017 20:52:51 for Contiki 3.x by
1.8.6