MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
OTP: One-Time Programmable memory and API

Overview

The MCUXpresso SDK provides a peripheral driver for the OTP module of MCUXpresso SDK devices.

Main clock has to be set to a frequency stated in user manual prior to using OTP driver. OTP memory is manipulated by calling provided API stored in ROM. MCUXpresso SDK driver encapsulates this.

OTP example

This example shows how to write to OTP.

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/otp

Enumerations

enum  otp_bank_t {
  kOTP_Bank0 = 0x1U,
  kOTP_Bank1 = 0x2U,
  kOTP_Bank2 = 0x4U,
  kOTP_Bank3 = 0x8U
}
 Bank bit flags. More...
 
enum  otp_word_t {
  kOTP_Word0 = 0x1U,
  kOTP_Word1 = 0x2U,
  kOTP_Word2 = 0x4U,
  kOTP_Word3 = 0x8U
}
 Bank word bit flags. More...
 
enum  otp_lock_t {
  kOTP_LockDontLock = 0U,
  kOTP_LockLock = 1U
}
 Lock modifications of a read or write access to a bank register. More...
 
enum  _otp_status {
  kStatus_OTP_WrEnableInvalid = MAKE_STATUS(kStatusGroup_OTP, 0x1U),
  kStatus_OTP_SomeBitsAlreadyProgrammed = MAKE_STATUS(kStatusGroup_OTP, 0x2U),
  kStatus_OTP_AllDataOrMaskZero = MAKE_STATUS(kStatusGroup_OTP, 0x3U),
  kStatus_OTP_WriteAccessLocked = MAKE_STATUS(kStatusGroup_OTP, 0x4U),
  kStatus_OTP_ReadDataMismatch = MAKE_STATUS(kStatusGroup_OTP, 0x5U),
  kStatus_OTP_UsbIdEnabled = MAKE_STATUS(kStatusGroup_OTP, 0x6U),
  kStatus_OTP_EthMacEnabled = MAKE_STATUS(kStatusGroup_OTP, 0x7U),
  kStatus_OTP_AesKeysEnabled = MAKE_STATUS(kStatusGroup_OTP, 0x8U),
  kStatus_OTP_IllegalBank = MAKE_STATUS(kStatusGroup_OTP, 0x9U),
  kStatus_OTP_ShufflerConfigNotValid = MAKE_STATUS(kStatusGroup_OTP, 0xAU),
  kStatus_OTP_ShufflerNotEnabled = MAKE_STATUS(kStatusGroup_OTP, 0xBU),
  kStatus_OTP_ShufflerCanOnlyProgSingleKey,
  kStatus_OTP_IllegalProgramData = MAKE_STATUS(kStatusGroup_OTP, 0xCU),
  kStatus_OTP_ReadAccessLocked = MAKE_STATUS(kStatusGroup_OTP, 0xDU)
}
 OTP error codes. More...
 

Functions

static status_t OTP_Init (void)
 Initializes OTP controller. More...
 
static status_t OTP_EnableBankWriteMask (otp_bank_t bankMask)
 Unlock one or more OTP banks for write access. More...
 
static status_t OTP_DisableBankWriteMask (otp_bank_t bankMask)
 Lock one or more OTP banks for write access. More...
 
static status_t OTP_EnableBankWriteLock (uint32_t bankIndex, otp_word_t regEnableMask, otp_word_t regDisableMask, otp_lock_t lockWrite)
 Locks or unlocks write access to a register of an OTP bank and possibly lock un/locking of it. More...
 
static status_t OTP_EnableBankReadLock (uint32_t bankIndex, otp_word_t regEnableMask, otp_word_t regDisableMask, otp_lock_t lockWrite)
 Locks or unlocks read access to a register of an OTP bank and possibly lock un/locking of it. More...
 
static status_t OTP_ProgramRegister (uint32_t bankIndex, uint32_t regIndex, uint32_t value)
 Program a single register in an OTP bank. More...
 
static uint32_t OTP_GetDriverVersion (void)
 Returns the version of the OTP driver in ROM. More...
 

Driver version

