PebbleOS
Loading...
Searching...
No Matches
Enumerations | Functions

One-time programmable slots holding factory data. More...

Enumerations

enum  OtpWriteResult { OtpWriteSuccess = 0 , OtpWriteFailAlreadyWritten = 1 , OtpWriteFailCorrupt = 2 }
 Result of otp_write_slot(). More...
 

Functions

uint8_t * otp_get_lock (const uint8_t index)
 Get the lock byte of a slot.
 
bool otp_is_locked (const uint8_t index)
 Check whether the OTP storage is locked.
 
char * otp_get_slot (const uint8_t index)
 Read a slot.
 
OtpWriteResult otp_write_slot (const uint8_t index, const char *value)
 Write a string to an unwritten slot.
 

Detailed Description

One-time programmable slots holding factory data.

Each slot holds a NUL-terminated string of up to 31 characters, stored in a flash security register. A slot can be written once.

char *serial = otp_get_slot(OTP_SERIAL);
char * otp_get_slot(const uint8_t index)
Read a slot.

Enumeration Type Documentation

◆ OtpWriteResult

Result of otp_write_slot().

Enumerator
OtpWriteSuccess 

Slot written and verified.

OtpWriteFailAlreadyWritten 

Slot already holds data.

OtpWriteFailCorrupt 

Invalid slot or value, or the write could not be verified.

Function Documentation

◆ otp_get_lock()

uint8_t * otp_get_lock ( const uint8_t  index)

Get the lock byte of a slot.

Parameters
indexSlot index.
Returns
Lock byte, or NULL when slots have no individual lock.

◆ otp_get_slot()

char * otp_get_slot ( const uint8_t  index)

Read a slot.

Parameters
indexSlot index.
Returns
Slot contents, in a static buffer overwritten by the next read, or NULL on error. An unwritten slot reads as 0xFF bytes.

◆ otp_is_locked()

bool otp_is_locked ( const uint8_t  index)

Check whether the OTP storage is locked.

Locking applies to the whole security register holding the slots.

Parameters
indexSlot index.
Returns
true if locked.

◆ otp_write_slot()

OtpWriteResult otp_write_slot ( const uint8_t  index,
const char *  value 
)

Write a string to an unwritten slot.

Parameters
indexSlot index.
valueNUL-terminated string, at most 31 characters.
Returns
Write result.