OpenCores
URL https://opencores.org/ocsvn/mlite/mlite/trunk

Subversion Repositories mlite

[/] [mlite/] [trunk/] [kernel/] [flash.c] - Blame information for rev 350

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 300 rhoads
/*--------------------------------------------------------------------
2
 * TITLE: Plasma Flash
3
 * AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
 * DATE CREATED: 12/17/05
5
 * FILENAME: plasma.h
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.
9
 * DESCRIPTION:
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
 *--------------------------------------------------------------------*/
15
#include "plasma.h"
16
#include "rtos.h"
17
 
18
 
19
void FlashRead(uint16 *dst, uint32 byteOffset, int bytes)
20
{
21
   volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
22
   *ptr = 0xff;                   //read mode
23
   while(bytes > 0)
24
   {
25
      *dst++ = (uint16)*ptr++;
26
      bytes -= 2;
27
   }
28
}
29
 
30
 
31
void FlashWrite(uint16 *src, uint32 byteOffset, int bytes)
32
{
33
   volatile uint32 *ptr=(uint32*)(FLASH_BASE + (byteOffset << 1));
34
   while(bytes > 0)
35
   {
36
      *ptr = 0x40;                //write mode
37
      *ptr++ = *src++;            //write data
38
      while((*ptr & 0x80) == 0)   //check status
39
         ;
40
      bytes -= 2;
41
   }
42
}
43
 
44
 
45
void FlashErase(uint32 byteOffset)
46
{
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
51
      ;
52
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.