#define FSL_OTP_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 OTP driver version 2.0.0. More...
 

Macro Definition Documentation

#define FSL_OTP_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Current version: 2.0.0

Change log:

  • Version 2.0.0
    • Initial version.

Enumeration Type Documentation

enum otp_bank_t
Enumerator
kOTP_Bank0 

Bank 0.

kOTP_Bank1 

Bank 1.

kOTP_Bank2 

Bank 2.

kOTP_Bank3 

Bank 3.

enum otp_word_t
Enumerator
kOTP_Word0 

Word 0.

kOTP_Word1 

Word 1.

kOTP_Word2 

Word 2.

kOTP_Word3 

Word 3.

enum otp_lock_t
Enumerator
kOTP_LockDontLock 

Do not lock.

kOTP_LockLock 

Lock till reset.

Enumerator
kStatus_OTP_WrEnableInvalid 

Write enable invalid.

kStatus_OTP_SomeBitsAlreadyProgrammed 

Some bits already programmed.

kStatus_OTP_AllDataOrMaskZero 

All data or mask zero.

kStatus_OTP_WriteAccessLocked 

Write access locked.

kStatus_OTP_ReadDataMismatch 

Read data mismatch.

kStatus_OTP_UsbIdEnabled 

USB ID enabled.

kStatus_OTP_EthMacEnabled 

Ethernet MAC enabled.

kStatus_OTP_AesKeysEnabled 

AES keys enabled.

kStatus_OTP_IllegalBank 

Illegal bank.

kStatus_OTP_ShufflerConfigNotValid 

Shuffler config not valid.

kStatus_OTP_ShufflerNotEnabled 

Shuffler not enabled.

kStatus_OTP_ShufflerCanOnlyProgSingleKey 

Shuffler can only program single key.

kStatus_OTP_IllegalProgramData 

Illegal program data.

kStatus_OTP_ReadAccessLocked 

Read access locked.

Function Documentation

static status_t OTP_Init ( void  )
inlinestatic
Returns
kStatus_Success upon successful execution, error status otherwise.
static status_t OTP_EnableBankWriteMask ( otp_bank_t  bankMask)
inlinestatic
Parameters
bankMaskbit flag that specifies which banks to unlock.
Returns
kStatus_Success upon successful execution, error status otherwise.
static status_t OTP_DisableBankWriteMask ( otp_bank_t  bankMask)
inlinestatic
Parameters
bankMaskbit flag that specifies which banks to lock.
Returns
kStatus_Success upon successful execution, error status otherwise.
static status_t OTP_EnableBankWriteLock ( uint32_t  bankIndex,
otp_word_t  regEnableMask,
otp_word_t  regDisableMask,
otp_lock_t  lockWrite 
)
inlinestatic
Parameters
bankIndexOTP bank index, 0 = bank 0, 1 = bank 1 etc.
regEnableMaskbit flag that specifies for which words to enable writing.
regDisableMaskbit flag that specifies for which words to disable writing.
lockWritespecifies if access set can be modified or is locked till reset.
Returns
kStatus_Success upon successful execution, error status otherwise.
static status_t OTP_EnableBankReadLock ( uint32_t  bankIndex,
otp_word_t  regEnableMask,
otp_word_t  regDisableMask,
otp_lock_t  lockWrite 
)
inlinestatic
Parameters
bankIndexOTP bank index, 0 = bank 0, 1 = bank 1 etc.
regEnableMaskbit flag that specifies for which words to enable reading.
regDisableMaskbit flag that specifies for which words to disable reading.
lockWritespecifies if access set can be modified or is locked till reset.
Returns
kStatus_Success upon successful execution, error status otherwise.
static status_t OTP_ProgramRegister ( uint32_t  bankIndex,
uint32_t  regIndex,
uint32_t  value 
)
inlinestatic
Parameters
bankIndexOTP bank index, 0 = bank 0, 1 = bank 1 etc.
regIndexOTP register index.
valuevalue to write.
Returns
kStatus_Success upon successful execution, error status otherwise.
static uint32_t OTP_GetDriverVersion ( void  )
inlinestatic
Returns
version.