The MCUXpresso SDK provides a peripheral driver for the OCOTP module of MCUXpresso SDK devices.
This section contains information describing the requirements for the on-chip eFuse OTP controller along with details about the block functionality and implementation.
OCOTP function group
The OCOTP driver support operaing API to allow read and write the fuse map.
Initialization and de-initialization
The funciton OCOTP_Init() is to initialize the OCOTP with peripheral base address and source clock frequency.
The function OCOTP_Deinit() is to de-initialize the OCOTP controller with peripheral base address.
Read and Write operation
The function OCOTP_ReloadShadowRegister() is to reload the value from the fuse map. this API should be called firstly before reading the register.
The OCOTP_ReadFuseShadowRegister() is to read the value from a given address, if operation is success, a known value will be return, othwise, a value of 0xBADABADA will be returned.
The function OCOTP_WriteFuseShadowRegister() will write a specific value to a known address. please check the return status o make sure whether the access to register is success.
OCOTP example
This example shows how to get the controller version using API. Due to the eFuse is One-Time programmable, example will only print the information of OCOTP controller version. If more operations are needed, please using the API to implement the write and read operation.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/ocotp
|
void | OCOTP_Init (OCOTP_Type *base, uint32_t srcClock_Hz) |
| Initializes OCOTP controller. More...
|
|
void | OCOTP_Deinit (OCOTP_Type *base) |
| De-initializes OCOTP controller. More...
|
|
static bool | OCOTP_CheckBusyStatus (OCOTP_Type *base) |
| Checking the BUSY bit in CTRL register. More...
|
|
static bool | OCOTP_CheckErrorStatus (OCOTP_Type *base) |
| Checking the ERROR bit in CTRL register. More...
|
|
static void | OCOTP_ClearErrorStatus (OCOTP_Type *base) |
| Clear the error bit if this bit is set. More...
|
|
status_t | OCOTP_ReloadShadowRegister (OCOTP_Type *base) |
| Reload the shadow register. More...
|
|
uint32_t | OCOTP_ReadFuseShadowRegister (OCOTP_Type *base, uint32_t address) |
| Read the fuse shadow register with the fuse addess. More...
|
|
status_t | OCOTP_ReadFuseShadowRegisterExt (OCOTP_Type *base, uint32_t address, uint32_t *data, uint8_t fuseWords) |
| Read the fuse shadow register from the fuse addess. More...
|
|
status_t | OCOTP_WriteFuseShadowRegister (OCOTP_Type *base, uint32_t address, uint32_t data) |
| Write the fuse shadow register with the fuse addess and data. More...
|
|
status_t | OCOTP_WriteFuseShadowRegisterWithLock (OCOTP_Type *base, uint32_t address, uint32_t data, bool lock) |
| Write the fuse shadow register and lock it. More...
|
|
static uint32_t | OCOTP_GetVersion (OCOTP_Type *base) |
| Get the OCOTP controller version from the register. More...
|
|
Enumerator |
---|
kStatus_OCOTP_AccessError |
eFuse and shadow register access error.
|
kStatus_OCOTP_CrcFail |
CRC check failed.
|
kStatus_OCOTP_ReloadError |
Error happens during reload shadow register.
|
kStatus_OCOTP_ProgramFail |
Fuse programming failed.
|
kStatus_OCOTP_Locked |
Fuse is locked and cannot be programmed.
|
void OCOTP_Init |
( |
OCOTP_Type * |
base, |
|
|
uint32_t |
srcClock_Hz |
|
) |
| |
- Parameters
-
base | OCOTP peripheral base address. |
srcClock_Hz | source clock frequency in unit of Hz. When the macro FSL_FEATURE_OCOTP_HAS_TIMING_CTRL is defined as 0, this parameter is not used, application could pass in 0 in this case. |
void OCOTP_Deinit |
( |
OCOTP_Type * |
base | ) |
|
- Return values
-
kStatus_Success | upon successful execution, error status otherwise. |
static bool OCOTP_CheckBusyStatus |
( |
OCOTP_Type * |
base | ) |
|
|
inlinestatic |
Checking this BUSY bit will help confirm if the OCOTP controller is ready for access.
- Parameters
-
base | OCOTP peripheral base address. |
- Return values
-
true | for bit set and false for cleared. |
static bool OCOTP_CheckErrorStatus |
( |
OCOTP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | OCOTP peripheral base address. |
- Return values
-
true | for bit set and false for cleared. |
static void OCOTP_ClearErrorStatus |
( |
OCOTP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | OCOTP peripheral base address. |
status_t OCOTP_ReloadShadowRegister |
( |
OCOTP_Type * |
base | ) |
|
This function will help reload the shadow register without reseting the OCOTP module. Please make sure the OCOTP has been initialized before calling this API.
- Parameters
-
base | OCOTP peripheral base addess. |
- Return values
-
kStatus_Success | Reload success. |
kStatus_OCOTP_ReloadError | Reload failed. |
uint32_t OCOTP_ReadFuseShadowRegister |
( |
OCOTP_Type * |
base, |
|
|
uint32_t |
address |
|
) |
| |
status_t OCOTP_ReadFuseShadowRegisterExt |
( |
OCOTP_Type * |
base, |
|
|
uint32_t |
address, |
|
|
uint32_t * |
data, |
|
|
uint8_t |
fuseWords |
|
) |
| |
This function reads fuse from address
, how many words to read is specified by the parameter fuseWords
. This function could read at most OCOTP_READ_FUSE_DATA_COUNT fuse word one time.
- Parameters
-
base | OCOTP peripheral base address. |
address | the fuse address to be read from. |
data | Data array to save the readout fuse value. |
fuseWords | How many words to read. |
- Return values
-
kStatus_Success | Read success. |
kStatus_Fail | Error occurs during read. |
status_t OCOTP_WriteFuseShadowRegister |
( |
OCOTP_Type * |
base, |
|
|
uint32_t |
address, |
|
|
uint32_t |
data |
|
) |
| |
Please make sure the wrtie address is not locked while calling this API.
- Parameters
-
base | OCOTP peripheral base address. |
address | the fuse address to be written. |
data | the value will be writen to fuse address. |
- Return values
-
write | status, kStatus_Success for success and kStatus_Fail for failed. |
status_t OCOTP_WriteFuseShadowRegisterWithLock |
( |
OCOTP_Type * |
base, |
|
|
uint32_t |
address, |
|
|
uint32_t |
data, |
|
|
bool |
lock |
|
) |
| |
Please make sure the wrtie address is not locked while calling this API.
Some OCOTP controller supports ECC mode and redundancy mode (see reference mananual for more details). OCOTP controller will auto select ECC or redundancy mode to program the fuse word according to fuse map definition. In ECC mode, the 32 fuse bits in one word can only be written once. In redundancy mode, the word can be written more than once as long as they are different fuse bits. Set parameter lock
as true to force use ECC mode.
- Parameters
-
base | OCOTP peripheral base address. |
address | The fuse address to be written. |
data | The value will be writen to fuse address. |
lock | Lock or unlock write fuse shadow register operation. |
- Return values
-
kStatus_Success | Program and reload success. |
kStatus_OCOTP_Locked | The eFuse word is locked and cannot be programmed. |
kStatus_OCOTP_ProgramFail | eFuse word programming failed. |
kStatus_OCOTP_ReloadError | eFuse word programming success, but error happens during reload the values. |
kStatus_OCOTP_AccessError | Cannot access eFuse word. |
static uint32_t OCOTP_GetVersion |
( |
OCOTP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | OCOTP peripheral base address. |
- Return values
-