BSB Developer Docs
Loading...
Searching...
No Matches
furi_hal_flash_otp.h
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5#include <core/common_defines.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11// OTP area (512 bytes) is split into 4x 128-byte blocks
12#define FURI_HAL_FLASH_OTP_BLOCK_SIZE (128)
13
14#define FURI_HAL_FLASH_OTP_MAGIC (0x3713)
15
17typedef enum {
18 FuriHalOtpBlockOtp1 = 1,
19 FuriHalOtpBlockOtp2 = 2,
20 FuriHalOtpBlockOtp3 = 3,
21 FuriHalOtpBlockOtp4 = 4,
22} FuriHalFlashOtpBlock;
23
24typedef struct {
25 uint16_t magic; // Magic value (FURI_HAL_FLASH_OTP_MAGIC)
26 uint8_t index; // OTP block index (FuriHalOtpBlock)
27 uint8_t version;
28} FURI_PACKED FuriHalFlashOtpHeader;
29
30_Static_assert(sizeof(FuriHalFlashOtpHeader) == 4, "OTP header size mismatch");
31
38static inline bool furi_hal_flash_otp_header_is_valid(
39 const FuriHalFlashOtpHeader* header,
40 FuriHalFlashOtpBlock expected_block) {
41 return (header->magic == FURI_HAL_FLASH_OTP_MAGIC) &&
42 (header->index == (uint8_t)expected_block);
43}
44
50uint32_t furi_hal_flash_otp_get_block_address(FuriHalFlashOtpBlock block);
51
59bool furi_hal_flash_otp_program(FuriHalFlashOtpBlock block, const uint8_t* data, uint16_t length);
60
61#ifdef __cplusplus
62}
63#endif
Frame header with fields which help control frame exchange.
Definition ble_intercom_types.h:40