forked

Revision:
170:19eb464bc2be
Parent:
168:9672193075cf
diff -r e3b6fe271b81 -r 19eb464bc2be targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c
--- a/targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c	Wed Jul 19 17:31:21 2017 +0100
+++ b/targets/TARGET_Realtek/TARGET_AMEBA/flash_api.c	Thu Aug 03 13:13:39 2017 +0100
@@ -15,10 +15,6 @@
  */
 #include "flash_ext.h"
 
-#define FLASH_START       (SPI_FLASH_BASE + FLASH_OFS_START)
-#define FLASH_END         (SPI_FLASH_BASE + FLASH_OFS_END)
-#define FLASH_OFS(addr)   ((addr) - SPI_FLASH_BASE)
-
 int32_t flash_init(flash_t *obj)
 {
     __flash_ext_turnon();
@@ -35,20 +31,25 @@
 
 int32_t flash_erase_sector(flash_t *obj, uint32_t address)
 {
-    __flash_ext_erase_sector(obj, FLASH_OFS(address));
+    flash_ext_erase_sector(obj, address);
 
     return 0;
 }
 
+int32_t flash_read(flash_t *obj, uint32_t address, uint8_t *data, uint32_t size)
+{
+    return flash_ext_stream_read(obj, address, size, data);;
+}
+
 int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, uint32_t size)
 {
-    return __flash_ext_stream_write(obj, FLASH_OFS(address), size, data);
+    return flash_ext_stream_write(obj, address, size, data);
 }
 
 uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address)
 {
-    if (address < FLASH_START || address >= FLASH_END)
-        return 0;
+    if (address >= FLASH_OFS_END)
+        return MBED_FLASH_INVALID_SIZE;
 
     return FLASH_SECTOR_SIZE;
 }
@@ -60,7 +61,7 @@
 
 uint32_t flash_get_start_address(const flash_t *obj)
 {
-    return FLASH_START;
+    return FLASH_OFS_START;
 }
 
 uint32_t flash_get_size(const flash_t *obj)