1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*******************************************************************************
*
* Copyright (C) 2021 STMicroelectronics - All rights reserved
*
* This file is part of STM32CubeProgrammer project.
*
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
*
******************************************************************************/
#ifndef DEVICEDATASTRUCTURE
#define DEVICEDATASTRUCTURE
#ifdef __cplusplus
extern "C" {
#endif
#define R_ACCESS 0x0
#define W_ACCESS 0x1
#define RW_ACCESS 0x2
#define RWE_ACCESS 0x3
/* -------------------------------------------------------------------------------------------- */
/* OB Data Structures */
/* -------------------------------------------------------------------------------------------- */
/**
* \struct bankSector.
* \brief This stucture indicates the sectors parameters.
*/
typedef struct bankSector
{
unsigned int index ; /**< Index of the sector. */
unsigned int size ; /**< Sector size. */
unsigned int address ; /**< Sector starting address. */
}bankSector;
/**
* \struct deviceBank.
* \brief This stucture defines the memory sectors for each bank.
*/
typedef struct deviceBank
{
unsigned int sectorsNumber; /**< Number of sectors of the considered bank. */
bankSector* sectors; /**< Sectors specifications #Bank_Sector. */
}deviceBank;
/**
* \struct storageStructure.
* \brief This stucture describes sotrage characterization.
*/
typedef struct storageStructure
{
unsigned int banksNumber; /**< Number of exsisted banks. */
deviceBank* banks; /**< Banks sectors definition #Device_Bank. */
}storageStructure;
/**
* \struct bitCoefficient_C.
* \brief This stucture indicates the coefficients to access to the adequate option bit.
*/
typedef struct bitCoefficient_C
{
unsigned int multiplier; /**< Bit multiplier. */
unsigned int offset; /**< Bit offset. */
}bitCoefficient_C;
/**
* \struct bitValue_C.
* \brief This stucture describes the option Bit value.
*/
typedef struct bitValue_C
{
unsigned int value; /**< Option bit value. */
char description[1000]; /**< Option bit description. */
}bitValue_C;
/**
* \struct bit_C.
* \brief This stucture will be filled by values which characterize the device's option bytes.
* \note See product reference manual for more details.
*/
typedef struct bit_C
{
char name[64]; /**< Bit name such as RDP, BOR_LEV, nBOOT0... */
char description[1000]; /**< Config description. */
unsigned int wordOffset; /**< Word offset. */
unsigned int bitOffset; /**< Bit offset. */
unsigned int bitWidth; /**< Number of bits build the option. */
unsigned char access; /**< Access Read/Write. */
unsigned int valuesNbr; /**< Number of possible values. */
bitValue_C** values; /**< Bits value, #BitValue_C. */
bitCoefficient_C equation; /**< Bits equation, #BitCoefficient_C. */
unsigned char* reference;
unsigned int bitValue;
}bit_C;
/**
* \struct category_C
* \brief Get option bytes banks categories descriptions.
*/
typedef struct category_C
{
char name[100]; /**< Get category name such as Read Out Protection, BOR Level... */
unsigned int bitsNbr; /**< Get bits number of the considered category. */
bit_C** bits; /**< Get internal bits descriptions. */
}category_C;
/**
* \struct bank_C
* \brief Get option bytes banks internal descriptions.
* \note STLINK and Bootloader interfaces have different addresses to access to option bytes registres.
*/
typedef struct bank_C
{
unsigned int size; /**< Bank size. */
unsigned int address; /**< Bank starting address. */
unsigned char access; /**< Bank access Read/Write. */
unsigned int categoriesNbr; /**< Number of option bytes categories. */
category_C** categories; /**< Get bank categories descriptions #Category_C. */
}bank_C;
/**
* \struct peripheral_C
* \brief Get peripheral option bytes general informations.
*/
typedef struct peripheral_C
{
char name[64]; /**< Peripheral name. */
char description[1000]; /**< Peripheral description. */
unsigned int banksNbr; /**< Number of existed banks. */
bank_C** banks; /**< Get banks descriptions #Bank_C. */
}peripheral_C;
#ifdef __cplusplus
}
#endif
#endif // DEVICEDATASTRUCTURE