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