mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #7675 from TomoYamanaka/improve_flashiap
Renesas : Improve Flash iappull/7604/merge
commit
e016d8d84d
|
@ -40,6 +40,7 @@
|
||||||
#define FLASH_BASE (0x18000000UL) /**< Flash Base Address */
|
#define FLASH_BASE (0x18000000UL) /**< Flash Base Address */
|
||||||
#define FLASH_SIZE (0x00800000UL) /**< Available Flash Memory */
|
#define FLASH_SIZE (0x00800000UL) /**< Available Flash Memory */
|
||||||
#define FLASH_PAGE_SIZE 256 /**< Flash Memory page size (interleaving off) */
|
#define FLASH_PAGE_SIZE 256 /**< Flash Memory page size (interleaving off) */
|
||||||
|
/**< Maximum size per one writing is 256 byte and minimum size per one writing is 1 byte */
|
||||||
#define FLASH_SECTOR_SIZE 4096 /**< Flash Memory sector size (interleaving off) */
|
#define FLASH_SECTOR_SIZE 4096 /**< Flash Memory sector size (interleaving off) */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#define FLASH_BASE (0x18000000UL) /**< Flash Base Address */
|
#define FLASH_BASE (0x18000000UL) /**< Flash Base Address */
|
||||||
#define FLASH_SIZE (0x00800000UL) /**< Available Flash Memory */
|
#define FLASH_SIZE (0x00800000UL) /**< Available Flash Memory */
|
||||||
#define FLASH_PAGE_SIZE 256 /**< Flash Memory page size (interleaving off) */
|
#define FLASH_PAGE_SIZE 256 /**< Flash Memory page size (interleaving off) */
|
||||||
|
/**< Maximum size per one writing is 256 byte and minimum size per one writing is 1 byte */
|
||||||
#define FLASH_SECTOR_SIZE 4096 /**< Flash Memory sector size (interleaving off) */
|
#define FLASH_SECTOR_SIZE 4096 /**< Flash Memory sector size (interleaving off) */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -167,7 +167,7 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
|
||||||
|
|
||||||
uint32_t flash_get_page_size(const flash_t *obj)
|
uint32_t flash_get_page_size(const flash_t *obj)
|
||||||
{
|
{
|
||||||
return FLASH_PAGE_SIZE;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t flash_get_start_address(const flash_t *obj)
|
uint32_t flash_get_start_address(const flash_t *obj)
|
||||||
|
@ -222,9 +222,23 @@ int32_t _sector_erase(uint32_t addr)
|
||||||
int32_t _page_program(uint32_t addr, const uint8_t * buf, int32_t size)
|
int32_t _page_program(uint32_t addr, const uint8_t * buf, int32_t size)
|
||||||
{
|
{
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
int32_t program_size;
|
||||||
|
int32_t remainder;
|
||||||
|
int32_t idx = 0;
|
||||||
|
|
||||||
spi_mode();
|
spi_mode();
|
||||||
|
|
||||||
|
while (size > 0) {
|
||||||
|
if (size > FLASH_PAGE_SIZE) {
|
||||||
|
program_size = FLASH_PAGE_SIZE;
|
||||||
|
} else {
|
||||||
|
program_size = size;
|
||||||
|
}
|
||||||
|
remainder = FLASH_PAGE_SIZE - (addr % FLASH_PAGE_SIZE);
|
||||||
|
if ((remainder != 0) && (program_size > remainder)) {
|
||||||
|
program_size = remainder;
|
||||||
|
}
|
||||||
|
|
||||||
/* ---- Write enable ---- */
|
/* ---- Write enable ---- */
|
||||||
ret = write_enable(); /* WREN Command */
|
ret = write_enable(); /* WREN Command */
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -257,13 +271,22 @@ int32_t _page_program(uint32_t addr, const uint8_t * buf, int32_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------- 2. Data ---------------*/
|
/* ----------- 2. Data ---------------*/
|
||||||
ret = data_send(SPIBSC_1BIT, SPIBSC_SPISSL_NEGATE, buf, size);
|
ret = data_send(SPIBSC_1BIT, SPIBSC_SPISSL_NEGATE, &buf[idx], program_size);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ex_mode();
|
ex_mode();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = busy_wait();
|
ret = busy_wait();
|
||||||
|
if (ret != 0) {
|
||||||
|
ex_mode();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr += program_size;
|
||||||
|
idx += program_size;
|
||||||
|
size -= program_size;
|
||||||
|
}
|
||||||
|
|
||||||
ex_mode();
|
ex_mode();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue