TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_otp.h
1 
30 #ifndef TM_OTP_H
31 #define TM_OTP_H 100
32 
33 /* C++ detection */
34 #ifdef __cplusplus
35 extern C {
36 #endif
37 
63 #include "stm32f4xx.h"
64 #include "stm32f4xx_rcc.h"
65 #include "stm32f4xx_flash.h"
66 #include "defines.h"
67 
77 #define OTP_START_ADDR (0x1FFF7800)
78 
82 #define OTP_LOCK_ADDR (0x1FFF7A00)
83 
87 #define OTP_BLOCKS 16
88 
92 #define OTP_BYTES_IN_BLOCK 32
93 
97 #define OTP_SIZE (OTP_BLOCKS * OTP_BYTES_IN_BLOCK)
98 
112 typedef enum {
118 
137 TM_OTP_Result_t TM_OTP_Write(uint8_t block, uint8_t byte, uint8_t data);
138 
146 uint8_t TM_OTP_Read(uint8_t block, uint8_t byte);
147 
155 TM_OTP_Result_t TM_OTP_BlockLock(uint8_t block);
156 
164 #define TM_OTP_BlockLocked(block) ((*(__IO uint8_t *) (OTP_LOCK_ADDR + block)) == 0x00 ? 1 : 0)
165 
178 /* C++ detection */
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #endif
Definition: tm_stm32f4_otp.h:114
uint8_t TM_OTP_Read(uint8_t block, uint8_t byte)
Reads data from specific block and specific byte in this block.
TM_OTP_Result_t
Result enumeration.
Definition: tm_stm32f4_otp.h:112
TM_OTP_Result_t TM_OTP_BlockLock(uint8_t block)
Locks entire block to prevent future programming inside.
Definition: tm_stm32f4_otp.h:113
TM_OTP_Result_t TM_OTP_Write(uint8_t block, uint8_t byte, uint8_t data)
Writes one-time data to specific block and specific byte in this block.