URL
https://opencores.org/ocsvn/plasma/plasma/trunk
Subversion Repositories plasma
Compare Revisions
- This comparison shows the changes necessary to convert path
/plasma/trunk
- from Rev 413 to Rev 414
- ↔ Reverse comparison
Rev 413 → Rev 414
/kernel/flash.c
15,10 → 15,26
#include "plasma.h" |
#include "rtos.h" |
|
static OS_Mutex_t *mutexFlash; |
|
void FlashLock(void) |
{ |
if(mutexFlash == NULL) |
mutexFlash = OS_MutexCreate("flash"); |
OS_MutexPend(mutexFlash); |
} |
|
|
void FlashUnlock(void) |
{ |
OS_MutexPost(mutexFlash); |
} |
|
|
void FlashRead(uint16 *dst, uint32 byteOffset, int bytes) |
{ |
volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1)); |
FlashLock(); |
*ptr = 0xff; //read mode |
while(bytes > 0) |
{ |
25,6 → 41,7
*dst++ = (uint16)*ptr++; |
bytes -= 2; |
} |
FlashUnlock(); |
} |
|
|
31,6 → 48,7
void FlashWrite(uint16 *src, uint32 byteOffset, int bytes) |
{ |
volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1)); |
FlashLock(); |
while(bytes > 0) |
{ |
*ptr = 0x40; //write mode |
39,6 → 57,7
; |
bytes -= 2; |
} |
FlashUnlock(); |
} |
|
|
45,8 → 64,10
void FlashErase(uint32 byteOffset) |
{ |
volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1)); |
FlashLock(); |
*ptr = 0x20; //erase block |
*ptr = 0xd0; //confirm |
while((*ptr & 0x80) == 0) //check status |
; |
FlashUnlock(); |
} |