User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 27 of 33
March 4, 2014
4.7 R_FlashProgramLockBit
Sets the lock bit for a flash block.
Format
uint8_t R_FlashProgramLockBit(uint32_t block);
Parameters
block
The ROM erasure block that will have its lock bit set.
Return Values
FLASH_SUCCESS: Operation successful, lock bit set.
FLASH_FAILURE: Operation failed.
FLASH_BUSY: Other flash operation in progress, try again later
FLASH_ERROR_ADDRESS: Invalid block was input.
Properties
Prototyped in file “r_flash_api_rx_if.h
Implemented in file “r_flash_api_rx.c
Description
Each block of ROM has a lock bit associated with it. If lock bit protection is enabled and the lock bit is set for
a given block then that block cannot be programmed or erased. If an attempt to erase or program the block
is made, the operation will be ignored. This function will set the lock bit for the selected flash block. Whether
lock bit protection is enabled or not is controlled by the API function R_FlashSetLockBitProtection().
Reentrant
No, but is protected by lock to prevent errors from concurrent function calls.
Example
uint8_t ret;
/* Enable lock bit protection (this is default out of reset) */
ret = R_FlashSetLockBitProtection(true);
/* Check for errors. */
if (FLASH_SUCCESS != ret)
{
. . .
}
/* Program lock bits */
ret = R_FlashProgramLockBit(flash_block);
/* Check for errors. */
if (FLASH_SUCCESS != ret)
{
. . .
}
Special Notes:
Lock bits for a flash block are cleared by erasing the flash block with lock bit protection disabled.
This function is not available for use when the FLASH_API_RX_CFG_IGNORE_LOCK_BITS macro
is defined in r_flash_api_rx_config.h.