diff packages/devs/flash/intel/strata/current/src/flash_unlock_block.c @ 286:845276b93eaa

Add support for K-series (synchronous) strataflash parts.
author msalter
date Mon, 12 Aug 2002 12:20:49 +0000
parents d2c90368aeef
children 59e96106029e
line wrap: on
line diff
--- a/packages/devs/flash/intel/strata/current/src/flash_unlock_block.c
+++ b/packages/devs/flash/intel/strata/current/src/flash_unlock_block.c
@@ -72,11 +72,15 @@
 int
 flash_unlock_block(volatile flash_t *block, int block_size, int blocks)
 {
-    volatile flash_t *ROM, *bp, *bpv;
+    volatile flash_t *ROM;
     flash_t stat;
     int timeout = 5000000;
+    int cache_on;
+#ifndef CYGOPT_FLASH_IS_SYNCHRONOUS
+    int i;
+    volatile flash_t *bp, *bpv;
     unsigned char is_locked[MAX_FLASH_BLOCKS];
-    int i, cache_on;
+#endif
 
     HAL_DCACHE_IS_ENABLED(cache_on);
     if (cache_on) {
@@ -91,6 +95,14 @@ flash_unlock_block(volatile flash_t *blo
     // Clear any error conditions
     ROM[0] = FLASH_Clear_Status;
 
+#ifdef CYGOPT_FLASH_IS_SYNCHRONOUS
+    // Clear lock bit
+    block[0] = FLASH_Clear_Locks;
+    block[0] = FLASH_Clear_Locks_Confirm;  // Confirmation
+    while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) {
+        if (--timeout == 0) break;
+    }
+#else
     // Get current block lock state.  This needs to access each block on
     // the device so currently locked blocks can be re-locked.
     bp = ROM;
@@ -131,6 +143,7 @@ flash_unlock_block(volatile flash_t *blo
         }
         bp += block_size / sizeof(*bp);
     }
+#endif  // CYGOPT_FLASH_IS_SYNCHRONOUS
 
     // Restore ROM to "normal" mode
     ROM[0] = FLASH_Reset;