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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [cfi_ctrl/] [sim/] [cfi_ctrl-simple.c] - Blame information for rev 655

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 655 julius
#include "board.h"
2
#include "cpu-utils.h"
3
#include "cfi_ctrl.h"
4
 
5
#include "orpsoc-defines.h"
6
 
7
 
8
int main(void)
9
{
10
  /* Reset the flash */
11
  cfi_ctrl_reset_flash();
12
 
13
  /* wait for the controller to be done */
14
  while (cfi_ctrl_busy());
15
 
16
#define NUM_PAGES 8
17
#define TEST_LENGTH 64
18
  int i,j;
19
  unsigned int page_base;
20
  unsigned short check_data[TEST_LENGTH];
21
  unsigned short tmp;
22
  unsigned short* flash_data_short_ptr;
23
 
24
  /* test for number of blocks... */
25
  for(j=0;j<NUM_PAGES;j++)
26
    {
27
      page_base = j*(128*1024);
28
 
29
      cfi_ctrl_clear_status();
30
 
31
      /* Erase block  */
32
      if (cfi_ctrl_erase_block(page_base))
33
        exit(0xbaaaaaad);
34
 
35
      cfi_ctrl_clear_status();
36
 
37
      for (i=0;i<TEST_LENGTH;i++)
38
        {
39
          tmp = (unsigned short)rand();
40
          report(tmp&0xffff);
41
          cfi_ctrl_write_short(tmp,page_base+i*2);
42
          check_data[i] = tmp;
43
 
44
        }
45
 
46
      /* Read back as shorts and check it */
47
      cfi_ctrl_enable_data_read();
48
      for (i=0;i<TEST_LENGTH;i++)
49
        {
50
          //tmp = REG16(CFI_CTRL_BASE + page_base + (i*2));
51
          flash_data_short_ptr = (short*) (CFI_CTRL_BASE + page_base);
52
          //if (tmp != check_data[i])
53
          if (flash_data_short_ptr[i] != check_data[i])
54
            exit(0xbaaaaaad);
55
 
56
        }
57
 
58
      char * flash_data_char_ptr = (char*) CFI_CTRL_BASE + page_base;
59
      char * chardata = (char*) check_data;
60
      /* Read back as bytes and check it */
61
      cfi_ctrl_enable_data_read();
62
      for (i=0;i<TEST_LENGTH*2;i++)
63
        {
64
          if (flash_data_char_ptr[i] != chardata[i])
65
            exit(0xbaaaaaad);
66
 
67
        }
68
 
69
      long * flash_data_long_ptr =  CFI_CTRL_BASE + page_base;
70
      long * longdata = (long*) check_data;
71
      /* Read back as longs and check it */
72
      cfi_ctrl_enable_data_read();
73
      for (i=0;i<TEST_LENGTH/2;i++)
74
        {
75
          if (flash_data_long_ptr[i] != longdata[i])
76
            exit(0xbaaaaaad);
77
 
78
        }
79
 
80
 
81
    }
82
 
83
  report(0x8000000d);
84
  exit(0);
85
}

powered by: WebSVN 2.1.0

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