User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 28 of 33
March 4, 2014
4.8 R_FlashReadLockBit
Reads the lock bit for a flash block.
Format
uint8_t R_FlashReadLockBit(uint32_t block);
Parameters
block
The ROM erasure block that will have its lock bit read.
Return Values
FLASH_LOCK_BIT_SET: Lock bit is set
FLASH_LOCK_BIT_NOT_SET: Lock bit is not set
FLASH_FAILURE: Operation Failed
FLASH_BUSY: Another flash operation is in progress
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 return whether a flash block has its lock bit set or
not. 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;
/* Program lock bits */
ret = R_FlashReadLockBit(flash_block);
/* Check result. */
if (FLASH_LOCK_BIT_SET == ret)
{
/* Lock bit is set for this block. */
. . .
}
else if (FLASH_LOCK_BIT_NOT_SET == ret)
{
/* Lock bit was not set for this block. */
. . .
}
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.