annotate Small_CPU/Inc/tm_stm32f4_otp.h @ 151:a98f91cca107 FlipDisplay

Bugfix ButtonResponsiveness
author Ideenmodellierer
date Sun, 03 Mar 2019 12:16:54 +0100
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 * @author Tilen Majerle
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @email tilen@majerle.eu
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @website http://stm32f4-discovery.com
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @link http://stm32f4-discovery.com/2015/01/library-49-one-time-programmable-otp-bytes-on-stm32f4xx
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @version v1.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @ide Keil uVision
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * @license GNU GPL v3
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * @brief OTP (One-Time Programmable) flash section library for STM32F4xx
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ----------------------------------------------------------------------
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 Copyright (C) Tilen Majerle, 2015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 This program is free software: you can redistribute it and/or modify
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 it under the terms of the GNU General Public License as published by
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 the Free Software Foundation, either version 3 of the License, or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 any later version.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 This program is distributed in the hope that it will be useful,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 GNU General Public License for more details.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 You should have received a copy of the GNU General Public License
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 ----------------------------------------------------------------------
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 #ifndef TM_STM32F4_OPT_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 #define TM_STM32F4_OPT_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 /* C++ detection */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #ifdef __cplusplus
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 extern "C" {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 * @addtogroup TM_STM32F4xx_Libraries
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 * @defgroup TM_OTP
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 * @brief OTP (One-Time Programmable) flash section library for STM32F4xx - http://stm32f4-discovery.com/2015/01/library-49-one-time-programmable-otp-bytes-on-stm32f4xx
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 * \par Changelog
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 Version 1.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 - First release
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 * \par Dependencies
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 - STM32F4xx
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 - STM32F4xx RCC
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 - STM32F4xx FLASH
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 - defines.h
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 //#include "stm32f4xx.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 //#include "stm32f4xx_rcc.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 //#include "stm32f4xx_flash.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 //#include "defines.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 * @defgroup TM_OTP_Macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 * @brief Library defines
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 * @brief OTP memory start address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 #define OTP_START_ADDR (0x1FFF7800)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 * @brief OTP memory lock address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 #define OTP_LOCK_ADDR (0x1FFF7A00)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 * @brief Number of OTP blocks
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 #define OTP_BLOCKS 16
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 * @brief Number of bytes in one block
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 #define OTP_BYTES_IN_BLOCK 32
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 * @brief Number of all OTP bytes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 #define OTP_SIZE (OTP_BLOCKS * OTP_BYTES_IN_BLOCK)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * @defgroup TM_OTP_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 * @brief Library Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 * @brief Writes one-time data to specific block and specific byte in this block
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 * @note You can only ONCE write data at desired byte in specific block, if you will try to do it more times, you can have broken data at this location.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 * @param block: OTP block number, 0 to 15 is allowed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 * @param byte: OTP byte inside one block, 0 to 31 is allowed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 * @param data: Data to be written to OTP memory
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 * @retval Member of @ref TM_OTP_Result_t enumeration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 HAL_StatusTypeDef TM_OTP_Write(uint8_t block, uint8_t byte, uint8_t data);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 * @brief Reads data from specific block and specific byte in this block
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 * @note You can read data unlimited times from locations
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 * @param block: OTP block number, 0 to 15 is allowed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 * @param byte: OTP byte inside one block, 0 to 31 is allowed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 * @retval Value at specific block and byte location, or 0 if location is invalid
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 uint8_t TM_OTP_Read(uint8_t block, uint8_t byte);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 /* C++ detection */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 #ifdef __cplusplus
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 #endif // TM_STM32F4_OPT_H