User`s manual

RX600 & RX200 Series Simple Flash API for RX
R01AN0544EU0250 Rev.2.50 Page 5 of 33
March 4, 2014
the backup PSW register. The downside to this approach is that the user loses the ability to use the fast interrupt for
another interrupt.
2.8 API Data Structures
This section details the data structures that are used with the middleware’s API functions.
2.8.1 Flash Block Addresses
If needed, the user can use the g_flash_BlockAddresses[] array to get the addresses associated with a MCU’s memory
blocks. Note that these addresses are the program and erasing addresses rather than the read addresses. The only
difference in these addresses is that when reading the high-order byte is always 0xFF (e.g. 0xFFFF4000) for ROM
addresses and when programming or erasing the high-order byte is always 0x00 (e.g. 0x00FF4000). This means that the
user can easily OR in 0xFF000000 to a ROM address from the array and have the appropriate read address. No change
is needed when using data flash addresses. Also, when erasing ROM, make sure you do not erase this array since it is a
constant array and is stored in ROM by default.
/* Data Structure #1 */
const uint32_t g_flash_BlockAddresses[86] = {
0x00FFF000, /* EB00 */
0x00FFE000, /* EB01 */
0x00FFD000, /* EB02 */
0x00FFC000, /* EB03 */
...
};
2.9 Return Values
This shows the different values API functions can return. These definitions are all found in r_flash_api_rx_if.h. Some
of the return values have the same value to keep compatibility with older versions of the middleware. No function will
use two return definitions from the list below with identical values.
/**** Function Return Values ****/
/* Operation was successful */
#define FLASH_SUCCESS (0x00)
/* Flash area checked was blank, making this 0x00 as well to keep existing
code checking compatibility */
#define FLASH_BLANK (0x00)
/* The address that was supplied was not on aligned correctly for ROM or DF */
#define FLASH_ERROR_ALIGNED (0x01)
/* Flash area checked was not blank, making this 0x01 as well to keep existing
code checking compatibility */
#define FLASH_NOT_BLANK (0x01)
/* The number of bytes supplied to write was incorrect */
#define FLASH_ERROR_BYTES (0x02)
/* The address provided is not a valid ROM or DF address */
#define FLASH_ERROR_ADDRESS (0x03)
/* Writes cannot cross the 1MB boundary on some parts */
#define FLASH_ERROR_BOUNDARY (0x04)
/* Flash is busy with another operation */
#define FLASH_BUSY (0x05)
/* Operation failed */
#define FLASH_FAILURE (0x06)
/* Lock bit was set for the block in question */
#define FLASH_LOCK_BIT_SET (0x07)
/* Lock bit was not set for the block in question */
#define FLASH_LOCK_BIT_NOT_SET (0x08)
/* 'Address + number of bytes' for this operation went past the end of this
* memory area. */
#define FLASH_ERROR_OVERFLOW (0x09)