1 /*--------------------------------------------------------------------
3 * AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4 * DATE CREATED: 12/17/05
6 * PROJECT: Plasma CPU core
7 * COPYRIGHT: Software placed into the public domain by the author.
8 * Software 'as is' without warranty. Author liable for nothing.
10 * Plasma flash controller
11 * Only the lower 16-bits of each 32-bit word are connected --
12 * this changes the address mapping to the flash.
13 * ByteOffset and bytes must be a multiple of two.
14 *--------------------------------------------------------------------*/
19 void FlashRead(uint16 *dst, uint32 byteOffset, int bytes)
21 volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
22 *ptr = 0xff; //read mode
25 *dst++ = (uint16)*ptr++;
31 void FlashWrite(uint16 *src, uint32 byteOffset, int bytes)
33 volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
36 *ptr = 0x40; //write mode
37 *ptr++ = *src++; //write data
38 while((*ptr & 0x80) == 0) //check status
45 void FlashErase(uint32 byteOffset)
47 volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
48 *ptr = 0x20; //erase block
49 *ptr = 0xd0; //confirm
50 while((*ptr & 0x80) == 0) //check status